home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 830925003

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/pull/5247#issuecomment-830925003 https://api.github.com/repos/pydata/xarray/issues/5247 830925003 MDEyOklzc3VlQ29tbWVudDgzMDkyNTAwMw== 1217238 2021-05-02T23:23:52Z 2021-05-02T23:23:52Z MEMBER

The model we have with DataArray.to_pandas() is that it converts into a corresponding pandas object without changing the number of dimensions. to_dataframe()/to_series() will flatten multiple dimensions into a MultiIndex, but that isn't the role of to_pandas().

Thus:

  • 0D xarray.DataArray -> 0D NumPy scalar
  • 1D xarray.DataArray -> 1D pandas.Series
  • 2D xarray.DataArray -> 2D pandas.DataFrame
  • 3D or higher xarray.DataArray -> error

If we treat a Dataset like a DataArray with one extra dimension (corresponding to variables), then it would make sense to have:

  • 0D xarray.Dataset -> 1D pandas.Series
  • 1D xarray.Dataset -> 2D pandas.DataFrame (same as to_dataframe())
  • 2D or higher xarray.Dataset -> error

I guess this is basically what you have here, except for raising an error in the final case (the error message should mention to_dataframe().

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  874044225
Powered by Datasette · Queries took 81.578ms · About: xarray-datasette