Resampling a dataframe to a given time interval in both Python and R
we have a dataframe read from a csv and want to resample to a period of 5mins. We also need to convert the string to a datetime format In Python: df=pd.read_csv( 'RAWdata.csv' ) df=df.set_index( 'Time' ) #Assuming there is a column named time df.index=pd.to_datetime(df.index, format = '%d-%b-%Y %H:%M:%S' ) df=df.resample( '5min' ).mean() The R equivalent: library( 'readr' ) library( 'dplyr' ) library( 'padr' ) df=read.csv( 'RAWdata.csv' ,header=TRUE) df $ Time= as .POSIXct(df $ Time, format = "%d-%b-%Y %H:%M:%S" ) df %>% thicken( "5 min" ) %>% group_by(Time_5_min) %>% summarise(mean(FT))