Julia Dataframes Countmap()

Edit: countmap() is in StatsBase.jl and is working as expected. I'm not sure how to change this to an answered problem or if I should I delete it.

using DataFrames
using CSV

train = DataFrame(CSV.File("training.csv"))
countmap(train.column)



UndefVarError: countmap not defined

Stacktrace:
 [1] top-level scope
   @ In[40]:1
 [2] eval
   @ .\boot.jl:360 [inlined]
 [3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base .\loading.jl:1094

I get that error running the code. Was countmap deprecated at some point and I just cannot find any updates about it or am I missing something?

0

2 Answers

Are you looking for countmap from the StatsBase.jl package?

You can use the following pattern to get a DataFrame instead of a Dict as a result:

combine(groupby(train, :column), nrow)

(in many cases it will be much faster than countmap)

Also instead of:

DataFrame(CSV.File("training.csv"))

it is more efficient to write:

CSV.read("training.csv", DataFrame)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest