Skip to content

Suggested changes to the experience of dataframes being truncated #2246

@IanButterworth

Description

@IanButterworth

DataFrame show() truncations are highly logical for safe general use, but there are some occasions where it would be nice to be able to override the default show() truncations.

For instance

function runanalysis() #produces a dataframe that has results that you want to display on screen and return as an object
   df = DataFrame(...) 
   return df
end
julia> results = runanalysis()
26×3 DataFrames.DataFrame #the report display is truncated as necessary

Currently the user has to do an additional, and unobvious show command to print the entire report.

julia> show(results, allrows = true, allcols = true)

I see two ways to improve this experience:

  1. When DataFrames are truncated, provide a tip about show(results, allrows = true, allcols = true)
  2. Allow temporary overriding of the truncations from within the function that wants to return the object

Even if the function has determined that no limit is acceptable for that function's output, 2 may be unsafe if it wasn't temporary, because you can't predict what the user might also try to print in their session.

Therefore, I propose:

DataFrames.forcenextshowall()

which only sustains the override for the next show function.

For instance, in DataFrames:

const forceshowall = Ref{Bool}(false)
function forcenextshowall()
    forceshowall[] = true
end

Defaults in the show functions could be changed to

allrows::Bool = forceshowall[] || !get(io, :limit, false),
allcols::Bool = forceshowall[] || !get(io, :limit, false),

and at the end of the show methods they would simply always set

forceshowall[] = false

to reset the override.

cc. @bkamins given we were discussing it in slack

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions