Question: I have the following data frame in Julia. 

```
using DataFrames 
data = DataFrame(Value = [23, 56, 10, 48, 51], Type = ["A", "B", "A", "B", "B"])

5×2 DataFrame
│ Row │ Value │ Type   │
│     │ Int64 │ String │
├─────┼───────┼────────┤
│ 1   │ 23    │ A      │
│ 2   │ 56    │ B      │
│ 3   │ 10    │ A      │
│ 4   │ 48    │ B      │
│ 5   │ 51    │ B      │

```

How to get the mean of the column **Value** based on the column **Type**?

Answer: 
A more succinct way of writing this would be:

```
julia> by(data, :Type, :Value => mean)
2×2 DataFrame
│ Row │ Type   │ Value_mean │
│     │ String │ Float64    │
├─────┼────────┼────────────┤
│ 1   │ A      │ 16.5       │
│ 2   │ B      │ 51.6667    │

```

Note that if grouping by one variable, it is not necessary to pass an array as the second argument. Also, the function(s) to apply can be passed directly as a `Pair` of column name and function to apply. This can be extended to additional functions as well: 

```
julia> by(data, :Type, :Value => mean, :Value => median)
2×3 DataFrame
│ Row │ Type   │ Value_mean │ Value_median │
│     │ String │ Float64    │ Float64      │
├─────┼────────┼────────────┼──────────────┤
│ 1   │ A      │ 16.5       │ 16.5         │
│ 2   │ B      │ 51.6667    │ 51.0         │

```

This will create new columns which automatically append the function name to the column that is being grouped. These default names can be overwritten by passing a new column name like so:

```
julia> by(data, :Type, my_new_column = :Value => mean)
2×2 DataFrame
│ Row │ Type   │ my_new_column │
│     │ String │ Float64       │
├─────┼────────┼───────────────┤
│ 1   │ A      │ 16.5          │
│ 2   │ B      │ 51.6667       │

```
Using the function `by()` will group the rows of the column and then applying the function `mean()` (from `Statistics`) will result in a single value for each **Type**: the mean of the **Type** **A** and of the **Type** **B**.

```
using DataFrames
using Statistics
data = DataFrame(Value = [23, 56, 10, 48, 51], Type = ["A", "B", "A", "B", "B"]);
by(data, [:Type], df -> mean(df[:, :Value]))

2×2 DataFrame
│ Row │ Type   │ x1      │
│     │ String │ Float64 │
├─────┼────────┼─────────┤
│ 1   │ A      │ 16.5    │
│ 2   │ B      │ 51.6667 │

```

More information on data frames in Julia can be found here: <https://juliadata.github.io/DataFrames.jl/stable/man/getting_started/>