列中没有索引 [英] None of Index are in the columns
问题描述
我正在尝试描述列表值,但是出现此错误:
I'm trying to describe a list values, but this error appears:
KeyError: "None of [Index(['...'],\n dtype='object')] are in the [columns]"
我尝试搜索空格.我已将header设置为0并尝试了delim_whitespace=True
,但是没有任何空格,因此我将其删除.
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可以正常显示,并让我认为它没有任何问题.问题始于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()
.
推荐答案
df['result_op']
指向列中的值.
DataFrame.describe()
或Series.describe()
仅适用于具有有效名称的用户.
dados[y]
不返回任何内容,更不用说dados[y].describe()
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()
这篇关于列中没有索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!