python中的多重索引
我正在使用jypyther python。我通过以下方式创建了一个数据集:python中的多重索引,python,pandas,jupyter-notebook,Python,Pandas,Jupyter Notebook,我正在使用jypyther python。我通过以下方式创建了一个数据集: scr_spread=pd.read_csv('C:/Users/e877780/Desktop/DEV/scr_spread.txt',sep=";") #scr_spread['idx']=range(1,len(scr_spread)+1) scr_spread.set_index(['Tipo','Rating','Duration_hasta'], inplace=True) scr_spread=scr_sp
scr_spread=pd.read_csv('C:/Users/e877780/Desktop/DEV/scr_spread.txt',sep=";")
#scr_spread['idx']=range(1,len(scr_spread)+1)
scr_spread.set_index(['Tipo','Rating','Duration_hasta'], inplace=True)
scr_spread=scr_spread.sort_index()
数据集还有一个字段“Duramaxima”。我试图得到对应于三元组的“Duramaxima”,例如(1,1,5)。我使用以下语法:
scr_spread.loc[(1,1,5),'DuraMaxima']
如果我从上面定义a=2*值并打印输出,我会得到以下结果:
我怎么才能得到346,而不是乘法的三元组加结果呢。我需要另一个数据集的346。
感谢当使用tuple访问
.loc
中的某一行时,它将返回pandas系列。
因此,通过
print(a.iloc[0])
您仅获得346。当您尝试a.values
时会发生什么?