You can use round(freq)
. There is also a shortcut column.dt
for datetime functions access (as @laurens-koppenol suggests).
Here’s one-liner:
df['old column'].dt.round('15min')
String aliases for valid frequencies can be found here. Full working example:
In [1]: import pandas as pd
In [2]: df = pd.DataFrame([pd.Timestamp('2015-07-18 13:53:33.280'),
pd.Timestamp('2015-07-18 13:33:33.330')],
columns=['old column'])
In [3]: df['new column']=df['old column'].dt.round('15min')
In [4]: df
Out[4]:
old column new column
0 2015-07-18 13:53:33.280 2015-07-18 14:00:00
1 2015-07-18 13:33:33.330 2015-07-18 13:30:00