Skip to content

BUG: fix IntervalIndex for pivot table raise type error #26765

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
Jun 13, 2019

Conversation

peterpanmj
Copy link
Contributor

@peterpanmj peterpanmj commented Jun 10, 2019

Close (#25814). When use IntervalIndex for pivot table, raise
TypeError: cannot determine next label for type <class 'str'>

@codecov
Copy link

codecov bot commented Jun 10, 2019

Codecov Report

Merging #26765 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26765      +/-   ##
==========================================
- Coverage   91.71%   91.71%   -0.01%     
==========================================
  Files         178      178              
  Lines       50740    50740              
==========================================
- Hits        46538    46534       -4     
- Misses       4202     4206       +4
Flag Coverage Δ
#multiple 90.3% <100%> (ø) ⬆️
#single 41.21% <0%> (-0.11%) ⬇️
Impacted Files Coverage Δ
pandas/core/arrays/categorical.py 95.92% <100%> (ø) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/frame.py 96.88% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.84% <0%> (-0.11%) ⬇️
pandas/core/indexes/interval.py 96.59% <0%> (+0.16%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f3e8e8...c242a8e. Read the comment docs.

@codecov
Copy link

codecov bot commented Jun 10, 2019

Codecov Report

Merging #26765 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26765      +/-   ##
==========================================
- Coverage   91.86%   91.86%   -0.01%     
==========================================
  Files         179      179              
  Lines       50706    50706              
==========================================
- Hits        46583    46580       -3     
- Misses       4123     4126       +3
Flag Coverage Δ
#multiple 90.45% <100%> (ø) ⬆️
#single 41.1% <0%> (-0.11%) ⬇️
Impacted Files Coverage Δ
pandas/core/arrays/categorical.py 95.92% <100%> (ø) ⬆️
pandas/io/gbq.py 88.88% <0%> (-11.12%) ⬇️
pandas/core/frame.py 96.88% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.84% <0%> (-0.11%) ⬇️
pandas/core/indexes/interval.py 96.44% <0%> (+0.32%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d66da60...64dcfee. Read the comment docs.

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.

can you add a whatsnew note (reshaping) bug fixes

@@ -198,6 +198,17 @@ def test_pivot_with_non_observable_dropna(self, dropna):

tm.assert_frame_equal(result, expected)

def test_pivot_with_interval_index(self, dropna):
df = pd.DataFrame(
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 the issue number as a comment

def test_pivot_with_interval_index(self, dropna):
df = pd.DataFrame(
{'A': pd.Categorical([pd.Interval(0, 1)] * 4),
'B': [1] * 4})
Copy link
Contributor

Choose a reason for hiding this comment

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

does this fully replicate the OP issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just added a fixture to include more scenarios.

@jreback jreback added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Jun 10, 2019
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.

tiny tiny comment, ping on green.

@jreback jreback added this to the 0.25.0 milestone Jun 11, 2019
Copy link
Member

@jschendel jschendel left a comment

Choose a reason for hiding this comment

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

lgtm, just some simplifications to the implementation

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

Merged master to fix the CI. Should be good to go.

@TomAugspurger TomAugspurger merged commit 2d2606d into pandas-dev:master Jun 13, 2019
@TomAugspurger
Copy link
Contributor

Thanks @peterpanmj!

@peterpanmj peterpanmj deleted the cat_index branch June 14, 2019 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use categorical IntervalIndex as index when creating pivot_table
4 participants