错误及解决办法:trackback (most recent call last) File “XXX文件路径” ,line 1, in import pandas as pd

最近学习《python 机器学习及实践》(作者范淼、李超),编写运行其第四章的代码。

书中源代码为:(相应的配置为python2..7.13,pandas版本为0.20.2)

import pandas as pd
train = pd.read_csv('../Datasets/titanic/train.csv')
test = pd.read_csv('../Datasets/titanic/test.csv')
print train.info()
print test.info()
 
  

 运行到此时出现错误trackback (most recent call last) File “XXX文件路径” ,line 1, in  import pandas as  pd 
  

.....................................

解决方法,更换python版本3.6.1,pandas版本依然为0.20.2,不过python版本不一样代码略有不同

import pandas as pd
train = pd.read_csv('../Datasets/titanic/train.csv')
test = pd.read_csv('../Datasets/titanic/test.csv')
print (train.info())

print (test.info())

原因分析:pandas与python版本不匹配



你可能感兴趣的:(python,trackback,import,pandas,as,pd)