子模块不是隐式导入的,必须显式声明,但我正在显式调用pd.Series
子模块,不是吗?
无论如何,不应该import pandas as pd
允许pd.Series
被调用吗?以下代码在iPython中完美运行,但在从脚本执行时失败。
#!/usr/bin/env/python2.7
# -*- coding: utf-8 -*-
import pandas as pd
import numpy as np
counts = pd.Series([632, 1638, 569, 115], index=["Firmicutes", "Proteobacteria", "Actinobacteria", "Bacteroidetes"])
结果是:
tyler@machine ~/src/stats $ python pandas.py
Traceback (most recent call last):
File "pandas.py", line 3, in <module>
import pandas as pd
File "/home/tyler/src/stats/pandas.py", line 6, in <module>
counts = pd.Series([632, 1638, 569, 115], index=["Firmicutes", "Proteobacteria", "Actinobacteria", "Bacteroidetes"])
AttributeError: 'module' object has no attribute 'Series'
我哪里出错了?