python pandas AttributeError: ‘DataFrame‘ object has no attribute ‘ix‘

python使用pandas DataFrame.ix的时候 AttributeError: 'DataFrame' object has no attribute 'ix'


在使用进行DataFrame.ix进行表中的数据块选择的时候,会抛出’DataFrame’ object has no attribute ‘ix’,这个是由于在不同的pandas的版本中,DataFrame的相关属性已过期,已不推荐使用导致的。

df.ix[:,'table_header'] # 已过期

可以使用loc进行替换即可

df.loc[:,'table_header']

你可能感兴趣的:(杂谈,pandas,dataframe,ix,loc,python)