我有PyCharm 18,我安装了pandas版本0.22.0.当我导入它不起作用,
这是我的代码:
import pandas as pd
datas = pd.DataFrame({
"fsfsd": ["fff", "fss"],
"ddfs": ["fsdfsd", "fdfsfs"]
})
print(datas)
但是当它执行时它会给我以下错误:
Traceback (most recent call last):
File "C:/Users/hp/PycharmProjects/PC18/pandas.py", line 1, in
import pandas as pd
File "C:\Users\hp\PycharmProjects\PC18\pandas.py", line 3, in
datas = pd.DataFrame({
AttributeError: module 'pandas' has no attribute 'DataFrame'
Process finished with exit code 1
请帮助;谢谢
问题是由于你的脚本“pandas.py”的名称,你当前的文件夹文件中没有调用pd或pandas等…
通常避免脚本,变量等的名称…也用于库,模块,函数等…