我有一个具有以下特征的数据集。 3个索引。 2层列级别。 每个索引都有2行数据。
话虽如此,我试图过滤一行中的值大于0.7的行,但我只会收到索引错误。
我的数据框如下
indx=['nmatch','pts','gfa','gco','cs','fts','bts','o25%','po25/bts']
findx=[('fecha',''),('torneo',''),('partido','')]+[('h/a stats',x) for x in indx]+[('total stats',y) for y in indx]
index=pd.MultiIndex.from_tuples(findx, names=['tipo', 'stat'])
fframe=pd.DataFrame(l,columns=index)
fframe.set_index(['fecha','torneo','partido'],inplace=True)
如果我愿意
fframe[fframe[('h/a stats','po25/bts')]>0.7]
我得到类似
date trophy match data
A B ganma v theta True
A B ganma v theta False
F B Etha v psi True
F B Etha v psi True
C D epsilon v mu False
C D epsilon v mu False
如果我愿意
ind=fframe.index[f[('h/a stats','po25/bts')]>0.7]
我得到了它的索引,但是当我这样做的时候
fframe.loc[ind]
>IndexError: list index out of range
我希望索引唯一,而不是4 B,应该只有一个B,而不是2个匹配,那里应该只有一个。 但是最主要的是,我想要得到一个包含所有True行的框架,如果发生这种情况,例如ganma v theta,其中一行为True,另一行为False,则将它们都显示出来