I have timestamps in pandas and I want to be able to write a function that allows me to pull back different parts of the date. Here is an MWE:
import pandas as pd
df = pd.DataFrame({'hit': pd.to_datetime(['2018-12-29 00:00:00', '2019-03-25 00:00:00'])})
And this is what I want to be able to do:
def test(timepart):
df['hit'].dt.timepart
So I could call test(month)
and the function would return 12, 03
.