Closed
Description
import pandas as pd
s = pd.Series()
s.apply(lambda x: x)
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-3-a33a9027c226> in <module>()
----> 1 s.apply(lambda x: x)
/usr/local/lib/python2.7/dist-packages/pandas/core/series.pyc in apply(self, func, convert_dtype, args, **kwds)
2295
2296 mapped = lib.map_infer(values, f, convert=convert_dtype)
-> 2297 if isinstance(mapped[0], Series):
2298 from pandas.core.frame import DataFrame
2299 return DataFrame(mapped.tolist(), index=self.index)
IndexError: index out of bounds
This happens since 0.10.0 because of the new feature which upcasts the returned object to a dataframe if the function passed as the func
argument returns a Series.