Pandas Reindex to Fill Missing Dates, or Better Method to Fill?

前端 未结 2 1800
小鲜肉
小鲜肉 2021-01-20 02:34

My data is absence records from a factory. Some days there are no absences so there is no data or date recorded for that day. However, and where this gets hairy with the o

2条回答
  •  时光说笑
    2021-01-20 03:26

    I think you just have a problem with the use of datetime, this approach worked for me

    ts.set_index(['Date'],inplace=True)
    ts.index = pd.to_datetime(ts.index,format='%b %d %Y')
    d2 = pd.DataFrame(index=pd.date_range('2014-01-01','2014-12-31'))
    
    print ts.join(d2,how='right')
    

提交回复
热议问题