When resample from monthly data to quarterly, I want my last value NaN to remain as NaN. How should I tweak my code?
Thank you
df=pd.read_excel(input_file, sheet_name='Sheet1', usecols='A:D', na_values='ND', index_col=0, header=0)
df.index.names = ['Period']
df.index = pd.to_datetime(df.index)
q0= pd.Series(df['HS6P1'], index=df.index)
m1 = q0.resample('Q'开发者_JAVA百科).sum()
Current Output
Period 1989-03-31 212.7 1989-06-30 302.1 1989-09-30 272.1 1989-12-31 163.9Desired Output
Period 1989-03-31 212.7 1989-06-30 302.1 1989-09-30 272.1 1989-12-31 NaN
精彩评论