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?
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 │
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 │
that’s great, thanks!
Maybe this is a bug?
In case someone ends up here first:
Getting Started · DataFrames.jl says
You can override this behavior by changing the values of the
ENV["COLUMNS"]
andENV["LINES"]
variables to hold the maximum width and height of output in characters respectively.
The correct way now seems to be:
show(df, allcols=true)
Just to add, one mightt want something like
show(first(df,5), allcols=true)
TerminalPager.jl is also really helpful here.