Expand description
List, array and struct cells as JSON text, for the destinations that hold
one value per field: a CSV export and every clipboard copy. JSON rather than
the table’s own rendering ([1, 2], {1,"a"}) because it keeps struct field
names and reads back with any JSON parser, Polars’ str.json_decode included.
The text is Polars’ own JSON writer, the one NDJSON export uses, so a list
reads the same in a CSV as in a .jsonl written from the same view.
Binary has no JSON or CSV form, and Polars’ JSON writer panics on it, so it is written as standard base64 text wherever it sits: a CSV, JSON or NDJSON export and a copy all spell the same bytes the same way.
Polars’ writers also panic on a date or datetime past the calendar’s range
(a sentinel like i64::MIN + 1 microseconds), so dates and millisecond and
microsecond datetimes are given to them as the text they would write, and
such a value as its stored number, as the table shows it. A nanosecond
count is always a date and goes to the writers as it is.
A duration has no CSV form either, and is written as the JSON writer spells
it: ISO 8601 in seconds (PT3723.004S, -PT1.5S, P0D). That is exact to
the nanosecond in every unit, and reads the same alone in a CSV cell or a
copy, inside a list, and in a JSON export.
Enums§
- Writer
- The writer whose text for a date or datetime
calendar_as_textwrites.
Functions§
- calendar_
as_ text - A date or datetime column as the text
writerwrites for it, with its nulls; a value past the calendar’s range, on which the writers panic, as its stored number (crate::exact::out_of_range), as the table shows it. - column_
as_ json - One nested column as a String column of JSON, null where the value is null.
- duration_
as_ iso - A duration column as a String column of
duration_isotext, with its nulls. - duration_
iso valueunits as ISO 8601 text, the way Polars’ JSON writer spells a duration (chrono’sTimeDeltadisplay): whole seconds and the fraction’s significant digits,P0Dfor zero, a leading-when negative. Computed here rather than through chrono, whose range ends short ofi64::MINms.- frame_
as_ cells frame_as_jsonwith dates and datetimes kept in their own type: the cells a Markdown or HTML copy writes throughcrate::exact::value_text, which spells one past the calendar as its stored number itself.- frame_
as_ json lazy_as_jsonfor frames already in memory: a copy’s rows, as the CSV writer takes them.- has_
binary - Whether
dtypeis binary or has binary anywhere inside. - is_
nested - Whether a column is a list, array or struct, which a delimited writer takes only as JSON text.
- lazy_
as_ json lfwith every column a CSV writer cannot take (needs_text) replaced by its text, in place and under its own name: what a CSV export writes. Planned, not run: the text is built as the rows are collected.- lazy_
for_ json lfwith every column that has binary, a date or a datetime in it as text (leaves_as_json_text), in place and under its own name: what a JSON export writes. Planned, not run.- leaves_
as_ json_ text serieswith every binary value, at any depth, as its base64 text, and every date and datetime as the JSON writer’s text (calendar_as_text). Lists, arrays and structs keep their shape and their nulls.- needs_
text - Whether a column needs to become text before a CSV writer takes it: it is nested, binary, a duration, or a date or datetime in ms or us, which the writer can panic on.