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
什么是去这里的路?