Skip to content

BUG: Should not raise errors in .set_names for MultiIndex with nlevels == 1 (GH21149) #21196

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 10 commits into from
May 29, 2018
Merged

BUG: Should not raise errors in .set_names for MultiIndex with nlevels == 1 (GH21149) #21196

merged 10 commits into from
May 29, 2018

Conversation

KalyanGokhale
Copy link
Contributor

@KalyanGokhale KalyanGokhale commented May 24, 2018

Initial PR #21182 is closed - and now split in 2 different PRs

@KalyanGokhale KalyanGokhale changed the title BUG: Should not raises errors in .set_names method for MultiIndex with nlevels == 1 (GH21149) BUG: Should not raise errors in .set_names method for MultiIndex with nlevels == 1 (GH21149) May 24, 2018
@KalyanGokhale KalyanGokhale changed the title BUG: Should not raise errors in .set_names method for MultiIndex with nlevels == 1 (GH21149) BUG: Should not raise errors in .set_names for MultiIndex with nlevels == 1 (GH21149) May 24, 2018
@codecov
Copy link

codecov bot commented May 24, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@d30cc74). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #21196   +/-   ##
=========================================
  Coverage          ?   91.84%           
=========================================
  Files             ?      153           
  Lines             ?    49506           
  Branches          ?        0           
=========================================
  Hits              ?    45467           
  Misses            ?     4039           
  Partials          ?        0
Flag Coverage Δ
#multiple 90.23% <100%> (?)
#single 41.88% <100%> (?)
Impacted Files Coverage Δ
pandas/core/indexes/base.py 96.68% <100%> (ø)

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 d30cc74...20fb292. Read the comment docs.

@@ -78,7 +78,8 @@ Indexing

- Bug in :meth:`Series.reset_index` where appropriate error was not raised with an invalid level name (:issue:`20925`)
- Bug in :func:`interval_range` when ``start``/``periods`` or ``end``/``periods`` are specified with float ``start`` or ``end`` (:issue:`21161`)
-
- Bug in :meth:`MultiIndex.set_names` where error raised for a MultiIndex with self.nlevels == 1 (:issue:`21149`)
Copy link
Contributor

Choose a reason for hiding this comment

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

just say nlevels == 1 (in double backticks)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - done

@@ -165,6 +165,18 @@ def test_set_name_methods(self):
assert res is None
assert ind.names == new_names2

def test_multiindex_set_names(self):
# GH 21149
'''Ensure that .set_names for MultiIndex with
Copy link
Contributor

Choose a reason for hiding this comment

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

use triple-double quotes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

nlevels == 1 does not raise any errors
'''
result = pd.MultiIndex.from_product([[0, 1]])
result.set_names('first', level=0, inplace=True)
Copy link
Contributor

Choose a reason for hiding this comment

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

test both inplace=True and False with a parameterized test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@jreback jreback added this to the 0.23.1 milestone May 29, 2018
@jreback jreback merged commit a5259cc into pandas-dev:master May 29, 2018
@jreback
Copy link
Contributor

jreback commented May 29, 2018

thanks @KalyanGokhale

certainly love for you to kill the nlevels==1 checks in the rest of the code base :>

@KalyanGokhale
Copy link
Contributor Author

Thanks @jreback - will comb through the codes for other nlevels==1 instances and would work on it

@KalyanGokhale KalyanGokhale deleted the GH21149-2 branch May 29, 2018 01:46
jorisvandenbossche pushed a commit to jorisvandenbossche/pandas that referenced this pull request Jun 8, 2018
jorisvandenbossche pushed a commit that referenced this pull request Jun 9, 2018
david-liu-brattle-1 pushed a commit to david-liu-brattle-1/pandas that referenced this pull request Jun 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants