pub struct SchemaSummary {
pub rows: usize,
pub columns: usize,
/* private fields */
}Expand description
A small, displayable description of a Table’s columns.
Fields§
§rows: usizeNumber of data rows.
columns: usizeNumber of columns.
Implementations§
Source§impl SchemaSummary
impl SchemaSummary
Sourcepub fn column_summaries(&self) -> &[ColumnSummary]
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
impl Clone for SchemaSummary
Source§fn clone(&self) -> SchemaSummary
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SchemaSummary
impl Debug for SchemaSummary
Auto Trait Implementations§
impl Freeze for SchemaSummary
impl RefUnwindSafe for SchemaSummary
impl Send for SchemaSummary
impl Sync for SchemaSummary
impl Unpin for SchemaSummary
impl UnsafeUnpin for SchemaSummary
impl UnwindSafe for SchemaSummary
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more