Python 筛选数据帧中的特定值
我试图在许多列中过滤某些值 在列(维度)中过滤教育,然后在下一列(指标名称),过滤平均受教育年限(年),然后在国家名称列中过滤美国、加拿大等 我已经尝试了下面的脚本,但我无法过滤上面提到的细节Python 筛选数据帧中的特定值,python,pandas,dataframe,for-loop,transpose,Python,Pandas,Dataframe,For Loop,Transpose,我试图在许多列中过滤某些值 在列(维度)中过滤教育,然后在下一列(指标名称),过滤平均受教育年限(年),然后在国家名称列中过滤美国、加拿大等 我已经尝试了下面的脚本,但我无法过滤上面提到的细节 raw_data={} for Dimension in new_df["Dimension"]: dimension_df=new_df.loc[new_df["Dimension"]==Dimension] arr=[] arr.append(dimension_df["Ind
raw_data={}
for Dimension in new_df["Dimension"]:
dimension_df=new_df.loc[new_df["Dimension"]==Dimension]
arr=[]
arr.append(dimension_df["Indicator Name"].values[0])
arr.append(dimension_df["ISO Country Code"].values[0])
raw_data[Dimension]=arr
pd.DataFrame(raw_data)
请展示您的输入和输出数据框架示例。您是否检查了此项?