Convert datetime.datetime to day of the week, and then plot

I have a list of datetime.datetime objects:


x1 = [datetime.datetime(2019, 8, 18, 21, 21, 23), datetime.datetime(2019, 8, 18, 20, 38, 6),        datetime.datetime(2019, 8, 18, 18, 45, 38), datetime.datetime(2019, 8, 18, 15, 35, 25), datetime.datetime(2019, 8, 18, 15, 29, 54), datetime.datetime(2019, 8, 18, 15, 26, 19)]


And I would like to extract the day of the week they are (0 Monday, 6 Sunday, for example), and then plot 7 histogram, one per day, with the hours in the x axis.

So far no luck using .weekday()



Not the answer you're looking for? Browse other questions tagged python datetime or ask your own question.