我正在使用Django获取天气数据。提取数据后,我尝试将每天转换为每周,但出现以下错误
TypeError at /filter
Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Int64Index'
django视图
def filter(request):
date_min = request.POST.get('date_min','')
date_max = request.POST.get('date_max','')
qs = weather_data.pdobjects.filter(DATE__range=(date_min,date_max))
df = qs.to_dataframe(fieldnames=['id','DATE','ET','EP','BSS','RF','WD','WD1','WS','DT1','WT1','DT2','WT2','MAXT','MINT','RH11','RH22','VP11','VP11','CLOUDM','CLOUDE','SOIL1','SOIL2','SOIL3','SOIL4','SOIL5','SOIL6','MinTtest','MaxTtest1','MaxTtest2'],index='id')
df = df.resample('W').agg({'ET':'sum','EP':'sum','BSS':'sum','RF':'sum','WD':'sum','WD1':'sum','WS':'sum','DT1':'sum','WT1':'sum','DT2':'sum','WT2':'sum','MAXT':'sum','MINT':'sum','RH11':'sum','RH22':'sum','VP11':'sum','VP11':'sum','CLOUDM':'sum','CLOUDE':'sum','SOIL1':'sum','SOIL2':'sum','SOIL3':'sum','SOIL4':'sum','SOIL5':'sum','SOIL6':'sum','MinTtest':'sum','MaxTtest1':'sum','MaxTtest2':'sum'},loffset = pd.offsets.timedelta(days=-6))
return render(request,"reports.html",locals())
{% for data in df %}
<td>{{data.ET}}</td>
<td>{{data.EP}}</td>
{% endfor %}