Skip to content
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

Fix wrong order of coordinate converted from pd.series with MultiIndex #3953

Merged
merged 4 commits into from
Apr 8, 2020

Conversation

fujiisoup
Copy link
Member

It looks
dataframe.set_index(index).index == index is not always true.

Added a workaround for this...

@pep8speaks
Copy link

pep8speaks commented Apr 7, 2020

Hello @fujiisoup! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-04-08 01:28:46 UTC

@fujiisoup fujiisoup changed the title Fix 3951 Fix wrong order of coordinate converted from pd.series with MultiIndex Apr 7, 2020
@@ -58,6 +58,8 @@ New Features

Bug fixes
~~~~~~~~~
- Fix wrong order in converting pd.seris with MultiIndex. (:issue:`3951`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Fix wrong order in converting pd.seris with MultiIndex. (:issue:`3951`)
- Fix wrong order in converting a ``pd.Series`` with a MultiIndex to ``DataArray``. (:issue:`3951`)

@max-sixty
Copy link
Collaborator

Thanks a lot @fujiisoup

@max-sixty max-sixty merged commit 1eedc5c into pydata:master Apr 8, 2020
@fujiisoup fujiisoup deleted the fix_3951 branch April 8, 2020 05:49
kmuehlbauer added a commit to kmuehlbauer/xarray that referenced this pull request Apr 14, 2020
dcherian added a commit to dcherian/xarray that referenced this pull request May 1, 2020
* upstream/master: (39 commits)
  Pint support for DataArray (pydata#3643)
  Apply blackdoc to the documentation (pydata#4012)
  ensure Variable._repr_html_ works (pydata#3973)
  Fix handling of abbreviated units like msec (pydata#3998)
  full_like: error on non-scalar fill_value (pydata#3979)
  Fix some code quality and bug-risk issues (pydata#3999)
  DOC: add pandas.DataFrame.to_xarray (pydata#3994)
  Better chunking error messages for zarr backend (pydata#3983)
  Silence sphinx warnings (pydata#3990)
  Fix distributed tests on upstream-dev (pydata#3989)
  Add multi-dimensional extrapolation example and mention different behavior of kwargs in interp (pydata#3956)
  keep attrs in interpolate_na (pydata#3970)
  actually use preformatted text in the details summary (pydata#3978)
  facetgrid: Ensure that colormap params are only determined once. (pydata#3915)
  RasterioDeprecationWarning (pydata#3964)
  Empty line missing for DataArray.assign_coords doc (pydata#3963)
  New coords to existing dim (doc) (pydata#3958)
  implement a more threadsafe call to colorbar (pydata#3944)
  Fix wrong order of coordinate converted from pd.series with MultiIndex (pydata#3953)
  Updated list of core developers (pydata#3943)
  ...
dcherian added a commit that referenced this pull request May 13, 2020
* FIX: correct dask array handling in _calc_idxminmax

* FIX: remove unneeded import, reformat via black

* fix idxmax, idxmin with dask arrays

* FIX: use array[dim].data in `_calc_idxminmax` as per @keewis suggestion, attach dim name to result

* ADD: add dask tests to `idxmin`/`idxmax` dataarray tests

* FIX: add back fixture line removed by accident

* ADD: complete dask handling in `idxmin`/`idxmax` tests in test_dataarray, xfail dask tests for dtype dateime64 (M)

* ADD: add "support dask handling for idxmin/idxmax" in whats-new.rst

* MIN: reintroduce changes added by #3953

* MIN: change if-clause to use `and` instead of `&` as per review-comment

* MIN: change if-clause to use `and` instead of `&` as per review-comment

* WIP: remove dask handling entirely for debugging purposes

* Test for dask computes

* WIP: re-add dask handling (map_blocks-approach), add `with raise_if_dask_computes()` context to idxmin-tests

* Use dask indexing instead of map_blocks.

* Better chunk choice.

* Return -1 for _nan_argminmax_object if all NaNs along dim

* Revert "Return -1 for _nan_argminmax_object if all NaNs along dim"

This reverts commit 58901b9.

* Raise error for object arrays

* No error for object arrays. Instead expect 1 compute in tests.

Co-authored-by: dcherian <deepak@cherian.net>
dcherian added a commit that referenced this pull request May 25, 2020
* Added chunks='auto' option in dataset.py

* FIX: correct dask array handling in _calc_idxminmax (#3922)

* FIX: correct dask array handling in _calc_idxminmax

* FIX: remove unneeded import, reformat via black

* fix idxmax, idxmin with dask arrays

* FIX: use array[dim].data in `_calc_idxminmax` as per @keewis suggestion, attach dim name to result

* ADD: add dask tests to `idxmin`/`idxmax` dataarray tests

* FIX: add back fixture line removed by accident

* ADD: complete dask handling in `idxmin`/`idxmax` tests in test_dataarray, xfail dask tests for dtype dateime64 (M)

* ADD: add "support dask handling for idxmin/idxmax" in whats-new.rst

* MIN: reintroduce changes added by #3953

* MIN: change if-clause to use `and` instead of `&` as per review-comment

* MIN: change if-clause to use `and` instead of `&` as per review-comment

* WIP: remove dask handling entirely for debugging purposes

* Test for dask computes

* WIP: re-add dask handling (map_blocks-approach), add `with raise_if_dask_computes()` context to idxmin-tests

* Use dask indexing instead of map_blocks.

* Better chunk choice.

* Return -1 for _nan_argminmax_object if all NaNs along dim

* Revert "Return -1 for _nan_argminmax_object if all NaNs along dim"

This reverts commit 58901b9.

* Raise error for object arrays

* No error for object arrays. Instead expect 1 compute in tests.

Co-authored-by: dcherian <deepak@cherian.net>

* fix the failing flake8 CI (#4057)

* rename d and l to dim and length

* Fixed typo in rasterio docs (#4063)

* Added chunks='auto' option in dataset.py

Added changes to whats-new.rst

* Added chunks='auto' option in dataset.py

Added changes to whats-new.rst

* Error fix, catch chunks=None

* Minor reformatting + flake8 changes

* Added isinstance(chunks, (Number, str)) in dataset.py, passing

* format changes

* added auto-chunk test for dataarrays

* Assert chunk sizes equal in auto-chunk test

Co-authored-by: Kai Mühlbauer <kmuehlbauer@users.noreply.github.com>
Co-authored-by: dcherian <deepak@cherian.net>
Co-authored-by: keewis <keewis@users.noreply.github.com>
Co-authored-by: clausmichele <31700619+clausmichele@users.noreply.github.com>
Co-authored-by: Keewis <keewis@posteo.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

series.to_xarray() fails when MultiIndex not sorted in xarray 0.15.1
3 participants