简体   繁体   中英

timeseries / dataframe manipulation in pandas

If I have one dataframe object created by read_csv that is indexed with 15 minute timestamp data, what would be the best way to concatenate that with another set of data that is indexed with daily data? The daily data would fill in the remaining rows of the 15 minute data where the timestamp is within that daterange.

I would extract the day from the minute data set and merge it with the day index of the other dataframe. Something like...

import pandas as pd
def extractDay(row):
    row['day'] = row['time'].day
    return row

minuteSet = pd.read_csv(...) #get 15minute data
daySet    = pd.read_csv(...) #get day data

minuteSet = minuteSet.apply(extractDay,axis=1) 
df = pd.merge(daySet,minuteSet,how="right",left_on="the day index",right_on="day")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM