This is Python code to bin data into bins with a numerical label:
pd.cut(housing["median_income"], bins=[0., 1.5, 3.0, 4.5, 6., np.inf], labels=[1, 2, 3, 4, 5])
I want to do this in Julia, but it seems that Julia’s cut() function only allows for string labels:
cut(housingDF[:,:median_income], [0., 1.5, 3.0, 4.5, 6., 100.], labels=[1, 2, 3, 4, 5])
ERROR: TypeError: in keyword argument labels, expected Union{Function, AbstractVector{var"#s54"} where var"#s54"<:AbstractString}, got a value of type Vector{Int64}
It works with string labels though:
cut(housingDF[:,:median_income], [0., 1.5, 3.0, 4.5, 6., 100.], labels=["1", "2", "3", "4", "5"])
How can I get a numerical label for a data bin in Julia?