Description
Code Sample, a copy-pastable example if possible
>>> import pandas as pd
>>> import numpy as np
>>> pd.Series([np.nan]).asof([0])
Traceback (most recent call last):
File "<ipython-input-268-2b0f8084a393>", line 1, in <module>
pd.Series([np.nan]).asof([0])
File "~/anaconda3/lib/python3.5/site-packages/pandas/core/generic.py", line 3985, in asof
locs = self.index.asof_locs(where, ~(nulls.values))
File "~/anaconda3/lib/python3.5/site-packages/pandas/indexes/base.py", line 1837, in asof_locs
result = np.arange(len(self))[mask].take(locs)
IndexError: cannot do a non-empty take from an empty axes.
Problem description
When calling Series.asof()
, if the series happens to contain all nans, an error is raised. See #10343.
Expected Output
0 NaN
dtype: float64
Output of pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.8-100.fc24.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: C
LANG: C
LOCALE: None.None
pandas: 0.19.0+579.g4ce9c0c
pytest: 3.0.5
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.2
numpy: 1.11.3
scipy: 0.18.1
xarray: 0.9.1
IPython: 4.2.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: 1.2.0
tables: 3.3.0
numexpr: 2.6.2
feather: None
matplotlib: 2.0.0
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: 0.9.6
lxml: 3.7.2
bs4: 4.5.3
html5lib: 0.999
sqlalchemy: 1.1.5
pymysql: None
psycopg2: None
jinja2: 2.9.4
s3fs: None
pandas_gbq: None
pandas_datareader: None