Julia group name and amount calculation

I'm new to Julia and have a simple question. I have a csv file with the following structures: [Category, Name, Account]. I have 2 things that I want to create.

1, i want to create a function in julia that groupBy categories and add counters (name is ignored). So the output will be [Name, Count]. Then I will create a chart bar by setting x = Name and y = Count

2, I want to create multiple plots for each category, with each name plotted on separate line plots. So, an iterative charting process?

I think I have a plot, but I'm not sure how to make the groupBy process. Any help / re-guidance to the tutorials would be greatly appreciated.

Sample of my data:



the function I'm currently working on:

function wordcount(text,opinion,number)
words= text
counts= Dict()
  for w = words
    counts[w]= number
return counts

function wcreduce(wcs)
  for c in wcs, (k,v) in c
    counts[k] = get(counts,k,0)+v
return counts


I'm looking for a function like reduceByKey or GroupByKey I think.


source to share

1 answer

So I solved it using Julia's DataFrames feature,

First load the csv data using:

data = readtable("iris.csv")


Now its function:

function trendingkeys(data::DataFrame,trends::Symbol,funcadd::Function)
  by(data, :trends, funcadd -> sum(funcadd[:counts]))


I have to say. DataFrame is so smart.



All Articles