Closed
Description
Lines 3770 to 3777 in 3a7f956
import pandas as pd
import numpy as np
df = pd.DataFrame({'a': [np.nan,np.nan]})
df.first_valid_index()
This code results in the following error message, which I believe is called because the boolean series returned by self.count(1) > 0 is all False.
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
df.first_valid_index()
File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 3859, in first_valid_index
return self.index[self.count(1) > 0][0]
File "C:\Python27\lib\site-packages\pandas\indexes\base.py", line 1423, in __getitem__
return getitem(key)
IndexError: index 0 is out of bounds for axis 0 with size 0
Should there be a check where None is returned if self.count(1) > 0 is all False?
As an aside, this issue also occurs in df.last_valid_index() for the same reason.