# Translation groupby and agg and join python to julia

**URL:** <https://discourse.julialang.org/t/translation-groupby-and-agg-and-join-python-to-julia/58835>\
**Category:** General Usage\
**Created:** [April 8, 2021, 2:02pm UTC](https://discourse.julialang.org/t/translation-groupby-and-agg-and-join-python-to-julia/58835 "2021-04-08T14:02:25Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [April 8, 2021, 2:54pm UTC](https://discourse.julialang.org/t/translation-groupby-and-agg-and-join-python-to-julia/58835/4 "2021-04-08T14:54:27Z")

</div>

Welcome to our community 🎊

I would recommend reading this [PSA](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757) for how to ask questions in this forum. It would be nice if you put triple backticks on your code and posted one or two CSVs instead of an image.

```julia
Nate;Text;Month
name1;hej;11
name1;du;11
name1;aj;12
name1;oj;12
name2;finn;11
name2;katt;11
name2;mycket;12
name2;lite;12

```

I believe that what you want is:

```julia
julia> using DataFrames
julia> using CSV
julia> df = DataFrame(CSV.File("data.csv"; delim = ';'))
8×3 DataFrame
 Row │ Nate Text Month 
     │ String String Int64 
─────┼───────────────────────
   1 │ name1 hej 11
   2 │ name1 du 11
   3 │ name1 aj 12
   4 │ name1 oj 12
   5 │ name2 finn 11
   6 │ name2 katt 11
   7 │ name2 mycket 12
   8 │ name2 lite 12

julia> gdf = groupby(df, [:Nate, :Month]) 
GroupedDataFrame with 4 groups based on keys: Nate, Month
First Group (2 rows): Nate = "name1", Month = 11
 Row │ Nate Text Month 
     │ String String Int64 
─────┼───────────────────────
   1 │ name1 hej 11
   2 │ name1 du 11
⋮
Last Group (2 rows): Nate = "name2", Month = 12
 Row │ Nate Text Month 
     │ String String Int64 
─────┼───────────────────────
   1 │ name2 mycket 12
   2 │ name2 lite 12

julia> cdf = combine(gdf, :Text => (xs -> join(xs, '!')))
4×3 DataFrame
 Row │ Nate Month Text_function 
     │ String Int64 String        
─────┼──────────────────────────────
   1 │ name1 11 hej!du
   2 │ name1 12 aj!oj
   3 │ name2 11 finn!katt
   4 │ name2 12 mycket!lite

```

You can already give the name of the new column if you add a `=> :NewColName` after the anonymous function.

---

_[View the full topic](https://discourse.julialang.org/t/translation-groupby-and-agg-and-join-python-to-julia/58835)._
