You can use StatsBase.jl ranking functions to generate proper ranking column. For example
using DataFrames
using StatsBase
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,])
sort!(df, :acceleration)
gdf = groupby(df, :Types)
transform(gdf, :acceleration => (x -> competerank(x, rev = true)) => :rank)
# 6×4 DataFrame
# Row │ Types models acceleration rank
# │ String String Float64 Int64
# ─────┼───────────────────────────────────────────
# 1 │ sedan F40 3.3 2
# 2 │ sedan Corolla 5.5 1
# 3 │ SUV Q5 8.0 3
# 4 │ SUV Kluger 8.0 3
# 5 │ SUV Q3 11.0 2
# 6 │ SUV Land Cruiser 19.0 1
I’ve used competerank, but you can choose any other function, which suits your needs.