Skip to content

BUG: Fix MutliIndexed unstack failures at tuple names #30943

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

Merged
merged 12 commits into from
Jan 20, 2020

Conversation

charlesdong1991
Copy link
Member

@charlesdong1991 charlesdong1991 commented Jan 12, 2020

@@ -0,0 +1,59 @@
import pytest
Copy link
Member Author

@charlesdong1991 charlesdong1991 Jan 12, 2020

Choose a reason for hiding this comment

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

I did not find test for series.unstack, so just created one, pls let me know where the tests are stored, then I could move this part into the corresponding file.

Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

See tests/series/test_analytics.py:

def test_unstack(self):

Copy link
Member Author

Choose a reason for hiding this comment

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

ahh! many thanks! @jschendel

not sure if it is the best place for tests for unstack since analytics sounds a bit weird to unstack, maybe worth a follow-up to move to somewhere else @jreback

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah don't appear to be many, could create (and move the existing ones from test_analytics) to pandas/tests/series/test_reshaping.py to mirror frame

@@ -0,0 +1,59 @@
import pytest
Copy link
Member

Choose a reason for hiding this comment

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

See tests/series/test_analytics.py:

def test_unstack(self):

@@ -1133,6 +1133,7 @@ Reshaping
- Bug in :func:`merge_asof` merging on a tz-aware ``left_index`` and ``right_on`` a tz-aware column (:issue:`29864`)
- Improved error message and docstring in :func:`cut` and :func:`qcut` when `labels=True` (:issue:`13318`)
- Bug in missing `fill_na` parameter to :meth:`DataFrame.unstack` with list of levels (:issue:`30740`)
- Bug in :func:`unstack` can take tuple names in MultiIndexed data (:issue:`19966`)
Copy link
Member

Choose a reason for hiding this comment

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

:func:`unstack` doesn't exist, so instead should probably be ":meth:`DataFrame.unstack` and :meth:`Series.unstack`"

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks! changed!

@jschendel jschendel added Bug MultiIndex Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Jan 12, 2020
@pep8speaks
Copy link

pep8speaks commented Jan 12, 2020

Hello @charlesdong1991! 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-01-20 20:12:00 UTC

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @charlesdong1991 for the PR. will need to move whatsnew to doc/source/whatsnew/v1.1.0.rst once #30907 is merged.

@charlesdong1991
Copy link
Member Author

charlesdong1991 commented Jan 13, 2020

sure! @simonjayhawkins I will keep this in mind and wait for that PR to be merged together with reviews from other maintainers

@jreback jreback added this to the 1.1 milestone Jan 15, 2020
@@ -317,6 +317,8 @@ def _unstack_multiple(data, clocs, fill_value=None):

index = data.index

if clocs in index.names:
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a comment here on what is going on

@@ -0,0 +1,59 @@
import pytest
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah don't appear to be many, could create (and move the existing ones from test_analytics) to pandas/tests/series/test_reshaping.py to mirror frame

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

if you can do that move, and minor comments; ping on green.

@charlesdong1991
Copy link
Member Author

comment added and tests moved, and also rebased

ping @jreback

@charlesdong1991
Copy link
Member Author

some followup reviews will be appreciated ^^

@charlesdong1991
Copy link
Member Author

gentle ping @jreback ^^ thanks 😅

@jreback jreback merged commit 24d7c06 into pandas-dev:master Jan 20, 2020
@jreback
Copy link
Contributor

jreback commented Jan 20, 2020

thanks @charlesdong1991

very nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug MultiIndex Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MultiIndexed unstack with tuple names fails with KeyError
5 participants