Help with transforming dates on pandas

Hi eveyrone

I’m working on a personal project and i have dates like this 29-06-2019 24:00 when i use pandas to transform it to a datetime type i got an error because pandas only goes until 23:00, 24:00 is actually 00:00 and it makes sense

So i have two questions here:

  1. How can i transform it?
  2. How can i transform that date into for example 29-06-23:00? I tried to replace every ‘-’ for a space and then apply df.col.str.split(' ') and that gave me a list of values, then i tried to iterate over every list and create a column with the date as i wanted but in the end all i got was the same value over and over

In case anyone needs the file that i’m using to understand more here it is Carvajal-Sevillana.xlsx (254.3 KB)
Thanks for your help

What about applying replace method?

It applies a vectorized method into a Series object.
You can use:
df[columns].str.replace(‘24:00’, ‘00:00’)

Thanks! @gabriel.belle

1 Like