How do I format the following string to shorter format. I have a list of strings that have the following shape
2022-06-03T17:00:00.000000000
2022-06-04T09:40:00.000000000
2022-06-05T02:20:00.000000000
2022-06-05T19:00:00.000000000
2022-06-06T11:40:00.000000000
2022-06-07T04:20:00.000000000
2022-06-07T21:00:00.000000000
2022-06-08T13:40:00.000000000
2022-06-09T06:20:00.000000000
They're taken from ax.get_xticklabels()
since I want to format xticklabels()
.
I want the following format: e.g. 2022-06-09 17:00
.
Now, I could use the following trick loop over each and tick.get_text()[:16].replace('T', ' ')
which gives me:
2022-06-03 17:00
2022-06-04 09:40
2022-06-05 02:20
2022-06-05 19:00
2022-06-06 11:40
2022-06-07 04:20
2022-06-07 21:00
2022-06-08 13:40
2022-06-09 06:20
But is there another, cleaner, simpler, way?