【发布时间】:2020-06-07 10:22:17
【问题描述】:
我有一个带有列名的数据框
** RI Na Mg Al Si K Ca Ba Fe 型 **
类型列是分类的,由 4 种类型组成。如何使用字典只提取类型为2的RI、Al、Si、Ba列?
我已尝试使用以下代码:
pd.DataFrame.from_dict(data=df[df['Type']==2], orient='index',columns=['RI','Al','Si','Ba'])
我收到一个错误:
'numpy.ndarray' object is not callable
如何只选择类型 2 的特定列?
【问题讨论】:
标签: python pandas numpy dataframe dictionary