我创建了以下多索引列:
Out[213]:
KEY POLL
count mean sum
0 1 21 0.80921 10
1 2 3 0.666667 2
2 3 67 0.835821 3
3 4 13 1.000000 4
4 5 674 0.876855 5
如果需要,我可以访问POLL多索引列:
session_counts_merged[('POLL','sum')].head()
Out[225]:
0 0
1 0
2 0
3 0
4 0
Name: (POLL, sum), dtype: int64
但是,当我将上表加入另一个表时,我无法弄清楚如何访问该表。
这是新表上的.info():
account_aggregates.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 9713 entries, 0 to 9712
Data columns (total 6 columns):
NATIVEACCOUNTKEY 9713 non-null int64
(NATIVEACCOUNTKEY, ) 9713 non-null int64
(POLL, count) 9713 non-null int64
(POLL, mean) 9713 non-null float64
(POLL, sum) 9713 non-null int64
session_deciles 9713 non-null object
如何访问名为(POLL,sum)的列?做这样的事情:
account_aggregates_grouped['(POLL, sum)'].head()
导致找不到密钥错误