1
設置多列值I具有MultiColumned數據幀如下:熊貓:基於平板圓柱值
Out[1]:
Empty DataFrame
Columns: [(price, mean), (price, mom_2), (units, mean), (units, mom_2)]
Index: []
我有mean
一些(平)值,這是我想投入price
和units
:
>>> value
Out[2]:
price 0.0
units 0.0
dtype: float64
我覺得要走的路是
resultsDf.loc[idx, pd.IndexSlice[:, 'mean']] = value
但它不是,因爲值不接管:
resultsDf.loc
price units
mean mom_2 mean mom_2
(desc, foo) (desc, bar)
1500002071 65 NaN NaN NaN NaN
我想,在進一步檢查中,問題是,儘管我選擇基於第一級,我仍然有一個多層次左手側,我不能從單一層次的右側合併/粘貼到:
>>> resultsDf.loc[idx, pd.IndexSlice[:, 'mean']]
Out[5]:
price mean NaN
units mean NaN
Name: (1500002071, 65), dtype: object
>>> value
Out[6]:
price 0.0
units 0.0
dtype: float64
什麼是去這裏的路?