I would like to optimize (the columns in) a Julia DataFrame. To do so, I would like to get the size of the the DataFrame before and after an optimization.
Here's an example DataFrame:
rows, columns = 10_000, 50
df = rand([x for x in "ABCDE"], rows, columns) |> DataFrame
The size of this df object...
sizeof(df)
The size is 24.
However, when I sum the sizes of the columns, the size is diffferent...
sum([sizeof(df[x]) for x in names(df)])
The sum of the column sizes is 2000000.
Here's the optimization...
for i = names(df)
df[i] = CategoricalArray(df[i], ordered=false)
end
Results are:
sizeof(df)
The size is 24.
sum([sizeof(df[x]) for x in names(df)])
The sum of the column sizes is 800.
Any suggestions how to get an accurate size of an DataFrame?