How to hide the types line when pretty printing a data frame

I’m sure this was mentioned before, I just can’t find it in PrettyTables.jl’s documentation nor here on Discourse. How can I hide the row indicating the columns’ types when printing a DataFrame?

julia> using DataFrames, PrettyTables

julia> n = 5
5

julia> df = DataFrame(x = rand(n), y = rand(Int, n))
5×2 DataFrame
│ Row │ x        │ y                    │
│     │ Float64  │ Int64                │
├─────┼──────────┼──────────────────────┤
│ 1   │ 0.719891 │ -5232346815017973625 │
│ 2   │ 0.205348 │ 2842626681257293791  │
│ 3   │ 0.060852 │ -2140500196739737047 │
│ 4   │ 0.897562 │ -1243809382461516784 │
│ 5   │ 0.502659 │ -8876359708955921854 │

julia> pretty_table(df)
┌──────────────────────┬────────────────────────┐
│                    x │                      y │
│              Float64 │                  Int64 │ # ← hide this row
├──────────────────────┼────────────────────────┤
│   0.7198907881907508 │  -5.232346815017974e18 │
│  0.20534849384840537 │   2.842626681257294e18 │
│ 0.060852015344203814 │  -2.140500196739737e18 │
│   0.8975619167730042 │ -1.2438093824615168e18 │
│   0.5026589809343593 │  -8.876359708955921e18 │
└──────────────────────┴────────────────────────┘

Is this what you want? If so, it’s in the documentation under Keywords:

julia> pretty_table(df, nosubheader=true)
┌─────────────────────┬───────────────────────┐
│                   x │                     y │
├─────────────────────┼───────────────────────┤
│  0.5368664265830216 │ -7.331895038144373e18 │
│  0.7266492236216804 │  2.529146168444223e18 │
│  0.2339360650833009 │ -9.159461584161755e18 │
│  0.4645563509191173 │  6.820674934457448e18 │
│ 0.25767054251840427 │ -7.139914099109241e18 │
└─────────────────────┴───────────────────────┘
3 Likes

Thanks. I didn’t even try

help?> pretty_table

just looked at the hosted documents. But of course, it’s there too… Thanks!

All kwargs are also accepted by show:

julia> show(DataFrame(rand(2,3), :auto), nosubheader=true)
2×3 DataFrame
 Row │ x1        x2        x3
─────┼──────────────────────────────
   1 │ 0.812423  0.815418  0.161294
   2 │ 0.834394  0.977342  0.327513
3 Likes

nosubheader was apparently deprecated Keyword arguments: change `noheader=true` -> `header=false` ? · Issue #160 · ronisbr/PrettyTables.jl · GitHub and replaced with show_subheader but I can’t find that replacement in the dev docs Search · Pretty Tables.

I have just copy-pasted the above.

Probably @Ronis_BR can guide us to a definite reference of currently supported kwargs.

BTW, why does show take the pretty_table kwargs?

show uses pretty_table under the hood, so it makes sense to forward the keyword arguments.

2 Likes

Hi @jar1 !

You can find the documentation about show_subheader here:

https://ronisbr.github.io/PrettyTables.jl/dev/man/usage/

Btw, I just realized that the docs ate wrong :slight_smile: I will fix it.

4 Likes