On this page:
show
introspect
sawzall-show-formatter

2 Displaying data🔗ℹ

These functions display data to the screen, for use in interactive data analysis. For saving data, see df-write/csv et al.

The following example is used in this section:
> (define anscombe
    (row-df [x1 x2 x3 x4 y1    y2   y3    y4]
            10  10 10 8  8.04  9.14 7.46  6.58
            8   8  8  8  6.95  8.14 6.77  5.76
            13  13 13 8  7.58  8.74 12.74 7.71
            9   9  9  8  8.81  8.77 7.11  8.84
            11  11 11 8  8.33  9.26 7.81  8.47
            14  14 14 8  9.96  8.11 8.84  7.04
            6   6  6  8  7.24  6.13 6.08  5.25
            4   4  4  19 4.26  3.11 5.39  12.5
            12  12 12 8  10.84 9.13 8.15  5.56
            7   7  7  8  4.82  7.26 6.42  7.91
            5   5  5  8  5.68  4.74 5.73  6.89))

syntax

(show df maybe-slice-spec maybe-n-rows)

 
maybe-slice-spec = 
  | slice-spec
     
maybe-n-rows = 
  | #:n-rows n-rows
 
  df : (or/c data-frame? grouped-data-frame?)
  n-rows : (or/c exact-nonnegative-integer? 'all)
Displays a data-frame df, alongside with grouping information (if it exists). Designed solely for interactive use. Also see df-describe, which presents summary statistics about a given data-frame.

By default, six rows and six columns are shown (along with the names of each column), and the rest are elided. The columns shown are an in an unspecified order (as is df-series-names). If not all columns or rows are shown in the output, information will be shown about the missing ones.

Optionally, a slice spec maybe-slice-spec (see Slicing) is taken. If a slice-spec that is deterministic (does not use everything or a nondeterministic sequence) is given, the output column order and presence will be deterministic.

Optionally, a number of rows n-rows to display is taken. This is either an integer or the symbol 'all, in which case all rows are shown.

Examples:
> (show anscombe)

data-frame: 11 rows x 8 columns

┌──┬─────┬────┬──┬──┬────┐

│x1│y3   │y1  │x4│x2│y4  

├──┼─────┼────┼──┼──┼────┤

│10│7.46 │8.04│8 │10│6.58│

├──┼─────┼────┼──┼──┼────┤

│8 │6.77 │6.95│8 │8 │5.76│

├──┼─────┼────┼──┼──┼────┤

│13│12.74│7.58│8 │13│7.71│

├──┼─────┼────┼──┼──┼────┤

│9 │7.11 │8.81│8 │9 │8.84│

├──┼─────┼────┼──┼──┼────┤

│11│7.81 │8.33│8 │11│8.47│

├──┼─────┼────┼──┼──┼────┤

│14│8.84 │9.96│8 │14│7.04│

└──┴─────┴────┴──┴──┴────┘

5 rows, 2 cols elided

(use (show df everything #:n-rows 'all) for full frame)

> (show anscombe #:n-rows 'all)

data-frame: 11 rows x 8 columns

┌──┬─────┬─────┬──┬──┬────┐

│x1│y3   │y1   │x4│x2│y4  

├──┼─────┼─────┼──┼──┼────┤

│10│7.46 │8.04 │8 │10│6.58│

├──┼─────┼─────┼──┼──┼────┤

│8 │6.77 │6.95 │8 │8 │5.76│

├──┼─────┼─────┼──┼──┼────┤

│13│12.74│7.58 │8 │13│7.71│

├──┼─────┼─────┼──┼──┼────┤

│9 │7.11 │8.81 │8 │9 │8.84│

├──┼─────┼─────┼──┼──┼────┤

│11│7.81 │8.33 │8 │11│8.47│

├──┼─────┼─────┼──┼──┼────┤

│14│8.84 │9.96 │8 │14│7.04│

├──┼─────┼─────┼──┼──┼────┤

│6 │6.08 │7.24 │8 │6 │5.25│

├──┼─────┼─────┼──┼──┼────┤

│4 │5.39 │4.26 │19│4 │12.5│

├──┼─────┼─────┼──┼──┼────┤

│12│8.15 │10.84│8 │12│5.56│

├──┼─────┼─────┼──┼──┼────┤

│7 │6.42 │4.82 │8 │7 │7.91│

├──┼─────┼─────┼──┼──┼────┤

│5 │5.73 │5.68 │8 │5 │6.89│

└──┴─────┴─────┴──┴──┴────┘

> (show anscombe everything)

data-frame: 11 rows x 8 columns

┌──┬─────┬────┬──┬──┬────┬────┬──┐

│x1│y3   │y1  │x4│x2│y4  │y2  │x3│

├──┼─────┼────┼──┼──┼────┼────┼──┤

│10│7.46 │8.04│8 │10│6.58│9.14│10│

├──┼─────┼────┼──┼──┼────┼────┼──┤

│8 │6.77 │6.95│8 │8 │5.76│8.14│8 │

├──┼─────┼────┼──┼──┼────┼────┼──┤

│13│12.74│7.58│8 │13│7.71│8.74│13│

├──┼─────┼────┼──┼──┼────┼────┼──┤

│9 │7.11 │8.81│8 │9 │8.84│8.77│9 │

├──┼─────┼────┼──┼──┼────┼────┼──┤

│11│7.81 │8.33│8 │11│8.47│9.26│11│

├──┼─────┼────┼──┼──┼────┼────┼──┤

│14│8.84 │9.96│8 │14│7.04│8.11│14│

└──┴─────┴────┴──┴──┴────┴────┴──┘

5 rows, 0 cols elided

(use (show df everything #:n-rows 'all) for full frame)

> (show anscombe ["x1" "y2" "y4"])

data-frame: 11 rows x 8 columns

┌──┬────┬────┐

│x1│y2  │y4  

├──┼────┼────┤

│10│9.14│6.58│

├──┼────┼────┤

│8 │8.14│5.76│

├──┼────┼────┤

│13│8.74│7.71│

├──┼────┼────┤

│9 │8.77│8.84│

├──┼────┼────┤

│11│9.26│8.47│

├──┼────┼────┤

│14│8.11│7.04│

└──┴────┴────┘

5 rows, 5 cols elided

(use (show df everything #:n-rows 'all) for full frame)

syntax

(introspect df maybe-slice-spec maybe-n-rows)

Like show, but returns its input. Useful for looking at the intermediate frame in a ~> chain, and then continuing processing.

parameter

(sawzall-show-formatter)  (-> any/c string?)

(sawzall-show-formatter formatter)  void?
  formatter : (-> any/c string?)
 = ~a
Controls the behavior of show and introspect by determining how to format each element.

For the purposes of this documentation (largely for Unnesting), this is
(λ (x)
  (if (vector? x)
      "#<vector>"
      (~a x
          #:max-width 15
          #:limit-marker "...")))

Example:
> (parameterize ([sawzall-show-formatter
                  (λ (x) (if (number? x) "#<number>" (~a x)))])
    (show example-df))

data-frame: 5 rows x 4 columns

┌───┬───┬─────────┬─────────┐

│grp│trt│adult    │juv      

├───┼───┼─────────┼─────────┤

│a  │b  │#<number>│#<number>│

├───┼───┼─────────┼─────────┤

│a  │b  │#<number>│#<number>│

├───┼───┼─────────┼─────────┤

│b  │a  │#<number>│#<number>│

├───┼───┼─────────┼─────────┤

│b  │b  │#<number>│#<number>│

├───┼───┼─────────┼─────────┤

│b  │b  │#<number>│#<number>│

└───┴───┴─────────┴─────────┘