-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
rename_axis(None) now (0.24) does nothing. Previously it removed the axis name #25034
Comments
`Series.rename(None)` would be my recommended way of removing the name from
a Series.
We could use `object()` as the default mapper if we want to support
`Series.rename_axis(None)`.
…On Wed, Jan 30, 2019 at 11:22 AM Ted Petrou ***@***.***> wrote:
Code Sample, a copy-pastable example if possible
In 0.23 rename_axis was able to remove the axis name like this:
>>> s = pd.Series([1, 2, 3])>>> s = s.rename_axis('asdf')>>> s
asdf0 11 22 3
dtype: int64
>>> s.rename_axis(None)0 11 22 3
dtype: int64
In 0.24, the mapper parameter is defaulted to None so this does not work.
The only way to remove an axis label is to use del s.index.name or
s.index.name = None
Problem description
Seems like a regression. I have some code that relies on axis name removal
with s.rename_axis(None). Seems like there is no clean way to remove an
axis name now.
Expected Output
s.rename_axis(None) should work as it did in 0.23.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#25034>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIke1TnqYETrTFTQkV_LufIcuE2Pwks5vIdTEgaJpZM4aarl4>
.
|
@TomAugspurger That renames the Series |
Ah, sorry misread.
…On Wed, Jan 30, 2019 at 11:37 AM Ted Petrou ***@***.***> wrote:
@TomAugspurger <https://github.com/TomAugspurger> That renames the Series
name attribute. My example involves renaming the axis name. This would go
for both the Series and the DataFrame.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#25034 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHItdbUXetlr8P_gUL4rpTDwZuCtoUks5vIdhPgaJpZM4aarl4>
.
|
You can also pass Still should fix the regression of course, but at least this provides method chaining compatible workaround in the meantime: In [2]: s = pd.Series([1, 2, 3], index=pd.Index(list('abc'), name='foo'))
In [3]: s
Out[3]:
foo
a 1
b 2
c 3
dtype: int64
In [4]: s.rename_axis(index=lambda x: None)
Out[4]:
a 1
b 2
c 3
dtype: int64 |
@jschendel Thank you for pointing out an alternative. Seems like one way to correct this is to have all the axis level names set equal to None when calling |
I think it could probably be implemented this way, though would require some care in handling all the params ( The PR I opened basically follows @TomAugspurger's suggestion of using a sentinel value, like Basically: In [1]: sentinel = object()
In [2]: def foo(bar=sentinel):
...: if bar is sentinel:
...: return 'sentinel'
...: return bar
In [3]: foo()
Out[3]: 'sentinel'
In [4]: foo(None) is None
Out[4]: True
In [5]: foo(object())
Out[5]: <object at 0x7ff8cde2d8e0> This implementation has the advantage that |
Code Sample, a copy-pastable example if possible
In 0.23
rename_axis
was able to remove the axis name like this:In 0.24, the
mapper
parameter is defaulted toNone
so this does not work. The only way to remove an axis label is to usedel s.index.name
ors.index.name = None
Problem description
Seems like a regression. I have some code that relies on axis name removal with
s.rename_axis(None)
. Seems like there is no clean way to remove an axis name now.Expected Output
s.rename_axis(None)
should work as it did in 0.23.The text was updated successfully, but these errors were encountered: