我有一个365行数据框,我想获取一个开始日期,时间范围和少于特定值(干旱)的降雨量
示例:
PRODUKT_CODE STATION_ID Ppt QN QB
ZEITSTEMPEL
2018-01-01 RS_MN006 1055 27.4 3 0
2018-01-02 RS_MN006 1055 28.1 3 0
2018-01-03 RS_MN006 1055 9.3 3 0
2018-01-04 RS_MN006 1055 7.8 3 0
2018-01-05 RS_MN006 1055 4.7 3 0
2018-01-06 RS_MN006 1055 5.3 3 0
2018-01-07 RS_MN006 1055 1.0 3 0
2018-01-08 RS_MN006 1055 0.0 3 0
2018-01-09 RS_MN006 1055 0.5 3 0
2018-01-10 RS_MN006 1055 2.1 3 0
2018-01-11 RS_MN006 1055 0.6 3 0
2018-01-12 RS_MN006 1055 0.0 3 0
df_1["Value"] = 0
for i in np.arange(df_1["Ppt"].count()-3):
if df_1["Ppt"][i]>10:
if df_1["Ppt"][i+1] < 2 and df_1["Ppt"][i+2] < 2 and df_1["Ppt"][i+3] <2:
df_1["Value"][i]=1
print("Sequence of days were found at: "+ str(df_1["Ppt"].index[i]))
print("Ppt for day 1 :", + str(df_1["Ppt"][i] + "Ppt for day 2,3,4:" + str(df_1["Ppt"][i+1]) + " " + str(df_1["Ppt"][i+2]) + " " + str(df_1["Ppt"][i+3])))
C:\Users\USER\Desktop\Masterarbeit\2 CODE\radolan\Rainall_analysis.py:31: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
df_1["Value"][i]=1
Sequence of days were found at: 2018-01-25 00:00:00
Traceback (most recent call last):
File "C:\Users\USER\Desktop\Masterarbeit\2 CODE\radolan\Rainall_analysis.py", line 33, in <module>
print("Ppt for day 1 :", + str(df_1["Ppt"][i] + "Ppt for day 2,3,4:" + str(df_1["Ppt"][i+1]) + " " + str(df_1["Ppt"][i+2]) + " " + str(df_1["Ppt"][i+3])))
TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U32') dtype('<U32') dtype('<U32')
是否有一种优雅的方法,或者有一个功能可以分析每日降水数据的模块?