pub struct Profile {
pub name: Option<String>,
/* private fields */
}Expand description
A profile of rows. See the module docs.
Fields§
§name: Option<String>What was profiled (a file name), for the heading.
Implementations§
Source§impl Profile
impl Profile
Sourcepub fn from_json_lines(
reader: impl BufRead,
options: ProfileOptions,
) -> Result<Self, DataError>
pub fn from_json_lines( reader: impl BufRead, options: ProfileOptions, ) -> Result<Self, DataError>
A nested profile of JSON Lines from reader, streamed: a line that
is not JSON is counted and skipped (malformed),
while a read error or a line longer than
jsonl::MAX_LINE fails. See
JsonProfiler.
Source§impl Profile
impl Profile
Sourcepub fn from_source(
source: impl RowSource,
options: ProfileOptions,
) -> Result<Self, DataError>
pub fn from_source( source: impl RowSource, options: ProfileOptions, ) -> Result<Self, DataError>
Profile every row of source, stopping at the first that cannot be
read.
Sourcepub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
Name what was profiled, for the heading.
Sourcepub fn note(&mut self, note: impl Into<String>)
pub fn note(&mut self, note: impl Into<String>)
Add a note shown under the heading (rows cut to fit, keys seen late).
Sourcepub fn sample_size(&self) -> usize
pub fn sample_size(&self) -> usize
The rows the types, statistics and distributions describe.
Sourcepub fn sampled(&self) -> bool
pub fn sampled(&self) -> bool
Whether the sample is fewer rows than were read; for a nested
profile, whether any path kept fewer of its values than it had (then
sample_size is the most values a path keeps).
Sourcepub fn columns(&self) -> &[ColumnProfile]
pub fn columns(&self) -> &[ColumnProfile]
One entry per column, in order.
Sourcepub fn column(&self, name: &str) -> Option<&ColumnProfile>
pub fn column(&self, name: &str) -> Option<&ColumnProfile>
The column called name.
Sourcepub fn missing(&self) -> &MissingMap
pub fn missing(&self) -> &MissingMap
Where the nulls are.
Sourcepub fn is_nested(&self) -> bool
pub fn is_nested(&self) -> bool
Whether this is a nested profile of JSON paths (JsonProfiler):
its columns are paths, each with its presence and type mix.
Sourcepub fn paths(&self) -> Option<&PathSummary>
pub fn paths(&self) -> Option<&PathSummary>
A nested profile’s limits, and the paths past its cap; None for a
profile of rows.
Sourcepub fn malformed(&self) -> u64
pub fn malformed(&self) -> u64
Lines skipped because they were not JSON (a nested profile only).
Sourcepub fn malformed_lines(&self) -> &[usize]
pub fn malformed_lines(&self) -> &[usize]
The first of them by line number (at most
MAX_MALFORMED_LINES).
Sourcepub fn style_rules(self, rules: StyleRules) -> Self
pub fn style_rules(self, rules: StyleRules) -> Self
Style the table of columns by value (rich_ext’s
table::rules). A rule names a heading
(table_headers) and compares the model’s
value, not the cell’s text: nulls, absent and distinct are
counts, mean a number, the rest text.
use rich::Console;
use rich_data::profile::Profile;
use rich_data::Rows;
use rich_ext::table::{StyleRule, StyleRules};
let mut rows = Rows::new(["a", "b"]);
rows.push(["1".into(), "".into()]);
let rules = StyleRules::new().rule(StyleRule::parse("nulls>0:row:bold red").unwrap());
let profile = Profile::of(&rows).style_rules(rules);
let console = Console::builder().width(60).force_terminal(true).build();
let out = console.render_export(&profile.to_table());
assert!(out.contains("\x1b[1;31mb"), "{out:?}");Sourcepub fn rules(&self) -> &StyleRules
pub fn rules(&self) -> &StyleRules
The style rules set with style_rules.
Sourcepub fn table_headers(&self) -> &'static [&'static str]
pub fn table_headers(&self) -> &'static [&'static str]
The headings of the table of columns, which style rules name:
column, type, nulls, distinct, min, max and mean; for
a nested profile path, types (the mix, null among them),
absent, distinct, min, max and mean.
Sourcepub fn to_json(&self) -> Value
pub fn to_json(&self) -> Value
The profile as JSON: rows, sample, sampled, columns,
missing, and name and notes when set. A nested profile adds
paths (its depth, max_paths, whether it was capped and the
paths dropped), malformed and malformed_lines when lines were
skipped, and per column present, absent, values, types and
mixed.
Sourcepub fn heading(&self) -> String
pub fn heading(&self) -> String
The heading: the name, the rows (and the sample, when smaller) and the columns.
Sourcepub fn to_table(&self) -> Table
pub fn to_table(&self) -> Table
The table of columns: type, nulls, distinct, min, max and mean (the median and quartiles are in the model and under each numeric column’s heading).
A nested profile’s table has each path’s type mix (str 90% · null 10%, with ! before the mix of a path holding more than one type
besides null) and the records that lack it (absent), in place of
the inferred type and the nulls (the mix has their share).
Sourcepub fn missing_heatmap(&self) -> Option<Heatmap>
pub fn missing_heatmap(&self) -> Option<Heatmap>
The missing-value map as a heatmap: a row per bucket, a column per
column, each cell the percentage of the bucket’s cells that are null.
None when nothing is null.
A nested profile counts a record as missing a path when it lacks the
path or holds only null there, and maps only the paths something is
missing from.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Profile
impl<'de> Deserialize<'de> for Profile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Renderable for Profile
impl Renderable for Profile
Source§fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement
fn measure(&self, console: &Console, options: &ConsoleOptions) -> Measurement
As wide as its widest line at the width given.
fn rich_render( &self, console: &Console, options: &ConsoleOptions, ) -> Vec<Segment>
Source§fn fit_to_measurement(&self) -> bool
fn fit_to_measurement(&self) -> bool
Console::print shrinks this renderable to its
measured width. Upstream renders every top-level renderable at the full
console width, so the default is false; an extension may opt in.Source§fn vertical(&self) -> Option<VerticalAlign>
fn vertical(&self) -> Option<VerticalAlign>
Table cell holding this renderable uses in
place of its column’s. Upstream reads getattr(renderable, "vertical", None); Align sets it.Source§fn print_end_line(&self, _options: &ConsoleOptions) -> bool
fn print_end_line(&self, _options: &ConsoleOptions) -> bool
"\n", so a print adds the final line break. A renderable
whose upstream output stops without one (Screen, LiveRender, a
Rule whose end has no newline) returns false, and the next
output continues its last line. options are the print’s options.