我对熊猫很陌生。
基本上,我有10个dfs中不同公司的10种不同类型的数据。例如总资产、资产管理规模等
对于每种类型的数据,可能有高重要性或低重要性:H或L。
对于每种类型的数据,可能有3个类别:Cat1、Cat2、Cat3
对于H重要性,我需要按3个类别分析数据。我的重要性也一样
我正在考虑在合并10个dfs之后,为每列数据添加一个mulit索引。可能吗
当前状态
**df_1**
|Total Assets|
Firm 1| 100 |
Firm 2| 200 |
Firm 3| 300 |
**df_2**
|AUMS |
Firm 1| 300 |
Firm 2| 3400 |
Firm 3| 800 |
Firm 4| 800 |
and so on until df_10. Also the firms for all the df could differ.
所需输出
**Merged_df**
Importance| L | H |
Category | Cat1 | Cat2 |
|Total Assets| AUMs |
Firm 1 | 100 | 300 |
Firm 2 | 200 | 3400 |
Firm 3 | 300 | 800 |
Firm 4 | NaN | 800 |
接下来,我需要按“重要性”和“类别”分组。欢迎使用除多索引之外的任何其他解决方案。谢谢大家!
我们可以使用^{} 键在} :
axis=1
上^{merged_df
:^{} 可用于建立排序:
然后可以使用^{} ,它将按预期工作}之前,等等
H
在{merged_df
:数据帧:
相关问题 更多 >
编程相关推荐