raylutz / daffodil

Python Daffodil: 2-D data arrays with mixed types, lightweight package, can be faster than Pandas
MIT License
7 stars 2 forks source link

Resolve list insertion ambiguity #16

Open raylutz opened 2 months ago

raylutz commented 2 months ago

There is ambiguity if a nested list structure is meant to be assigned to an array cell, when a list with one item is being inserted.

For example:

   collist = my_daf[:, 'colname'].to_list()    # this will return a list, but sometimes of only one value, if there is only one row.
   my_daf[:, 'colname2'] = collist             # there is ambiguity here as to whether the list with one
                                               # item should be placed in the cell or if just the value.

Currently, the code will insert just the value. But then:

   my_daf[3,3] = [4]

will not insert the list, but just the value, which seems wrong.

raylutz commented 1 month ago

To solve this, will need to propagate whether the initial indexing specification was a single cell, or a range of cells. The singular flag should be propagated for each coordinate.

if both coordinates are singular, then insert a list or list of list entirely into the cell. if one coordinate is singular, but the other is not, then insert the list among the range of the non-singular range. if both coordinates are non-singular, then insert a list of list in row and col orientation.