-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: first_valid_index() empty Series and DataFrame inconsistencies #9752
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
Comments
these are prob not tested very well. The SparseDataFrame exception looks like an actual code error somewhere. returning |
There is a test for I changed the
|
Same issue with all missing rows. #14397 pd.Series([np.nan]).first_valid_index() # this returns None
pd.DataFrame([np.nan]).first_valid_index() # raise error
>>> pd.__version__
u'0.18.1' |
This looks to be fixed on master. Could use a test
|
I came across some inconsistencies in how
first_valid_index()
works on emptySeries
andDataFrames
(andlast_valid_index()
).Is there a reason for this different behavior? Note also that the
DataFrame
/SparseDataFrame
exceptions are different. Here's theDataFrame
andSeries
methods. TheSeries
method has aif len(self) == 0
check. I can make a PR if you think one of these should be changed and tell me which way you want to go.For what it's worth, I came across this issue trying to use this function in a list comprehension to get a list of minimum times from a handful of
Series, DataFrames, and SparseDataFrames
that may or may not be empty. (Although it just occurred to me that I could, of course, put an if empty check in my list comprehension.)The text was updated successfully, but these errors were encountered: