Search code examples
sklearn-pandas

TypeError : 'method' object is not subscriptable


The error i have is this: TypeError: 'method' object is not subscriptable

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

Im trying to write the results to a new csv file.


Solution

  • .to_csv is a function/method, and you can't use [] after it, it must be ().

    So the code should be:

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