Skip to content

Conversation

@hurcy
Copy link

@hurcy hurcy commented Aug 14, 2017

I added name parameter value to preserve index name before reset_index.

@hurcy
Copy link
Author

hurcy commented Aug 14, 2017

Oh, now I realize that I shouldn't modify core/common.py :(
I found where to fix, and working on it.

def _default_index(n):
from pandas.core.index import RangeIndex
return RangeIndex(0, n, name=None)
return RangeIndex(0, n, name='index')
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is right... the name of a default index should just be None.

@gfyoung gfyoung added Bug Indexing Related to indexing on series/frames, not to indexes themselves labels Aug 14, 2017
@codecov
Copy link

codecov bot commented Aug 15, 2017

Codecov Report

Merging #17243 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #17243 +/- ## ======================================= Coverage 91.53% 91.53% ======================================= Files 148 148 Lines 48688 48688 ======================================= Hits 44566 44566 Misses 4122 4122
Flag Coverage Δ
#multiple 89.9% <100%> (ø) ⬆️
#single 41.63% <66.66%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/indexes/base.py 96.45% <100%> (ø) ⬆️
pandas/core/common.py 92.92% <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 c0e3767...5759763. Read the comment docs.

- Fixes ``DataFrame.loc`` for setting with alignment and tz-aware ``DatetimeIndex`` (:issue:`16889`)
- Avoids ``IndexError`` when passing an Index or Series to ``.iloc`` with older numpy (:issue:`17193`)
- Allow unicode empty strings as placeholders in multilevel columns in Python 2 (:issue:`17099`)
- Bug in reset_index reset index name (:issue: `17067`)
Copy link
Contributor

Choose a reason for hiding this comment

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

be more descriptive here, no space before the issue number and the colon

assert 'a_x' in index

def test_iadd_index_name(self):
s = pd.Series([1, 2, 3])
Copy link
Contributor

Choose a reason for hiding this comment

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

add the issue number as a comment. add a 1-liner here what you are testing

s.index += 1
assert s.index.name == 'foo'

def test_reset_index_name(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

this test needs to go to pandas/tests/frame/test_alter_axes.py (with other reset_index tests)


def __add__(self, other):
return Index(np.array(self) + other)
return Index(np.array(self) + other, name=self.name)
Copy link
Contributor

Choose a reason for hiding this comment

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

actually this is not correct. We don't assign the index name on a boolean operation. only on an inplace operation (e.g. __iadd__). This also would apply to other ops like isub etc.

Copy link
Author

Choose a reason for hiding this comment

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

@jreback Thank you for your advice on my first pandas PR. :) Should I raise exception in case of

s = pd.Series([1, 2, 3]) s.index.name = 'foo' s.index += 1 assert s.index.name == 'foo' 
Copy link
Contributor

Choose a reason for hiding this comment

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

no, this is slightly complicated. the __iadd__ operator needs to be modified (and not __add__), and corresponding ones.

@jreback
Copy link
Contributor

jreback commented Oct 28, 2017

can you rebase and update

@jreback
Copy link
Contributor

jreback commented Oct 28, 2017

and move note to 0.22.0

@jreback
Copy link
Contributor

jreback commented Nov 12, 2017

can you rebase / update

@jreback
Copy link
Contributor

jreback commented Jan 5, 2018

I rebased; if you can fix according to comments.

@jreback
Copy link
Contributor

jreback commented Feb 11, 2018

@hurcy can you rebase this and update

@jreback
Copy link
Contributor

jreback commented Feb 19, 2018

closing as stale

@jreback jreback closed this Feb 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Indexing Related to indexing on series/frames, not to indexes themselves

5 participants