I have a column that represents minutes and seconds as 20:00, or 19:58.
import pandas as pd
d = {'clock': ['19:58', '20:00']}
df = pd.DataFrame(data=d)
I want to truly express this as an object in a pandas column that is minutes and seconds.
I have attempted to use pd.to_datetime(df.clock, format="%M:%S")
, and that doesn't error, but the a time of 20:00
(twenty minutes, zero seconds) parses as 1900-01-01 00:20:00
.
I am drawing a blank on how to retain just the minutes and seconds in the result so that I can look the time elapsed, in seconds, between records.
The trick?
I am looking at sporting data, and there are 3 periods in the game, each that count backwards from twenty minutes, so its not as if I can just append the game date and move on, as each time sequence can appear 3 times (or more).
question from:https://stackoverflow.com/questions/66055312/parse-mmss-from-a-string-column-in-pandas