2014-01-20 44 views

回答

3

挖掘到大熊貓源,它看起來像這樣是罪魁禍首:

if not all(self.shape): 
    # How to determine this better? 
    is_reduction = False 
    try: 
     is_reduction = not isinstance(f(_EMPTY_SERIES), Series) 
    except Exception: 
     pass 

    if is_reduction: 
     return Series(NA, index=self._get_agg_axis(axis)) 
    else: 
     return self.copy() 

它看起來像熊貓是調用不帶參數的函數,企圖猜測結果應該是Series還是DataFrame

我想補丁是有序的。

編輯:這個問題已經被修補,現在都被記錄在案,並允許reduce選項可以用來避免它:http://pandas.pydata.org/pandas-docs/dev/generated/pandas.DataFrame.apply.html

相關問題