How to fix: KeyError: "None of [Index([...], dtype='object')] are in the [columns]"

Viewed 8011

I'm a beginner/Student and want to develop a prototype for a neural Network. I want to create a variable from a DataFrame-column, but I get an error I do not understand:

# take() does not accept boolean indexers
KeyError: "None of [Index(['Solar - Actual Aggregated [MW]'], dtype='object')] are in the [columns]"

I have seen a post which said that spaces in the column name are not good, but in the past I did not had a Problem with that.

import pandas as pd
import numpy as np

df = pd.read_csv("...Test_Trainingsdaten/03.06.19/Produziert%20Solar%20Wind_28-06-19.csv")

df.info()
# MTU                               96 non-null object
# Solar - Actual Aggregated [MW]    96 non-null int64


X = df[["MTU"]].values                               # works                 
Y = df[["Solar - Actual Aggregated [MW]"]].values    # error

With those two variables i wanted to create a simple machine learning model, but I don't know how to fix that error

0 Answers
Related