AttributeError:'DataFrame'对象没有属性'Height'

use*_*459 10 python-2.7 pandas

我能够将csv文件转换为pandas DataFormat并能够打印出表格,如下所示.但是,当我尝试打印出高度列时,我收到一个错误.我怎样才能解决这个问题?

import pandas as pd

df = pd.read_csv('/path../NavieBayes.csv')
print df #this prints out as seen below
print df.Height  #this gives me the "AttributeError: 'DataFrame' object has no attribute 'Height'

      Height   Weight  Classifer
0      70.0      180     Adult
1      58.0      109     Adult
2      59.0      111     Adult
3      60.0      113     Adult
4      61.0      115     Adult
Run Code Online (Sandbox Code Playgroud)

JAB*_*JAB 13

我在阅读之前遇到过类似的问题csv.假设它是相同的:

col_name =df.columns[0]
df=df.rename(columns = {col_name:'new_name'})
Run Code Online (Sandbox Code Playgroud)

我的情况中的错误是由(我认为)由csv中的字节顺序标记或其他一些非打印字符添加到第一列标签引起的.df.columns返回列名称的数组.df.columns[0]获得第一个.尝试打印它,看看结果是否有些奇怪.