Hello
I am interested in Datascience and now i am using Julia for Data analysis with python.
I have a question,
How can we get the count of each categorical values in an array(dataframe subset) in Julia?
For. Eg.
we should get answer like this from a dataframe ‘df’,
julia> using DataFrames, StatsBase
julia> df = DataFrame(x = rand('a':'d', 100));
julia> countmap(df.x)
Dict{Char, Int64} with 4 entries:
'c' => 23
'a' => 25
'd' => 25
'b' => 27
julia> combine(groupby(df, :x), nrow => :count)
4×2 DataFrame
Row │ x count
│ Char Int64
─────┼─────────────
1 │ c 23
2 │ a 25
3 │ b 27
4 │ d 25
The first is a generic way which works everywhere and for all vectors but requires a different package, while the second is DataFrames specific and only uses the functionality already available in DataFrames.