concatenating TimeSeries of different lengths using Pandas

大城市里の小女人 提交于 2020-02-02 11:17:30

问题


I am using pandas in python. I have several Series indexed by dates that I would like to concat into a single DataFrame, but the Series are of different lengths because of missing dates etc. I would like the dates that do match up to match up, but where there is missing data for it to be interpolated or just use the previous date or something like that. What is the easiest way to do this?


回答1:


If the Series are in a dict data, you need only do:

frame = DataFrame(data)

That puts things into a DataFrame and unions all the dates. If you want to fill values forward, you can call frame = frame.fillna(method='ffill').



来源:https://stackoverflow.com/questions/11298097/concatenating-timeseries-of-different-lengths-using-pandas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!