tech.v3.dataset.print

dataset->str

(dataset->str ds options)(dataset->str ds)

Convert a dataset to a string. Prints a single line header and then calls dataset-data->str.

For options documentation see dataset-data->str.

dataset-data->str

(dataset-data->str dataset)(dataset-data->str dataset options)

Convert the dataset values to a string.

Options may be provided in the dataset metadata or may be provided as an options map. The options map overrides the dataset metadata.

  • :print-index-range - The set of indexes to print. If an integer then is interpreted according to :print-style. Defaults to the integer *default-table-row-print-length*.
  • :print-style - Defaults to :first-last. Options are #{:first-last :first :last}. In the case :print-index-range is an integer and the dataset has more than that number of rows prints the first N/2 and last N/2 rows or the first N or last N rows.
  • :print-line-policy - defaults to :repl - one of:
    • :repl - multiline table - default nice printing for repl
    • :markdown - lines delimited by
    • :single - Only print first line
  • :print-column-max-width - set the max width of a column when printing.
  • :print-column-types? - show/hide column types.
  • :maximum-precision - When provided, the maximum double precision as an integer.
  • :elide-header? - When true, the header such as test/data/alldtypes.arrow-feather-compressed [1000 15]: is hidden.

Examples of print styles:

user> (require '[tech.v3.dataset :as ds])
nil
user> (require '[tech.v3.libs.arrow :as arrow])
nil
user> (def ds (ds/->dataset "test/data/alldtypes.arrow-feather-compressed" {:file-type :arrow}))
08:26:03.156 [tech.resource.gc ref thread] INFO  tech.v3.resource.gc - Reference thread starting
#'user/ds

user> (vary-meta ds assoc :print-style :last :print-index-range 10)
test/data/alldtypes.arrow-feather-compressed [1000 15]:

| uints | longs | ubytes | strings | doubles | ushorts |  local_times | local_dates | ints |            instants | shorts | bytes | boolean | floats | text |
|------:|------:|-------:|---------|--------:|--------:|--------------|-------------|-----:|--------------------:|-------:|------:|---------|-------:|------|
|   990 |   990 |    222 |     990 |   990.0 |     990 | 13:39:59.923 |  2022-02-19 |  990 | 1645303199916000000 |    990 |   -34 |         |  990.0 |  990 |
|   991 |   991 |    223 |     991 |   991.0 |     991 | 13:39:59.923 |  2022-02-19 |  991 | 1645303199916000000 |    991 |   -33 |         |  991.0 |  991 |
|   992 |   992 |    224 |     992 |   992.0 |     992 | 13:39:59.923 |  2022-02-19 |  992 | 1645303199916000000 |    992 |   -32 |         |  992.0 |  992 |
|   993 |   993 |    225 |     993 |   993.0 |     993 | 13:39:59.923 |  2022-02-19 |  993 | 1645303199916000000 |    993 |   -31 |         |  993.0 |  993 |
|   994 |   994 |    226 |     994 |   994.0 |     994 | 13:39:59.923 |  2022-02-19 |  994 | 1645303199916000000 |    994 |   -30 |         |  994.0 |  994 |
|   995 |   995 |    227 |     995 |   995.0 |     995 | 13:39:59.923 |  2022-02-19 |  995 | 1645303199916000000 |    995 |   -29 |         |  995.0 |  995 |
|   996 |   996 |    228 |     996 |   996.0 |     996 | 13:39:59.923 |  2022-02-19 |  996 | 1645303199916000000 |    996 |   -28 |         |  996.0 |  996 |
|   997 |   997 |    229 |     997 |   997.0 |     997 | 13:39:59.923 |  2022-02-19 |  997 | 1645303199916000000 |    997 |   -27 |         |  997.0 |  997 |
|   998 |   998 |    230 |     998 |   998.0 |     998 | 13:39:59.923 |  2022-02-19 |  998 | 1645303199916000000 |    998 |   -26 |         |  998.0 |  998 |
|   999 |   999 |    231 |     999 |   999.0 |     999 | 13:39:59.923 |  2022-02-19 |  999 | 1645303199916000000 |    999 |   -25 |         |  999.0 |  999 |
user> (vary-meta ds assoc :print-style :first :print-index-range 10)
test/data/alldtypes.arrow-feather-compressed [1000 15]:

| uints | longs | ubytes | strings | doubles | ushorts |  local_times | local_dates | ints |            instants | shorts | bytes | boolean | floats | text |
|------:|------:|-------:|---------|--------:|--------:|--------------|-------------|-----:|--------------------:|-------:|------:|---------|-------:|------|
|     0 |     0 |      0 |       0 |     0.0 |       0 | 13:39:59.908 |  2022-02-19 |    0 | 1645303199909000000 |      0 |     0 |    true |    0.0 |    0 |
|     1 |     1 |      1 |       1 |     1.0 |       1 | 13:39:59.910 |  2022-02-19 |    1 | 1645303199911000000 |      1 |     1 |   false |    1.0 |    1 |
|     2 |     2 |      2 |       2 |     2.0 |       2 | 13:39:59.910 |  2022-02-19 |    2 | 1645303199911000000 |      2 |     2 |    true |    2.0 |    2 |
|     3 |     3 |      3 |       3 |     3.0 |       3 | 13:39:59.910 |  2022-02-19 |    3 | 1645303199911000000 |      3 |     3 |    true |    3.0 |    3 |
|     4 |     4 |      4 |       4 |     4.0 |       4 | 13:39:59.910 |  2022-02-19 |    4 | 1645303199911000000 |      4 |     4 |   false |    4.0 |    4 |
|     5 |     5 |      5 |       5 |     5.0 |       5 | 13:39:59.910 |  2022-02-19 |    5 | 1645303199911000000 |      5 |     5 |   false |    5.0 |    5 |
|     6 |     6 |      6 |       6 |     6.0 |       6 | 13:39:59.910 |  2022-02-19 |    6 | 1645303199911000000 |      6 |     6 |    true |    6.0 |    6 |
|     7 |     7 |      7 |       7 |     7.0 |       7 | 13:39:59.910 |  2022-02-19 |    7 | 1645303199911000000 |      7 |     7 |   false |    7.0 |    7 |
|     8 |     8 |      8 |       8 |     8.0 |       8 | 13:39:59.910 |  2022-02-19 |    8 | 1645303199911000000 |      8 |     8 |   false |    8.0 |    8 |
|     9 |     9 |      9 |       9 |     9.0 |       9 | 13:39:59.910 |  2022-02-19 |    9 | 1645303199911000000 |      9 |     9 |    true |    9.0 |    9 |

;; first-last is default with print-index-range of 20
user> (vary-meta ds assoc :print-style :first-last :print-index-range 10)
test/data/alldtypes.arrow-feather-compressed [1000 15]:

| uints | longs | ubytes | strings | doubles | ushorts |  local_times | local_dates | ints |            instants | shorts | bytes | boolean | floats | text |
|------:|------:|-------:|---------|--------:|--------:|--------------|-------------|-----:|--------------------:|-------:|------:|---------|-------:|------|
|     0 |     0 |      0 |       0 |     0.0 |       0 | 13:39:59.908 |  2022-02-19 |    0 | 1645303199909000000 |      0 |     0 |    true |    0.0 |    0 |
|     1 |     1 |      1 |       1 |     1.0 |       1 | 13:39:59.910 |  2022-02-19 |    1 | 1645303199911000000 |      1 |     1 |   false |    1.0 |    1 |
|     2 |     2 |      2 |       2 |     2.0 |       2 | 13:39:59.910 |  2022-02-19 |    2 | 1645303199911000000 |      2 |     2 |    true |    2.0 |    2 |
|     3 |     3 |      3 |       3 |     3.0 |       3 | 13:39:59.910 |  2022-02-19 |    3 | 1645303199911000000 |      3 |     3 |    true |    3.0 |    3 |
|     4 |     4 |      4 |       4 |     4.0 |       4 | 13:39:59.910 |  2022-02-19 |    4 | 1645303199911000000 |      4 |     4 |   false |    4.0 |    4 |
|   ... |   ... |    ... |     ... |     ... |     ... |          ... |         ... |  ... |                 ... |    ... |   ... |     ... |    ... |  ... |
|   994 |   994 |    226 |     994 |   994.0 |     994 | 13:39:59.923 |  2022-02-19 |  994 | 1645303199916000000 |    994 |   -30 |         |  994.0 |  994 |
|   995 |   995 |    227 |     995 |   995.0 |     995 | 13:39:59.923 |  2022-02-19 |  995 | 1645303199916000000 |    995 |   -29 |         |  995.0 |  995 |
|   996 |   996 |    228 |     996 |   996.0 |     996 | 13:39:59.923 |  2022-02-19 |  996 | 1645303199916000000 |    996 |   -28 |         |  996.0 |  996 |
|   997 |   997 |    229 |     997 |   997.0 |     997 | 13:39:59.923 |  2022-02-19 |  997 | 1645303199916000000 |    997 |   -27 |         |  997.0 |  997 |
|   998 |   998 |    230 |     998 |   998.0 |     998 | 13:39:59.923 |  2022-02-19 |  998 | 1645303199916000000 |    998 |   -26 |         |  998.0 |  998 |
|   999 |   999 |    231 |     999 |   999.0 |     999 | 13:39:59.923 |  2022-02-19 |  999 | 1645303199916000000 |    999 |   -25 |         |  999.0 |  999 |

Example of conservative printing:

tech.ml.dataset.github-test> (def ds (with-meta ds
                                       (assoc (meta ds)
                                              :print-column-max-width 25
                                              :print-line-policy :single)))

print-policy

(print-policy dataset line-policy)

Convenience function to vary printing behavior.

Defaults to :repl - one of:

  • :repl - multiline table - default nice printing for repl
  • :markdown - lines delimited by
  • :single - Only print first line

print-range

(print-range dataset index-range)

Convenience function to set the number of rows to print.

Defaults to (range default-table-row-print-length) - one of:

  • n - prints the first n rows
  • range - prints the rows at positions corresponding to the range
  • :all - prints all the rows in a dataset

print-types

(print-types dataset column-types)

Convenience function to show/hide column types

print-width

(print-width dataset column-width)

Convenience function to set the max width of a column when printing.