DataFrame icon indicating copy to clipboard operation
DataFrame copied to clipboard

DataFrame addRow/addColumn doesnt work on empty frames

Open AtharvaKhare opened this issue 6 years ago • 1 comments

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

AtharvaKhare avatar Jul 22 '19 10:07 AtharvaKhare

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:

  1. 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.)?
  2. 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.

olekscode avatar Jul 26 '21 13:07 olekscode