I'm new to python and have been given a data set that has time stored in form X hr Y min. I would like to covert the data to an integer (minutes) to do further calculations.
I tried the following:
movies['Movie Runtime']=movies['Movie Runtime'].str.replace('hr','').str.replace('min','').str.replace(' ','').astype(object)
movies['Movie Runtime']=movies['Movie Runtime'].astype(int)
movies['Movie Runtime']=((movies['Movie Runtime']//100)*60) +((movies['Movie Runtime']%100))
However, it does not work for data given in form 5hr 3Min
source https://stackoverflow.com/questions/71197921/converting-xhr-y-min-to-minutes-to-do-further-calculations
Comments
Post a Comment