Here are some selected operations on the entire dataframe.
Get the Number of rows and columns of a dataframe df using
size(df)
Get details about the columns of the dataframe df
describe(df)
Let’s define a new, small dataframe df1. A dataframe based on a 2x2 unity matrix might do.
df1 = DataFrame(A = [1, 0], B = [0, 1] )
Multiply the dataframe with pi.
Subtract the square root of 2.
df2 = df1 .* π df2 = df1 .- sqrt(2)
Mind the broadcasting operator!
A matrix contains the body of a dataframe. Some operations on a Julia dataframe are not available, but can be retrieved by extracting this matrix and then re-assembling the dataframe.
There is no built-in transpose command in Julia Dataframes. You need to extract the matrix, transpose the matrix and re-built a dataframe.
You can get the matrix, ma, from the dataframe with the matrix command
ma = Matrix(df)
Then, you transpose the matrix
mat = transpose(ma) mat = ma'
The matrix mat holds the transposed matrix.
Finally, you need to get back to a new dataframe, dfT,
dfT = DataFrame(mat, :auto)
and to adjust the column names later. Mind the second parameter (“auto”) which is required in higher versions of DataFrames.
Do the same as for transpose, but invert the matrix.
mai = inv(ma)