use matten_data::Table;
fn main() -> Result<(), matten_data::MattenDataError> {
let csv = "\
region,sales,cost,quantity
north,100,40,5
south,150,,7
east,120,55,6";
let table = Table::from_csv_str(csv)?;
println!("{}", table.schema_summary());
let tensor = table
.select_columns(["sales", "cost", "quantity"])?
.fill_missing(0.0)?
.try_numeric()?
.to_tensor()?;
println!("tensor shape: {:?}", tensor.shape());
println!("tensor data : {:?}", tensor.as_slice());
assert_eq!(tensor.shape(), &[3, 3]);
assert_eq!(
tensor.as_slice(),
&[100.0, 40.0, 5.0, 150.0, 0.0, 7.0, 120.0, 55.0, 6.0]
);
println!("csv_to_tensor: OK");
Ok(())
}