【发布时间】:2019-05-03 11:17:36
【问题描述】:
我有一个看起来像
的数据框Country | IndicatorName | Value
Spain | Indicator1 | 3
Spain | Indicator2 | 4
Germany | Indicator16 | 24
......
我想将其转换为具有 IndicatorName 列、Country 行和 Value 交叉点的数据框
Country | Indicator 1 | Indicator 2 | Indicator 3 | ......
Spain | 3 | 4 | 16 | ......
Germany | 23 | 232 | 232 | ......
.......
我正在尝试通过 groupby(["IndicatorName","Value"]) 但不确定如何继续
import pandas as pd
indicators = pd.read_csv("Indicators.csv")
indicators.groupbby(["IndicatorName","Value"])
.....
是否有适当的方法来处理这个问题,还是需要通过迭代来完成?
【问题讨论】:
标签: python pandas dataframe machine-learning