csv_to_tensor/
csv_to_tensor.rs1use matten_data::Table;
6
7fn main() -> Result<(), matten_data::MattenDataError> {
8 let csv = "\
10region,sales,cost,quantity
11north,100,40,5
12south,150,,7
13east,120,55,6";
14
15 let table = Table::from_csv_str(csv)?;
16
17 println!("{}", table.schema_summary());
19
20 let tensor = table
23 .select_columns(["sales", "cost", "quantity"])?
24 .fill_missing(0.0)?
25 .try_numeric()?
26 .to_tensor()?;
27
28 println!("tensor shape: {:?}", tensor.shape());
29 println!("tensor data : {:?}", tensor.as_slice());
30
31 assert_eq!(tensor.shape(), &[3, 3]);
32 Ok(())
33}