我想根据Mean-CArea,Mean-chpressure和Mean-u-Force对数据帧进行分组。但是,我得到了以下结果:
如您所见,列名是0,1,2,不是原生的,解剖的,非解剖的。有没有办法从原始数据帧中获取正确的列名?在
以下是我目前为止的代码:
def function(self, df):
d = dict()
for head in df.columns.tolist():
RH, j_mechanics = head
if j_mechanics not in d:
d[j_mechanics] = df[head]
else:
d[j_mechanics] = pd.concat([d[j_mechanics],df[head]], axis=1, ignore_index=True)
for df_name, df in sorted(d.items()):
print(df_name)
print(df.head())
先谢谢你!在
您想使用
xs
以及
^{pr2}$以及
IIUC您可以按列(} 与^{} 一起使用:
axis=1
)和第一级(level=0
)将^{相关问题 更多 >
编程相关推荐