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

inconsistent behavior of series.last_valid_index, and df.last_valid_index when dataframe empty #12800

Closed
phil20686 opened this issue Apr 5, 2016 · 3 comments
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@phil20686
Copy link

idx = pd.DataFrame().last_valid_index() #throws index error
idx = pd.Series().last_valid_index() #returns None

if you call last_valid_index() on df it throws an IndexError, if you call it on series it returns None. It seems like it would be very little effort to make these two cases consistent. Moreover, I believe they should be consistent with the behavior of

series.get_value(index_value)

where index value is not in the index (i.e. a KeyError).

output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 2.7.6.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 45 Stepping 7, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.0
nose: 1.3.4
pip: 8.1.1
setuptools: 20.2.2
Cython: None
numpy: 1.9.2
scipy: 0.17.0
statsmodels: 0.6.1
xarray: None
IPython: 2.3.0
sphinx: None
patsy: 0.4.1
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.4.2
openpyxl: 2.3.1
xlrd: 0.9.4
xlwt: None
xlsxwriter: 0.8.4
lxml: 3.5.0
bs4: 4.4.1
html5lib: 0.999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.7.3
boto: None

@jreback
Copy link
Contributor

jreback commented Apr 5, 2016

yep, I would agree. pull-requests are welcome! (the frame methods are untested it appears).
series tests are in tests/series/test_timeseries.

@jreback jreback added Bug Indexing Related to indexing on series/frames, not to indexes themselves Difficulty Novice labels Apr 5, 2016
@jreback jreback added this to the 0.18.1 milestone Apr 5, 2016
@phil20686
Copy link
Author

I would love to have time to do some PR but just don't atm :(

@jreback
Copy link
Contributor

jreback commented Apr 5, 2016

ok, though this is a quickie :)

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
Projects
None yet
2 participants