-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
series.to_xarray() fails when MultiIndex not sorted in xarray 0.15.1 #3951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the issue @delgadom . This looks like a fairly significant bug. I'll try and look more at it later; if anyone else can @pydata/xarray that would be great. |
yeah I use this pattern all the time - df.stack().to_xarray() seems to now fail unless your columns were sorted alphabetically. not sure yet where this is happening but it does result in some pernicious bad data errors that can be hard to debug if you catch them at all. |
Here's a test script I'm using for this: echo '$ conda create -n py37xr14 -c conda-forge --yes python=3.7 xarray=0.14.1'
conda create -n py37xr14 -c conda-forge --yes python=3.7 xarray=0.14.1 > /dev/null
echo '$ conda create -n py37xr15 -c conda-forge --yes python=3.7 xarray=0.15.1'
conda create -n py37xr15 -c conda-forge --yes python=3.7 xarray=0.15.1 > /dev/null
echo '$ conda run -n py37xr14 python test.py'
conda run -n py37xr14 python test.py
echo
echo '$ conda run -n py37xr15 python test.py'
conda run -n py37xr15 python test.py
echo
echo '$ conda list -n py37xr14'
conda list -n py37xr14
echo
echo '$ conda list -n py37xr15'
conda list -n py37xr15
conda env remove -n py37xr14 > /dev/null 2>&1
conda env remove -n py37xr15 > /dev/null 2>&1 |
Thanks, @delgadom, for reporting this issue. I'll take a look. |
series.to_xarray() fails when MultiIndex not sorted in xarray 0.15.1
Summary
It seems that
series.to_xarray()
fails (returns incorrect data) in xarray 0.15.1 when the dataframe's MultiIndex dimensions are not sortedDemonstration
xarray should be able to handle MultiIndices with unsorted dimensions. Using a fresh conda environment with xarray 0.14.1:
This fails in xarray 0.15.1 - note the data is not merely reordered - the data in column 'B' now has the incorrect values 4, 5, 6 rather than 1, 2, 3:
Test setup & environment info
contents of test.py
packages in py37xr14 environment
packages in py37xr15 environment
The text was updated successfully, but these errors were encountered: