Jun-20-2018, 01:11 PM
Hi all,
I'm hoping to eventually reformat a series of time values so that they are all in military time. I'm still a few steps away from that, but I'm having trouble with one of the first steps, which is to get rid of the 'AM' or 'PM' value.
I'm hoping to eventually reformat a series of time values so that they are all in military time. I'm still a few steps away from that, but I'm having trouble with one of the first steps, which is to get rid of the 'AM' or 'PM' value.
import pandas as pd s = pd.Series(['12:34 AM', '12:57 PM', '14:53', '19:00', '6:33 PM'], index = [1, 2, 3, 4, 5]) for i in s: if i[-3:] == ' PM': i = i.rstrip(' PM') sI expect to find the 'PM values gone, but when I print my series, they are still there. Hoping to figure out what it is that I'm missing. Thank you.
Output:1 12:34 AM
2 12:57 PM
3 14:53
4 19:00
5 6:33 PM
dtype: object