BUG: applymap on empty DataFrame returns Series · Issue #8222 · pandas-dev/pandas (original) (raw)

@ojdo

I'm unsure about a corner case I encountered:

pd.DataFrame([]).applymap(round) Series([], dtype: float64)

full example

In [1]: df = pandas.DataFrame({ 'x' : [], 'y' : [], 'z' : []})

In [2]: df
Out[2]: 
Empty DataFrame
Columns: [x, y, z]
Index: []

In [3]: df.applymap(lambda x: x)
Out[3]: 
x   NaN
y   NaN
z   NaN
dtype: float64

In [4]: df = pandas.DataFrame({ 'x' : [1], 'y' : [1], 'z' : [1]})

In [5]: df.applymap(lambda x: x)
Out[5]: 
   x  y  z
0  1  1  1

I would have expected to get the empty DataFrame back.