4
爲什麼Pandas的DataFrame.apply
方法在DataFrame
爲空時調用正在應用的函數?熊貓:爲什麼DataFrame.apply(f,axis = 1)在DataFrame爲空時調用f?
例如:
>>> import pandas as pd
>>> df = pd.DataFrame({"foo": []})
>>> df
Empty DataFrame
Columns: [foo]
Index: []
>>> x = []
>>> df.apply(x.append, axis=1)
Series([], dtype: float64)
>>> x
[Series([], dtype: float64)] # <<< why was the apply callback called with an empty row?