我在 Windows 中运行脚本,我收到以下错误:
Traceback (most recent call last):
File "C:\Users\esalazar\Desktop\datos\stat_cea_2011\emas\amealco\promedios-emas.py", line 64, in <module>
g=index.groupby(level=0)
AttributeError: 'NoneType' object has no attribute 'groupby'
我已经安装了 pandas、scipy 和 numpy。我需要安装其他库吗?如何修复此错误?
这是我的代码的一部分:
data = pd.read_csv('C:/Users/esalazar/Desktop/datos/stat_cea_2011/emas/amealco/enero.csv',skiprows=1,names=['Fecha','Hora','C','D','E','Temperatura','TempRocio','DirViento','I','MagViento','K','Humedad','Presion','N','PreciAcu','P','Q','R','S'],header=0)
Uviento=[]
Vviento=[]
for i in range(0,len(data['MagViento'])):
Uviento.append((data['MagViento'][i]*sin((data['DirViento'][i]+180)*(pi/180.0))))
Vviento.append((data['MagViento'][i]*cos((data['DirViento'][i]+180)*(pi/180.0))))
data['PromeU']=Uviento
data['PromeV']=Vviento
data
<class 'pandas.core.frame.DataFrame'>
Int64Index: 4463 entries, 0 to 4462
Data columns (total 19 columns):
Fecha 4463 non-null values
Hora 4463 non-null values
C 4463 non-null values
D 4463 non-null values
E 4463 non-null values
Temperatura 4463 non-null values
TempRocio 4463 non-null values
DirViento 4463 non-null values
I 4463 non-null values
MagViento 4463 non-null values
K 4463 non-null values
Humedad 4463 non-null values
Presion 4463 non-null values
N 4463 non-null values
PreciAcu 4463 non-null values
P 4463 non-null values
Q 4463 non-null values
R 4463 non-null values
S 4463 non-null values
dtypes: float64(8), int64(4), object(7)
df = data.set_index(['Fecha','Hora'],inplace=True)
df
我得到这个错误
TypeError: NoneType object has no atribute '--getitem--'
所以,
grouped = df.groupby(level=0)
也是错误。