home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 592991059

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/issues/2459#issuecomment-592991059 https://api.github.com/repos/pydata/xarray/issues/2459 592991059 MDEyOklzc3VlQ29tbWVudDU5Mjk5MTA1OQ== 1277781 2020-02-29T20:27:20Z 2020-02-29T20:27:20Z CONTRIBUTOR

I know this is not a recent thread but I found no resolution, and we just ran in the same issue recently. In our case we had a pandas series of roughly 15 milliion entries, with a 3-level multi-index which had to be converted to an xarray.DataArray. The .to_xarray took almost 2 minutes. Unstack + to_array took it down to roughly 3 seconds, provided the last level of the multi index was unstacked.

However a much faster solution was through numpy array. The below code is based on the idea of Igor Raush

(In this case df is a dataframe with a single column, or a series) arr = np.full(df.index.levshape, np.nan) arr[tuple(df.index.codes)] = df.values.flat da = xr.DataArray(arr,dims=df.index.names,coords=dict(zip(df.index.names, df.index.levels)))

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