Print all columns of a dataframe

The latest version of the DataFrames package omits columns that don’t fit the screen when printing. Is there a way to print all columns of a dataframe? Can this be made the default behavior on a given user’s system?

2 Likes
julia> df = DataFrame((Symbol('a' + i) => [i] for i in 0:25)...)
1×26 DataFrames.DataFrame. Omitted printing of 6 columns
│ Row │ a │ b │ c │ d │ e │ f │ g │ h │ i │ j │ k  │ l  │ m  │ n  │ o  │ p  │ q  │ r  │ s  │ t  │
├─────┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
│ 1   │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12 │ 13 │ 14 │ 15 │ 16 │ 17 │ 18 │ 19 │

julia> showall(df)
1×26 DataFrames.DataFrame
│ Row │ a │ b │ c │ d │ e │ f │ g │ h │ i │ j │ k  │ l  │ m  │ n  │ o  │ p  │ q  │ r  │ s  │ t  │ u  │ v  │ w  │ x  │ y  │ z  │
├─────┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
│ 1   │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12 │ 13 │ 14 │ 15 │ 16 │ 17 │ 18 │ 19 │ 20 │ 21 │ 22 │ 23 │ 24 │ 25 │
2 Likes

Thanks I didn’t know about this function. Unfortunately, however, the formatting is not very nice when using showall, the printout becomes unreadable with dataframes with many rows (I also tried showall(head(df)) to limit the number of rows but the columns seem all misaligned). The previous (before v0.11) DataFrames version had a much nicer formatting that showed all columns by default.

An MWE would help clarify this.

df = DataFrame((Symbol('a' + i) => rand(10) for i in 0:100)...)
showall(df)

The old dataframe behavior was to print n rows of all the columns that fit the screen and then print n rows of the remaining columns. showall prints a row with ‘carriage return’ for all columns, then another row for all columns etc…, which becomes difficult to read.

I see. Looking at the source code, you can get back the old behavior with

julia> show(df, true)
1×26 DataFrames.DataFrame
│ Row │ a │ b │ c │ d │ e │ f │ g │ h │ i │ j │ k  │ l  │ m  │ n  │ o  │ p  │ q  │ r  │ s  │ t  │
├─────┼───┼───┼───┼───┼───┼───┼───┼───┼───┼───┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
│ 1   │ 0 │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10 │ 11 │ 12 │ 13 │ 14 │ 15 │ 16 │ 17 │ 18 │ 19 │

│ Row │ u  │ v  │ w  │ x  │ y  │ z  │
├─────┼────┼────┼────┼────┼────┼────┤
│ 1   │ 20 │ 21 │ 22 │ 23 │ 24 │ 25 │
5 Likes

that’s great, thanks!

Maybe this is a bug?

In case someone ends up here first:

https://juliadata.github.io/DataFrames.jl/stable/man/getting_started/ says

You can override this behavior by changing the values of the ENV["COLUMNS"] and ENV["LINES"] variables to hold the maximum width and height of output in characters respectively.

5 Likes

The correct way now seems to be:

show(df, allcols=true)
1 Like