Print all columns of a dataframe

dataframes

#1

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
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 │

#3

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.


#4

An MWE would help clarify this.


#5
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.


#6

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 │

#7

that’s great, thanks!


#8

Maybe this is a bug?