Manipulating columns of a DataFrame#
Renaming columns#
Let’s start with a DataFrame of Bools that has default column names.
using DataFrames
x = DataFrame(rand(Bool, 3, 4), :auto)
Row | x1 | x2 | x3 | x4 |
---|---|---|---|---|
Bool | Bool | Bool | Bool | |
1 | false | true | true | false |
2 | true | true | true | true |
3 | false | true | false | true |
With rename()
, we create new DataFrame; here we rename the column :x1
to :A
. (rename
also accepts collections of Pairs.)
rename(x, :x1 => :A)
Row | A | x2 | x3 | x4 |
---|---|---|---|---|
Bool | Bool | Bool | Bool | |
1 | false | true | true | false |
2 | true | true | true | true |
3 | false | true | false | true |
With rename!()
we do an in place transformation.
This time we’ve applied a function to every column name (note that the function gets a column names as a string).
rename!(c -> c^2, x)
Row | x1x1 | x2x2 | x3x3 | x4x4 |
---|---|---|---|---|
Bool | Bool | Bool | Bool | |
1 | false | true | true | false |
2 | true | true | true | true |
3 | false | true | false | true |
We can also change the name of a particular column without knowing the original. Here we change the name of the third column, creating a new DataFrame.
rename(x, 3 => :third)
Row | x1x1 | x2x2 | third | x4x4 |
---|---|---|---|---|
Bool | Bool | Bool | Bool | |
1 | false | true | true | false |
2 | true | true | true | true |
3 | false | true | false | true |
If we pass a vector of names to rename!, we can change the names of all variables.
rename!(x, [:a, :b, :c, :d])
Row | a | b | c | d |
---|---|---|---|---|
Bool | Bool | Bool | Bool | |
1 | false | true | true | false |
2 | true | true | true | true |
3 | false | true | false | true |
In all the above examples you could have used strings instead of symbols, for example,
rename!(x, string.('a':'d'))
Row | a | b | c | d |
---|---|---|---|---|
Bool | Bool | Bool | Bool | |
1 | false | true | true | false |
2 | true | true | true | true |
3 | false | true | false | true |
rename! allows for circular renaming of columns:
x
Row | a | b | c | d |
---|---|---|---|---|
Bool | Bool | Bool | Bool | |
1 | false | true | true | false |
2 | true | true | true | true |
3 | false | true | false | true |
rename!(x, "a"=>"d", "d"=>"a")
Row | d | b | c | a |
---|---|---|---|---|
Bool | Bool | Bool | Bool | |
1 | false | true | true | false |
2 | true | true | true | true |
3 | false | true | false | true |
We get an error when we try to provide duplicate names
try
rename(x, fill(:a, 4))
catch e
show(e)
end
ArgumentError("Duplicate variable names: :a. Pass makeunique=true to make them unique using a suffix automatically.")
unless we pass makeunique=true, which allows us to handle duplicates in passed names.
rename(x, fill(:a, 4), makeunique=true)
Row | a | a_1 | a_2 | a_3 |
---|---|---|---|---|
Bool | Bool | Bool | Bool | |
1 | false | true | true | false |
2 | true | true | true | true |
3 | false | true | false | true |
Reordering columns#
We can reorder the names(x) vector as needed, creating a new DataFrame.
using Random
Random.seed!(1234)
x[:, shuffle(names(x))]
Row | c | b | a | d |
---|---|---|---|---|
Bool | Bool | Bool | Bool | |
1 | true | true | false | false |
2 | true | true | true | true |
3 | false | true | true | false |
Also select! can be used to achieve this in place (or select to perform a copy):
x
Row | d | b | c | a |
---|---|---|---|---|
Bool | Bool | Bool | Bool | |
1 | false | true | true | false |
2 | true | true | true | true |
3 | false | true | false | true |
select!(x, 4:-1:1);
x
Row | a | c | b | d |
---|---|---|---|---|
Bool | Bool | Bool | Bool | |
1 | false | true | true | false |
2 | true | true | true | true |
3 | true | false | true | false |
Mrging/adding columns#
x = DataFrame([(i,j) for i in 1:3, j in 1:4], :auto)
Row | x1 | x2 | x3 | x4 |
---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) |
2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) |
3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) |
With hcat
we can merge two DataFrames
. Also [x y]
syntax is supported but only when DataFrames have unique column names.
hcat(x, x, makeunique=true)
Row | x1 | x2 | x3 | x4 | x1_1 | x2_1 | x3_1 | x4_1 |
---|---|---|---|---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) | (1, 1) | (1, 2) | (1, 3) | (1, 4) |
2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) | (2, 1) | (2, 2) | (2, 3) | (2, 4) |
3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) | (3, 1) | (3, 2) | (3, 3) | (3, 4) |
You can append a vector to a data frame with the following syntax:
y = [x DataFrame(A=[1,2,3])]
Row | x1 | x2 | x3 | x4 | A |
---|---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | Int64 | |
1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) | 1 |
2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) | 2 |
3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) | 3 |
Here we do the same but add column :A
to the front.
y = [DataFrame(A=[1,2,3]) x]
Row | A | x1 | x2 | x3 | x4 |
---|---|---|---|---|---|
Int64 | Tuple… | Tuple… | Tuple… | Tuple… | |
1 | 1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) |
2 | 2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) |
3 | 3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) |
A column can also be added in the middle. Here a brute-force method is used and a new DataFrame
is created.
using BenchmarkTools
@btime [$x[!, 1:2] DataFrame(A=[1,2,3]) $x[!, 3:4]]
5.016 μs (93 allocations: 5.78 KiB)
Row | x1 | x2 | A | x3 | x4 |
---|---|---|---|---|---|
Tuple… | Tuple… | Int64 | Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) | 1 | (1, 3) | (1, 4) |
2 | (2, 1) | (2, 2) | 2 | (2, 3) | (2, 4) |
3 | (3, 1) | (3, 2) | 3 | (3, 3) | (3, 4) |
We could also do this with a specialized in place method insertcols!
. Let’s add :newcol
to the DataFrame
y.
insertcols!(y, 2, "newcol" => [1,2,3])
Row | A | newcol | x1 | x2 | x3 | x4 |
---|---|---|---|---|---|---|
Int64 | Int64 | Tuple… | Tuple… | Tuple… | Tuple… | |
1 | 1 | 1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) |
2 | 2 | 2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) |
3 | 3 | 3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) |
If you want to insert the same column name several times makeunique=true
is needed as usual.
insertcols!(y, 2, :newcol => [1,2,3], makeunique=true)
Row | A | newcol_1 | newcol | x1 | x2 | x3 | x4 |
---|---|---|---|---|---|---|---|
Int64 | Int64 | Int64 | Tuple… | Tuple… | Tuple… | Tuple… | |
1 | 1 | 1 | 1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) |
2 | 2 | 2 | 2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) |
3 | 3 | 3 | 3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) |
We can see how much faster it is to insert a column with insertcols!
than with hcat
using @btime
(note that we use here a Pair
notation as an example).
@btime insertcols!(copy($x), 3, :A => [1,2,3])
1.306 μs (26 allocations: 1.55 KiB)
Row | x1 | x2 | A | x3 | x4 |
---|---|---|---|---|---|
Tuple… | Tuple… | Int64 | Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) | 1 | (1, 3) | (1, 4) |
2 | (2, 1) | (2, 2) | 2 | (2, 3) | (2, 4) |
3 | (3, 1) | (3, 2) | 3 | (3, 3) | (3, 4) |
Let’s use insertcols!
to append a column in place (note that we dropped the index at which we insert the column)
insertcols!(x, :A => [1,2,3])
Row | x1 | x2 | x3 | x4 | A |
---|---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | Int64 | |
1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) | 1 |
2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) | 2 |
3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) | 3 |
and to in place prepend a column.
insertcols!(x, 1, :B => [1,2,3])
Row | B | x1 | x2 | x3 | x4 | A |
---|---|---|---|---|---|---|
Int64 | Tuple… | Tuple… | Tuple… | Tuple… | Int64 | |
1 | 1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) | 1 |
2 | 2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) | 2 |
3 | 3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) | 3 |
Note that insertcols!
can be used to insert several columns to a data frame at once and that it performs broadcasting if needed:
df = DataFrame(a = [1, 2, 3])
Row | a |
---|---|
Int64 | |
1 | 1 |
2 | 2 |
3 | 3 |
insertcols!(df, :b => "x", :c => 'a':'c', :d => Ref([1,2,3]))
Row | a | b | c | d |
---|---|---|---|---|
Int64 | String | Char | Array… | |
1 | 1 | x | a | [1, 2, 3] |
2 | 2 | x | b | [1, 2, 3] |
3 | 3 | x | c | [1, 2, 3] |
Interestingly we can emulate hcat
mutating the data frame in-place using insertcols!
:
df1 = DataFrame(a=[1,2])
Row | a |
---|---|
Int64 | |
1 | 1 |
2 | 2 |
df2 = DataFrame(b=[2,3], c=[3,4])
Row | b | c |
---|---|---|
Int64 | Int64 | |
1 | 2 | 3 |
2 | 3 | 4 |
hcat(df1, df2)
Row | a | b | c |
---|---|---|---|
Int64 | Int64 | Int64 | |
1 | 1 | 2 | 3 |
2 | 2 | 3 | 4 |
df1 is not touched
df1
Row | a |
---|---|
Int64 | |
1 | 1 |
2 | 2 |
insertcols!(df1, pairs(eachcol(df2))...)
Row | a | b | c |
---|---|---|---|
Int64 | Int64 | Int64 | |
1 | 1 | 2 | 3 |
2 | 2 | 3 | 4 |
now we have changed df1
df1
Row | a | b | c |
---|---|---|---|
Int64 | Int64 | Int64 | |
1 | 1 | 2 | 3 |
2 | 2 | 3 | 4 |
Subsetting/removing columns#
Let’s create a new DataFrame
x
and show a few ways to create DataFrames with a subset of x
’s columns.
x = DataFrame([(i,j) for i in 1:3, j in 1:5], :auto)
Row | x1 | x2 | x3 | x4 | x5 |
---|---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) | (1, 5) |
2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) | (2, 5) |
3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) | (3, 5) |
First we could do this by index:
You could use !
instead of :
for non-copying operation
x[:, [1,2,4,5]]
Row | x1 | x2 | x4 | x5 |
---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) | (1, 4) | (1, 5) |
2 | (2, 1) | (2, 2) | (2, 4) | (2, 5) |
3 | (3, 1) | (3, 2) | (3, 4) | (3, 5) |
or by column name:
x[:, [:x1, :x4]]
Row | x1 | x4 |
---|---|---|
Tuple… | Tuple… | |
1 | (1, 1) | (1, 4) |
2 | (2, 1) | (2, 4) |
3 | (3, 1) | (3, 4) |
We can also choose to keep or exclude columns by Bool
(we need a vector whose length is the number of columns in the original DataFrame
).
x[:, [true, false, true, false, true]]
Row | x1 | x3 | x5 |
---|---|---|---|
Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 3) | (1, 5) |
2 | (2, 1) | (2, 3) | (2, 5) |
3 | (3, 1) | (3, 3) | (3, 5) |
Here we create a single column DataFrame
,
x[:, [:x1]]
Row | x1 |
---|---|
Tuple… | |
1 | (1, 1) |
2 | (2, 1) |
3 | (3, 1) |
and here we access the vector contained in column :x1
.
x[!, :x1] ## use : instead of ! to copy
3-element Vector{Tuple{Int64, Int64}}:
(1, 1)
(2, 1)
(3, 1)
x.x1 ## the same
3-element Vector{Tuple{Int64, Int64}}:
(1, 1)
(2, 1)
(3, 1)
We could grab the same vector by column number
x[!, 1]
3-element Vector{Tuple{Int64, Int64}}:
(1, 1)
(2, 1)
(3, 1)
Note that getting a single column returns it without copying while creating a new DataFrame
performs a copy of the column
x[!, 1] === x[!, [1]]
false
you can also use Regex
, All
, Between
and Not
from InvertedIndies.jl for column selection:
x[!, r"[12]"]
Row | x1 | x2 |
---|---|---|
Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) |
2 | (2, 1) | (2, 2) |
3 | (3, 1) | (3, 2) |
x[!, Not(1)]
Row | x2 | x3 | x4 | x5 |
---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 2) | (1, 3) | (1, 4) | (1, 5) |
2 | (2, 2) | (2, 3) | (2, 4) | (2, 5) |
3 | (3, 2) | (3, 3) | (3, 4) | (3, 5) |
x[!, Between(:x2, :x4)]
Row | x2 | x3 | x4 |
---|---|---|---|
Tuple… | Tuple… | Tuple… | |
1 | (1, 2) | (1, 3) | (1, 4) |
2 | (2, 2) | (2, 3) | (2, 4) |
3 | (3, 2) | (3, 3) | (3, 4) |
x[!, Cols(:x1, Between(:x3, :x5))]
Row | x1 | x3 | x4 | x5 |
---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 3) | (1, 4) | (1, 5) |
2 | (2, 1) | (2, 3) | (2, 4) | (2, 5) |
3 | (3, 1) | (3, 3) | (3, 4) | (3, 5) |
select(x, :x1, Between(:x3, :x5), copycols=false) ## the same as above
Row | x1 | x3 | x4 | x5 |
---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 3) | (1, 4) | (1, 5) |
2 | (2, 1) | (2, 3) | (2, 4) | (2, 5) |
3 | (3, 1) | (3, 3) | (3, 4) | (3, 5) |
you can use select
and select!
functions to select a subset of columns from a data frame. select
creates a new data frame and select!
operates in place
df = copy(x)
Row | x1 | x2 | x3 | x4 | x5 |
---|---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) | (1, 5) |
2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) | (2, 5) |
3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) | (3, 5) |
df2 = select(df, [1, 2])
Row | x1 | x2 |
---|---|---|
Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) |
2 | (2, 1) | (2, 2) |
3 | (3, 1) | (3, 2) |
select(df, Not([1, 2]))
Row | x3 | x4 | x5 |
---|---|---|---|
Tuple… | Tuple… | Tuple… | |
1 | (1, 3) | (1, 4) | (1, 5) |
2 | (2, 3) | (2, 4) | (2, 5) |
3 | (3, 3) | (3, 4) | (3, 5) |
by default select
copies columns
df2[!, 1] === df[!, 1]
false
which can be avoided by giving copycols=false
df2 = select(df, [1, 2], copycols=false)
Row | x1 | x2 |
---|---|---|
Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) |
2 | (2, 1) | (2, 2) |
3 | (3, 1) | (3, 2) |
df2[!, 1] === df[!, 1]
true
using select!
will modify the source data frame
select!(df, [1,2])
Row | x1 | x2 |
---|---|---|
Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) |
2 | (2, 1) | (2, 2) |
3 | (3, 1) | (3, 2) |
df == df2
true
Here we create a copy of x
and delete the 3rd column from the copy with select!
and Not
z = copy(x)
select!(z, Not(3))
Row | x1 | x2 | x4 | x5 |
---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) | (1, 4) | (1, 5) |
2 | (2, 1) | (2, 2) | (2, 4) | (2, 5) |
3 | (3, 1) | (3, 2) | (3, 4) | (3, 5) |
alternatively we can achieve the same by using the select
function
select(x, Not(3))
Row | x1 | x2 | x4 | x5 |
---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) | (1, 4) | (1, 5) |
2 | (2, 1) | (2, 2) | (2, 4) | (2, 5) |
3 | (3, 1) | (3, 2) | (3, 4) | (3, 5) |
x
stays unchanged
x
Row | x1 | x2 | x3 | x4 | x5 |
---|---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) | (1, 5) |
2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) | (2, 5) |
3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) | (3, 5) |
Views#
Note, that you can also create a view of a DataFrame when we want a subset of its columns:
@btime x[:, [1,3,5]]
1.185 μs (25 allocations: 1.50 KiB)
Row | x1 | x3 | x5 |
---|---|---|---|
Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 3) | (1, 5) |
2 | (2, 1) | (2, 3) | (2, 5) |
3 | (3, 1) | (3, 3) | (3, 5) |
@btime @view x[:, [1,3,5]]
416.232 ns (5 allocations: 240 bytes)
Row | x1 | x3 | x5 |
---|---|---|---|
Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 3) | (1, 5) |
2 | (2, 1) | (2, 3) | (2, 5) |
3 | (3, 1) | (3, 3) | (3, 5) |
(Right now creation of the view
is slow, but in the coming releases of the DataFrames.jl
package it will become significantly faster)
Modify column by name#
x = DataFrame([(i,j) for i in 1:3, j in 1:5], :auto)
Row | x1 | x2 | x3 | x4 | x5 |
---|---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) | (1, 5) |
2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) | (2, 5) |
3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) | (3, 5) |
With the following syntax, the existing column is modified without performing any copying (this is discouraged as it creates column alias).
x[!, :x1] = x[!, :x2]
x
Row | x1 | x2 | x3 | x4 | x5 |
---|---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 2) | (1, 2) | (1, 3) | (1, 4) | (1, 5) |
2 | (2, 2) | (2, 2) | (2, 3) | (2, 4) | (2, 5) |
3 | (3, 2) | (3, 2) | (3, 3) | (3, 4) | (3, 5) |
this syntax is safer since it performs copy
x[!, :x1] = x[:, :x2]
3-element Vector{Tuple{Int64, Int64}}:
(1, 2)
(2, 2)
(3, 2)
We can also use the following syntax to add a new column at the end of a DataFrame
.
x[!, :A] = [1,2,3]
x
Row | x1 | x2 | x3 | x4 | x5 | A |
---|---|---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | Tuple… | Int64 | |
1 | (1, 2) | (1, 2) | (1, 3) | (1, 4) | (1, 5) | 1 |
2 | (2, 2) | (2, 2) | (2, 3) | (2, 4) | (2, 5) | 2 |
3 | (3, 2) | (3, 2) | (3, 3) | (3, 4) | (3, 5) | 3 |
A new column name will be added to our DataFrame
with the following syntax as well:
x.B = 11:13
x
Row | x1 | x2 | x3 | x4 | x5 | A | B |
---|---|---|---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | Tuple… | Int64 | Int64 | |
1 | (1, 2) | (1, 2) | (1, 3) | (1, 4) | (1, 5) | 1 | 11 |
2 | (2, 2) | (2, 2) | (2, 3) | (2, 4) | (2, 5) | 2 | 12 |
3 | (3, 2) | (3, 2) | (3, 3) | (3, 4) | (3, 5) | 3 | 13 |
Find column name#
x = DataFrame([(i,j) for i in 1:3, j in 1:5], :auto)
Row | x1 | x2 | x3 | x4 | x5 |
---|---|---|---|---|---|
Tuple… | Tuple… | Tuple… | Tuple… | Tuple… | |
1 | (1, 1) | (1, 2) | (1, 3) | (1, 4) | (1, 5) |
2 | (2, 1) | (2, 2) | (2, 3) | (2, 4) | (2, 5) |
3 | (3, 1) | (3, 2) | (3, 3) | (3, 4) | (3, 5) |
We can check if a column with a given name exists via hasproperty
hasproperty(x, :x1)
true
and determine its index via columnindex
columnindex(x, :x2)
2
Advanced ways of column selection#
these are most useful for non-standard column names (e.g. containing spaces)
df = DataFrame()
df.x1 = 1:3
df[!, "column 2"] = 4:6
df
Row | x1 | column 2 |
---|---|---|
Int64 | Int64 | |
1 | 1 | 4 |
2 | 2 | 5 |
3 | 3 | 6 |
df."column 2"
3-element Vector{Int64}:
4
5
6
df[:, "column 2"]
3-element Vector{Int64}:
4
5
6
or you can interpolate column names using the :()
syntax
for n in names(df)
println(n, "\n", df.:($n), "\n")
end
x1
[1, 2, 3]
column 2
[4, 5, 6]
Working on a collection of columns#
When using eachcol
of a data frame the resulting object retains reference to its parent and e.g. can be queried with getproperty
df = DataFrame(reshape(1:12, 3, 4), :auto)
Row | x1 | x2 | x3 | x4 |
---|---|---|---|---|
Int64 | Int64 | Int64 | Int64 | |
1 | 1 | 4 | 7 | 10 |
2 | 2 | 5 | 8 | 11 |
3 | 3 | 6 | 9 | 12 |
ec_df = eachcol(df)
Row | x1 | x2 | x3 | x4 |
---|---|---|---|---|
Int64 | Int64 | Int64 | Int64 | |
1 | 1 | 4 | 7 | 10 |
2 | 2 | 5 | 8 | 11 |
3 | 3 | 6 | 9 | 12 |
ec_df[1]
3-element Vector{Int64}:
1
2
3
ec_df.x1
3-element Vector{Int64}:
1
2
3
Transforming columns#
We will get to this subject later in 10_transforms.ipynb notebook, but here let us just note that select
, select!
, transform
, transform!
and combine
functions allow to generate new columns based on the old columns of a data frame.
The general rules are the following:
select
andtransform
always return the number of rows equal to the source data frame, whilecombine
returns any number of rows (combine
is allowed to combine rows of the source data frame)transform
retains columns from the old data frameselect!
andtransform!
are in-place versions ofselect
andtransform
df = DataFrame(reshape(1:12, 3, 4), :auto)
Row | x1 | x2 | x3 | x4 |
---|---|---|---|---|
Int64 | Int64 | Int64 | Int64 | |
1 | 1 | 4 | 7 | 10 |
2 | 2 | 5 | 8 | 11 |
3 | 3 | 6 | 9 | 12 |
Here we add a new column :res
that is a sum of columns :x1
and :x2
. A general syntax of transformations of this kind is:
source_columns => function_to_apply => target_column_name
then function_to_apply
gets columns selected by source_columns
as positional arguments.
transform(df, [:x1, :x2] => (+) => :res)
Row | x1 | x2 | x3 | x4 | res |
---|---|---|---|---|---|
Int64 | Int64 | Int64 | Int64 | Int64 | |
1 | 1 | 4 | 7 | 10 | 5 |
2 | 2 | 5 | 8 | 11 | 7 |
3 | 3 | 6 | 9 | 12 | 9 |
One can omit passing target_column_name in which case it is automatically generated:
using Statistics
combine(df, [:x1, :x2] => cor)
Row | x1_x2_cor |
---|---|
Float64 | |
1 | 1.0 |
Note that combine
allowed the number of columns in the resulting data frame to be changed. If we used select
instead it would automatically broadcast the return value to match the number of rows of the source:
select(df, [:x1, :x2] => cor)
Row | x1_x2_cor |
---|---|
Float64 | |
1 | 1.0 |
2 | 1.0 |
3 | 1.0 |
If you want to apply some function on each row of the source wrap it in ByRow
:
select(df, :x1, :x2, [:x1, :x2] => ByRow(string))
Row | x1 | x2 | x1_x2_string |
---|---|---|---|
Int64 | Int64 | String | |
1 | 1 | 4 | 14 |
2 | 2 | 5 | 25 |
3 | 3 | 6 | 36 |
Also if you want columns to be passed as a NamedTuple
to a function (instead of being positional arguments) wrap them in AsTable
:
select(df, :x1, :x2, AsTable([:x1, :x2]) => x -> x.x1 + x.x2)
Row | x1 | x2 | x1_x2_function |
---|---|---|---|
Int64 | Int64 | Int64 | |
1 | 1 | 4 | 5 |
2 | 2 | 5 | 7 |
3 | 3 | 6 | 9 |
For simplicity (as this functionality is often needed) there is a special treatment of nrow
function that can be just passed as a transformation (without specifying of column selector):
select(df, :x1, nrow => "number_of_rows")
Row | x1 | number_of_rows |
---|---|---|
Int64 | Int64 | |
1 | 1 | 3 |
2 | 2 | 3 |
3 | 3 | 3 |
(note that in select
the number of rows is automatically broadcasted to match the number of rows of the source data frame)
Finally you can conveniently create multiple columns with one function, :
select(df, :x1, :x1 => ByRow(x -> [x ^ 2, x ^ 3]) => ["x1²", "x1³"])
Row | x1 | x1² | x1³ |
---|---|---|---|
Int64 | Int64 | Int64 | |
1 | 1 | 1 | 1 |
2 | 2 | 4 | 8 |
3 | 3 | 9 | 27 |
or (this produces the same result)
select(df, :x1, :x1 => (x -> DataFrame("x1²" => x .^ 2, "x1³" => x .^ 3)) => AsTable)
Row | x1 | x1² | x1³ |
---|---|---|---|
Int64 | Int64 | Int64 | |
1 | 1 | 1 | 1 |
2 | 2 | 4 | 8 |
3 | 3 | 9 | 27 |
Note that since DataFrames.jl
row aggregation for wide tables is efficient. Here is an example of a wide table with sum
(other standard reductions are similarly supported):
large_df = DataFrame(rand(1000, 10000), :auto)
Row | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | x10 | x11 | x12 | x13 | x14 | x15 | x16 | x17 | x18 | x19 | x20 | x21 | x22 | x23 | x24 | x25 | x26 | x27 | x28 | x29 | x30 | x31 | x32 | x33 | x34 | x35 | x36 | x37 | x38 | x39 | x40 | x41 | x42 | x43 | x44 | x45 | x46 | x47 | x48 | x49 | x50 | x51 | x52 | x53 | x54 | x55 | x56 | x57 | x58 | x59 | x60 | x61 | x62 | x63 | x64 | x65 | x66 | x67 | x68 | x69 | x70 | x71 | x72 | x73 | x74 | x75 | x76 | x77 | x78 | x79 | x80 | x81 | x82 | x83 | x84 | x85 | x86 | x87 | x88 | x89 | x90 | x91 | x92 | x93 | x94 | x95 | x96 | x97 | x98 | x99 | x100 | ⋯ |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | Float64 | ⋯ | |
1 | 0.639562 | 0.0423618 | 0.779594 | 0.130453 | 0.173812 | 0.525416 | 0.324965 | 0.905649 | 0.0863895 | 0.504512 | 0.831362 | 0.609332 | 0.362646 | 0.296489 | 0.124294 | 0.445428 | 0.383877 | 0.701939 | 0.899178 | 0.802026 | 0.596313 | 0.550465 | 0.0130267 | 0.305685 | 0.242941 | 0.976732 | 0.855757 | 0.185339 | 0.492588 | 0.886498 | 0.0670387 | 0.224632 | 0.973181 | 0.700497 | 0.927605 | 0.244754 | 0.552813 | 0.232683 | 0.535975 | 0.756654 | 0.663562 | 0.417351 | 0.610787 | 0.32249 | 0.977989 | 0.959334 | 0.825686 | 0.933289 | 0.15489 | 0.427586 | 0.921159 | 0.0408699 | 0.178735 | 0.182879 | 0.299849 | 0.646616 | 0.163978 | 0.685145 | 0.897406 | 0.689855 | 0.430954 | 0.695262 | 0.00489971 | 0.684737 | 0.112393 | 0.620627 | 0.329097 | 0.568049 | 0.53415 | 0.368477 | 0.713737 | 0.791697 | 0.0436433 | 0.356715 | 0.29434 | 0.8489 | 0.73944 | 0.577009 | 0.369629 | 0.0308708 | 0.0632458 | 0.668124 | 0.481055 | 0.629309 | 0.93324 | 0.107562 | 0.982491 | 0.453432 | 0.281526 | 0.372878 | 0.837115 | 0.196414 | 0.776446 | 0.191924 | 0.256692 | 0.0757817 | 0.274321 | 0.84296 | 0.899023 | 0.00600951 | ⋯ |
2 | 0.839622 | 0.740699 | 0.360969 | 0.456934 | 0.398093 | 0.509447 | 0.335432 | 0.373952 | 0.398662 | 0.851182 | 0.402862 | 0.827348 | 0.222065 | 0.646395 | 0.139992 | 0.720584 | 0.0681818 | 0.452283 | 0.655416 | 0.919854 | 0.634287 | 0.552484 | 0.39818 | 0.722039 | 0.8756 | 0.448769 | 0.554755 | 0.613562 | 0.710213 | 0.00465215 | 0.963763 | 0.111464 | 0.579245 | 0.0783318 | 0.811602 | 0.0586896 | 0.121353 | 0.451426 | 0.416095 | 0.167802 | 0.296337 | 0.68025 | 0.865083 | 0.455578 | 0.984931 | 0.699277 | 0.113661 | 0.0172499 | 0.389797 | 0.731438 | 0.179854 | 0.181849 | 0.64722 | 0.73755 | 0.0387112 | 0.163176 | 0.5831 | 0.618315 | 0.858166 | 0.487437 | 0.649856 | 0.510468 | 0.265383 | 0.716345 | 0.858997 | 0.421035 | 0.71227 | 0.210916 | 0.0728364 | 0.115068 | 0.923333 | 0.872 | 0.394273 | 0.575864 | 0.947865 | 0.511522 | 0.00605284 | 0.818524 | 0.226928 | 0.949736 | 0.757384 | 0.66079 | 0.827428 | 0.568193 | 0.00421599 | 0.12546 | 0.585029 | 0.31564 | 0.981435 | 0.229752 | 0.826171 | 0.133524 | 0.286998 | 0.544742 | 0.70628 | 0.61295 | 0.130509 | 0.473567 | 0.410999 | 0.685049 | ⋯ |
3 | 0.967143 | 0.302672 | 0.706902 | 0.0653216 | 0.644417 | 0.976457 | 0.36895 | 0.80553 | 0.704988 | 0.229158 | 0.422051 | 0.0835024 | 0.0600902 | 0.139551 | 0.851271 | 0.513128 | 0.4164 | 0.7523 | 0.173736 | 0.189301 | 0.389565 | 0.701714 | 0.743298 | 0.439659 | 0.646357 | 0.0539669 | 0.835487 | 0.632989 | 0.374562 | 0.266812 | 0.344614 | 0.0987843 | 0.205053 | 0.0121658 | 0.714131 | 0.94708 | 0.161188 | 0.31177 | 0.583715 | 0.887539 | 0.337576 | 0.0647835 | 0.78173 | 0.796417 | 0.426654 | 0.264726 | 0.10321 | 0.341679 | 0.180502 | 0.347792 | 0.142075 | 0.159654 | 0.847052 | 0.553683 | 0.548342 | 0.898875 | 0.147509 | 0.34916 | 0.49193 | 0.830147 | 0.75918 | 0.29523 | 0.552179 | 0.395406 | 0.203592 | 0.355477 | 0.128912 | 0.460629 | 0.974718 | 0.598744 | 0.536191 | 0.49289 | 0.337427 | 0.266863 | 0.598862 | 0.0480737 | 0.0973554 | 0.0952945 | 0.327903 | 0.33965 | 0.942363 | 0.424944 | 0.609847 | 0.0431133 | 0.938313 | 0.678512 | 0.246945 | 0.758531 | 0.143185 | 0.54149 | 0.290775 | 0.854097 | 0.5934 | 0.0493715 | 0.308289 | 0.932613 | 0.100065 | 0.83117 | 0.964044 | 0.532569 | ⋯ |
4 | 0.205168 | 0.683128 | 0.786909 | 0.819635 | 0.759663 | 0.588019 | 0.244011 | 0.888136 | 0.794367 | 0.360823 | 0.199259 | 0.826867 | 0.761233 | 0.0448482 | 0.856025 | 0.901308 | 0.540944 | 0.560751 | 0.352295 | 0.767541 | 0.44367 | 0.678469 | 0.19966 | 0.732522 | 0.502541 | 0.597413 | 0.656933 | 0.301444 | 0.181241 | 0.157532 | 0.714083 | 0.171852 | 0.42279 | 0.699374 | 0.13507 | 0.682853 | 0.543554 | 0.0820418 | 0.270709 | 0.835811 | 0.322101 | 0.383821 | 0.39942 | 0.21642 | 0.689587 | 0.290182 | 0.0742331 | 0.727136 | 0.208275 | 0.485364 | 0.432417 | 0.643245 | 0.124293 | 0.812727 | 0.335484 | 0.0194431 | 0.143856 | 0.254743 | 0.47993 | 0.00236364 | 0.896375 | 0.528712 | 0.600894 | 0.0705582 | 0.41725 | 0.1068 | 0.267478 | 0.745548 | 0.129849 | 0.269369 | 0.968378 | 0.73323 | 0.250992 | 0.0711908 | 0.763779 | 0.878408 | 0.695854 | 0.800981 | 0.0822155 | 0.228832 | 0.640236 | 0.739513 | 0.629127 | 0.175419 | 0.675191 | 0.851447 | 0.841781 | 0.748765 | 0.897175 | 0.518425 | 0.568143 | 0.792276 | 0.561812 | 0.59942 | 0.927527 | 0.105334 | 0.325056 | 0.0615128 | 0.668108 | 0.584317 | ⋯ |
5 | 0.527184 | 0.22961 | 0.395737 | 0.712888 | 0.286281 | 0.0784137 | 0.214371 | 0.693681 | 0.812741 | 0.850144 | 0.633995 | 0.380388 | 0.513486 | 0.104272 | 0.894109 | 0.774682 | 0.79541 | 0.951264 | 0.253308 | 0.294483 | 0.457423 | 0.15226 | 0.517339 | 0.959809 | 0.261888 | 0.562237 | 0.125323 | 0.883358 | 0.301598 | 0.0422402 | 0.355124 | 0.642006 | 0.691682 | 0.911635 | 0.53746 | 0.596286 | 0.385353 | 0.663463 | 0.581572 | 0.318694 | 0.498642 | 0.525428 | 0.549403 | 0.976401 | 0.144109 | 0.572332 | 0.331346 | 0.641637 | 0.934612 | 0.928831 | 0.642698 | 0.25521 | 0.30113 | 0.698648 | 0.788803 | 0.93338 | 0.188807 | 0.390641 | 0.916819 | 0.517061 | 0.844072 | 0.902947 | 0.322715 | 0.158913 | 0.849192 | 0.0943718 | 0.539887 | 0.853765 | 0.10927 | 0.558812 | 0.400448 | 0.971353 | 0.830961 | 0.302348 | 0.666566 | 0.17653 | 0.234576 | 0.553072 | 0.804793 | 0.661114 | 0.794541 | 0.495311 | 0.696857 | 0.268942 | 0.792013 | 0.739865 | 0.305898 | 0.784717 | 0.154662 | 0.950777 | 0.810738 | 0.991764 | 0.180139 | 0.954313 | 0.297343 | 0.436954 | 0.978416 | 0.32379 | 0.424663 | 0.877706 | ⋯ |
6 | 0.951162 | 0.963781 | 0.176482 | 0.751149 | 0.394366 | 0.945845 | 0.62704 | 0.96774 | 0.103318 | 0.674938 | 0.550164 | 0.717422 | 0.606048 | 0.295866 | 0.538989 | 0.13301 | 0.939215 | 0.418093 | 0.649185 | 0.983029 | 0.578834 | 0.0552365 | 0.154984 | 0.590466 | 0.108776 | 0.449178 | 0.248731 | 0.174672 | 0.983469 | 0.21593 | 0.820917 | 0.556617 | 0.429342 | 0.436862 | 0.435403 | 0.041061 | 0.0840443 | 0.651938 | 0.818201 | 0.839926 | 0.995171 | 0.78029 | 0.0299824 | 0.606447 | 0.467301 | 0.838808 | 0.624765 | 0.614341 | 0.740568 | 0.308466 | 0.160896 | 0.682842 | 0.556888 | 0.0769152 | 0.821016 | 0.416731 | 0.392941 | 0.23032 | 0.425042 | 0.361674 | 0.570486 | 0.383419 | 0.812583 | 0.496401 | 0.538982 | 0.633557 | 0.994718 | 0.893841 | 0.79299 | 0.961518 | 0.627831 | 0.0425985 | 0.424132 | 0.86962 | 0.78264 | 0.116515 | 0.751977 | 0.0872114 | 0.148502 | 0.149564 | 0.718268 | 0.719193 | 0.305653 | 0.737801 | 0.0611981 | 0.285703 | 0.83414 | 0.92305 | 0.0805378 | 0.436171 | 0.0366427 | 0.439864 | 0.749147 | 0.925019 | 0.519798 | 0.550835 | 0.229706 | 0.437717 | 0.45817 | 0.104438 | ⋯ |
7 | 0.0739957 | 0.283035 | 0.799618 | 0.933321 | 0.507272 | 0.784482 | 0.796879 | 0.696612 | 0.894212 | 0.382362 | 0.908464 | 0.308248 | 0.210729 | 0.346736 | 0.844222 | 0.807014 | 0.982418 | 0.865151 | 0.765427 | 0.873813 | 0.412594 | 0.339431 | 0.342532 | 0.303684 | 0.199616 | 0.273681 | 0.0992714 | 0.857483 | 0.679987 | 0.395899 | 0.891678 | 0.946146 | 0.474167 | 0.140058 | 0.586656 | 0.310985 | 0.372675 | 0.97048 | 0.696956 | 0.000570175 | 0.784109 | 0.484797 | 0.403814 | 0.810146 | 0.311677 | 0.612799 | 0.331593 | 0.622582 | 0.642823 | 0.678849 | 0.571178 | 0.0541166 | 0.362722 | 0.105572 | 0.579129 | 0.480578 | 0.317466 | 0.480973 | 0.268329 | 0.395828 | 0.581477 | 0.693115 | 0.079105 | 0.43919 | 0.573477 | 0.764633 | 0.542909 | 0.571959 | 0.523436 | 0.472797 | 0.694659 | 0.161305 | 0.421671 | 0.226012 | 0.577362 | 0.393822 | 0.20944 | 0.198858 | 0.820826 | 0.620017 | 0.267211 | 0.549776 | 0.749344 | 0.847738 | 0.103822 | 0.228632 | 0.396743 | 0.9309 | 0.809751 | 0.760363 | 0.68731 | 0.868271 | 0.643134 | 0.638336 | 0.256193 | 0.614016 | 0.944516 | 0.993462 | 0.579241 | 0.0483441 | ⋯ |
8 | 0.110817 | 0.0200235 | 0.183445 | 0.608763 | 0.329629 | 0.395999 | 0.223654 | 0.540622 | 0.333467 | 0.95319 | 0.623775 | 0.546129 | 0.171263 | 0.12402 | 0.704357 | 0.981682 | 0.38245 | 0.0824933 | 0.40361 | 0.773983 | 0.303502 | 0.333662 | 0.856646 | 0.799011 | 0.00792759 | 0.922241 | 0.0542892 | 0.805216 | 0.0436283 | 0.0576058 | 0.245166 | 0.0537874 | 0.617031 | 0.518009 | 0.327581 | 0.416586 | 0.379606 | 0.552033 | 0.087396 | 0.564731 | 0.0226406 | 0.135114 | 0.657373 | 0.532859 | 0.213292 | 0.546442 | 0.112593 | 0.819173 | 0.139977 | 0.167824 | 0.701922 | 0.996612 | 0.404718 | 0.54209 | 0.00265105 | 0.708725 | 0.553089 | 0.945526 | 0.77876 | 0.393942 | 0.210356 | 0.56444 | 0.366649 | 0.490977 | 0.43466 | 0.0446814 | 0.972688 | 0.159408 | 0.62489 | 0.598965 | 0.743671 | 0.416403 | 0.793989 | 0.131092 | 0.390912 | 0.388496 | 0.857239 | 0.249479 | 0.40868 | 0.397858 | 0.633608 | 0.390416 | 0.643316 | 0.590817 | 0.611692 | 0.94996 | 0.313106 | 0.143876 | 0.817705 | 0.112249 | 0.648748 | 0.509789 | 0.0737565 | 0.785168 | 0.478926 | 0.940682 | 0.958308 | 0.58343 | 0.691115 | 0.786075 | ⋯ |
9 | 0.103929 | 0.489357 | 0.943654 | 0.981498 | 0.906475 | 0.27605 | 0.319854 | 0.505438 | 0.27844 | 0.778794 | 0.130514 | 0.169551 | 0.596171 | 0.458798 | 0.95805 | 0.0328401 | 0.58501 | 0.834443 | 0.285972 | 0.552548 | 0.724397 | 0.744955 | 0.0488314 | 0.390639 | 0.465757 | 0.160463 | 0.70125 | 0.194893 | 0.526646 | 0.365876 | 0.0372343 | 0.726442 | 0.0175973 | 0.769848 | 0.451365 | 0.401056 | 0.420727 | 0.560409 | 0.471766 | 0.337263 | 0.145229 | 0.0791614 | 0.758629 | 0.698382 | 0.75589 | 0.629202 | 0.902828 | 0.605323 | 0.034645 | 0.491409 | 0.0471005 | 0.426415 | 0.518352 | 0.22079 | 0.0364343 | 0.965219 | 0.239123 | 0.304706 | 0.654597 | 0.311824 | 0.175638 | 0.090416 | 0.977695 | 0.644337 | 0.856763 | 0.637181 | 0.373946 | 0.98665 | 0.468634 | 0.969294 | 0.0833085 | 0.458731 | 0.822941 | 0.633568 | 0.216647 | 0.680109 | 0.0503443 | 0.217752 | 0.55126 | 0.0549194 | 0.968164 | 0.638207 | 0.464517 | 0.383313 | 0.13081 | 0.524253 | 0.327397 | 0.0178429 | 0.857295 | 0.729045 | 0.556046 | 0.317141 | 0.801009 | 0.381532 | 0.784044 | 0.787365 | 0.311033 | 0.410349 | 0.551543 | 0.933318 | ⋯ |
10 | 0.806704 | 0.597994 | 0.293338 | 0.71464 | 0.821485 | 0.421753 | 0.578613 | 0.274216 | 0.424539 | 0.379679 | 0.839805 | 0.902456 | 0.252799 | 0.563533 | 0.23067 | 0.806573 | 0.402857 | 0.7225 | 0.763932 | 0.663562 | 0.839098 | 0.026974 | 0.615383 | 0.143334 | 0.444809 | 0.367943 | 0.506325 | 0.0397944 | 0.604328 | 0.357131 | 0.422544 | 0.0409795 | 0.533926 | 0.501725 | 0.821395 | 0.374021 | 0.769564 | 0.676575 | 0.439214 | 0.759525 | 0.824962 | 0.58322 | 0.115094 | 0.906221 | 0.826537 | 0.829707 | 0.738376 | 0.418851 | 0.191779 | 0.469279 | 0.222718 | 0.523448 | 0.129809 | 0.00748883 | 0.437603 | 0.094494 | 0.493551 | 0.191608 | 0.449934 | 0.653904 | 0.684418 | 0.0223881 | 0.754044 | 0.339028 | 0.384908 | 0.262317 | 0.912023 | 0.754209 | 0.506818 | 0.825813 | 0.460699 | 0.00281085 | 0.941587 | 0.0613782 | 0.169732 | 0.403069 | 0.155711 | 0.322738 | 0.973102 | 0.0762117 | 0.569624 | 0.34844 | 0.335365 | 0.582599 | 0.107247 | 0.607799 | 0.512198 | 0.00637144 | 0.328829 | 0.714854 | 0.339914 | 0.985819 | 0.500261 | 0.521552 | 0.28377 | 0.20955 | 0.469604 | 0.652663 | 0.683621 | 0.746581 | ⋯ |
11 | 0.870539 | 0.0866983 | 0.720978 | 0.957936 | 0.410978 | 0.132653 | 0.665372 | 0.593325 | 0.0465987 | 0.135042 | 0.0570036 | 0.121709 | 0.430551 | 0.724999 | 0.46881 | 0.626354 | 0.397452 | 0.254975 | 0.517491 | 0.373471 | 0.384463 | 0.897556 | 0.257818 | 0.167195 | 0.560633 | 0.726255 | 0.478231 | 0.185042 | 0.624979 | 0.771154 | 0.912102 | 0.111355 | 0.464301 | 0.0200843 | 0.170537 | 0.334158 | 0.588337 | 0.980649 | 0.313508 | 0.800289 | 0.684536 | 0.813531 | 0.748087 | 0.607404 | 0.865426 | 0.364455 | 0.407324 | 0.719172 | 0.47475 | 0.543448 | 0.884125 | 0.495734 | 0.895777 | 0.388243 | 0.788063 | 0.449247 | 0.326003 | 0.975798 | 0.0260481 | 0.883035 | 0.55042 | 0.871367 | 0.16296 | 0.879233 | 0.590651 | 0.712671 | 0.918869 | 0.872322 | 0.624434 | 0.349621 | 0.216777 | 0.605672 | 0.226441 | 0.0657425 | 0.117751 | 0.500955 | 0.19695 | 0.0973536 | 0.0954175 | 0.0388831 | 0.646106 | 0.141421 | 0.97455 | 0.100159 | 0.541999 | 0.250148 | 0.974178 | 0.819375 | 0.613793 | 0.302014 | 0.472027 | 0.329189 | 0.177003 | 0.373291 | 0.812304 | 0.433818 | 0.597939 | 0.283612 | 0.781218 | 0.550587 | ⋯ |
12 | 0.790207 | 0.957745 | 0.144518 | 0.988098 | 0.558975 | 0.855644 | 0.890067 | 0.0355403 | 0.614722 | 0.010735 | 0.131757 | 0.985604 | 0.487734 | 0.504373 | 0.639166 | 0.940391 | 0.0246699 | 0.811424 | 0.319053 | 0.226824 | 0.342274 | 0.995385 | 0.48907 | 0.0329517 | 0.503777 | 0.710012 | 0.20882 | 0.867677 | 0.197408 | 0.174302 | 0.679219 | 0.0984427 | 0.0557107 | 0.187365 | 0.313153 | 0.407695 | 0.854104 | 0.443166 | 0.219914 | 0.681128 | 0.959626 | 0.507634 | 0.15965 | 0.775183 | 0.750562 | 0.751946 | 0.696714 | 0.56582 | 0.255894 | 0.81349 | 0.49304 | 0.814149 | 0.185817 | 0.823473 | 0.450371 | 0.935392 | 0.673961 | 0.49567 | 0.688948 | 0.412266 | 0.766071 | 0.412645 | 0.40351 | 0.700514 | 0.922201 | 0.164178 | 0.655495 | 0.597995 | 0.074381 | 0.460613 | 0.428115 | 0.80045 | 0.163432 | 0.697937 | 0.828925 | 0.710106 | 0.721434 | 0.875123 | 0.116641 | 0.531262 | 0.189546 | 0.850723 | 0.896629 | 0.270588 | 0.0552421 | 0.849768 | 0.0193452 | 0.366311 | 0.771415 | 0.286502 | 0.63524 | 0.25816 | 0.714818 | 0.484916 | 0.524371 | 0.134777 | 0.439961 | 0.809517 | 0.597424 | 0.110481 | ⋯ |
13 | 0.800393 | 0.155563 | 0.21758 | 0.898822 | 0.751869 | 0.585648 | 0.993167 | 0.927108 | 0.895842 | 0.677554 | 0.927235 | 0.301437 | 0.795641 | 0.609869 | 0.952645 | 0.867056 | 0.47506 | 0.670733 | 0.561747 | 0.749897 | 0.691213 | 0.89734 | 0.350725 | 0.992192 | 0.356751 | 0.52648 | 0.696362 | 0.543172 | 0.636909 | 0.857589 | 0.283382 | 0.0506339 | 0.69603 | 0.0370107 | 0.0600706 | 0.423499 | 0.618501 | 0.130617 | 0.728638 | 0.892869 | 0.260576 | 0.489066 | 0.44997 | 0.448691 | 0.645738 | 0.603548 | 0.635739 | 0.0614138 | 0.914319 | 0.1329 | 0.34448 | 0.284202 | 0.399856 | 0.894362 | 0.41953 | 0.754306 | 0.629104 | 0.171604 | 0.115664 | 0.898324 | 0.114151 | 0.0275549 | 0.0868022 | 0.804994 | 0.902578 | 0.725342 | 0.401018 | 0.721672 | 0.855185 | 0.281244 | 0.114554 | 0.641207 | 0.766798 | 0.0107582 | 0.420291 | 0.416782 | 0.987019 | 0.295208 | 0.0983196 | 0.461359 | 0.767911 | 0.103142 | 0.97657 | 0.356033 | 0.043109 | 0.438298 | 0.0689969 | 0.89705 | 0.699477 | 0.0645848 | 0.0708957 | 0.363345 | 0.678557 | 0.36596 | 0.714326 | 0.781373 | 0.708633 | 0.671032 | 0.490127 | 0.391542 | ⋯ |
⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋮ | ⋱ |
989 | 0.318699 | 0.855621 | 0.89789 | 0.186005 | 0.757165 | 0.537527 | 0.523455 | 0.810702 | 0.413644 | 0.290425 | 0.958096 | 0.578765 | 0.63485 | 0.262268 | 0.245943 | 0.497027 | 0.366844 | 0.414837 | 0.346189 | 0.406763 | 0.811995 | 0.450049 | 0.889867 | 0.0975864 | 0.698496 | 0.469912 | 0.211348 | 0.270257 | 0.511298 | 0.324656 | 0.567215 | 0.0882201 | 0.20443 | 0.849721 | 0.139073 | 0.392252 | 0.122165 | 0.545188 | 0.638874 | 0.124667 | 0.784196 | 0.682275 | 0.860103 | 0.787796 | 0.286325 | 0.867909 | 0.988358 | 0.245936 | 0.214267 | 0.0564961 | 0.207305 | 0.745315 | 0.552497 | 0.53583 | 0.519448 | 0.8416 | 0.806909 | 0.444427 | 0.175787 | 0.744833 | 0.226012 | 0.867389 | 0.523275 | 0.753208 | 0.971446 | 0.930404 | 0.0443151 | 0.739493 | 0.177052 | 0.411851 | 0.565202 | 0.219197 | 0.741081 | 0.849491 | 0.923764 | 0.160924 | 0.150755 | 0.727482 | 0.347877 | 0.996283 | 0.952941 | 0.81976 | 0.404814 | 0.949774 | 0.726088 | 0.639014 | 0.298294 | 0.490915 | 0.718063 | 0.552294 | 0.384831 | 0.549358 | 0.724398 | 0.626641 | 0.00012028 | 0.854545 | 0.195479 | 0.0122166 | 0.495049 | 0.930874 | ⋯ |
990 | 0.385526 | 0.0811559 | 0.479614 | 0.163361 | 0.0102084 | 0.649546 | 0.657604 | 0.720042 | 0.465867 | 0.94045 | 0.782627 | 0.691367 | 0.0662754 | 0.732791 | 0.574579 | 0.381599 | 0.0708026 | 0.667565 | 0.531275 | 0.584148 | 0.199724 | 0.455764 | 0.607253 | 0.910883 | 0.737946 | 0.703731 | 0.849884 | 0.495902 | 0.242281 | 0.831206 | 0.207193 | 0.064264 | 0.00131496 | 0.959967 | 0.312419 | 0.595587 | 0.201843 | 0.0075384 | 0.846742 | 0.858428 | 0.579144 | 0.434224 | 0.333309 | 0.626536 | 0.590739 | 0.0646044 | 0.462775 | 0.490585 | 0.740537 | 0.592094 | 0.137367 | 0.549106 | 0.869887 | 0.705717 | 0.717586 | 0.363997 | 0.327315 | 0.654602 | 0.285881 | 0.73758 | 0.476954 | 0.439074 | 0.772946 | 0.774809 | 0.558633 | 0.359676 | 0.249601 | 0.310865 | 0.883622 | 0.594976 | 0.590758 | 0.494172 | 0.97784 | 0.515925 | 0.196056 | 0.759124 | 0.221263 | 0.510825 | 0.68341 | 0.544371 | 0.526324 | 0.192338 | 0.647001 | 0.422677 | 0.833559 | 0.455662 | 0.775089 | 0.554409 | 0.862595 | 0.604311 | 0.348085 | 0.556081 | 0.00258774 | 0.924799 | 0.840598 | 0.239618 | 0.470394 | 0.967358 | 0.038375 | 0.878066 | ⋯ |
991 | 0.767534 | 0.0617792 | 0.176153 | 0.131868 | 0.724383 | 0.123287 | 0.107581 | 0.729821 | 0.457523 | 0.828607 | 0.776822 | 0.244263 | 0.299397 | 0.412247 | 0.238761 | 0.207391 | 0.462917 | 0.364635 | 0.776059 | 0.32608 | 0.837259 | 0.463038 | 0.0127677 | 0.771429 | 0.119694 | 0.480773 | 0.0695285 | 0.806073 | 0.956675 | 0.894771 | 0.142201 | 0.883067 | 0.598491 | 0.530636 | 0.820437 | 0.31164 | 0.352237 | 0.890712 | 0.40235 | 0.464537 | 0.548343 | 0.0458953 | 0.641145 | 0.998334 | 0.145257 | 0.0875282 | 0.336953 | 0.699896 | 0.496931 | 0.793747 | 0.526583 | 0.654746 | 0.43628 | 0.488587 | 0.57485 | 0.250552 | 0.413833 | 0.739591 | 0.71607 | 0.911943 | 0.273417 | 0.224299 | 0.800708 | 0.256788 | 0.591665 | 0.680674 | 0.37792 | 0.593567 | 0.219588 | 0.195633 | 0.564893 | 0.655271 | 0.603345 | 0.625339 | 0.568971 | 0.771376 | 0.114952 | 0.821432 | 0.536726 | 0.818444 | 0.258796 | 0.0236264 | 0.184601 | 0.508794 | 0.088357 | 0.932051 | 0.837706 | 0.605877 | 0.807712 | 0.0458814 | 0.187622 | 0.0967899 | 0.030952 | 0.742876 | 0.40893 | 0.490123 | 0.595382 | 0.943939 | 0.266214 | 0.636875 | ⋯ |
992 | 0.0418284 | 0.335537 | 0.268967 | 0.506713 | 0.469135 | 0.854577 | 0.0525686 | 0.82436 | 0.789938 | 0.224031 | 0.435811 | 0.232425 | 0.260417 | 0.0905046 | 0.686003 | 0.756296 | 0.893411 | 0.756007 | 0.0732088 | 0.56236 | 0.170785 | 0.125606 | 0.8414 | 0.604793 | 0.30813 | 0.612169 | 0.354236 | 0.593016 | 0.567588 | 0.600515 | 0.174025 | 0.23901 | 0.0526941 | 0.869911 | 0.521615 | 0.29082 | 0.410553 | 0.273815 | 0.293903 | 0.663315 | 0.054443 | 0.220799 | 0.797752 | 0.111243 | 0.736725 | 0.59533 | 0.23797 | 0.430257 | 0.778644 | 0.428128 | 0.381536 | 0.617893 | 0.622634 | 0.902369 | 0.613745 | 0.233596 | 0.241457 | 0.767441 | 0.0605369 | 0.411935 | 0.00523765 | 0.969333 | 0.759425 | 0.684955 | 0.57601 | 0.44125 | 0.670824 | 0.451863 | 0.12151 | 0.908785 | 0.492328 | 0.596549 | 0.181193 | 0.536584 | 0.509993 | 0.840449 | 0.0228164 | 0.763183 | 0.660011 | 0.280108 | 0.988254 | 0.480485 | 0.52471 | 0.923312 | 0.574786 | 0.852336 | 0.435635 | 0.0190297 | 0.0334936 | 0.653838 | 0.542043 | 0.00297419 | 0.883895 | 0.146688 | 0.00245372 | 0.241135 | 0.678929 | 0.326385 | 0.507362 | 0.793913 | ⋯ |
993 | 0.481554 | 0.0441882 | 0.700181 | 0.317677 | 0.0846761 | 0.949135 | 0.457341 | 0.571596 | 0.0640147 | 0.781281 | 0.432866 | 0.119252 | 0.395297 | 0.286058 | 0.512666 | 0.28892 | 0.889065 | 0.392283 | 0.625326 | 0.638938 | 0.267646 | 0.753392 | 0.621089 | 0.0658605 | 0.59495 | 0.343818 | 0.770693 | 0.94488 | 0.227965 | 0.60915 | 0.296814 | 0.529701 | 0.207136 | 0.959052 | 0.383638 | 0.892441 | 0.62196 | 0.175727 | 0.549517 | 0.137818 | 0.918747 | 0.546968 | 0.668477 | 0.444744 | 0.931012 | 0.148076 | 0.507896 | 0.692397 | 0.942958 | 0.829974 | 0.506719 | 0.667715 | 0.382446 | 0.389034 | 0.592372 | 0.211112 | 0.0536174 | 0.435104 | 0.654613 | 0.0985265 | 0.724492 | 0.120103 | 0.193283 | 0.111822 | 0.136294 | 0.871079 | 0.406365 | 0.153837 | 0.492183 | 0.0707954 | 0.0270011 | 0.854367 | 0.76891 | 0.960738 | 0.256492 | 0.901838 | 0.457021 | 0.0812045 | 0.442128 | 0.397439 | 0.51791 | 0.75772 | 0.323711 | 0.779831 | 0.331937 | 0.896385 | 0.151654 | 0.752883 | 0.61111 | 0.233529 | 0.430181 | 0.162369 | 0.685753 | 0.734598 | 0.787228 | 0.327247 | 0.558746 | 0.632998 | 0.592922 | 0.329131 | ⋯ |
994 | 0.401528 | 0.658903 | 0.438309 | 0.211217 | 0.211515 | 0.441902 | 0.0280903 | 0.412717 | 0.180855 | 0.628166 | 0.949295 | 0.0234695 | 0.626841 | 0.70688 | 0.197621 | 0.216484 | 0.607782 | 0.769642 | 0.949958 | 0.249306 | 0.481014 | 0.697822 | 0.681857 | 0.920842 | 0.391799 | 0.567247 | 0.581468 | 0.275073 | 0.0414921 | 0.960641 | 0.120329 | 0.955094 | 0.84551 | 0.540647 | 0.072297 | 0.423689 | 0.545505 | 0.287923 | 0.281248 | 0.658782 | 0.481355 | 0.586361 | 0.527756 | 0.694976 | 0.772877 | 0.87787 | 0.782064 | 0.981036 | 0.393483 | 0.478884 | 0.673706 | 0.5727 | 0.518801 | 0.518592 | 0.787306 | 0.32225 | 0.668103 | 0.234636 | 0.36528 | 0.954682 | 0.938105 | 0.959623 | 0.151342 | 0.923438 | 0.313945 | 0.00595974 | 0.947103 | 0.852135 | 0.178326 | 0.546221 | 0.36211 | 0.143301 | 0.371219 | 0.72453 | 0.181077 | 0.591335 | 0.877893 | 0.717275 | 0.383012 | 0.182125 | 0.0768744 | 0.949392 | 0.437771 | 0.133059 | 0.984711 | 0.725745 | 0.92119 | 0.149844 | 0.591016 | 0.299839 | 0.793963 | 0.435089 | 0.739725 | 0.233321 | 0.0305735 | 0.945321 | 0.0268155 | 0.0756352 | 0.571333 | 0.623045 | ⋯ |
995 | 0.58985 | 0.909857 | 0.354735 | 0.442829 | 0.438322 | 0.847835 | 0.843131 | 0.727618 | 0.043537 | 0.2958 | 0.0626168 | 0.0375887 | 0.480541 | 0.187324 | 0.159619 | 0.681808 | 0.382427 | 0.7819 | 0.193915 | 0.918742 | 0.339773 | 0.996588 | 0.0750327 | 0.667384 | 0.813943 | 0.648744 | 0.778451 | 0.352497 | 0.805257 | 0.950376 | 0.286605 | 0.861475 | 0.137177 | 0.586876 | 0.747203 | 0.562411 | 0.633759 | 0.00705207 | 0.544606 | 0.818714 | 0.740385 | 0.56901 | 0.0370867 | 0.707534 | 0.119938 | 0.754687 | 0.113022 | 0.153186 | 0.571747 | 0.664875 | 0.884798 | 0.686204 | 0.336496 | 0.759956 | 0.0350065 | 0.238342 | 0.829981 | 0.778296 | 0.400111 | 0.460372 | 0.122122 | 0.0100303 | 0.514388 | 0.157644 | 0.439795 | 0.43117 | 0.169505 | 0.457244 | 0.557165 | 0.801513 | 0.70288 | 0.081918 | 0.21622 | 0.202525 | 0.973381 | 0.630359 | 0.625955 | 0.868939 | 0.0546023 | 0.386919 | 0.111863 | 0.444876 | 0.0105433 | 0.768942 | 0.94646 | 0.266636 | 0.334259 | 0.533529 | 0.342496 | 0.298016 | 0.768956 | 0.207063 | 0.587475 | 0.901736 | 0.337462 | 0.0886105 | 0.754298 | 0.595919 | 0.955853 | 0.548087 | ⋯ |
996 | 0.871944 | 0.821183 | 0.725636 | 0.521645 | 0.230773 | 0.506747 | 0.47283 | 0.902559 | 0.806089 | 0.710561 | 0.343707 | 0.291233 | 0.948628 | 0.525034 | 0.408663 | 0.784639 | 0.207999 | 0.916874 | 0.973697 | 0.594586 | 0.120818 | 0.591678 | 0.555085 | 0.269047 | 0.149341 | 0.836679 | 0.174623 | 0.0653285 | 0.247579 | 0.800229 | 0.805376 | 0.141725 | 0.70089 | 0.484247 | 0.542784 | 0.133376 | 0.706461 | 0.139403 | 0.311023 | 0.252198 | 0.110557 | 0.139412 | 0.402585 | 0.313334 | 0.485571 | 0.923477 | 0.232277 | 0.18273 | 0.216354 | 0.34598 | 0.716719 | 0.89775 | 0.85979 | 0.469057 | 0.353088 | 0.0658065 | 0.630643 | 0.194692 | 0.945528 | 0.263228 | 0.227477 | 0.898712 | 0.573841 | 0.834761 | 0.678992 | 0.0698554 | 0.606778 | 0.0664735 | 0.870948 | 0.0566045 | 0.240453 | 0.118974 | 0.814929 | 0.628905 | 0.834959 | 0.341687 | 0.303889 | 0.202003 | 0.639411 | 0.697289 | 0.00421912 | 0.799744 | 0.488837 | 0.335656 | 0.0953115 | 0.69099 | 0.928979 | 0.630334 | 0.225244 | 0.977107 | 0.108807 | 0.631775 | 0.0412976 | 0.621693 | 0.401818 | 0.599301 | 0.298324 | 0.427501 | 0.0149224 | 0.466253 | ⋯ |
997 | 0.702069 | 0.399582 | 0.377331 | 0.542735 | 0.38631 | 0.555332 | 0.742833 | 0.787603 | 0.728299 | 0.0205224 | 0.0392208 | 0.59181 | 0.134989 | 0.0577118 | 0.237958 | 0.66476 | 0.941283 | 0.801746 | 0.6268 | 0.885924 | 0.98753 | 0.555681 | 0.0225242 | 0.867217 | 0.213395 | 0.844451 | 0.45556 | 0.404991 | 0.548041 | 0.244942 | 0.378365 | 0.691279 | 0.478979 | 0.925638 | 0.583101 | 0.140049 | 0.772856 | 0.561587 | 0.00306217 | 0.549884 | 0.342337 | 0.588316 | 0.276132 | 0.589743 | 0.220219 | 0.545051 | 0.63901 | 0.0112304 | 0.789922 | 0.619918 | 0.888162 | 0.888522 | 0.0871537 | 0.170892 | 0.257639 | 0.0514265 | 0.0285141 | 0.495923 | 0.0645104 | 0.0369986 | 0.737504 | 0.352119 | 0.209841 | 0.540092 | 0.592286 | 0.027314 | 0.092139 | 0.600756 | 0.164885 | 0.409008 | 0.947233 | 0.177876 | 0.643399 | 0.742034 | 0.269545 | 0.464876 | 0.338276 | 0.464954 | 0.613252 | 0.561679 | 0.612696 | 0.313784 | 0.7675 | 0.901055 | 0.696108 | 0.0105366 | 0.266548 | 0.00447812 | 0.502627 | 0.454181 | 0.249365 | 0.361495 | 0.865166 | 0.546343 | 0.941237 | 0.859312 | 0.409052 | 0.32661 | 0.400972 | 0.768701 | ⋯ |
998 | 0.70703 | 0.166208 | 0.45823 | 0.0682235 | 0.458422 | 0.836939 | 0.58208 | 0.721586 | 0.171453 | 0.353899 | 0.922517 | 0.394151 | 0.661091 | 0.381341 | 0.558679 | 0.847687 | 0.671701 | 0.373212 | 0.196267 | 0.353311 | 0.813622 | 0.192031 | 0.911645 | 0.452465 | 0.604791 | 0.743038 | 0.776148 | 0.00348142 | 0.332103 | 0.903827 | 0.88745 | 0.891842 | 0.203428 | 0.259077 | 0.243465 | 0.877412 | 0.614433 | 0.766943 | 0.22814 | 0.302435 | 0.849376 | 0.194502 | 0.903999 | 0.0363242 | 0.536268 | 0.886766 | 0.491461 | 0.87315 | 0.0148271 | 0.257042 | 0.210517 | 0.570115 | 0.684481 | 0.466046 | 0.367677 | 0.692357 | 0.922489 | 0.0315743 | 0.964974 | 0.523279 | 0.338024 | 0.509674 | 0.163316 | 0.362407 | 0.301272 | 0.879559 | 0.499213 | 0.631802 | 0.331658 | 0.370499 | 0.450381 | 0.604831 | 0.125916 | 0.934434 | 0.306163 | 0.207142 | 0.471049 | 0.0668867 | 0.0232546 | 0.212272 | 0.267954 | 0.398719 | 0.695908 | 0.850557 | 0.0875997 | 0.421732 | 0.330967 | 0.784816 | 0.0130859 | 0.341161 | 0.396292 | 0.412785 | 0.302764 | 0.849904 | 0.175216 | 0.687009 | 0.909296 | 0.692519 | 0.244417 | 0.0393655 | ⋯ |
999 | 0.82876 | 0.526196 | 0.298927 | 0.639369 | 0.261559 | 0.979035 | 0.934639 | 0.121346 | 0.251586 | 0.393869 | 0.15334 | 0.151882 | 0.640286 | 0.00827146 | 0.326673 | 0.125069 | 0.569502 | 0.227871 | 0.581491 | 0.429951 | 0.879147 | 0.0513471 | 0.962291 | 0.230274 | 0.564554 | 0.165625 | 0.0164029 | 0.631812 | 0.656675 | 0.723722 | 0.759431 | 0.701123 | 0.579314 | 0.81696 | 0.962671 | 0.829105 | 0.720869 | 0.506352 | 0.57007 | 0.91433 | 0.497342 | 0.189965 | 0.476128 | 0.19098 | 0.887968 | 0.0811497 | 0.397893 | 0.947995 | 0.433129 | 0.77806 | 0.625571 | 0.716419 | 0.553762 | 0.680455 | 0.776873 | 0.947365 | 0.368453 | 0.908491 | 0.337273 | 0.470834 | 0.857936 | 0.587565 | 0.246281 | 0.5715 | 0.475906 | 0.305129 | 0.460335 | 0.271297 | 0.222014 | 0.304069 | 0.736394 | 0.265666 | 0.74351 | 0.0904265 | 0.579612 | 0.621476 | 0.574681 | 0.427771 | 0.935226 | 0.533929 | 0.540672 | 0.458916 | 0.519859 | 0.0649 | 0.727934 | 0.952153 | 0.628522 | 0.77493 | 0.951054 | 0.372006 | 0.468555 | 0.787296 | 0.263424 | 0.944512 | 0.888987 | 0.0766307 | 0.78849 | 0.49701 | 0.570614 | 0.781092 | ⋯ |
1000 | 0.660552 | 0.435304 | 0.69959 | 0.118418 | 0.512571 | 0.389409 | 0.532196 | 0.0679856 | 0.704732 | 0.75332 | 0.37092 | 0.881958 | 0.73611 | 0.771431 | 0.812656 | 0.246535 | 0.872655 | 0.382756 | 0.359612 | 0.178767 | 0.769021 | 0.869384 | 0.138377 | 0.0559011 | 0.208121 | 0.106749 | 0.291899 | 0.160197 | 0.911127 | 0.376926 | 0.455296 | 0.860396 | 0.324969 | 0.653302 | 0.642319 | 0.813912 | 0.534663 | 0.921934 | 0.494164 | 0.275349 | 0.800289 | 7.54625e-5 | 0.912104 | 0.614587 | 0.0111345 | 0.550388 | 0.389368 | 0.126729 | 0.995746 | 0.425596 | 0.718592 | 0.668344 | 0.862516 | 0.231098 | 0.209897 | 0.436451 | 0.656335 | 0.556578 | 0.804893 | 0.258121 | 0.28222 | 0.636424 | 0.652443 | 0.222565 | 0.479368 | 0.426149 | 0.175931 | 0.405326 | 0.00835287 | 0.565661 | 0.432638 | 0.0971571 | 0.433251 | 0.999749 | 0.506784 | 0.722461 | 0.605742 | 0.0421695 | 0.809622 | 0.594125 | 0.262733 | 0.935439 | 0.96583 | 0.763589 | 0.0738046 | 0.554941 | 0.938291 | 0.878693 | 0.873989 | 0.658703 | 0.263339 | 0.277613 | 0.387373 | 0.239012 | 0.140129 | 0.0874112 | 0.0975285 | 0.577632 | 0.406463 | 0.126622 | ⋯ |
@time select(large_df, AsTable(:) => ByRow(sum) => :sum)
0.040210 seconds (26.27 k allocations: 1.419 MiB, 80.16% compilation time)
Row | sum |
---|---|
Float64 | |
1 | 4987.2 |
2 | 5016.2 |
3 | 4978.86 |
4 | 5018.0 |
5 | 5011.07 |
6 | 4991.09 |
7 | 4952.1 |
8 | 5006.35 |
9 | 4997.14 |
10 | 4994.29 |
11 | 5020.93 |
12 | 4917.99 |
13 | 5023.11 |
⋮ | ⋮ |
989 | 4997.01 |
990 | 5003.09 |
991 | 4938.96 |
992 | 4974.83 |
993 | 4952.49 |
994 | 5015.75 |
995 | 5013.19 |
996 | 4976.72 |
997 | 5015.42 |
998 | 5054.93 |
999 | 5033.81 |
1000 | 5013.15 |
@time select(large_df, AsTable(:) => ByRow(sum) => :sum)
0.008024 seconds (19.63 k allocations: 1.069 MiB)
Row | sum |
---|---|
Float64 | |
1 | 4987.2 |
2 | 5016.2 |
3 | 4978.86 |
4 | 5018.0 |
5 | 5011.07 |
6 | 4991.09 |
7 | 4952.1 |
8 | 5006.35 |
9 | 4997.14 |
10 | 4994.29 |
11 | 5020.93 |
12 | 4917.99 |
13 | 5023.11 |
⋮ | ⋮ |
989 | 4997.01 |
990 | 5003.09 |
991 | 4938.96 |
992 | 4974.83 |
993 | 4952.49 |
994 | 5015.75 |
995 | 5013.19 |
996 | 4976.72 |
997 | 5015.42 |
998 | 5054.93 |
999 | 5033.81 |
1000 | 5013.15 |
This notebook was generated using Literate.jl.