-1

date_index = np.arange('2015-01-01','2016-01-01', dtype='datetime64[D]') hello I want to convert the date_index to the month name but I don't know how can I do that.

1 Answers1

1

You can try this:

months = date_index.astype('datetime64[M]').astype(int) % 12 + 1
Viettel Solutions
  • 1,519
  • 11
  • 22
  • 1
    And after getting month number, you can ```import locale import calendar locale.setlocale(locale.LC_ALL, 'en_US') print(calendar.month_name[1])``` (where ```1``` is just month number). Pandas would also be helpful. – Sylogista Dec 30 '21 at 04:03