Skip to main content

SchemaSummary

Struct SchemaSummary 

Source
pub struct SchemaSummary {
    pub rows: usize,
    pub columns: usize,
    /* private fields */
}
Expand description

A small, displayable description of a Table’s columns.

Fields§

§rows: usize

Number of data rows.

§columns: usize

Number of columns.

Implementations§

Source§

impl SchemaSummary

Source

pub fn column_summaries(&self) -> &[ColumnSummary]

Per-column summaries, in column order.

Examples found in repository?
examples/data_01_schema_summary.rs (line 39)
18fn main() -> Result<(), matten_data::MattenDataError> {
19    let csv = "\
20region,sales,cost,active
21north,100,40.5,true
22south,150,,true
23east,120,55.0,false";
24
25    let table = Table::from_csv_str(csv)?;
26
27    // Top-level shape of the table.
28    println!("rows    : {}", table.row_count());
29    println!("columns : {}", table.column_count());
30    println!("names   : {:?}", table.column_names());
31
32    // A printable, one-glance summary (Table: R rows x C columns, then a line
33    // per column with its inferred kind and missing count).
34    let summary = table.schema_summary();
35    print!("{summary}");
36
37    // The same information, per column, if you want to act on it in code.
38    println!("--- per-column ---");
39    for col in summary.column_summaries() {
40        println!(
41            "{:<8} kind={:<7} missing={}",
42            col.name, col.kind, col.missing
43        );
44    }
45
46    // The "cost" column has exactly one missing cell (south).
47    let cost = summary
48        .column_summaries()
49        .iter()
50        .find(|c| c.name == "cost")
51        .expect("cost column exists");
52    assert_eq!(cost.missing, 1);
53    assert_eq!(table.row_count(), 3);
54    assert_eq!(table.column_count(), 4);
55
56    println!("data_01_schema_summary: OK");
57    Ok(())
58}

Trait Implementations§

Source§

impl Clone for SchemaSummary

Source§

fn clone(&self) -> SchemaSummary

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SchemaSummary

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for SchemaSummary

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.