index
columns with missing values
#51
Replies: 3 comments
-
This is a constraint of HDF5 and Zarr, whose Datasets must have the same underlying data type. Columns of DynamicTables are Datasets in these backends, so they have the same constraint. If it's an integer column, all values must be an integer. You are right that float has the special values NaN, Inf and -Inf that can be used for this purpose, but ints do not. There are three solutions I'd seen for this type of thing, none of which are perfect:
|
Beta Was this translation helpful? Give feedback.
-
@bendichter summarizes quite well - here are some extra comments for each of their points
|
Beta Was this translation helpful? Give feedback.
-
Re 2., I agree this is the most elegant approach. These two section show examples of how this works in Python:
If you need to reference ranges in a TimeSeries then the TimeSeriesReferenceVectorData type will be useful. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi NWB community!
Is there a way to deal with columns in
TimeIntervals
tables which are intended as an index into an array - and should therefore be an integer datatype - but which also contain missing values?Using
np.nan
for those missing values converts the whole column to floats, which then makes indexing awkward and doesn't clearly convey to a user that the values are meant to be used as indices.Two things I've tested that haven't worked completely:
using the
pandas
datatypeInt64
DataFrame
can hold integers and null values in a column - partial success!hdmf
viapynwb
fails due to the unsupported type of the null valueshdf
viapandas
fails for the same reasonusing the
pyarrow
backend for aDataFrame
DataFrame
handles integers and null values nicely, but writing tohdf5
ultimately failsI haven't tried adding row-by-row to the table, in order to mix types across the column, but it looks like a column must have a single datatype when written to
hdf5
.Does anyone know a way to achieve this? Is it something that could be supported by
hdmf
when writing/reading?Beta Was this translation helpful? Give feedback.
All reactions