Hello There,
I am just wondering what is the best way to add a new Categorical/String column to existing dataframe based on a continuous value column?
‘using DataFrames
df = DataFrame(Types = [“SUV”, “SUV”,“SUV”, “SUV”, “sedan”,“sedan”], models=[“Q3”,“Q5”, “Kluger”, “Land Cruiser”, “Corolla”, “F40”], acceleration = [11,8, 8, 19, 5.5,3.3,])’
6×3 DataFrame
Row │ Types models acceleration
│ String String Float64
─────┼────────────────────────────────────
1 │ SUV Q3 11.0
2 │ SUV Q5 8.0
3 │ SUV Kluger 8.0
4 │ SUV Land Cruiser 19.0
5 │ sedan Corolla 5.5
6 │ sedan F40 3.3
Want:
Acceleration less than 6: “Fast”
Acceleration greater than 10 “Slow”
else “Normal”
sorry, i know this is most basic, and in Python, i would have used .apply of a custom function. I did a 20 min search on Goggle but couldn’t find anything.
Thanks!