数据框对象没有属性 [英] Data-frame Object has no Attribute

查看:81
本文介绍了数据框对象没有属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道以前曾问过这种问题,我已经检查了所有答案,并且尝试过几次,但徒劳无功. 实际上,我使用Pandas来调用Dataframe.我已经上传了一个csv.file.

I know that this kind of question was asked before and I've checked all the answers and I have tried several times to find a solution but in vain. In fact I call a Dataframe using Pandas. I've uploaded a csv.file.

当我键入data.Countrydata.Year时,我得到第一列,并显示第二列.但是,当我键入data.Number时,每次都会出现此错误:

When I type data.Country and data.Year, I get the 1st Column and the second one displayed. However when I type data.Number, everytime it gives me this error:

AttributeError:"DataFrame"对象没有属性"Number".

AttributeError: 'DataFrame' object has no attribute 'Number'.

推荐答案

使用data.columns

它应该打印出这样的内容

It should print something like this

Index([u'regiment', u'company',  u'name',u'postTestScore'], dtype='object')

检查隐藏的空格.然后可以使用

Check for hidden white spaces..Then you can rename with

data = data.rename(columns={'Number ': 'Number'})

这篇关于数据框对象没有属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆