tiled
tiled copied to clipboard
Let `Container.write_dataframe` accept a dict
It is convenient that Container.write_array accepts a list, like:
$ tiled serve catalog --temp --api-key=secret
In [1]: from tiled.client import from_uri
In [2]: c = from_uri('http://localhost:8000', api_key='secret')
In [3]: c
Out[3]: <Container {}>
In [4]: c.write_array([1,2,3], key='x')
Out[4]: <ArrayClient shape=(3,) chunks=((3,),) dtype=int64>
It would be convenient if
c.write_dataframe({'a': [1,2,3], 'b':, [4,5,6]}, key='y')
were likewise acceptable. Currently, a pandas.DataFrame or dask.dataframe object must be passed.
This needs two additions:
- Add a branch to this conditional that checks for
isinstance(dataframe, dict)and, if so, attemptsdataframe = pandas.DataFrame(dataframe).
https://github.com/bluesky/tiled/blob/07c8925746e977352606432743534158972e6da0/tiled/client/container.py#L943-L946
- Add a variation on this test that passes the dict
datatowrite_dataframeinstead of thepandas.DataFramedf.
https://github.com/bluesky/tiled/blob/07c8925746e977352606432743534158972e6da0/tiled/_tests/test_writing.py#L125-L147
Closed/addressed via PR above.