Home > Blockchain >  Parse HHMMSS.nano correctly in Dataframe
Parse HHMMSS.nano correctly in Dataframe

Time:07-29

Time right
1 122241.000000 Three
2 122242.003906 Three
3 122243.001532 Three
4 122244.008520 Three

I would like to convert the time using datetime, given that the actual format is HHMMSS.nano

for example I tried :

datetime.strptime('122241.082031','%H%M%S.%f').time()

output :

datetime.time(12, 22, 41, 82031)

In order to get the correct time but now how am I supposed to display this correct time into the dataframe column ?

CodePudding user response:

is that what you're looking for?

df['tm']=pd.to_datetime(df['Time'], unit='m').dt.time
df
    Time            right   tm
1   122241.000000   Three   21:21:00
2   122242.003906   Three   21:22:00.234360
3   122243.001532   Three   21:23:00.091920
4   122244.008520   Three   21:24:00.511200
  • Related