1

I have a column in this format:

Date/Time Opened

2014-09-01 00:17:00

2014-09-18 18:55:00

I have converted it to datetime using below function

df['Date/Time Opened'] = pd.to_datetime(df['Date/Time Opened'])

How can I convert it to 'mm/yyyy' format so that I can plot it in a graph by frequency/count?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Tejas Gupta
  • 11
  • 1
  • 2
  • 1
    I'm voting to close this as duplicate of [Extracting just Month and Year separately from Pandas Datetime column](https://stackoverflow.com/questions/25146121/extracting-just-month-and-year-separately-from-pandas-datetime-column) – mkrieger1 Nov 04 '21 at 10:20

1 Answers1

1

Try:

df['Date/Time Opened'].dt.to_period('M')
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Gedas Miksenas
  • 959
  • 7
  • 15