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.
Asked
Active
Viewed 132 times
-1
-
Do you try this ? https://stackoverflow.com/questions/13648774/get-year-month-or-day-from-numpy-datetime64 – Viettel Solutions Dec 30 '21 at 03:29
1 Answers
1
You can try this:
months = date_index.astype('datetime64[M]').astype(int) % 12 + 1

Viettel Solutions
- 1,519
- 11
- 22
-
1And 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