问题
I'm trying to describe a list values, but this error appears:
KeyError: "None of [Index(['...'],\n dtype='object')] are in the [columns]"
I've tried to search for whitespaces. I've set header to 0 and tried the delim_whitespace=True but there aren't any whitespace so I removed it.
%matplotlib inline
import scipy as sp
import pandas as pd
import matplotlib.pyplot as plt
import statsmodels.formula.api as sm
import csv
df = pd.read_csv('Dados.csv', sep=";", header=0)
x1 = df['com_proc'].values.tolist()
y = df['result_op'].values.tolist()
dados = pd.DataFrame(data=df)
dados
print("Estatísticas descritivas de y:")
dados[y].describe()
Dataframe shows as it should and makes me think that there's nothing wrong with it. The problem starts in the dados[y].describe().
回答1:
df['result_op'] is pointing at the values in the column.DataFrame.describe() or Series.describe() only works for those with valid names.dados[y] is not returning anything, let alone dados[y].describe()
来源:https://stackoverflow.com/questions/58595459/none-of-index-are-in-the-columns