Skip to content

Instantly share code, notes, and snippets.

@Steboss89
Created June 28, 2021 14:46
Show Gist options
  • Save Steboss89/da6039df64759236bad99c4786b4ab7c to your computer and use it in GitHub Desktop.
Save Steboss89/da6039df64759236bad99c4786b4ab7c to your computer and use it in GitHub Desktop.
Get shape and info from a dataframe
pub fn deal_with_shape<P: AsRef<Path>>(path: P) -> () {
/* Example function to retrieve shape info from a dataframe */
let df = read_csv(&path).unwrap();
// shape
// reming {:#?} otherwise error ^^^^^ `(usize, usize)` cannot be formatted with the default formatter
let shape = df.shape();
println!("{:#?}", shape);
// schema
println!("{:#?}", df.schema());
// dtypes
println!("{:#?}", df.dtypes());
// or width and height
let width = df.width();
println!("{}", width);
let height = df.height();
println!("{}", height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment