I wanted to check out xarray and wrote the following sample code:
import numpy as np
import pandas as pd
import xarray as xr
rng = np.random.default_rng(42)
df = pd.DataFrame(data=rng.normal(size=(5000, 4017)))
a = xr.Dataset(df)
b = xr.Dataset.from_dataframe(df)
While a = xr.Dataset(df) seem to work ok the line b = xr.Dataset.from_dataframe(df) takes 100% CPU and does not seem to return. Maybe I'm to impatient, but i takes a lot longer than the previous line.
a returns:
<xarray.Dataset>
Dimensions: (dim_0: 5000)
Coordinates:
* dim_0 (dim_0) int64 0 1 2 3 4 5 6 ... 4993 4994 4995 4996 4997 4998 4999
Data variables: (12/4017)
0 (dim_0) float64 0.3047 0.9676 0.8428 ... -0.09173 -1.844 0.1756
...
...
What is the difference between a and b?
Why does b take so long?
xarray 0.19.0 pandas 1.3.1