DataFrame
DataFrame copied to clipboard
DataFrame addRow/addColumn doesnt work on empty frames
Code:
x := DataFrame new.
x addRow: #(1 2 3)
Current workaround is:
x := DataFrame withColumnNames: #(1 2 3).
x addRow: #(1 2 3)
This is due to https://github.com/PolyMathOrg/DataFrame/blob/c4a86848c2d7e5d215a2f880af453f87aca5644f/src/DataFrame/DataFrameInternal.class.st#L100-L101
It seems like a bug that should be fixed. Indeed, it would be nice to create an empty DataFrame and then fill it with values. When adding a row, we could check if DataFrame is empty, and if yes, set the number of columns to the size of a new row.
But I have several doubts:
- Do we want to make that check every time we add a row? Will it not slow down the operations that use
add:(e.g.,collect:,select:, ect.)? - Does it make sense to create a DataFrame with 0 columns and then resize it to fit the first inserted row? Would we do the same for Matrix?
Perhaps, we should check how this is done in pandas or R.