Skip to content
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

Series.rename doesn't accept "axis" argument #18589

Closed
toobaz opened this issue Dec 1, 2017 · 1 comment · Fixed by #18923
Closed

Series.rename doesn't accept "axis" argument #18589

toobaz opened this issue Dec 1, 2017 · 1 comment · Fixed by #18923
Labels
Compat pandas objects compatability with Numpy or Python functions Enhancement good first issue Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@toobaz
Copy link
Member

toobaz commented Dec 1, 2017

Code Sample, a copy-pastable example if possible

In [2]: pd.Series(-1, index=range(3)).rename({}, axis=0)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-2588ce9f0737> in <module>()
----> 1 pd.Series(-1, index=range(3)).rename({}, axis=0)

/home/pietro/nobackup/repo/pandas/pandas/core/series.py in rename(self, index, **kwargs)
   2648         if non_mapping:
   2649             return self._set_name(index, inplace=kwargs.get('inplace'))
-> 2650         return super(Series, self).rename(index=index, **kwargs)
   2651 
   2652     @Appender(generic._shared_docs['reindex'] % _shared_doc_kwargs)

/home/pietro/nobackup/repo/pandas/pandas/core/generic.py in rename(self, *args, **kwargs)
    850         if kwargs:
    851             raise TypeError('rename() got an unexpected keyword '
--> 852                             'argument "{0}"'.format(list(kwargs.keys())[0]))
    853 
    854         if com._count_not_none(*axes.values()) == 0:

TypeError: rename() got an unexpected keyword argument "axis"

Problem description

Sure, it is redundant, but for compatibility it would be good to support it.

In particular, I have an old method which calls obj.rename_index(axis=n) with obj sometimes being a DataFrame and sometimes a Series, and now I get a warning asking me to use rename... but if I do, I get the above error.

Expected Output

The same as without axis=0.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: 2a0e54b
python: 3.5.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.0-4-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8

pandas: 0.22.0.dev0+251.g2a0e54bc8
pytest: 3.0.6
pip: 9.0.1
setuptools: 33.1.1
Cython: 0.25.2
numpy: 1.12.1
scipy: 0.18.1
pyarrow: None
xarray: None
IPython: 5.2.2
sphinx: None
patsy: 0.4.1+dev
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: 1.2.0
tables: 3.3.0
numexpr: 2.6.1
feather: 0.3.1
matplotlib: 2.0.0
openpyxl: 2.3.0
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: None
lxml: 3.7.1
bs4: 4.5.3
html5lib: 0.999999999
sqlalchemy: 1.0.15
pymysql: None
psycopg2: None
jinja2: 2.8
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@jreback jreback added Compat pandas objects compatability with Numpy or Python functions Difficulty Novice Enhancement Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Dec 1, 2017
@jreback jreback modified the milestones: No action, Next Major Release Dec 1, 2017
@jreback
Copy link
Contributor

jreback commented Dec 1, 2017

sure for compat this would be ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Enhancement good first issue Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants