Skip to content

Silently ignored kwargs in Index.to_series #18699

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

Closed
jbrockmendel opened this issue Dec 8, 2017 · 3 comments · Fixed by #18707
Closed

Silently ignored kwargs in Index.to_series #18699

jbrockmendel opened this issue Dec 8, 2017 · 3 comments · Fixed by #18707
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@jbrockmendel
Copy link
Member

>>> idx = pd.date_range('1994-10-06', freq='D', periods=4)
>>> idx.day.to_series(index=idx)
>>> idx.day.to_series(index=idx)
6    6
7    7
8    8
9    9

Expected:

>>> idx.day.to_series(index=idx)
1994-10-06    6
1994-10-07    7
1994-10-08    8
1994-10-09    9

Looks like Index.to_series takes **kwargs but then ignores them. Should be an easy fix; would be nice to systematically track down other places this might happen.

@jreback
Copy link
Contributor

jreback commented Dec 9, 2017

yeah looks like old/typo. should be removable.

@jreback jreback added API Design Difficulty Novice Indexing Related to indexing on series/frames, not to indexes themselves labels Dec 9, 2017
@jreback jreback added this to the Next Major Release milestone Dec 9, 2017
@alysivji
Copy link
Contributor

alysivji commented Dec 9, 2017

I'm looking into this issue.

Fixed the Index.to_series(**kwargs) bug and added tests to common.py which also contains the original test for this method.

None of the tests in this module are being run:

$ pytest pandas/tests/indexes/common.py
================================= test session starts ==================================
platform darwin -- Python 3.6.1, pytest-3.1.2, py-1.4.34, pluggy-0.4.0
rootdir: /Users/alysivji/Documents/siv-dev/projects/open-source/pandas, inifile: setup.cfg
plugins: xdist-1.17.1
collected 0 items

============================= no tests ran in 0.01 seconds =============================

Where should I be writing my tests?

Note: same bug is also showing up in Index.to_frame(), where index=True is a default kwarg.

>>> import pandas as pd
>>> idx = pd.date_range('1994-10-06', freq='D', periods=4)
>>> idx.day.to_frame()
   0
6  6
7  7
8  8
9  9

@jreback
Copy link
Contributor

jreback commented Dec 9, 2017

common is included in all the subclasses

you can add them there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants