TypeError : 'method' object is not subscriptable

TypeError : 'method' object is not subscriptable

我的错误是这样的: 类型错误:'method' 对象不可订阅

      pd.DataFrame({'Pokemon_name':test.Pokemon_name,'CP':new_pred_class}).set_index['Pokemon_name'].to_csv['new_pred_cp.csv']

我正在尝试将结果写入新的 csv 文件。

.to_csv是一个function/method,后面不能用[],必须是().

所以代码应该是:

....['Pokemon_name'].to_csv("new_pred_cp.csv")