0

I have dataset that the column is about duration time, e.g. 90 mins, 87, min, 107 mins, etc. What the best method to change this object type into integer type? so i know how to calculate the mean, mode, median, etc

1 Answers1

0

From your question I dont know if you have '90' or '90 min' inside your cell. If you have 90 min you first have to remove the string component 'min', then you have to convert the type of the column:

df['column_name'] = df['column_name'].apply(lambda x: x.replace(' min', ''))
df = df.astype({'column_name':'int'})
Giovanni Frison
  • 628
  • 3
  • 19
  • i have '90 min' each row. I have to split them first maybe. So i will have two columns. But i dont know how to remove 'min' – Handri Mauludin Maulana Feb 19 '21 at 09:52
  • 1
    here you go @HandriMauludinMaulana, but your question has been asked many times (as pointed out by admins), so next time try to spend more time searching for your solution – Giovanni Frison Feb 19 '21 at 09:57