# How to get a quick description of a vector/matrix like \`pd.DataFrame.describe\`

**URL:** https://discourse.julialang.org/t/how-to-get-a-quick-description-of-a-vector-matrix-like-pd-dataframe-describe/78013
**Category:** General Usage
**Tags:** question
**Created:** [March 17, 2022, 8:36am UTC](https://discourse.julialang.org/t/how-to-get-a-quick-description-of-a-vector-matrix-like-pd-dataframe-describe/78013 "2022-03-17T08:36:10Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![this\_josh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/this_josh/32/42679_2.png) [@this\_josh](https://discourse.julialang.org/u/this_josh)
#### Post date: [March 17, 2022, 8:36am UTC](https://discourse.julialang.org/t/how-to-get-a-quick-description-of-a-vector-matrix-like-pd-dataframe-describe/78013/1 "2022-03-17T08:36:10Z")

</div>

When in python pandas I find [`pd.DataFrame.describe`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.describe.html) a helpful tool to get some quick insight about my DataFrame, particularly when using large DataFrames in the REPL. It works as follows, from the linked docs:

```python
>>> s = pd.Series([1, 2, 3])
>>> s.describe()
count 3.0
mean 2.0
std 1.0
min 1.0
25% 1.5
50% 2.0
75% 2.5
max 3.0
dtype: float64

```

Is there anything similar in Julia?

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [March 17, 2022, 8:54am UTC](https://discourse.julialang.org/t/how-to-get-a-quick-description-of-a-vector-matrix-like-pd-dataframe-describe/78013/2 "2022-03-17T08:54:25Z")

</div>

Yes:

```julia
julia> df = DataFrame(x1 = rand('a':'z', 50), x2 = rand(50), x3 = rand(Int, 50));

julia> describe(df)
3×7 DataFrame
 Row │ variable mean min median max nmissing eltype
     │ Symbol Union… Any Union… Any Int64 DataType
─────┼───────────────────────────────────────────────────────────────────────────────────────────────────
   1 │ x1 b z 0 Char
   2 │ x2 0.557368 0.0171211 0.61268 0.980724 0 Float64
   3 │ x3 -8.54368e17 -9192866872846841147 -1.90444e18 8714825590927121417 0 Int64

```

you can also pass extra arguments to customize which metrics are calculated:

```julia
julia> describe(df, :q75, :nunique, :first, :last)
3×5 DataFrame
 Row │ variable q75 nunique first last
     │ Symbol Union… Union… Any Any
─────┼────────────────────────────────────────────────────────────────────────
   1 │ x1 22 k d
   2 │ x2 0.766689 0.795076 0.252337
   3 │ x3 3.48812e18 3819380600561978128 913260025103986027

```

(allowed arguments are `:mean, :std, :min, :q25, :median, :q75, :max, :nunique, :nmissing, :first, :last, :eltype`)

---

<div class="post-metadata">

### Author: ![this\_josh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/this_josh/32/42679_2.png) [@this\_josh](https://discourse.julialang.org/u/this_josh)
#### Post date: [March 17, 2022, 9:14am UTC](https://discourse.julialang.org/t/how-to-get-a-quick-description-of-a-vector-matrix-like-pd-dataframe-describe/78013/3 "2022-03-17T09:14:37Z")

</div>

When I used Python I mainly used pandas, but for my Julia work I tend to use Vectors and Matrices. It’s good to know that `DataFrames.jl` has that functionality, and it’s clearly a valid answer. Interestingly this method does accept vectors, but not matrices

```nohighlight
julia> describe(ones(10))
Summary Stats:
Length: 10
Missing Count: 0
Mean: 1.000000
Minimum: 1.000000
1st Quartile: 1.000000
Median: 1.000000
3rd Quartile: 1.000000
Maximum: 1.000000
Type: Float64

julia> describe(ones(10,10))
ERROR: MethodError: no method matching quantile!(::Matrix{Float64}, ::Vector{Float64}; sorted=false, alpha=1.0, beta=1.0)...

```

It seems that StatsBase.jl is implementing the describe and tries to work out quantiles over the entire matrix which it doesn’t have a method for. One solution is:

```nohighlight
julia> describe(ones(10,10)[:])
Summary Stats:
Length: 100
Missing Count: 0
Mean: 1.000000
Minimum: 1.000000
1st Quartile: 1.000000
Median: 1.000000
3rd Quartile: 1.000000
Maximum: 1.000000
Type: Float64

```

But it would probably be best for describe to have a `dims` argument so it can work row/column wise. Unless you know of this functionality elsewhere I might open a ticket with StatsBase

---

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [March 17, 2022, 9:17am UTC](https://discourse.julialang.org/t/how-to-get-a-quick-description-of-a-vector-matrix-like-pd-dataframe-describe/78013/4 "2022-03-17T09:17:31Z")

</div>

If you want a summary of each column, you could perhaps broadcast the `describe` function

```julia
describe.(eachcol(ones(10,10)))

```

---

<div class="post-metadata">

### Author: ![this\_josh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/this_josh/32/42679_2.png) [@this\_josh](https://discourse.julialang.org/u/this_josh)
#### Post date: [March 17, 2022, 9:28am UTC](https://discourse.julialang.org/t/how-to-get-a-quick-description-of-a-vector-matrix-like-pd-dataframe-describe/78013/5 "2022-03-17T09:28:55Z")

</div>

This does give the correct information but the output is quite ugly as it’s 10x Vector description. It’d be better if the description could maintain the matrices columns, as it would with `pandas.DataFrame.describe` and the simple `describe(ones(10,10))` syntax.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [March 17, 2022, 10:43am UTC](https://discourse.julialang.org/t/how-to-get-a-quick-description-of-a-vector-matrix-like-pd-dataframe-describe/78013/6 "2022-03-17T10:43:12Z")

</div>

You could just do

```julia
describe(DataFrame(mymatrix, :auto; copycols = false))

```

or even define that method lcoally for `describe(x::AbstractMatrix)` locally if you want to save on keystrokes.

---

<div class="post-metadata">

### Author: ![this\_josh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/this_josh/32/42679_2.png) [@this\_josh](https://discourse.julialang.org/u/this_josh)
#### Post date: [March 17, 2022, 10:57am UTC](https://discourse.julialang.org/t/how-to-get-a-quick-description-of-a-vector-matrix-like-pd-dataframe-describe/78013/7 "2022-03-17T10:57:08Z")

</div>

True, but I intend on doing this a lot, so I’d rather not have to keep creating DataFrames and saving the keystrokes would be preferred. As you suggest, to implement it would be rather trivial, if I get time I think I’ll make a PR for this of StatsBase. Thanks for your help
