I have a dataframe (sample of which is shown below):
import pandas as pd
df = pd.DataFrame(data={'Date': ['Jan-1', 'Jan-1', 'Jan-4', 'Jan-4', 'Jan-5', 'Jan-6', 'Jan-6', 'Jan-6']})
i.e. :
Date
0 Jan-1
1 Jan-1
2 Jan-4
3 Jan-4
4 Jan-5
5 Jan-6
6 Jan-6
7 Jan-6
I want to extract only the day part from it. which should return me as follows:
1
1
4
4
5
6
6
6
and what I am trying is as follows:
df['Date2'] = pd.to_datetime(df['Date'], format="%M-%d")
but this has resulted in error... not sure what I am doing wrong here.
how to extract the day
then, in my case?