home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 648721465

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-648721465 https://api.github.com/repos/pydata/xarray/issues/2459 648721465 MDEyOklzc3VlQ29tbWVudDY0ODcyMTQ2NQ== 5442433 2020-06-24T09:55:00Z 2020-06-24T09:55:00Z NONE

Hi All. I stumble across the same issue trying to convert a 5000 column dataframe to xarray (it was never going to happen...). I found a workaround and I am posting the test below. Hope it helps.

```python import xarray as xr import pandas as pd import numpy as np

xr.version

'0.15.1'

pd.version

'1.0.5'

df = pd.DataFrame(np.random.randn(200, 500))

%%time one = df.to_xarray()

CPU times: user 29.6 s, sys: 60.4 ms, total: 29.6 s
Wall time: 29.7 s

%%time dic={} for name in df.columns: dic.update({name:(['index'],df[name].values)})

two = xr.Dataset(dic, coords={'index': ('index', df.index.values)})

CPU times: user 17.6 ms, sys: 158 µs, total: 17.8 ms
Wall time: 17.8 ms

one.equals(two)

True

```

{
    "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 80.023ms · About: xarray-datasette