Arrange two variables by two mismatching irregular time-series in R/Python? -
i have date/time hourly gives stream discharge , date/time on hour @ irregular intervals gives stream sediment concentration. i'm unsure how post data frames here, looks like:
datetimedis, discharge, datetimesed, sediment 6/12/15 12:00 1.1 6/12/15 18:00 1231 6/12/15 13:00 113 6/13/15 1:00 12312 6/12/15 14:00 123 21 6/13/15 8:00 12321 6/12/15 15:00 12 6/13/15 15:00 12312 6/12/15 16:00 12 6/14/15 19:00 4324 6/12/15 17:00 23 6/15/15 2:00 534523 6/12/15 18:00 123 6/15/15 9:00 52341
etc
i have ~2500 raws of data discharge, , ~500 columns sediment. there way use ddply or r package or python paste values of sediment next discharge value corresponds same time?
in example data, want instance sediment value @ 6/12/15 18:00 paste next discharge value @ time.
i need paste them there space in-between containing na values or empty values can later interpolate them.
assuming have 1 dataframe datetime , discharge(df) , time , sediment concentration(df2) following python pandas ...
create new column time datetime in df:
df['hours'] = df.index.hour
then use map function pandas map sediment concentration in df2 df:
df['sediment']=df['hours'].map(df2)
Comments
Post a Comment