'What does this KeyError mean and how can I solve it?
import pandas as pd
df = pd.read_csv("output.csv")
df["Output_before"] = df["Output(kWh)"].shift(-1)
df["Output_changes"] = (df["Output(kWh)"] / df["Output_before"]) - 1
df["Output_before"] = df["Output(kWh)"].shift(-1)
df["Output_changed"] = (df["Output(kWh)"] / df["Output_before"]) -1
df = df.dropna()
changes = df["Output(kWh)"]
# input shape: (number_of_train_examples, sequence_length, input_dim)
import numpy as np
X = []
Y = []
for i in range (0, len(changes) - 20):
Y.append(changes[i])
X.append(np.array(changes[i+1:i+21][::-1]))
X = np.array(X).reshape(-1, 20, 1)
Y = np.array(Y)
The KeyError is '191' and I don't understand why. I tested the same code with an other dataset and it worked. Is there an issue with my dataset? In the attachment is a picture of the error code. KeyError.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
