Commit 24bfcc9
committed
Skip call to
`np.tile` returns an NDArray and there is no need to convert this to a
Python `list` prior to passing it to `pd.MultiIndex`. The interface to
Pandas requires the object to be array-like, and one of the first things
that the constructor does is coerce the list back to an NDArray.
For arrays with large coordinate axes, `to_dataframe()` is extremely
slow due to Pandas needing to iterate through a `list` object rather
than an array.
For an (1000, 500, 20) array -- 10M rows in the cartesian product --
this results in a ~20x speed-up for `xr.Dataset.to_dataframe()` (tested
on x86 and Apple Silicon).
```python
da = xr.DataArray(np.ones((1000, 500, 20)), name="foo")
da.to_dataframe()
```
Closes #10617.tolist() when creating pd.Index1 parent 938e186 commit 24bfcc9
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| |||
0 commit comments