pub struct DataFrame { /* private fields */ }Implementations§
Source§impl DataFrame
impl DataFrame
pub fn new( index: Index, columns: BTreeMap<String, Column>, ) -> Result<Self, FrameError>
Sourcepub fn new_with_column_order(
index: Index,
columns: BTreeMap<String, Column>,
column_order: Vec<String>,
) -> Result<Self, FrameError>
pub fn new_with_column_order( index: Index, columns: BTreeMap<String, Column>, column_order: Vec<String>, ) -> Result<Self, FrameError>
Examples found in repository?
More examples
17fn df_from(labels: Vec<i64>, c0: Vec<i64>, c1: Vec<i64>) -> DataFrame {
18 let index = Index::new(labels.into_iter().map(IndexLabel::Int64).collect());
19 let mut cols = BTreeMap::new();
20 cols.insert(
21 "a".to_string(),
22 Column::from_values(c0.into_iter().map(Scalar::Int64).collect()).unwrap(),
23 );
24 cols.insert(
25 "b".to_string(),
26 Column::from_values(c1.into_iter().map(Scalar::Int64).collect()).unwrap(),
27 );
28 DataFrame::new_with_column_order(index, cols, vec!["a".to_string(), "b".to_string()]).unwrap()
29}16fn build_frame(rows: usize, cols: usize, seed: u64) -> DataFrame {
17 let labels: Vec<IndexLabel> = (0..rows)
18 .map(|i| IndexLabel::Int64(i as i64 + seed as i64 * 10))
19 .collect();
20 let mut columns = BTreeMap::new();
21 let mut order = Vec::new();
22 for c in 0..cols {
23 let name = format!("c{c}");
24 let column = fp_columnar::Column::from_f64_values(
25 (0..rows)
26 .map(|i| (i as f64).mul_add(0.25, (c as f64) * 1000.0 + seed as f64))
27 .collect(),
28 );
29 columns.insert(name.clone(), column);
30 order.push(name);
31 }
32 DataFrame::new_with_column_order(Index::new(labels), columns, order).expect("frame")
33}23fn build(n: usize) -> DataFrame {
24 let labels: Vec<IndexLabel> = (0..n as i64).map(IndexLabel::Int64).collect();
25 let mut map = BTreeMap::new();
26 let mut order = Vec::new();
27 for c in 0..6 {
28 let name = format!("i{c}");
29 map.insert(name.clone(), Column::from_i64_values((0..n as i64).collect()));
30 order.push(name);
31 }
32 let name = "s".to_string();
33 map.insert(
34 name.clone(),
35 Column::from_i64_values((0..n as i64).map(|x| x % 100).collect()),
36 );
37 order.push(name);
38 for c in 0..3usize {
39 let name = format!("f{c}");
40 let vals: Vec<f64> = (0..n)
41 .map(|i| {
42 if (i.wrapping_mul(c + 7)) % 23 == 0 {
43 f64::NAN
44 } else {
45 (i % 9973) as f64 * 0.5
46 }
47 })
48 .collect();
49 map.insert(name.clone(), Column::from_f64_values(vals));
50 order.push(name);
51 }
52 DataFrame::new_with_column_order(Index::new(labels), map, order).expect("frame")
53}pub fn new_with_row_multiindex( index: Index, row_multiindex: MultiIndex, columns: BTreeMap<String, Column>, ) -> Result<Self, FrameError>
Sourcepub fn plot(&self) -> Result<PlotSpec, FrameError>
pub fn plot(&self) -> Result<PlotSpec, FrameError>
Return a backend-neutral pandas-style plotting request.
Sourcepub fn hist(&self) -> Result<HistogramSpec, FrameError>
pub fn hist(&self) -> Result<HistogramSpec, FrameError>
Return a backend-neutral pandas-style histogram request.
Sourcepub fn boxplot(&self) -> Result<BoxPlotSpec, FrameError>
pub fn boxplot(&self) -> Result<BoxPlotSpec, FrameError>
Return a backend-neutral pandas-style boxplot request.
Sourcepub fn from_series(series_list: Vec<Series>) -> Result<Self, FrameError>
pub fn from_series(series_list: Vec<Series>) -> Result<Self, FrameError>
AG-05: Pre-compute N-way union index across all series first, then reindex each column exactly once. Eliminates O(N²) iterative realignment where N = number of series.
Sourcepub fn from_dict(
column_order: &[&str],
data: Vec<(&str, Vec<Scalar>)>,
) -> Result<Self, FrameError>
pub fn from_dict( column_order: &[&str], data: Vec<(&str, Vec<Scalar>)>, ) -> Result<Self, FrameError>
Construct a DataFrame from a dict of column vectors.
Matches pd.DataFrame({"a": [1, 2], "b": [3, 4]}).
All vectors must have the same length. Index is auto-generated
as 0..n (RangeIndex-style).
column_order controls observable column label order.
Sourcepub fn from_dict_index(
data: Vec<(&str, Vec<Scalar>)>,
) -> Result<Self, FrameError>
pub fn from_dict_index( data: Vec<(&str, Vec<Scalar>)>, ) -> Result<Self, FrameError>
Construct a DataFrame from a dict with orient='index'.
Matches pd.DataFrame.from_dict(data, orient='index').
Each key becomes a row index label, and each value is a list of
column values. Column names default to 0, 1, 2, …
Sourcepub fn from_dict_index_columns(
data: Vec<(&str, Vec<Scalar>)>,
column_names: &[&str],
) -> Result<Self, FrameError>
pub fn from_dict_index_columns( data: Vec<(&str, Vec<Scalar>)>, column_names: &[&str], ) -> Result<Self, FrameError>
Construct a DataFrame from a dict with orient=‘index’ and custom column names.
Like from_dict_index but with explicit column names.
Sourcepub fn from_records(
records: Vec<Vec<Scalar>>,
column_order: Option<&[String]>,
index_labels: Option<Vec<IndexLabel>>,
) -> Result<Self, FrameError>
pub fn from_records( records: Vec<Vec<Scalar>>, column_order: Option<&[String]>, index_labels: Option<Vec<IndexLabel>>, ) -> Result<Self, FrameError>
Construct a DataFrame from row-oriented list-like records.
Matches pd.DataFrame.from_records(data, columns=..., index=...) for
tuple/list-style records. Short rows are null-filled; explicit columns
may also introduce trailing all-null columns.
Sourcepub fn from_tuples(
records: Vec<Vec<Scalar>>,
columns: &[&str],
) -> Result<Self, FrameError>
pub fn from_tuples( records: Vec<Vec<Scalar>>, columns: &[&str], ) -> Result<Self, FrameError>
Construct a DataFrame from row-oriented tuples.
Matches the rectangular tuple/list subset of
pd.DataFrame.from_records(data, columns=...). Each inner Vec is a row;
all rows must have the same length as columns.
Sourcepub fn from_tuples_with_index(
records: Vec<Vec<Scalar>>,
columns: &[&str],
index_labels: Vec<IndexLabel>,
) -> Result<Self, FrameError>
pub fn from_tuples_with_index( records: Vec<Vec<Scalar>>, columns: &[&str], index_labels: Vec<IndexLabel>, ) -> Result<Self, FrameError>
Construct a DataFrame from a list of row tuples with custom index.
Matches pd.DataFrame(data, columns=columns, index=index) for list-of-lists.
Sourcepub fn from_dict_mixed(
column_order: &[&str],
data: Vec<(&str, DataFrameColumnInput)>,
) -> Result<Self, FrameError>
pub fn from_dict_mixed( column_order: &[&str], data: Vec<(&str, DataFrameColumnInput)>, ) -> Result<Self, FrameError>
Construct a DataFrame from mixed dict inputs (Vec<Scalar> and scalar).
Scalar values are broadcast to the row count inferred from the first non-scalar column. If all inputs are scalar, an explicit index is required and this constructor rejects the operation.
Sourcepub fn from_record_maps(
records: Vec<BTreeMap<String, Scalar>>,
column_order: Option<&[String]>,
index_labels: Option<Vec<IndexLabel>>,
) -> Result<Self, FrameError>
pub fn from_record_maps( records: Vec<BTreeMap<String, Scalar>>, column_order: Option<&[String]>, index_labels: Option<Vec<IndexLabel>>, ) -> Result<Self, FrameError>
Construct a DataFrame from mapping records.
Matches the mapping-record branch of
pd.DataFrame.from_records(records, columns=..., index=...).
Missing keys are null-filled. If column_order is provided, it is used
as the exact output column selector/order and may include labels absent
from the records (materialized as all-null columns).
Sourcepub fn from_csv(text: &str, sep: char) -> Result<Self, FrameError>
pub fn from_csv(text: &str, sep: char) -> Result<Self, FrameError>
Parse a CSV string into a DataFrame.
Matches pd.read_csv(StringIO(text)). The first line is treated as
column headers. Values are auto-detected as Int64, Float64, Bool, or Utf8.
Sourcepub fn from_csv_with_options(
text: &str,
options: &DataFrameCsvReadOptions,
) -> Result<Self, FrameError>
pub fn from_csv_with_options( text: &str, options: &DataFrameCsvReadOptions, ) -> Result<Self, FrameError>
Parse a CSV string into a DataFrame with explicit parsing options.
Matches the pd.read_csv(..., header=..., dtype=..., index_col=..., na_values=...)
shape for currently supported options.
Sourcepub fn from_dict_with_index(
data: Vec<(&str, Vec<Scalar>)>,
index_labels: Vec<IndexLabel>,
) -> Result<Self, FrameError>
pub fn from_dict_with_index( data: Vec<(&str, Vec<Scalar>)>, index_labels: Vec<IndexLabel>, ) -> Result<Self, FrameError>
Construct a DataFrame from a dict of column vectors with an explicit index.
Matches pd.DataFrame({"a": [1, 2]}, index=["x", "y"]).
Sourcepub fn from_dict_with_index_mixed(
data: Vec<(&str, DataFrameColumnInput)>,
index_labels: Vec<IndexLabel>,
) -> Result<Self, FrameError>
pub fn from_dict_with_index_mixed( data: Vec<(&str, DataFrameColumnInput)>, index_labels: Vec<IndexLabel>, ) -> Result<Self, FrameError>
Construct a DataFrame from mixed dict inputs with an explicit index.
Scalar values are broadcast to the explicit index length.
Sourcepub fn select_columns(&self, names: &[&str]) -> Result<Self, FrameError>
pub fn select_columns(&self, names: &[&str]) -> Result<Self, FrameError>
Return a new DataFrame with only the specified columns, in order.
Matches df[["a", "c"]] column selection in pandas.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Return the number of rows.
Examples found in repository?
64fn main() {
65 let g = golden();
66 print!("GOLDEN_BEGIN\n{g}GOLDEN_END\n");
67
68 let n: usize = 60_000;
69 let labels: Vec<i64> = (0..n as i64).collect();
70 let df = df_from(
71 labels.clone(),
72 (0..n as i64).map(|v| v * 2).collect(),
73 (0..n as i64).map(|v| v * 3).collect(),
74 );
75 let selector: Vec<IndexLabel> = (0..n as i64).map(IndexLabel::Int64).collect();
76
77 // warmup
78 let _ = df.loc(&selector).unwrap();
79
80 let t = Instant::now();
81 let r = df.loc(&selector).unwrap();
82 let d = t.elapsed();
83 assert_eq!(r.len(), n);
84
85 println!("TIMING n={n} m={n} df_loc={:.3}ms", d.as_secs_f64() * 1e3);
86}More examples
71fn main() {
72 let g = golden();
73 print!("GOLDEN_BEGIN\n{g}GOLDEN_END\n");
74
75 let n: usize = 500_000;
76 let df = frame(
77 (0..n as i64).collect(),
78 (0..n as i64).map(|v| v * 2).collect(),
79 (0..n).map(|v| Scalar::Float64(v as f64 * 0.5)).collect(),
80 );
81 let mut x: u64 = 0xabcd_1234;
82 let pos: Vec<i64> = (0..n)
83 .map(|_| {
84 x = x
85 .wrapping_mul(6364136223846793005)
86 .wrapping_add(1442695040888963407);
87 (x >> 16) as i64 % (n as i64)
88 })
89 .collect();
90
91 let _ = df.iloc(&pos).unwrap(); // warmup
92
93 let t = Instant::now();
94 let r = df.iloc(&pos).unwrap();
95 let d = t.elapsed();
96 assert_eq!(r.len(), n);
97
98 println!("TIMING n={n} df_iloc={:.3}ms", d.as_secs_f64() * 1e3);
99}55fn main() {
56 let args: Vec<String> = std::env::args().collect();
57 let n: usize = args.get(1).and_then(|s| s.parse().ok()).unwrap_or(1_000_000);
58 let iters: usize = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(30);
59 let df = build(n);
60
61 let out = df.dropna().expect("dropna");
62 let mut chk: u64 = 0xcbf29ce484222325;
63 for lbl in out.index().labels() {
64 let bits = match lbl {
65 IndexLabel::Int64(v) => *v as u64,
66 _ => 0xDEAD,
67 };
68 chk = (chk ^ bits).wrapping_mul(0x100000001b3);
69 }
70
71 let mut sink = 0usize;
72 let start = Instant::now();
73 for _ in 0..iters {
74 sink ^= black_box(df.dropna().expect("dropna")).len();
75 }
76 let elapsed = start.elapsed();
77 println!(
78 "dropna n={n} iters={iters}: {:.3} ms/iter (kept={} chk={chk:016x} sink={sink})",
79 elapsed.as_secs_f64() * 1000.0 / iters as f64,
80 out.len(),
81 );
82}35fn golden_dump(frame: &DataFrame) -> String {
36 let mut out = String::new();
37 let labels = frame.index().labels();
38 writeln!(&mut out, "len={}", frame.len()).unwrap();
39 // Full label sequence digestible: write every 997th label plus ends.
40 for (i, label) in labels.iter().enumerate() {
41 if i % 997 == 0 || i + 1 == labels.len() {
42 writeln!(&mut out, "L{i}={label:?}").unwrap();
43 }
44 }
45 for name in frame.column_names() {
46 let col = frame.column(name).expect("col");
47 let values = col.values();
48 for (i, v) in values.iter().enumerate() {
49 if i % 4999 == 0 || i + 1 == values.len() {
50 if let Scalar::Float64(x) = v {
51 writeln!(&mut out, "{name}[{i}]={:016x}", x.to_bits()).unwrap();
52 } else {
53 writeln!(&mut out, "{name}[{i}]={v:?}").unwrap();
54 }
55 }
56 }
57 }
58 out
59}
60
61fn main() {
62 let args: Vec<String> = std::env::args().collect();
63 let mode = args.get(1).map(String::as_str).unwrap_or("bench");
64 match mode {
65 "bench" => {
66 let rows: usize = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(250_000);
67 let frames_n: usize = args.get(3).and_then(|s| s.parse().ok()).unwrap_or(8);
68 let iters: usize = args.get(4).and_then(|s| s.parse().ok()).unwrap_or(20);
69 let frames: Vec<DataFrame> = (0..frames_n)
70 .map(|k| build_frame(rows, 4, k as u64))
71 .collect();
72 let refs: Vec<&DataFrame> = frames.iter().collect();
73 let start = std::time::Instant::now();
74 let mut sink = 0usize;
75 for _ in 0..iters {
76 let out = concat_dataframes_with_ignore_index(&refs, true).expect("concat");
77 sink = sink.wrapping_add(out.len());
78 }
79 let elapsed = start.elapsed();
80 eprintln!(
81 "concat_bench: {iters} iters in {:.3}s ({:.3} ms/iter), sink={sink}",
82 elapsed.as_secs_f64(),
83 elapsed.as_secs_f64() * 1000.0 / iters as f64
84 );
85 }
86 "golden" => {
87 let rows: usize = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(5_000);
88 let frames_n: usize = args.get(3).and_then(|s| s.parse().ok()).unwrap_or(3);
89 let frames: Vec<DataFrame> = (0..frames_n)
90 .map(|k| build_frame(rows, 4, k as u64))
91 .collect();
92 let refs: Vec<&DataFrame> = frames.iter().collect();
93 let out = concat_dataframes_with_ignore_index(&refs, true).expect("concat");
94 print!("{}", golden_dump(&out));
95 }
96 "bench_reset" => {
97 let rows: usize = args
98 .get(2)
99 .and_then(|s| s.parse().ok())
100 .unwrap_or(2_000_000);
101 let iters: usize = args.get(3).and_then(|s| s.parse().ok()).unwrap_or(20);
102 let frame = build_frame(rows, 4, 7);
103 let start = std::time::Instant::now();
104 let mut sink = 0usize;
105 for _ in 0..iters {
106 let out = frame.reset_index(true).expect("reset_index");
107 sink = sink.wrapping_add(out.len());
108 }
109 let elapsed = start.elapsed();
110 eprintln!(
111 "reset_bench: {iters} iters in {:.3}s ({:.3} ms/iter), sink={sink}",
112 elapsed.as_secs_f64(),
113 elapsed.as_secs_f64() * 1000.0 / iters as f64
114 );
115 }
116 "golden_reset" => {
117 let rows: usize = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(5_000);
118 let frame = build_frame(rows, 4, 7);
119 let out = frame.reset_index(true).expect("reset_index");
120 print!("{}", golden_dump(&out));
121 }
122 other => {
123 eprintln!("unknown mode: {other}");
124 std::process::exit(2);
125 }
126 }
127}Sourcepub fn empty(&self) -> bool
pub fn empty(&self) -> bool
Pandas-style .empty property: true iff the DataFrame contains
zero rows OR zero columns.
Matches pd.DataFrame.empty. This is a stricter predicate than
is_empty() — a frame with rows but no columns is still empty
under pandas’ definition because there are no values to
operate on.
Sourcepub fn num_columns(&self) -> usize
pub fn num_columns(&self) -> usize
Return the number of columns.
Sourcepub fn dtypes(&self) -> Result<Series, FrameError>
pub fn dtypes(&self) -> Result<Series, FrameError>
Return a Series of dtypes, one per column.
Matches pd.DataFrame.dtypes.
Sourcepub fn copy(&self) -> Self
pub fn copy(&self) -> Self
Return a deep copy of this DataFrame.
Matches pd.DataFrame.copy(deep=True).
Sourcepub fn keys(&self) -> MultiIndexOrIndex
pub fn keys(&self) -> MultiIndexOrIndex
Return the DataFrame info axis.
Matches pd.DataFrame.keys(). This is an alias for the column labels.
Sourcepub fn index(&self) -> &Index
pub fn index(&self) -> &Index
Examples found in repository?
More examples
55fn main() {
56 let args: Vec<String> = std::env::args().collect();
57 let n: usize = args.get(1).and_then(|s| s.parse().ok()).unwrap_or(1_000_000);
58 let iters: usize = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(30);
59 let df = build(n);
60
61 let out = df.dropna().expect("dropna");
62 let mut chk: u64 = 0xcbf29ce484222325;
63 for lbl in out.index().labels() {
64 let bits = match lbl {
65 IndexLabel::Int64(v) => *v as u64,
66 _ => 0xDEAD,
67 };
68 chk = (chk ^ bits).wrapping_mul(0x100000001b3);
69 }
70
71 let mut sink = 0usize;
72 let start = Instant::now();
73 for _ in 0..iters {
74 sink ^= black_box(df.dropna().expect("dropna")).len();
75 }
76 let elapsed = start.elapsed();
77 println!(
78 "dropna n={n} iters={iters}: {:.3} ms/iter (kept={} chk={chk:016x} sink={sink})",
79 elapsed.as_secs_f64() * 1000.0 / iters as f64,
80 out.len(),
81 );
82}35fn golden_dump(frame: &DataFrame) -> String {
36 let mut out = String::new();
37 let labels = frame.index().labels();
38 writeln!(&mut out, "len={}", frame.len()).unwrap();
39 // Full label sequence digestible: write every 997th label plus ends.
40 for (i, label) in labels.iter().enumerate() {
41 if i % 997 == 0 || i + 1 == labels.len() {
42 writeln!(&mut out, "L{i}={label:?}").unwrap();
43 }
44 }
45 for name in frame.column_names() {
46 let col = frame.column(name).expect("col");
47 let values = col.values();
48 for (i, v) in values.iter().enumerate() {
49 if i % 4999 == 0 || i + 1 == values.len() {
50 if let Scalar::Float64(x) = v {
51 writeln!(&mut out, "{name}[{i}]={:016x}", x.to_bits()).unwrap();
52 } else {
53 writeln!(&mut out, "{name}[{i}]={v:?}").unwrap();
54 }
55 }
56 }
57 }
58 out
59}31fn golden() -> String {
32 let mut out = String::new();
33 // Duplicate index label 10 at positions 0 and 2.
34 let df = df_from(
35 vec![10, 20, 10, 30],
36 vec![100, 200, 300, 400],
37 vec![1, 2, 3, 4],
38 );
39 // Selector order [30, 10, 20]; 10 returns both matches (ascending position).
40 let r = df
41 .loc(&[
42 IndexLabel::Int64(30),
43 IndexLabel::Int64(10),
44 IndexLabel::Int64(20),
45 ])
46 .unwrap();
47 out.push_str(&format!("labels={:?}\n", r.index().labels()));
48 out.push_str(&format!("a={:?}\n", r.columns().get("a").unwrap().values()));
49 out.push_str(&format!("b={:?}\n", r.columns().get("b").unwrap().values()));
50 // Duplicate selector entries preserved.
51 let r2 = df
52 .loc(&[IndexLabel::Int64(20), IndexLabel::Int64(20)])
53 .unwrap();
54 out.push_str(&format!(
55 "dup_a={:?}\n",
56 r2.columns().get("a").unwrap().values()
57 ));
58 // Missing label fails closed.
59 let err = df.loc(&[IndexLabel::Int64(99)]);
60 out.push_str(&format!("missing_is_err={}\n", err.is_err()));
61 out
62}32fn golden() -> String {
33 let mut out = String::new();
34 // Duplicate labels 1 and 3 with distinct values prove stable tie order.
35 let s = series(vec![3, 1, 2, 1, 3], vec![10, 20, 30, 40, 50]);
36 let asc = s.sort_index(true).unwrap();
37 out.push_str(&format!("s_asc_labels={:?}\n", asc.index().labels()));
38 out.push_str(&format!("s_asc_vals={:?}\n", asc.values()));
39 let desc = s.sort_index(false).unwrap();
40 out.push_str(&format!("s_desc_labels={:?}\n", desc.index().labels()));
41 out.push_str(&format!("s_desc_vals={:?}\n", desc.values()));
42
43 // Negative + zero labels.
44 let s2 = series(vec![0, -5, 7, -5, 0], vec![1, 2, 3, 4, 5]);
45 let a2 = s2.sort_index(true).unwrap();
46 out.push_str(&format!("s2_asc_labels={:?}\n", a2.index().labels()));
47 out.push_str(&format!("s2_asc_vals={:?}\n", a2.values()));
48
49 let df = frame(vec![3, 1, 2, 1, 3], vec![10, 20, 30, 40, 50]);
50 let dfa = df.sort_index(true).unwrap();
51 out.push_str(&format!("df_asc_labels={:?}\n", dfa.index().labels()));
52 out.push_str(&format!(
53 "df_asc_v={:?}\n",
54 dfa.columns().get("v").unwrap().values()
55 ));
56 let dfd = df.sort_index(false).unwrap();
57 out.push_str(&format!("df_desc_labels={:?}\n", dfd.index().labels()));
58 out.push_str(&format!(
59 "df_desc_v={:?}\n",
60 dfd.columns().get("v").unwrap().values()
61 ));
62 out
63}Sourcepub fn row_index(&self) -> MultiIndexOrIndex
pub fn row_index(&self) -> MultiIndexOrIndex
Return the logical DataFrame row index.
When row MultiIndex metadata is present, this returns it instead of the
flat storage fallback in index().
pub fn row_multiindex(&self) -> Option<&MultiIndex>
Sourcepub fn columns(&self) -> &BTreeMap<String, Column>
pub fn columns(&self) -> &BTreeMap<String, Column>
Examples found in repository?
More examples
31fn golden() -> String {
32 let mut out = String::new();
33 // Duplicate index label 10 at positions 0 and 2.
34 let df = df_from(
35 vec![10, 20, 10, 30],
36 vec![100, 200, 300, 400],
37 vec![1, 2, 3, 4],
38 );
39 // Selector order [30, 10, 20]; 10 returns both matches (ascending position).
40 let r = df
41 .loc(&[
42 IndexLabel::Int64(30),
43 IndexLabel::Int64(10),
44 IndexLabel::Int64(20),
45 ])
46 .unwrap();
47 out.push_str(&format!("labels={:?}\n", r.index().labels()));
48 out.push_str(&format!("a={:?}\n", r.columns().get("a").unwrap().values()));
49 out.push_str(&format!("b={:?}\n", r.columns().get("b").unwrap().values()));
50 // Duplicate selector entries preserved.
51 let r2 = df
52 .loc(&[IndexLabel::Int64(20), IndexLabel::Int64(20)])
53 .unwrap();
54 out.push_str(&format!(
55 "dup_a={:?}\n",
56 r2.columns().get("a").unwrap().values()
57 ));
58 // Missing label fails closed.
59 let err = df.loc(&[IndexLabel::Int64(99)]);
60 out.push_str(&format!("missing_is_err={}\n", err.is_err()));
61 out
62}32fn golden() -> String {
33 let mut out = String::new();
34 // Duplicate labels 1 and 3 with distinct values prove stable tie order.
35 let s = series(vec![3, 1, 2, 1, 3], vec![10, 20, 30, 40, 50]);
36 let asc = s.sort_index(true).unwrap();
37 out.push_str(&format!("s_asc_labels={:?}\n", asc.index().labels()));
38 out.push_str(&format!("s_asc_vals={:?}\n", asc.values()));
39 let desc = s.sort_index(false).unwrap();
40 out.push_str(&format!("s_desc_labels={:?}\n", desc.index().labels()));
41 out.push_str(&format!("s_desc_vals={:?}\n", desc.values()));
42
43 // Negative + zero labels.
44 let s2 = series(vec![0, -5, 7, -5, 0], vec![1, 2, 3, 4, 5]);
45 let a2 = s2.sort_index(true).unwrap();
46 out.push_str(&format!("s2_asc_labels={:?}\n", a2.index().labels()));
47 out.push_str(&format!("s2_asc_vals={:?}\n", a2.values()));
48
49 let df = frame(vec![3, 1, 2, 1, 3], vec![10, 20, 30, 40, 50]);
50 let dfa = df.sort_index(true).unwrap();
51 out.push_str(&format!("df_asc_labels={:?}\n", dfa.index().labels()));
52 out.push_str(&format!(
53 "df_asc_v={:?}\n",
54 dfa.columns().get("v").unwrap().values()
55 ));
56 let dfd = df.sort_index(false).unwrap();
57 out.push_str(&format!("df_desc_labels={:?}\n", dfd.index().labels()));
58 out.push_str(&format!(
59 "df_desc_v={:?}\n",
60 dfd.columns().get("v").unwrap().values()
61 ));
62 out
63}Sourcepub fn columns_index(&self) -> MultiIndexOrIndex
pub fn columns_index(&self) -> MultiIndexOrIndex
Return the logical DataFrame columns index.
Matches pd.DataFrame.columns, including MultiIndex columns for
operations like groupby.ohlc().
pub fn columns_multiindex(&self) -> Option<&MultiIndex>
Sourcepub fn column_names(&self) -> Vec<&String>
pub fn column_names(&self) -> Vec<&String>
Return the flat storage column names in observable DataFrame order.
For the pandas-visible logical column index, including MultiIndex
metadata, use columns_index().
Examples found in repository?
35fn golden_dump(frame: &DataFrame) -> String {
36 let mut out = String::new();
37 let labels = frame.index().labels();
38 writeln!(&mut out, "len={}", frame.len()).unwrap();
39 // Full label sequence digestible: write every 997th label plus ends.
40 for (i, label) in labels.iter().enumerate() {
41 if i % 997 == 0 || i + 1 == labels.len() {
42 writeln!(&mut out, "L{i}={label:?}").unwrap();
43 }
44 }
45 for name in frame.column_names() {
46 let col = frame.column(name).expect("col");
47 let values = col.values();
48 for (i, v) in values.iter().enumerate() {
49 if i % 4999 == 0 || i + 1 == values.len() {
50 if let Scalar::Float64(x) = v {
51 writeln!(&mut out, "{name}[{i}]={:016x}", x.to_bits()).unwrap();
52 } else {
53 writeln!(&mut out, "{name}[{i}]={v:?}").unwrap();
54 }
55 }
56 }
57 }
58 out
59}Sourcepub fn column(&self, name: &str) -> Option<&Column>
pub fn column(&self, name: &str) -> Option<&Column>
Examples found in repository?
35fn golden_dump(frame: &DataFrame) -> String {
36 let mut out = String::new();
37 let labels = frame.index().labels();
38 writeln!(&mut out, "len={}", frame.len()).unwrap();
39 // Full label sequence digestible: write every 997th label plus ends.
40 for (i, label) in labels.iter().enumerate() {
41 if i % 997 == 0 || i + 1 == labels.len() {
42 writeln!(&mut out, "L{i}={label:?}").unwrap();
43 }
44 }
45 for name in frame.column_names() {
46 let col = frame.column(name).expect("col");
47 let values = col.values();
48 for (i, v) in values.iter().enumerate() {
49 if i % 4999 == 0 || i + 1 == values.len() {
50 if let Scalar::Float64(x) = v {
51 writeln!(&mut out, "{name}[{i}]={:016x}", x.to_bits()).unwrap();
52 } else {
53 writeln!(&mut out, "{name}[{i}]={v:?}").unwrap();
54 }
55 }
56 }
57 }
58 out
59}More examples
28fn main() {
29 let n: usize = std::env::args()
30 .nth(1)
31 .and_then(|s| s.parse().ok())
32 .unwrap_or(1_000_000);
33 let m: usize = std::env::args()
34 .nth(2)
35 .and_then(|s| s.parse().ok())
36 .unwrap_or(8);
37
38 let labels: Vec<IndexLabel> = (0..n as i64).map(IndexLabel::Int64).collect();
39 let index = Index::new(labels);
40 let mut columns = BTreeMap::new();
41 let mut order = Vec::with_capacity(m);
42 let mut input = Vec::<f64>::with_capacity(n * m);
43 for c in 0..m {
44 let col: Vec<f64> = (0..n).map(|i| splitmix_unit(i, c)).collect();
45 input.extend_from_slice(&col); // col-major: c0 rows, c1 rows, ...
46 let name = format!("c{c}");
47 columns.insert(name.clone(), Column::from_f64_values(col));
48 order.push(name);
49 }
50 let df = DataFrame::new_with_column_order(index, columns, order.clone()).expect("frame");
51
52 let corr = df.corr().expect("corr");
53 // corr is m x m; extract row-major by the same column order.
54 let mut fp = Vec::<f64>::with_capacity(m * m);
55 for ri in 0..m {
56 let col = corr.column(&order[ri]).expect("corr col");
57 let vals = col.values();
58 for cj in 0..m {
59 fp.push(vals[cj].to_f64().unwrap_or(f64::NAN));
60 }
61 }
62
63 let _ = input;
64 let mut line = String::from("FPCORR");
65 for x in &fp {
66 line.push(' ');
67 line.push_str(&format!("{x:.17e}"));
68 }
69 let mut out = std::io::stdout().lock();
70 writeln!(out, "DIMS {n} {m}").unwrap();
71 writeln!(out, "{line}").unwrap();
72}Sourcepub fn filter_rows(&self, mask: &Series) -> Result<Self, FrameError>
pub fn filter_rows(&self, mask: &Series) -> Result<Self, FrameError>
Filter rows where mask is True.
Matches df[bool_series] boolean indexing in pandas.
The mask must be a Bool-typed Series. Indexes are aligned; missing
mask values are treated as False.
Sourcepub fn isna(&self) -> Result<Self, FrameError>
pub fn isna(&self) -> Result<Self, FrameError>
Return a DataFrame of booleans indicating missing values.
Matches df.isna().
Sourcepub fn notna(&self) -> Result<Self, FrameError>
pub fn notna(&self) -> Result<Self, FrameError>
Return a DataFrame of booleans indicating non-missing values.
Matches df.notna().
Sourcepub fn isnull(&self) -> Result<Self, FrameError>
pub fn isnull(&self) -> Result<Self, FrameError>
Alias for isna.
Matches df.isnull().
Sourcepub fn notnull(&self) -> Result<Self, FrameError>
pub fn notnull(&self) -> Result<Self, FrameError>
Alias for notna.
Matches df.notnull().
Sourcepub fn count(&self) -> Result<Series, FrameError>
pub fn count(&self) -> Result<Series, FrameError>
Return non-missing counts for each column.
Matches df.count() default behavior (axis=0, skipna=True).
Sourcepub fn count_na(&self) -> Result<Series, FrameError>
pub fn count_na(&self) -> Result<Series, FrameError>
Count of missing (NaN/null) values per column.
Matches df.isna().sum(). Returns a Series indexed by column name.
Sourcepub fn fillna(&self, fill_value: &Scalar) -> Result<Self, FrameError>
pub fn fillna(&self, fill_value: &Scalar) -> Result<Self, FrameError>
Fill missing values in each column with fill_value.
Matches df.fillna(value) for scalar value.
Sourcepub fn fillna_limit(
&self,
fill_value: &Scalar,
limit: usize,
) -> Result<Self, FrameError>
pub fn fillna_limit( &self, fill_value: &Scalar, limit: usize, ) -> Result<Self, FrameError>
Fill missing values with fill_value, filling at most limit
consecutive NaN positions per column.
Matches df.fillna(value, limit=N).
Sourcepub fn fillna_dict(
&self,
fill_map: &BTreeMap<String, Scalar>,
) -> Result<Self, FrameError>
pub fn fillna_dict( &self, fill_map: &BTreeMap<String, Scalar>, ) -> Result<Self, FrameError>
Fill missing values with per-column values.
Matches df.fillna({'col1': val1, 'col2': val2}).
Columns not listed in fill_map are left unchanged.
Sourcepub fn dropna(&self) -> Result<Self, FrameError>
pub fn dropna(&self) -> Result<Self, FrameError>
Drop rows containing missing values in any selected column.
Matches default df.dropna() row-wise behavior (axis=0, how='any').
Examples found in repository?
55fn main() {
56 let args: Vec<String> = std::env::args().collect();
57 let n: usize = args.get(1).and_then(|s| s.parse().ok()).unwrap_or(1_000_000);
58 let iters: usize = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(30);
59 let df = build(n);
60
61 let out = df.dropna().expect("dropna");
62 let mut chk: u64 = 0xcbf29ce484222325;
63 for lbl in out.index().labels() {
64 let bits = match lbl {
65 IndexLabel::Int64(v) => *v as u64,
66 _ => 0xDEAD,
67 };
68 chk = (chk ^ bits).wrapping_mul(0x100000001b3);
69 }
70
71 let mut sink = 0usize;
72 let start = Instant::now();
73 for _ in 0..iters {
74 sink ^= black_box(df.dropna().expect("dropna")).len();
75 }
76 let elapsed = start.elapsed();
77 println!(
78 "dropna n={n} iters={iters}: {:.3} ms/iter (kept={} chk={chk:016x} sink={sink})",
79 elapsed.as_secs_f64() * 1000.0 / iters as f64,
80 out.len(),
81 );
82}Sourcepub fn dropna_with_options(
&self,
how: DropNaHow,
subset: Option<&[String]>,
) -> Result<Self, FrameError>
pub fn dropna_with_options( &self, how: DropNaHow, subset: Option<&[String]>, ) -> Result<Self, FrameError>
Drop rows by configurable missing-value policy.
Matches df.dropna(how=..., subset=...) for row-wise mode (axis=0).
Sourcepub fn dropna_with_threshold(
&self,
thresh: usize,
subset: Option<&[String]>,
) -> Result<Self, FrameError>
pub fn dropna_with_threshold( &self, thresh: usize, subset: Option<&[String]>, ) -> Result<Self, FrameError>
Drop rows by minimum non-missing value count.
Matches df.dropna(thresh=..., subset=...) for row-wise mode (axis=0).
Sourcepub fn dropna_columns(&self) -> Result<Self, FrameError>
pub fn dropna_columns(&self) -> Result<Self, FrameError>
Drop columns containing missing values in any row.
Matches default df.dropna(axis=1) behavior (how='any').
Sourcepub fn dropna_columns_with_options(
&self,
how: DropNaHow,
subset: Option<&[IndexLabel]>,
) -> Result<Self, FrameError>
pub fn dropna_columns_with_options( &self, how: DropNaHow, subset: Option<&[IndexLabel]>, ) -> Result<Self, FrameError>
Drop columns by configurable missing-value policy.
Matches df.dropna(axis=1, how=..., subset=...) where subset selects
row labels to consider during missing-value checks.
Sourcepub fn dropna_columns_with_threshold(
&self,
thresh: usize,
subset: Option<&[IndexLabel]>,
) -> Result<Self, FrameError>
pub fn dropna_columns_with_threshold( &self, thresh: usize, subset: Option<&[IndexLabel]>, ) -> Result<Self, FrameError>
Drop columns by minimum non-missing value count.
Matches df.dropna(axis=1, thresh=..., subset=...) where subset
selects row labels to consider.
Sourcepub fn duplicated(
&self,
subset: Option<&[String]>,
keep: DuplicateKeep,
) -> Result<Series, FrameError>
pub fn duplicated( &self, subset: Option<&[String]>, keep: DuplicateKeep, ) -> Result<Series, FrameError>
Return a boolean Series indicating duplicated rows.
Matches df.duplicated(subset=..., keep=...).
Uses hash-based O(n) deduplication instead of O(n²) pairwise comparison. Per br-frankenpandas-cclly performance optimization.
Sourcepub fn drop_duplicates(
&self,
subset: Option<&[String]>,
keep: DuplicateKeep,
ignore_index: bool,
) -> Result<Self, FrameError>
pub fn drop_duplicates( &self, subset: Option<&[String]>, keep: DuplicateKeep, ignore_index: bool, ) -> Result<Self, FrameError>
Drop duplicated rows.
Matches df.drop_duplicates(subset=..., keep=..., ignore_index=...).
Sourcepub fn head(&self, n: i64) -> Result<Self, FrameError>
pub fn head(&self, n: i64) -> Result<Self, FrameError>
Return the first n rows.
Matches df.head(n). If n is negative, this returns all rows except
the last -n rows.
Sourcepub fn tail(&self, n: i64) -> Result<Self, FrameError>
pub fn tail(&self, n: i64) -> Result<Self, FrameError>
Return the last n rows.
Matches df.tail(n). If n is negative, this returns all rows except
the first -n rows.
Sourcepub fn set_index(&self, column: &str, drop: bool) -> Result<Self, FrameError>
pub fn set_index(&self, column: &str, drop: bool) -> Result<Self, FrameError>
Set the DataFrame index from an existing column.
Matches df.set_index(column, drop=...) for a single column selector.
Sourcepub fn set_index_with_verify_integrity(
&self,
column: &str,
drop: bool,
verify_integrity: bool,
) -> Result<Self, FrameError>
pub fn set_index_with_verify_integrity( &self, column: &str, drop: bool, verify_integrity: bool, ) -> Result<Self, FrameError>
Set the DataFrame index from an existing column while optionally rejecting duplicate labels.
Sourcepub fn set_index_multi(
&self,
columns: &[&str],
drop: bool,
sep: &str,
) -> Result<Self, FrameError>
pub fn set_index_multi( &self, columns: &[&str], drop: bool, sep: &str, ) -> Result<Self, FrameError>
Set the index from multiple columns, creating a composite index.
Matches df.set_index([col1, col2, ...]) in pandas. The composite
index labels are created by joining column values with a separator.
A MultiIndex can be recovered via to_multi_index().
Sourcepub fn to_multi_index(&self, columns: &[&str]) -> Result<MultiIndex, FrameError>
pub fn to_multi_index(&self, columns: &[&str]) -> Result<MultiIndex, FrameError>
Extract a MultiIndex from the specified columns.
Does NOT modify the DataFrame. Returns a standalone MultiIndex
that can be used for hierarchical indexing operations.
Sourcepub fn reset_index(&self, drop: bool) -> Result<Self, FrameError>
pub fn reset_index(&self, drop: bool) -> Result<Self, FrameError>
Reset the index to a default RangeIndex.
Matches df.reset_index(drop=...) for the single-index DataFrame model.
Examples found in repository?
61fn main() {
62 let args: Vec<String> = std::env::args().collect();
63 let mode = args.get(1).map(String::as_str).unwrap_or("bench");
64 match mode {
65 "bench" => {
66 let rows: usize = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(250_000);
67 let frames_n: usize = args.get(3).and_then(|s| s.parse().ok()).unwrap_or(8);
68 let iters: usize = args.get(4).and_then(|s| s.parse().ok()).unwrap_or(20);
69 let frames: Vec<DataFrame> = (0..frames_n)
70 .map(|k| build_frame(rows, 4, k as u64))
71 .collect();
72 let refs: Vec<&DataFrame> = frames.iter().collect();
73 let start = std::time::Instant::now();
74 let mut sink = 0usize;
75 for _ in 0..iters {
76 let out = concat_dataframes_with_ignore_index(&refs, true).expect("concat");
77 sink = sink.wrapping_add(out.len());
78 }
79 let elapsed = start.elapsed();
80 eprintln!(
81 "concat_bench: {iters} iters in {:.3}s ({:.3} ms/iter), sink={sink}",
82 elapsed.as_secs_f64(),
83 elapsed.as_secs_f64() * 1000.0 / iters as f64
84 );
85 }
86 "golden" => {
87 let rows: usize = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(5_000);
88 let frames_n: usize = args.get(3).and_then(|s| s.parse().ok()).unwrap_or(3);
89 let frames: Vec<DataFrame> = (0..frames_n)
90 .map(|k| build_frame(rows, 4, k as u64))
91 .collect();
92 let refs: Vec<&DataFrame> = frames.iter().collect();
93 let out = concat_dataframes_with_ignore_index(&refs, true).expect("concat");
94 print!("{}", golden_dump(&out));
95 }
96 "bench_reset" => {
97 let rows: usize = args
98 .get(2)
99 .and_then(|s| s.parse().ok())
100 .unwrap_or(2_000_000);
101 let iters: usize = args.get(3).and_then(|s| s.parse().ok()).unwrap_or(20);
102 let frame = build_frame(rows, 4, 7);
103 let start = std::time::Instant::now();
104 let mut sink = 0usize;
105 for _ in 0..iters {
106 let out = frame.reset_index(true).expect("reset_index");
107 sink = sink.wrapping_add(out.len());
108 }
109 let elapsed = start.elapsed();
110 eprintln!(
111 "reset_bench: {iters} iters in {:.3}s ({:.3} ms/iter), sink={sink}",
112 elapsed.as_secs_f64(),
113 elapsed.as_secs_f64() * 1000.0 / iters as f64
114 );
115 }
116 "golden_reset" => {
117 let rows: usize = args.get(2).and_then(|s| s.parse().ok()).unwrap_or(5_000);
118 let frame = build_frame(rows, 4, 7);
119 let out = frame.reset_index(true).expect("reset_index");
120 print!("{}", golden_dump(&out));
121 }
122 other => {
123 eprintln!("unknown mode: {other}");
124 std::process::exit(2);
125 }
126 }
127}Sourcepub fn sort_index(&self, ascending: bool) -> Result<Self, FrameError>
pub fn sort_index(&self, ascending: bool) -> Result<Self, FrameError>
Return a new DataFrame sorted by index labels.
Matches df.sort_index(ascending=...) for 1D index labels.
Examples found in repository?
32fn golden() -> String {
33 let mut out = String::new();
34 // Duplicate labels 1 and 3 with distinct values prove stable tie order.
35 let s = series(vec![3, 1, 2, 1, 3], vec![10, 20, 30, 40, 50]);
36 let asc = s.sort_index(true).unwrap();
37 out.push_str(&format!("s_asc_labels={:?}\n", asc.index().labels()));
38 out.push_str(&format!("s_asc_vals={:?}\n", asc.values()));
39 let desc = s.sort_index(false).unwrap();
40 out.push_str(&format!("s_desc_labels={:?}\n", desc.index().labels()));
41 out.push_str(&format!("s_desc_vals={:?}\n", desc.values()));
42
43 // Negative + zero labels.
44 let s2 = series(vec![0, -5, 7, -5, 0], vec![1, 2, 3, 4, 5]);
45 let a2 = s2.sort_index(true).unwrap();
46 out.push_str(&format!("s2_asc_labels={:?}\n", a2.index().labels()));
47 out.push_str(&format!("s2_asc_vals={:?}\n", a2.values()));
48
49 let df = frame(vec![3, 1, 2, 1, 3], vec![10, 20, 30, 40, 50]);
50 let dfa = df.sort_index(true).unwrap();
51 out.push_str(&format!("df_asc_labels={:?}\n", dfa.index().labels()));
52 out.push_str(&format!(
53 "df_asc_v={:?}\n",
54 dfa.columns().get("v").unwrap().values()
55 ));
56 let dfd = df.sort_index(false).unwrap();
57 out.push_str(&format!("df_desc_labels={:?}\n", dfd.index().labels()));
58 out.push_str(&format!(
59 "df_desc_v={:?}\n",
60 dfd.columns().get("v").unwrap().values()
61 ));
62 out
63}Sourcepub fn sort_index_axis1(&self, ascending: bool) -> Result<Self, FrameError>
pub fn sort_index_axis1(&self, ascending: bool) -> Result<Self, FrameError>
Sort the DataFrame by column names (axis=1).
Matches df.sort_index(axis=1, ascending=...).
Sourcepub fn sort_values(
&self,
column: &str,
ascending: bool,
) -> Result<Self, FrameError>
pub fn sort_values( &self, column: &str, ascending: bool, ) -> Result<Self, FrameError>
Return a new DataFrame sorted by a column’s values.
Matches df.sort_values(by=column, ascending=...) for a single
column key with default na_position='last'.
Sourcepub fn sort_values_na(
&self,
column: &str,
ascending: bool,
na_position: &str,
) -> Result<Self, FrameError>
pub fn sort_values_na( &self, column: &str, ascending: bool, na_position: &str, ) -> Result<Self, FrameError>
Return a new DataFrame sorted by a column’s values with explicit NA position.
Matches df.sort_values(by=column, ascending=..., na_position='first'|'last').
Sourcepub fn sort_values_multi(
&self,
by: &[&str],
ascending: &[bool],
na_position: &str,
) -> Result<Self, FrameError>
pub fn sort_values_multi( &self, by: &[&str], ascending: &[bool], na_position: &str, ) -> Result<Self, FrameError>
Sort by multiple columns with per-column ascending flags.
Matches df.sort_values(by=[...], ascending=[...], na_position='first'|'last').
na_position defaults to “last”.
Sourcepub fn loc(&self, labels: &[IndexLabel]) -> Result<Self, FrameError>
pub fn loc(&self, labels: &[IndexLabel]) -> Result<Self, FrameError>
Label-based row selection for list-like indexers.
Matches df.loc[[...]] for list selectors. Requested labels are
returned in selector order and duplicate labels are preserved.
Missing labels fail closed.
Examples found in repository?
31fn golden() -> String {
32 let mut out = String::new();
33 // Duplicate index label 10 at positions 0 and 2.
34 let df = df_from(
35 vec![10, 20, 10, 30],
36 vec![100, 200, 300, 400],
37 vec![1, 2, 3, 4],
38 );
39 // Selector order [30, 10, 20]; 10 returns both matches (ascending position).
40 let r = df
41 .loc(&[
42 IndexLabel::Int64(30),
43 IndexLabel::Int64(10),
44 IndexLabel::Int64(20),
45 ])
46 .unwrap();
47 out.push_str(&format!("labels={:?}\n", r.index().labels()));
48 out.push_str(&format!("a={:?}\n", r.columns().get("a").unwrap().values()));
49 out.push_str(&format!("b={:?}\n", r.columns().get("b").unwrap().values()));
50 // Duplicate selector entries preserved.
51 let r2 = df
52 .loc(&[IndexLabel::Int64(20), IndexLabel::Int64(20)])
53 .unwrap();
54 out.push_str(&format!(
55 "dup_a={:?}\n",
56 r2.columns().get("a").unwrap().values()
57 ));
58 // Missing label fails closed.
59 let err = df.loc(&[IndexLabel::Int64(99)]);
60 out.push_str(&format!("missing_is_err={}\n", err.is_err()));
61 out
62}
63
64fn main() {
65 let g = golden();
66 print!("GOLDEN_BEGIN\n{g}GOLDEN_END\n");
67
68 let n: usize = 60_000;
69 let labels: Vec<i64> = (0..n as i64).collect();
70 let df = df_from(
71 labels.clone(),
72 (0..n as i64).map(|v| v * 2).collect(),
73 (0..n as i64).map(|v| v * 3).collect(),
74 );
75 let selector: Vec<IndexLabel> = (0..n as i64).map(IndexLabel::Int64).collect();
76
77 // warmup
78 let _ = df.loc(&selector).unwrap();
79
80 let t = Instant::now();
81 let r = df.loc(&selector).unwrap();
82 let d = t.elapsed();
83 assert_eq!(r.len(), n);
84
85 println!("TIMING n={n} m={n} df_loc={:.3}ms", d.as_secs_f64() * 1e3);
86}Sourcepub fn loc_with_columns(
&self,
labels: &[IndexLabel],
column_selector: Option<&[String]>,
) -> Result<Self, FrameError>
pub fn loc_with_columns( &self, labels: &[IndexLabel], column_selector: Option<&[String]>, ) -> Result<Self, FrameError>
Label-based row+column selection for list-like indexers.
Matches df.loc[[...], [...]] for list selectors. Requested rows are
returned in selector order and duplicate row labels are preserved.
Missing labels/columns fail closed.
Sourcepub fn loc_tuple(&self, key: &[IndexLabel]) -> Result<Self, FrameError>
pub fn loc_tuple(&self, key: &[IndexLabel]) -> Result<Self, FrameError>
Tuple-/prefix-key row selection against a row MultiIndex.
Exact tuple keys ([lvl0, lvl1, ...]) match full composite rows.
Shorter keys act as prefix selection, mirroring df.loc[(a, slice(None))]
for the leading levels.
Sourcepub fn loc_tuple_with_columns(
&self,
key: &[IndexLabel],
column_selector: Option<&[String]>,
) -> Result<Self, FrameError>
pub fn loc_tuple_with_columns( &self, key: &[IndexLabel], column_selector: Option<&[String]>, ) -> Result<Self, FrameError>
Tuple-/prefix-key row selection with an optional column subset.
Sourcepub fn get_loc(
&self,
key: &[IndexLabel],
level: Option<usize>,
) -> Result<Vec<usize>, FrameError>
pub fn get_loc( &self, key: &[IndexLabel], level: Option<usize>, ) -> Result<Vec<usize>, FrameError>
Return row positions for a row-MultiIndex tuple or a single level key.
level=None performs exact or prefix tuple lookup depending on key arity.
level=Some(n) performs a single-label lookup on the N-th level.
Sourcepub fn get_loc_level(
&self,
key: &[IndexLabel],
) -> Result<(Vec<usize>, Option<MultiIndexOrIndex>), FrameError>
pub fn get_loc_level( &self, key: &[IndexLabel], ) -> Result<(Vec<usize>, Option<MultiIndexOrIndex>), FrameError>
pandas-style tuple lookup returning matching positions and the remaining row index.
Sourcepub fn iloc(&self, positions: &[i64]) -> Result<Self, FrameError>
pub fn iloc(&self, positions: &[i64]) -> Result<Self, FrameError>
Position-based row selection for list-like indexers.
Matches df.iloc[[...]] for list selectors. Requested positions are
returned in selector order and duplicates are preserved.
Negative positions are resolved from the end of the DataFrame.
Examples found in repository?
37fn golden() -> String {
38 let mut out = String::new();
39 let df = frame(
40 vec![10, 11, 12, 13, 14],
41 vec![100, 200, 300, 400, 500],
42 vec![
43 Scalar::Float64(1.5),
44 Scalar::Float64(f64::NAN),
45 Scalar::Float64(-3.0),
46 Scalar::Float64(2.0),
47 Scalar::Float64(9.0),
48 ],
49 );
50
51 // iloc: reorder + negative + duplicate
52 out.push_str(&format!(
53 "iloc={}\n",
54 dump(&df.iloc(&[4, 0, -1, 2, 2]).unwrap())
55 ));
56 out.push_str(&format!("iloc_oob_err={}\n", df.iloc(&[99]).is_err()));
57 // take axis=0
58 out.push_str(&format!(
59 "take={}\n",
60 dump(&df.take(&[3, 1, 0], 0).unwrap())
61 ));
62 out.push_str(&format!("take_oob_err={}\n", df.take(&[99], 0).is_err()));
63 // sample deterministic (fixed seed)
64 out.push_str(&format!(
65 "sample={}\n",
66 dump(&df.sample(Some(3), None, false, Some(7)).unwrap())
67 ));
68 out
69}
70
71fn main() {
72 let g = golden();
73 print!("GOLDEN_BEGIN\n{g}GOLDEN_END\n");
74
75 let n: usize = 500_000;
76 let df = frame(
77 (0..n as i64).collect(),
78 (0..n as i64).map(|v| v * 2).collect(),
79 (0..n).map(|v| Scalar::Float64(v as f64 * 0.5)).collect(),
80 );
81 let mut x: u64 = 0xabcd_1234;
82 let pos: Vec<i64> = (0..n)
83 .map(|_| {
84 x = x
85 .wrapping_mul(6364136223846793005)
86 .wrapping_add(1442695040888963407);
87 (x >> 16) as i64 % (n as i64)
88 })
89 .collect();
90
91 let _ = df.iloc(&pos).unwrap(); // warmup
92
93 let t = Instant::now();
94 let r = df.iloc(&pos).unwrap();
95 let d = t.elapsed();
96 assert_eq!(r.len(), n);
97
98 println!("TIMING n={n} df_iloc={:.3}ms", d.as_secs_f64() * 1e3);
99}Sourcepub fn iloc_with_columns(
&self,
positions: &[i64],
column_selector: Option<&[String]>,
) -> Result<Self, FrameError>
pub fn iloc_with_columns( &self, positions: &[i64], column_selector: Option<&[String]>, ) -> Result<Self, FrameError>
Position-based row+column selection for list-like indexers.
Matches df.iloc[[...], [...]] for list selectors. Requested rows are
returned in selector order and duplicates are preserved.
Missing columns fail closed.
Sourcepub fn loc_bool(&self, mask: &[bool]) -> Result<Self, FrameError>
pub fn loc_bool(&self, mask: &[bool]) -> Result<Self, FrameError>
Boolean mask row selection.
Matches df.loc[bool_array] in pandas. The boolean mask must have the
same length as the DataFrame. Rows where the mask is True are kept.
Sourcepub fn iloc_bool(&self, mask: &[bool]) -> Result<Self, FrameError>
pub fn iloc_bool(&self, mask: &[bool]) -> Result<Self, FrameError>
Boolean mask row selection (position-based).
Matches df.iloc[bool_array] in pandas. Semantically identical to
loc_bool for DataFrames (the mask selects rows by position either way).
Sourcepub fn loc_bool_series(&self, mask: &Series) -> Result<Self, FrameError>
pub fn loc_bool_series(&self, mask: &Series) -> Result<Self, FrameError>
Boolean Series mask row selection with index alignment.
Matches df.loc[bool_series] in pandas, the most common usage pattern
(e.g., df.loc[df['col'] > 5]). The mask Series is aligned with the
DataFrame by index before filtering. Missing mask values are treated
as False. This is an alias for DataFrame::filter_rows.
Sourcepub fn iloc_bool_series(&self, mask: &Series) -> Result<Self, FrameError>
pub fn iloc_bool_series(&self, mask: &Series) -> Result<Self, FrameError>
Position-based boolean Series mask row selection with index alignment.
Matches df.iloc[bool_series] in pandas. Semantically identical to
loc_bool_series (delegates to filter_rows).
Sourcepub fn loc_slice(
&self,
start: Option<&IndexLabel>,
stop: Option<&IndexLabel>,
) -> Result<Self, FrameError>
pub fn loc_slice( &self, start: Option<&IndexLabel>, stop: Option<&IndexLabel>, ) -> Result<Self, FrameError>
Label-based slice row selection (inclusive on both ends).
Matches df.loc[start:stop] in pandas. Both endpoints are inclusive
(pandas label-slicing semantics). Either may be None to mean “from
the beginning” or “to the end”.
Sourcepub fn iloc_slice(
&self,
start: Option<i64>,
stop: Option<i64>,
) -> Result<Self, FrameError>
pub fn iloc_slice( &self, start: Option<i64>, stop: Option<i64>, ) -> Result<Self, FrameError>
Position-based slice row selection (exclusive end).
Matches df.iloc[start:stop] in pandas. The start is inclusive and
stop is exclusive (Python slice semantics). Negative values are
resolved from the end. Both are optional.
Sourcepub fn loc_row(&self, label: &IndexLabel) -> Result<Series, FrameError>
pub fn loc_row(&self, label: &IndexLabel) -> Result<Series, FrameError>
Return a single row as a Series by label.
Matches df.loc[label] when label is a scalar in pandas. The
returned Series has the DataFrame’s column names as its index and the
row values as data.
Sourcepub fn loc_row_tuple(&self, key: &[IndexLabel]) -> Result<Series, FrameError>
pub fn loc_row_tuple(&self, key: &[IndexLabel]) -> Result<Series, FrameError>
Return a single row as a Series by exact row-MultiIndex tuple.
Sourcepub fn iloc_row(&self, position: i64) -> Result<Series, FrameError>
pub fn iloc_row(&self, position: i64) -> Result<Series, FrameError>
Return a single row as a Series by position.
Matches df.iloc[n] when n is a scalar in pandas. The returned
Series has the DataFrame’s column names as its index and the row values
as data.
Sourcepub fn with_column(
&self,
name: impl Into<String>,
column: Column,
) -> Result<Self, FrameError>
pub fn with_column( &self, name: impl Into<String>, column: Column, ) -> Result<Self, FrameError>
Add or replace a column.
Matches df['new_col'] = values.
Sourcepub fn astype_columns(
&self,
mapping: &[(&str, DType)],
) -> Result<Self, FrameError>
pub fn astype_columns( &self, mapping: &[(&str, DType)], ) -> Result<Self, FrameError>
Cast one or more columns to target dtypes.
Matches mapping-style df.astype({"a": dtype_a, "b": dtype_b}).
Mapping order is processed deterministically and duplicate selectors
are rejected.
Sourcepub fn astype_column(
&self,
name: &str,
dtype: DType,
) -> Result<Self, FrameError>
pub fn astype_column( &self, name: &str, dtype: DType, ) -> Result<Self, FrameError>
Cast a single column to a target dtype.
Matches df.astype({\"col\": dtype}) for single-column mapping.
Sourcepub fn astype(&self, dtype: DType) -> Result<Self, FrameError>
pub fn astype(&self, dtype: DType) -> Result<Self, FrameError>
Cast all columns to a single target dtype.
Matches df.astype(dtype) (scalar form).
Sourcepub fn tz_localize(&self, tz: Option<&str>) -> Result<Self, FrameError>
pub fn tz_localize(&self, tz: Option<&str>) -> Result<Self, FrameError>
Localize tz-naive datetime columns to a timezone or strip timezone info.
Matches the supported subset of pd.DataFrame.tz_localize(tz). Walks
every Utf8-typed column whose values look like ISO-8601 datetime
strings and applies DatetimeAccessor::tz_localize column-by-column.
Non-Utf8 columns and Utf8 columns whose contents don’t parse as
datetimes are passed through unchanged. Per br-frankenpandas-6iac0.
Note: pandas’ DataFrame.tz_localize operates on the index axis by
default; this implementation deviates by walking column VALUES because
fp-index doesn’t yet have a dedicated DatetimeIndex variant (tracked
separately under br-frankenpandas-t8hz0). When the DatetimeIndex
variant lands, this method should grow an axis parameter.
Sourcepub fn tz_localize_with_options(
&self,
tz: Option<&str>,
options: TzLocalizeOptions,
) -> Result<Self, FrameError>
pub fn tz_localize_with_options( &self, tz: Option<&str>, options: TzLocalizeOptions, ) -> Result<Self, FrameError>
Localize tz-naive datetime columns with explicit DST policy.
Matches the supported subset of pd.DataFrame.tz_localize(tz, ambiguous=..., nonexistent=...). Same column-walking rules as
Self::tz_localize.
Sourcepub fn tz_convert(&self, tz: Option<&str>) -> Result<Self, FrameError>
pub fn tz_convert(&self, tz: Option<&str>) -> Result<Self, FrameError>
Convert timezone-aware datetime columns to a different timezone.
Matches the supported subset of pd.DataFrame.tz_convert(tz). Walks
every Utf8 datetime-string column and applies DatetimeAccessor::tz_convert
column-by-column. Non-Utf8 columns are passed through; columns whose
values are tz-naive (no offset suffix) raise an error matching
pandas’ “Cannot convert tz-naive timestamps, use tz_localize” message.
Per br-frankenpandas-6iac0.
Same axis-deviation note as Self::tz_localize.
Sourcepub fn to_period(&self, freq: &str) -> Result<Self, FrameError>
pub fn to_period(&self, freq: &str) -> Result<Self, FrameError>
Convert a datetime-like row index to period-style labels.
Matches the row-index default of pd.DataFrame.to_period(freq) for the
supported Y, Q, M, W, D, B, H, T/min, and S
frequencies.
FrankenPandas stores the converted labels in the existing flat Index
as canonical period strings until a dedicated Period label variant lands.
Sourcepub fn to_timestamp(&self, freq: &str, how: &str) -> Result<Self, FrameError>
pub fn to_timestamp(&self, freq: &str, how: &str) -> Result<Self, FrameError>
Convert period-style row index labels to timestamp labels.
Matches the row-index default of pd.DataFrame.to_timestamp(freq, how)
for the supported Y, Q, M, D, H, T/min, and S
frequencies. Until FrankenPandas has a dedicated PeriodIndex label type,
this accepts the canonical period strings emitted by Self::to_period.
Sourcepub fn astype_columns_safe(
&self,
mapping: &[(&str, DType)],
errors: &str,
) -> Result<Self, FrameError>
pub fn astype_columns_safe( &self, mapping: &[(&str, DType)], errors: &str, ) -> Result<Self, FrameError>
Cast one or more columns with error handling.
Matches df.astype({"a": dtype}, errors='coerce'|'raise'|'ignore').
errors="raise"(default): propagate conversion errorserrors="coerce": values that fail conversion become NaNerrors="ignore": return the original DataFrame unchanged on error
Sourcepub fn astype_safe(
&self,
dtype: DType,
errors: &str,
) -> Result<Self, FrameError>
pub fn astype_safe( &self, dtype: DType, errors: &str, ) -> Result<Self, FrameError>
Cast all columns with error handling.
Matches df.astype(dtype, errors='coerce'|'raise'|'ignore').
Sourcepub fn drop_column(&self, name: &str) -> Result<Self, FrameError>
pub fn drop_column(&self, name: &str) -> Result<Self, FrameError>
Remove a column by name, returning the modified DataFrame.
Matches df.drop(columns=['col']).
Sourcepub fn drop_columns(&self, names: &[&str]) -> Result<Self, FrameError>
pub fn drop_columns(&self, names: &[&str]) -> Result<Self, FrameError>
Drop multiple columns at once.
Matches df.drop(columns=[...]). Returns error if any column is missing.
Sourcepub fn filter(
&self,
items: Option<&[&str]>,
like: Option<&str>,
regex: Option<&str>,
) -> Result<Self, FrameError>
pub fn filter( &self, items: Option<&[&str]>, like: Option<&str>, regex: Option<&str>, ) -> Result<Self, FrameError>
Filter the DataFrame by column-label patterns.
Matches pd.DataFrame.filter(items=None, like=None, regex=None, axis=1)
(column-axis filter). Exactly one of items, like, or regex must
be Some; the others must be None. Per br-frankenpandas-nk54a.
items: Some(list): keep columns whose names appear inlist, inlistorder. Missing names are silently dropped (matches pandas).like: Some(substr): keep columns whose names containsubstr.regex: Some(pattern): keep columns whose names match the regex.
Use DataFrame::filter_axis with axis=0 for row-index label
matching.
Sourcepub fn filter_axis(
&self,
items: Option<&[&str]>,
like: Option<&str>,
regex: Option<&str>,
axis: usize,
) -> Result<Self, FrameError>
pub fn filter_axis( &self, items: Option<&[&str]>, like: Option<&str>, regex: Option<&str>, axis: usize, ) -> Result<Self, FrameError>
Filter rows or columns by label.
Matches pd.DataFrame.filter(items=None, like=None, regex=None, axis=...).
axis=0: filter rows by row-index label string form.axis=1: filter columns by column label.
Exactly one of items, like, or regex must be provided. items
preserves the caller-provided item order and silently drops missing
labels.
Sourcepub fn rename(&self, mapping: &[(&str, &str)]) -> Result<Self, FrameError>
pub fn rename(&self, mapping: &[(&str, &str)]) -> Result<Self, FrameError>
pandas-named column rename alias.
Matches df.rename(columns={'old': 'new'}) for mapping-style
column renames.
Sourcepub fn rename_columns(
&self,
mapping: &[(&str, &str)],
) -> Result<Self, FrameError>
pub fn rename_columns( &self, mapping: &[(&str, &str)], ) -> Result<Self, FrameError>
Rename columns using a mapping.
Matches df.rename(columns={'old': 'new'}).
Sourcepub fn rename_columns_map(
&self,
mapping: &HashMap<String, String>,
) -> Result<Self, FrameError>
pub fn rename_columns_map( &self, mapping: &HashMap<String, String>, ) -> Result<Self, FrameError>
Rename columns using a HashMap mapping.
Convenience wrapper matching df.rename(columns={...}) semantics.
Only columns present in the mapping are renamed; others are kept as-is.
Sourcepub fn rename_with<F>(&self, func: F) -> Result<Self, FrameError>
pub fn rename_with<F>(&self, func: F) -> Result<Self, FrameError>
Rename columns using a mapper function.
Matches df.rename(columns=func). Applies the function to each column name.
Sourcepub fn rename_index(&self, mapping: &[(IndexLabel, IndexLabel)]) -> Self
pub fn rename_index(&self, mapping: &[(IndexLabel, IndexLabel)]) -> Self
Rename index labels using a mapping.
Matches df.rename(index={...}). Labels not in the mapping are
left unchanged.
Sourcepub fn rename_index_with<F>(&self, func: F) -> Self
pub fn rename_index_with<F>(&self, func: F) -> Self
Rename index labels using a function.
Matches df.rename(index=func). Applies the function to each
index label.
Sourcepub fn rename_axis(&self, name: &str) -> Result<Self, FrameError>
pub fn rename_axis(&self, name: &str) -> Result<Self, FrameError>
Rename the row index axis.
Matches pd.DataFrame.rename_axis(name) for flat row indexes.
Sourcepub fn add_prefix(&self, prefix: &str) -> Result<Self, FrameError>
pub fn add_prefix(&self, prefix: &str) -> Result<Self, FrameError>
Add a prefix to all column names.
Matches df.add_prefix(prefix).
Sourcepub fn add_suffix(&self, suffix: &str) -> Result<Self, FrameError>
pub fn add_suffix(&self, suffix: &str) -> Result<Self, FrameError>
Add a suffix to all column names.
Matches df.add_suffix(suffix).
Sourcepub fn add_prefix_axis(
&self,
prefix: &str,
axis: usize,
) -> Result<Self, FrameError>
pub fn add_prefix_axis( &self, prefix: &str, axis: usize, ) -> Result<Self, FrameError>
Add a prefix to labels along the chosen axis.
Matches df.add_prefix(prefix, axis=...). axis=0 prefixes the
index (labels are stringified), axis=1 prefixes column names.
Sourcepub fn add_suffix_axis(
&self,
suffix: &str,
axis: usize,
) -> Result<Self, FrameError>
pub fn add_suffix_axis( &self, suffix: &str, axis: usize, ) -> Result<Self, FrameError>
Add a suffix to labels along the chosen axis.
Matches df.add_suffix(suffix, axis=...). axis=0 suffixes the
index (labels are stringified), axis=1 suffixes column names.
Sourcepub fn describe(&self) -> Result<Self, FrameError>
pub fn describe(&self) -> Result<Self, FrameError>
Summary statistics for numeric columns.
Matches df.describe() — returns a DataFrame with index
[count, mean, std, min, 25%, 50%, 75%, max] and one column per
numeric input column.
Sourcepub fn describe_with_percentiles(
&self,
percentiles: &[f64],
) -> Result<Self, FrameError>
pub fn describe_with_percentiles( &self, percentiles: &[f64], ) -> Result<Self, FrameError>
Describe with custom percentiles.
Matches pd.DataFrame.describe(percentiles=[...]).
Sourcepub fn describe_dtypes(
&self,
include: &[&str],
exclude: &[&str],
) -> Result<Self, FrameError>
pub fn describe_dtypes( &self, include: &[&str], exclude: &[&str], ) -> Result<Self, FrameError>
Describe with include/exclude dtype filters.
Matches df.describe(include=[...], exclude=[...]). Pass empty
slices to use defaults (numeric only). Supported dtype strings:
“int64”, “float64”, “bool”, “object”/“string”.
Sourcepub fn quantile(&self, q: f64) -> Result<Series, FrameError>
pub fn quantile(&self, q: f64) -> Result<Series, FrameError>
Compute quantile(s) for each numeric column.
Matches df.quantile(q) for a single quantile value.
Returns a Series indexed by column names.
Sourcepub fn apply<A>(&self, func: A, axis: usize) -> Result<A::Output, FrameError>where
A: DataFrameApplyArg,
pub fn apply<A>(&self, func: A, axis: usize) -> Result<A::Output, FrameError>where
A: DataFrameApplyArg,
Apply either a built-in reducer name or a user closure along an axis.
df.apply("sum", 0)returns aSeries.df.apply(|vals| ..., 1)returns a single-columnDataFrame.
Sourcepub fn transpose(&self) -> Result<Self, FrameError>
pub fn transpose(&self) -> Result<Self, FrameError>
Transpose the DataFrame: rows become columns, columns become rows.
Matches df.T / df.transpose(). Column names become the index
of the result, and the original index labels become column names
(converted to strings).
Sourcepub fn t(&self) -> Result<Self, FrameError>
pub fn t(&self) -> Result<Self, FrameError>
Alias for transpose().
Matches df.T in pandas.
Sourcepub fn T(&self) -> Result<Self, FrameError>
pub fn T(&self) -> Result<Self, FrameError>
Uppercase pandas spelling for Self::transpose.
Rust style prefers Self::t, but pandas exposes df.T.
Sourcepub fn values(&self) -> Vec<Vec<Scalar>>
pub fn values(&self) -> Vec<Vec<Scalar>>
Return row-major scalar values.
Matches pd.DataFrame.values at the API-shape level. Unlike
Self::to_numpy, this preserves non-numeric scalar values.
Sourcepub fn product(&self) -> Result<Series, FrameError>
pub fn product(&self) -> Result<Series, FrameError>
Per-column product alias.
Matches pd.DataFrame.product() as an alias of prod().
Sourcepub fn get(&self, key: &str) -> Result<Option<Series>, FrameError>
pub fn get(&self, key: &str) -> Result<Option<Series>, FrameError>
Dict-like column lookup.
Matches pd.DataFrame.get(key) by returning None instead of an
error for a missing column.
Sourcepub fn get_or(&self, key: &str, default: Series) -> Result<Series, FrameError>
pub fn get_or(&self, key: &str, default: Series) -> Result<Series, FrameError>
Dict-like column lookup with a fallback Series.
Matches pd.DataFrame.get(key, default) for Series defaults.
Sourcepub fn bool_(&self) -> Result<bool, FrameError>
pub fn bool_(&self) -> Result<bool, FrameError>
Extract the single boolean value from a 1x1 DataFrame.
Matches pd.DataFrame.bool(). Raises unless the DataFrame has exactly
one row, one column, and that cell is a boolean scalar.
Sourcepub fn attrs(&self) -> BTreeMap<String, Scalar>
pub fn attrs(&self) -> BTreeMap<String, Scalar>
User metadata mapping.
Matches pd.DataFrame.attrs shape. FrankenPandas does not yet persist
mutable attrs on the DataFrame storage object, so the current accessor
returns the default empty metadata map.
Sourcepub fn flags(&self) -> DataFrameFlags
pub fn flags(&self) -> DataFrameFlags
DataFrame flags metadata.
Matches pd.DataFrame.flags for the duplicate-label flag currently
represented by FrankenPandas.
Sourcepub fn set_flags(
&self,
allows_duplicate_labels: Option<bool>,
) -> Result<Self, FrameError>
pub fn set_flags( &self, allows_duplicate_labels: Option<bool>, ) -> Result<Self, FrameError>
Return a DataFrame with updated flags.
Matches pd.DataFrame.set_flags(allows_duplicate_labels=...) for the
duplicate-label flag.
Sourcepub fn style(&self) -> StyledDataFrame<'_>
pub fn style(&self) -> StyledDataFrame<'_>
Styling accessor for DataFrame HTML and text rendering helpers.
Matches pd.DataFrame.style as a typed accessor over the current
DataFrame. The current implementation supports practical table
rendering methods such as StyledDataFrame::to_html,
StyledDataFrame::to_string_table, and classed HTML output.
Sourcepub fn sparse(&self) -> SparseDataFrameView<'_>
pub fn sparse(&self) -> SparseDataFrameView<'_>
Sparse accessor for DataFrame density and dense materialization helpers.
Matches pd.DataFrame.sparse as a typed accessor over the current
DataFrame. The current dense-backed implementation exposes non-fill
counts, density metrics, caller-provided fill-value variants, and
SparseDataFrameView::to_dense.
Sourcepub fn swapaxes(&self) -> Result<Self, FrameError>
pub fn swapaxes(&self) -> Result<Self, FrameError>
Swap axes (rows and columns).
Matches df.swapaxes('index', 'columns'). Alias for transpose().
Sourcepub fn lookup(
&self,
row_labels: &[IndexLabel],
col_labels: &[&str],
) -> Result<Vec<Scalar>, FrameError>
pub fn lookup( &self, row_labels: &[IndexLabel], col_labels: &[&str], ) -> Result<Vec<Scalar>, FrameError>
Label-based element lookup.
Matches df.lookup(row_labels, col_labels). Returns a Vec of Scalars
where element i is the value at (row_labels[i], col_labels[i]).
Sourcepub fn where_cond(
&self,
cond: &Self,
other: Option<&Scalar>,
) -> Result<Self, FrameError>
pub fn where_cond( &self, cond: &Self, other: Option<&Scalar>, ) -> Result<Self, FrameError>
Keep values where cond is True; replace others with other.
Matches df.where(cond, other). Applies element-wise to each column.
If other is None, replaced values become NaN.
Sourcepub fn where(
&self,
cond: &Self,
other: Option<&Scalar>,
) -> Result<Self, FrameError>
pub fn where( &self, cond: &Self, other: Option<&Scalar>, ) -> Result<Self, FrameError>
pandas-named alias for Self::where_cond. Matches df.where(cond, other).
Per br-frankenpandas-nk54a. where would conflict with the Rust
keyword in where clauses if used as an identifier in some
contexts, but it’s not a reserved identifier — the inherent
method works directly. Provided as a pandas-faithful alias.
Sourcepub fn mask(
&self,
cond: &Self,
other: Option<&Scalar>,
) -> Result<Self, FrameError>
pub fn mask( &self, cond: &Self, other: Option<&Scalar>, ) -> Result<Self, FrameError>
Replace values where cond is True with other.
Matches df.mask(cond, other). Inverse of where_cond.
Sourcepub fn where_cond_df(
&self,
cond: &Self,
other: &Self,
) -> Result<Self, FrameError>
pub fn where_cond_df( &self, cond: &Self, other: &Self, ) -> Result<Self, FrameError>
Keep values where cond is True, replacing False positions with
corresponding values from other DataFrame.
Matches df.where(cond, other=df).
Sourcepub fn mask_df_other(
&self,
cond: &Self,
other: &Self,
) -> Result<Self, FrameError>
pub fn mask_df_other( &self, cond: &Self, other: &Self, ) -> Result<Self, FrameError>
Replace values where cond is True with corresponding values from
other DataFrame.
Matches df.mask(cond, other=df).
Sourcepub fn where_mask_df_other(
&self,
cond: &Self,
other: &Self,
) -> Result<Self, FrameError>
pub fn where_mask_df_other( &self, cond: &Self, other: &Self, ) -> Result<Self, FrameError>
Symmetry alias for where_cond_df (br-frankenpandas-df9v7 /
fd90.138, refactored in br-frankenpandas-a2sck / fd90.139).
mask_df_other already existed but no parallel-named where_* was
reachable from a mask_df_other callsite without remembering the
where_cond_df name. This alias makes the symmetry explicit; both
names dispatch through the same implementation. Prefer where_cond_df
in new code.
Sourcepub fn iterrows(&self) -> Vec<(IndexLabel, Vec<(&str, Scalar)>)>
pub fn iterrows(&self) -> Vec<(IndexLabel, Vec<(&str, Scalar)>)>
Iterate over rows as (IndexLabel, Vec<(&str, Scalar)>) pairs.
Matches df.iterrows(). Returns an iterator over (index_label, row_data)
where row_data is a vector of (column_name, value) pairs.
Sourcepub fn itertuples(&self) -> Vec<(IndexLabel, Vec<Scalar>)>
pub fn itertuples(&self) -> Vec<(IndexLabel, Vec<Scalar>)>
Iterate over rows as tuples of (IndexLabel, Vec<Scalar>).
Matches df.itertuples(). Returns (index_label, values_in_column_order).
Sourcepub fn to_records(&self) -> Vec<Vec<Scalar>>
pub fn to_records(&self) -> Vec<Vec<Scalar>>
Convert DataFrame to a list of record tuples.
Matches df.to_records(). Each record is a Vec of Scalar where the
first element is the index label (converted to Scalar) followed by
each column value in column order.
Sourcepub fn to_numpy_2d(&self) -> Vec<Vec<f64>>
pub fn to_numpy_2d(&self) -> Vec<Vec<f64>>
Convert numeric columns to a 2D Vec<Vec<f64>>.
Matches df.to_numpy(). Rows are outer, columns are inner.
Non-numeric values become f64::NAN.
Sourcepub fn items(&self) -> Result<Vec<(String, Series)>, FrameError>
pub fn items(&self) -> Result<Vec<(String, Series)>, FrameError>
Iterate over columns as (column_name, Series) pairs.
Matches df.items() / df.iteritems().
§Panics
Panics if self.column_order references a column that is absent from
self.columns, which indicates internal DataFrame metadata corruption.
Sourcepub fn iteritems(&self) -> Result<Vec<(String, Series)>, FrameError>
👎Deprecated: use items() instead
pub fn iteritems(&self) -> Result<Vec<(String, Series)>, FrameError>
use items() instead
Alias for items (deprecated in pandas but kept for compatibility).
Sourcepub fn assign(
&self,
assignments: Vec<(&str, Column)>,
) -> Result<Self, FrameError>
pub fn assign( &self, assignments: Vec<(&str, Column)>, ) -> Result<Self, FrameError>
Assign new or overwrite existing columns.
Matches df.assign(**kwargs). Takes a list of (column_name, Column) pairs.
Existing columns are replaced; new columns are appended.
Sourcepub fn assign_fn(
&self,
assignments: Vec<(&str, Box<dyn Fn(&DataFrame) -> Result<Column, FrameError>>)>,
) -> Result<Self, FrameError>
pub fn assign_fn( &self, assignments: Vec<(&str, Box<dyn Fn(&DataFrame) -> Result<Column, FrameError>>)>, ) -> Result<Self, FrameError>
Assign new columns computed from the DataFrame via closures.
Matches df.assign(col=lambda df: ...). Each closure receives a
reference to the current DataFrame (including previously-assigned
columns in this call) and must return a Column of the correct length.
Sourcepub fn pipe<F>(&self, func: F) -> Result<Self, FrameError>
pub fn pipe<F>(&self, func: F) -> Result<Self, FrameError>
Apply a transformation function to the DataFrame.
Matches df.pipe(func). The function receives a reference to self
and returns a new DataFrame.
Sourcepub fn rank(
&self,
method: &str,
ascending: bool,
na_option: &str,
) -> Result<Self, FrameError>
pub fn rank( &self, method: &str, ascending: bool, na_option: &str, ) -> Result<Self, FrameError>
Rank values in each column of the DataFrame.
Applies Series::rank independently to each column.
Sourcepub fn rank_with_pct(
&self,
method: &str,
ascending: bool,
na_option: &str,
pct: bool,
) -> Result<Self, FrameError>
pub fn rank_with_pct( &self, method: &str, ascending: bool, na_option: &str, pct: bool, ) -> Result<Self, FrameError>
Rank values in each column of the DataFrame and optionally scale them to percentile ranks.
Sourcepub fn rank_axis1(
&self,
method: &str,
ascending: bool,
na_option: &str,
) -> Result<Self, FrameError>
pub fn rank_axis1( &self, method: &str, ascending: bool, na_option: &str, ) -> Result<Self, FrameError>
Ranks values across columns for each row independently.
Matches pd.DataFrame.rank(axis=1).
Sourcepub fn rank_axis1_with_pct(
&self,
method: &str,
ascending: bool,
na_option: &str,
pct: bool,
) -> Result<Self, FrameError>
pub fn rank_axis1_with_pct( &self, method: &str, ascending: bool, na_option: &str, pct: bool, ) -> Result<Self, FrameError>
Rank values across columns for each row and optionally scale them to percentile ranks.
Sourcepub fn melt(
&self,
id_vars: &[&str],
value_vars: &[&str],
var_name: Option<&str>,
value_name: Option<&str>,
) -> Result<Self, FrameError>
pub fn melt( &self, id_vars: &[&str], value_vars: &[&str], var_name: Option<&str>, value_name: Option<&str>, ) -> Result<Self, FrameError>
Unpivot (melt) a DataFrame from wide to long format.
id_vars: columns to keep as identifiers
value_vars: columns to unpivot (if empty, uses all non-id columns)
var_name: name for the variable column (default “variable”)
value_name: name for the value column (default “value”)
Sourcepub fn pivot_table(
&self,
values: &str,
index_col: &str,
columns_col: &str,
aggfunc: &str,
) -> Result<Self, FrameError>
pub fn pivot_table( &self, values: &str, index_col: &str, columns_col: &str, aggfunc: &str, ) -> Result<Self, FrameError>
Pivot table: aggregate values grouped by index and column keys.
values: column containing values to aggregate
index_col: column to use as the new row index
columns_col: column whose unique values become new columns
aggfunc: aggregation function (“mean”, “sum”, “count”, “size”, “min”, “max”, “first”, “last”)
Sourcepub fn pivot_table_with_dropna(
&self,
values: &str,
index_col: &str,
columns_col: &str,
aggfunc: &str,
dropna: bool,
) -> Result<Self, FrameError>
pub fn pivot_table_with_dropna( &self, values: &str, index_col: &str, columns_col: &str, aggfunc: &str, dropna: bool, ) -> Result<Self, FrameError>
Pivot table with explicit control over whether missing index/column keys are dropped before aggregation.
Matches df.pivot_table(..., dropna=...) for the core single-value
case. The default pivot_table() wrapper uses dropna=true.
Sourcepub fn pivot_table_fill(
&self,
values: &str,
index_col: &str,
columns_col: &str,
aggfunc: &str,
fill_value: f64,
) -> Result<Self, FrameError>
pub fn pivot_table_fill( &self, values: &str, index_col: &str, columns_col: &str, aggfunc: &str, fill_value: f64, ) -> Result<Self, FrameError>
Create a pivot table with a fill_value for missing cells.
Matches df.pivot_table(values, index, columns, aggfunc, fill_value=v).
Sourcepub fn pivot_table_multi_values(
&self,
values: &[&str],
index_col: &str,
columns_col: &str,
aggfunc: &str,
) -> Result<Self, FrameError>
pub fn pivot_table_multi_values( &self, values: &[&str], index_col: &str, columns_col: &str, aggfunc: &str, ) -> Result<Self, FrameError>
Create a pivot table with multiple value columns.
Matches df.pivot_table(values=['col1','col2'], index=..., columns=..., aggfunc=...).
Column names in the result are formatted as “value_column_pivot_value”
(e.g. “sales_East”, “profit_East”).
Sourcepub fn pivot_table_aggfunc_dict(
&self,
value_aggs: &[(&str, &str)],
index_col: &str,
columns_col: &str,
) -> Result<Self, FrameError>
pub fn pivot_table_aggfunc_dict( &self, value_aggs: &[(&str, &str)], index_col: &str, columns_col: &str, ) -> Result<Self, FrameError>
Create a pivot table where each value column uses its own aggregation.
Matches df.pivot_table(values=[...], index=..., columns=..., aggfunc={'col1':'sum','col2':'mean'}).
Each (value_col, aggfunc) entry is pivoted independently and the
result columns are prefixed with the value column name
({value_col}_{pivot_column}), matching the layout of
pivot_table_multi_values. Duplicate value column names are rejected
(a dict has unique keys). Missing columns and unsupported aggfuncs
propagate from the single-value pivot_table call.
Sourcepub fn pivot_table_with_margins(
&self,
values: &str,
index_col: &str,
columns_col: &str,
aggfunc: &str,
margins: bool,
) -> Result<Self, FrameError>
pub fn pivot_table_with_margins( &self, values: &str, index_col: &str, columns_col: &str, aggfunc: &str, margins: bool, ) -> Result<Self, FrameError>
Create a pivot table with optional margin totals.
Matches df.pivot_table(values, index, columns, aggfunc, margins=True).
When margins is true, appends an “All” row and “All” column with
totals computed using the same aggregation function.
Sourcepub fn pivot_table_with_margins_name(
&self,
values: &str,
index_col: &str,
columns_col: &str,
aggfunc: &str,
margins: bool,
margins_name: &str,
) -> Result<Self, FrameError>
pub fn pivot_table_with_margins_name( &self, values: &str, index_col: &str, columns_col: &str, aggfunc: &str, margins: bool, margins_name: &str, ) -> Result<Self, FrameError>
Pivot table with margins and a customizable margin label.
Like pivot_table_with_margins but allows specifying the label used
for the margin row/column (default is “All” in pandas).
Sourcepub fn agg(
&self,
funcs: &HashMap<String, Vec<String>>,
) -> Result<Self, FrameError>
pub fn agg( &self, funcs: &HashMap<String, Vec<String>>, ) -> Result<Self, FrameError>
Aggregate using one or more operations over the specified axis.
funcs: mapping of column_name → list of aggregation function names.
Returns a DataFrame with index = function names and columns = original column names.
Sourcepub fn aggregate(
&self,
funcs: &HashMap<String, Vec<String>>,
) -> Result<Self, FrameError>
pub fn aggregate( &self, funcs: &HashMap<String, Vec<String>>, ) -> Result<Self, FrameError>
pandas alias for Self::agg.
Matches pd.DataFrame.aggregate(...) for dict-style column
aggregation specifications.
Sourcepub fn applymap<F>(&self, func: F) -> Result<Self, FrameError>
pub fn applymap<F>(&self, func: F) -> Result<Self, FrameError>
Apply a function element-wise to every value in the DataFrame.
Returns a new DataFrame with the same shape and index.
Sourcepub fn map<F>(&self, func: F) -> Result<Self, FrameError>
pub fn map<F>(&self, func: F) -> Result<Self, FrameError>
pandas-2.1+ alias for Self::applymap. Matches df.map(func).
Per br-frankenpandas-nk54a. pandas 2.1 deprecated applymap in
favor of map; this alias supports the new spelling so users
migrating from pandas 2.x don’t need to rename.
Sourcepub fn applymap_na_action<F>(&self, func: F) -> Result<Self, FrameError>
pub fn applymap_na_action<F>(&self, func: F) -> Result<Self, FrameError>
Apply a function element-wise, skipping missing values.
Matches df.applymap(func, na_action='ignore'). Missing values
(Null/NaN) are passed through unchanged; func is only called on
non-missing values.
Sourcepub fn map_elements<F>(&self, func: F) -> Result<Self, FrameError>
pub fn map_elements<F>(&self, func: F) -> Result<Self, FrameError>
Apply a function element-wise (pandas 2.0 name for applymap).
Matches pd.DataFrame.map(func).
Sourcepub fn transform<F>(&self, func: F) -> Result<Self, FrameError>
pub fn transform<F>(&self, func: F) -> Result<Self, FrameError>
Apply a function element-wise, preserving the shape of the DataFrame.
Similar to applymap but validates that the output has the same shape.
Sourcepub fn pivot_table_multi_agg(
&self,
values: &str,
index_col: &str,
columns_col: &str,
aggfuncs: &[&str],
) -> Result<Self, FrameError>
pub fn pivot_table_multi_agg( &self, values: &str, index_col: &str, columns_col: &str, aggfuncs: &[&str], ) -> Result<Self, FrameError>
Create a pivot table applying multiple aggregation functions.
Matches df.pivot_table(values, index, columns, aggfunc=['sum','mean']).
Returns a DataFrame with columns named "{col}_{func}" for each
combination of pivot column value and aggregation function.
Sourcepub fn corr(&self) -> Result<Self, FrameError>
pub fn corr(&self) -> Result<Self, FrameError>
Compute the Pearson correlation matrix between numeric columns.
Examples found in repository?
28fn main() {
29 let n: usize = std::env::args()
30 .nth(1)
31 .and_then(|s| s.parse().ok())
32 .unwrap_or(1_000_000);
33 let m: usize = std::env::args()
34 .nth(2)
35 .and_then(|s| s.parse().ok())
36 .unwrap_or(8);
37
38 let labels: Vec<IndexLabel> = (0..n as i64).map(IndexLabel::Int64).collect();
39 let index = Index::new(labels);
40 let mut columns = BTreeMap::new();
41 let mut order = Vec::with_capacity(m);
42 let mut input = Vec::<f64>::with_capacity(n * m);
43 for c in 0..m {
44 let col: Vec<f64> = (0..n).map(|i| splitmix_unit(i, c)).collect();
45 input.extend_from_slice(&col); // col-major: c0 rows, c1 rows, ...
46 let name = format!("c{c}");
47 columns.insert(name.clone(), Column::from_f64_values(col));
48 order.push(name);
49 }
50 let df = DataFrame::new_with_column_order(index, columns, order.clone()).expect("frame");
51
52 let corr = df.corr().expect("corr");
53 // corr is m x m; extract row-major by the same column order.
54 let mut fp = Vec::<f64>::with_capacity(m * m);
55 for ri in 0..m {
56 let col = corr.column(&order[ri]).expect("corr col");
57 let vals = col.values();
58 for cj in 0..m {
59 fp.push(vals[cj].to_f64().unwrap_or(f64::NAN));
60 }
61 }
62
63 let _ = input;
64 let mut line = String::from("FPCORR");
65 for x in &fp {
66 line.push(' ');
67 line.push_str(&format!("{x:.17e}"));
68 }
69 let mut out = std::io::stdout().lock();
70 writeln!(out, "DIMS {n} {m}").unwrap();
71 writeln!(out, "{line}").unwrap();
72}Sourcepub fn corr_with_numeric_only(
&self,
numeric_only: bool,
) -> Result<Self, FrameError>
pub fn corr_with_numeric_only( &self, numeric_only: bool, ) -> Result<Self, FrameError>
Compute the Pearson correlation matrix, optionally restricting to numeric dtypes.
Matches df.corr(numeric_only=...). Boolean columns are treated as numeric,
and non-numeric columns are excluded from the result.
Sourcepub fn corr_min_periods(&self, min_periods: usize) -> Result<Self, FrameError>
pub fn corr_min_periods(&self, min_periods: usize) -> Result<Self, FrameError>
Compute pairwise Pearson correlation with a minimum-observations threshold.
Matches df.corr(min_periods=n). Pairs with fewer than min_periods
valid (non-NaN) observations yield NaN.
Sourcepub fn corr_min_periods_with_numeric_only(
&self,
min_periods: usize,
numeric_only: bool,
) -> Result<Self, FrameError>
pub fn corr_min_periods_with_numeric_only( &self, min_periods: usize, numeric_only: bool, ) -> Result<Self, FrameError>
Compute pairwise Pearson correlation with a minimum-observations threshold.
Matches df.corr(min_periods=n, numeric_only=...).
Sourcepub fn corr_method(&self, method: &str) -> Result<Self, FrameError>
pub fn corr_method(&self, method: &str) -> Result<Self, FrameError>
Compute correlation matrix using the specified method.
Supported methods: “pearson”, “spearman”, “kendall”.
Sourcepub fn corr_method_with_numeric_only(
&self,
method: &str,
numeric_only: bool,
) -> Result<Self, FrameError>
pub fn corr_method_with_numeric_only( &self, method: &str, numeric_only: bool, ) -> Result<Self, FrameError>
Compute correlation matrix using the specified method and numeric_only policy.
Supported methods: “pearson”, “spearman”, “kendall”.
Sourcepub fn cov(&self) -> Result<Self, FrameError>
pub fn cov(&self) -> Result<Self, FrameError>
Compute the pairwise covariance matrix between numeric columns.
Sourcepub fn cov_min_periods(&self, min_periods: usize) -> Result<Self, FrameError>
pub fn cov_min_periods(&self, min_periods: usize) -> Result<Self, FrameError>
Compute pairwise covariance with a minimum-observations threshold.
Matches df.cov(min_periods=n). Pairs with fewer than min_periods
valid (non-NaN) observations yield NaN.
Sourcepub fn corrwith(&self, other: &Self) -> Result<Series, FrameError>
pub fn corrwith(&self, other: &Self) -> Result<Series, FrameError>
Column-wise correlation with another DataFrame.
Matches df.corrwith(other). Returns a Series of Pearson correlations
for each shared numeric column.
Sourcepub fn corrwith_axis(
&self,
other: &Self,
axis: usize,
) -> Result<Series, FrameError>
pub fn corrwith_axis( &self, other: &Self, axis: usize, ) -> Result<Series, FrameError>
Compute pairwise correlation with another DataFrame along the given axis.
Matches df.corrwith(other, axis=...).
axis=0(default): correlate matching columnsaxis=1: correlate matching rows
Examples found in repository?
34fn golden() -> String {
35 // self has rows r0,r1,r2,r3 ; other has r1 (dup, first wins), r0, r3, rX.
36 let s = frame(
37 vec![lbl("r0"), lbl("r1"), lbl("r2"), lbl("r3")],
38 vec![
39 ("a", vec![1.0, 2.0, 3.0, 4.0]),
40 ("b", vec![2.0, 1.0, 5.0, 4.0]),
41 ("c", vec![9.0, 8.0, 7.0, 1.0]),
42 ],
43 );
44 let o = frame(
45 vec![lbl("r1"), lbl("r0"), lbl("r3"), lbl("r1"), lbl("rX")],
46 vec![
47 ("a", vec![5.0, 1.5, 4.0, -9.0, 0.0]),
48 ("b", vec![6.0, 2.5, 3.0, -9.0, 0.0]),
49 ("c", vec![1.0, 0.5, 8.0, -9.0, 0.0]),
50 ],
51 );
52 let r = s.corrwith_axis(&o, 1).unwrap();
53 let mut out = String::new();
54 out.push_str(&format!("labels={:?}\n", r.index().labels()));
55 // Round values to 9 decimals for a stable digest.
56 let vals: Vec<String> = r
57 .column()
58 .values()
59 .iter()
60 .map(|v| match v {
61 Scalar::Float64(f) if f.is_nan() => "nan".to_string(),
62 Scalar::Float64(f) => format!("{:.9}", f),
63 other => format!("{other:?}"),
64 })
65 .collect();
66 out.push_str(&format!("values={:?}\n", vals));
67 out
68}
69
70fn main() {
71 let g = golden();
72 print!("GOLDEN_BEGIN\n{g}GOLDEN_END\n");
73
74 // Large non-ascending-Int64 (string) index so position() is linear.
75 let n: usize = 20_000;
76 let labels: Vec<IndexLabel> = (0..n).map(|i| lbl(&format!("k{i:08}"))).collect();
77 let mkcol = |mult: f64| (0..n).map(|i| (i as f64) * mult).collect::<Vec<f64>>();
78 let s = frame(
79 labels.clone(),
80 vec![
81 ("a", mkcol(1.0)),
82 ("b", mkcol(2.0)),
83 ("c", mkcol(0.5)),
84 ("d", mkcol(3.0)),
85 ],
86 );
87 // other: same labels, reversed order (so a sorted shortcut can't apply).
88 let mut rlabels = labels.clone();
89 rlabels.reverse();
90 let o = frame(
91 rlabels,
92 vec![
93 ("a", mkcol(1.1)),
94 ("b", mkcol(2.2)),
95 ("c", mkcol(0.7)),
96 ("d", mkcol(3.3)),
97 ],
98 );
99
100 // warmup
101 let _ = s.corrwith_axis(&o, 1).unwrap();
102
103 let t = Instant::now();
104 let r = s.corrwith_axis(&o, 1).unwrap();
105 let d = t.elapsed();
106 assert_eq!(r.len(), n);
107
108 println!("TIMING n={n} corrwith_axis1={:.3}ms", d.as_secs_f64() * 1e3);
109}Sourcepub fn dot(&self, other: &Self) -> Result<Self, FrameError>
pub fn dot(&self, other: &Self) -> Result<Self, FrameError>
Matrix dot product with another DataFrame.
Matches df.dot(other). Computes matrix multiplication where
self’s columns are matched to other’s index.
Sourcepub fn value_counts_per_column(&self) -> Result<Self, FrameError>
pub fn value_counts_per_column(&self) -> Result<Self, FrameError>
Compute the number of unique values per column.
Sourcepub fn iat(&self, row_pos: i64, col_pos: i64) -> Result<Scalar, FrameError>
pub fn iat(&self, row_pos: i64, col_pos: i64) -> Result<Scalar, FrameError>
Single-cell access by integer (row_pos, col_pos).
Matches pd.DataFrame.iat[i, j]. Negative positions count
from the end (pandas convention). Returns
CompatibilityRejected for out-of-range row or column
positions.
Sourcepub fn set_axis(
&self,
labels: Vec<IndexLabel>,
axis: usize,
) -> Result<Self, FrameError>
pub fn set_axis( &self, labels: Vec<IndexLabel>, axis: usize, ) -> Result<Self, FrameError>
Replace the row index or column names without touching data.
Matches pd.DataFrame.set_axis(labels, axis=0|1):
axis=0: replace the row index withlabels.axis=1: replace column names with stringifiedlabels.
Returns LengthMismatch when labels.len() doesn’t match the
chosen axis; returns CompatibilityRejected for unknown axis.
Sourcepub fn at(&self, label: &IndexLabel, column: &str) -> Result<Scalar, FrameError>
pub fn at(&self, label: &IndexLabel, column: &str) -> Result<Scalar, FrameError>
Single-cell access by (row label, column name).
Matches pd.DataFrame.at[label, col]. Returns None when the
row label is not present in the index or the column name is
unknown. Use .iloc / iat-style positional access on the
underlying Index+Column for integer positions.
Sourcepub fn value_counts_map(&self) -> Result<BTreeMap<String, Series>, FrameError>
pub fn value_counts_map(&self) -> Result<BTreeMap<String, Series>, FrameError>
Per-column value counts as a map of Series.
Returns {column_name → Series} where each Series is the
value_counts() result for that column. This is distinct from
both value_counts() (counts unique full-row tuples) and
value_counts_per_column() (returns a nunique summary
DataFrame). Callers who want the pandas idiom
{col: df[col].value_counts() for col in df.columns} get it
in one pass here.
Sourcepub fn value_counts(&self) -> Result<Series, FrameError>
pub fn value_counts(&self) -> Result<Series, FrameError>
Count unique rows in the DataFrame.
Matches pd.DataFrame.value_counts(). Returns a Series indexed by
composite row values, with counts as values, sorted descending.
Sourcepub fn value_counts_subset(&self, subset: &[&str]) -> Result<Series, FrameError>
pub fn value_counts_subset(&self, subset: &[&str]) -> Result<Series, FrameError>
Count unique value combinations for a subset of columns.
Matches df.value_counts(subset=['col1','col2']). Counts
combinations of values in the specified columns only.
Sourcepub fn infer_objects(&self) -> Result<Self, FrameError>
pub fn infer_objects(&self) -> Result<Self, FrameError>
Infer better dtypes for object columns.
Matches pd.DataFrame.infer_objects(). Attempts to convert Utf8
columns to numeric types. Delegates to per-column convert_dtypes.
Sourcepub fn nlargest(&self, n: usize, column: &str) -> Result<Self, FrameError>
pub fn nlargest(&self, n: usize, column: &str) -> Result<Self, FrameError>
Get the top N rows ordered by a column.
Sourcepub fn nsmallest(&self, n: usize, column: &str) -> Result<Self, FrameError>
pub fn nsmallest(&self, n: usize, column: &str) -> Result<Self, FrameError>
Get the bottom N rows ordered by a column.
Sourcepub fn nlargest_multi(
&self,
n: usize,
columns: &[&str],
) -> Result<Self, FrameError>
pub fn nlargest_multi( &self, n: usize, columns: &[&str], ) -> Result<Self, FrameError>
Get the top N rows ordered by multiple columns.
Matches df.nlargest(n, columns=[...]).
Sourcepub fn nsmallest_multi(
&self,
n: usize,
columns: &[&str],
) -> Result<Self, FrameError>
pub fn nsmallest_multi( &self, n: usize, columns: &[&str], ) -> Result<Self, FrameError>
Get the bottom N rows ordered by multiple columns.
Matches df.nsmallest(n, columns=[...]).
Sourcepub fn nlargest_keep(
&self,
n: usize,
column: &str,
keep: &str,
) -> Result<Self, FrameError>
pub fn nlargest_keep( &self, n: usize, column: &str, keep: &str, ) -> Result<Self, FrameError>
Get the top N rows with keep parameter.
Matches pd.DataFrame.nlargest(n, columns, keep).
- “first”: keep first occurrence (default)
- “last”: keep last occurrence
- “all”: keep all tied values (may return more than n rows)
Sourcepub fn nsmallest_keep(
&self,
n: usize,
column: &str,
keep: &str,
) -> Result<Self, FrameError>
pub fn nsmallest_keep( &self, n: usize, column: &str, keep: &str, ) -> Result<Self, FrameError>
Get the bottom N rows with keep parameter.
Matches pd.DataFrame.nsmallest(n, columns, keep).
Sourcepub fn take(&self, indices: &[i64], axis: usize) -> Result<Self, FrameError>
pub fn take(&self, indices: &[i64], axis: usize) -> Result<Self, FrameError>
Return the elements in the given positional indices along an axis.
Matches df.take(indices, axis=0|1), including negative indices from the end.
Examples found in repository?
37fn golden() -> String {
38 let mut out = String::new();
39 let df = frame(
40 vec![10, 11, 12, 13, 14],
41 vec![100, 200, 300, 400, 500],
42 vec![
43 Scalar::Float64(1.5),
44 Scalar::Float64(f64::NAN),
45 Scalar::Float64(-3.0),
46 Scalar::Float64(2.0),
47 Scalar::Float64(9.0),
48 ],
49 );
50
51 // iloc: reorder + negative + duplicate
52 out.push_str(&format!(
53 "iloc={}\n",
54 dump(&df.iloc(&[4, 0, -1, 2, 2]).unwrap())
55 ));
56 out.push_str(&format!("iloc_oob_err={}\n", df.iloc(&[99]).is_err()));
57 // take axis=0
58 out.push_str(&format!(
59 "take={}\n",
60 dump(&df.take(&[3, 1, 0], 0).unwrap())
61 ));
62 out.push_str(&format!("take_oob_err={}\n", df.take(&[99], 0).is_err()));
63 // sample deterministic (fixed seed)
64 out.push_str(&format!(
65 "sample={}\n",
66 dump(&df.sample(Some(3), None, false, Some(7)).unwrap())
67 ));
68 out
69}Sourcepub fn take_rows(&self, indices: &[usize]) -> Result<Self, FrameError>
pub fn take_rows(&self, indices: &[usize]) -> Result<Self, FrameError>
Helper for selecting rows by normalized non-negative positional indices.
Used by df.take(indices, axis=0) after negative indices have been resolved.
Sourcepub fn fillna_method(&self, method: &str) -> Result<Self, FrameError>
pub fn fillna_method(&self, method: &str) -> Result<Self, FrameError>
Fill missing values using a method (‘ffill’ or ‘bfill’).
Matches pd.DataFrame.fillna(method='ffill') / method='bfill'.
Sourcepub fn reindex(&self, new_labels: Vec<IndexLabel>) -> Result<Self, FrameError>
pub fn reindex(&self, new_labels: Vec<IndexLabel>) -> Result<Self, FrameError>
Reindex the DataFrame to a new set of index labels.
Missing rows are filled with NaN.
Sourcepub fn reindex_like(&self, other: &Self) -> Result<Self, FrameError>
pub fn reindex_like(&self, other: &Self) -> Result<Self, FrameError>
Reindex this DataFrame to match another DataFrame’s row index.
Matches pd.DataFrame.reindex_like(other) for row-index alignment.
Sourcepub fn reindex_axis(
&self,
labels: Vec<IndexLabel>,
axis: usize,
) -> Result<Self, FrameError>
pub fn reindex_axis( &self, labels: Vec<IndexLabel>, axis: usize, ) -> Result<Self, FrameError>
Conform DataFrame to new index or columns.
Matches pd.DataFrame.reindex(labels, axis=...).
Sourcepub fn reindex_fill(
&self,
new_labels: Vec<IndexLabel>,
fill_value: Scalar,
) -> Result<Self, FrameError>
pub fn reindex_fill( &self, new_labels: Vec<IndexLabel>, fill_value: Scalar, ) -> Result<Self, FrameError>
Reindex with a static fill_value for missing labels.
Matches df.reindex(new_labels, fill_value=X). Labels not found
in the current index are filled with fill_value instead of NaN.
Sourcepub fn reindex_with_method(
&self,
new_labels: Vec<IndexLabel>,
method: &str,
) -> Result<Self, FrameError>
pub fn reindex_with_method( &self, new_labels: Vec<IndexLabel>, method: &str, ) -> Result<Self, FrameError>
Reindex to new labels with a fill method for introduced NaN.
Matches df.reindex(new_labels, method='ffill'|'bfill').
After reindexing, missing values introduced by new labels are filled.
Sourcepub fn reindex_columns(&self, new_columns: &[&str]) -> Result<Self, FrameError>
pub fn reindex_columns(&self, new_columns: &[&str]) -> Result<Self, FrameError>
Reindex columns: reorder, filter, or add columns.
Matches df.reindex(columns=[...]). Columns present in the new list
but missing from the DataFrame are filled with NaN. Columns not in the
new list are dropped. Order follows the provided list.
Sourcepub fn update(&self, other: &Self) -> Result<Self, FrameError>
pub fn update(&self, other: &Self) -> Result<Self, FrameError>
Update values using non-null values from another DataFrame.
Analogous to pandas.DataFrame.update(other). Only updates values
at matching index labels and column names where other has non-null
values. Retains self’s index and columns (no new labels/columns
added from other).
Sourcepub fn combine_first(&self, other: &Self) -> Result<Self, FrameError>
pub fn combine_first(&self, other: &Self) -> Result<Self, FrameError>
Combine two DataFrames, preferring non-null values from self.
Analogous to pandas.DataFrame.combine_first(other). Uses union
of indices and columns. For overlapping positions, uses self’s value
if non-null, else other’s value.
Sourcepub fn combine_elementwise<F>(
&self,
other: &Self,
func: F,
) -> Result<Self, FrameError>
pub fn combine_elementwise<F>( &self, other: &Self, func: F, ) -> Result<Self, FrameError>
Combine two DataFrames element-wise using a binary function.
Matches df.combine(other, func). Aligns on both index and columns
(union), filling missing positions with NaN before applying func.
Sourcepub fn combine<F>(
&self,
other: &Self,
func: F,
fill_value: Option<&Scalar>,
overwrite: bool,
) -> Result<Self, FrameError>
pub fn combine<F>( &self, other: &Self, func: F, fill_value: Option<&Scalar>, overwrite: bool, ) -> Result<Self, FrameError>
Combine the DataFrame with another DataFrame using a column-wise function.
Matches pd.DataFrame.combine(other, func, fill_value=None, overwrite=True).
Sourcepub fn rolling(
&self,
window: usize,
min_periods: Option<usize>,
) -> DataFrameRolling<'_>
pub fn rolling( &self, window: usize, min_periods: Option<usize>, ) -> DataFrameRolling<'_>
Create a rolling window view over all numeric columns.
Matches df.rolling(window) semantics.
Sourcepub fn expanding(&self, min_periods: Option<usize>) -> DataFrameExpanding<'_>
pub fn expanding(&self, min_periods: Option<usize>) -> DataFrameExpanding<'_>
Create an expanding window view over all numeric columns.
Matches df.expanding(min_periods) semantics.
Sourcepub fn ewm(&self, span: Option<f64>, alpha: Option<f64>) -> DataFrameEwm<'_>
pub fn ewm(&self, span: Option<f64>, alpha: Option<f64>) -> DataFrameEwm<'_>
Create an exponentially weighted moving window view over all numeric columns.
Matches df.ewm(span=...) semantics.
Sourcepub fn resample(&self, freq: &str) -> DataFrameResample<'_>
pub fn resample(&self, freq: &str) -> DataFrameResample<'_>
Create a time-based resampler view for the DataFrame.
Matches df.resample(freq). The DataFrame must have Utf8 datetime-like
index labels. Applies aggregation to each numeric column per time bucket.
Sourcepub fn asfreq(&self, freq: &str) -> Result<Self, FrameError>
pub fn asfreq(&self, freq: &str) -> Result<Self, FrameError>
Conform the row index to a datetime frequency.
Matches the row-axis default of pd.DataFrame.asfreq(freq) for flat,
strictly increasing datetime-like indexes. Missing rows introduced by
the new frequency are filled with NaN.
Sourcepub fn asfreq_with_options(
&self,
freq: &str,
method: Option<&str>,
fill_value: Option<Scalar>,
) -> Result<Self, FrameError>
pub fn asfreq_with_options( &self, freq: &str, method: Option<&str>, fill_value: Option<Scalar>, ) -> Result<Self, FrameError>
Conform the row index to a datetime frequency with optional fill.
method accepts pandas spellings "ffill"/"pad" and
"bfill"/"backfill" for labels introduced by the frequency grid.
fill_value, when present, fills any remaining missing values after
reindexing/method fill.
Sourcepub fn between_time(&self, start: &str, end: &str) -> Result<Self, FrameError>
pub fn between_time(&self, start: &str, end: &str) -> Result<Self, FrameError>
Select rows where the time component of the index is between two times.
Matches df.between_time(start_time, end_time).
Index labels should be datetime-like strings with time component (HH:MM or HH:MM:SS).
Sourcepub fn at_time(&self, time: &str) -> Result<Self, FrameError>
pub fn at_time(&self, time: &str) -> Result<Self, FrameError>
Select rows where the time component exactly matches the given time.
Matches df.at_time(time).
Sourcepub fn to_latex(&self, include_index: bool) -> String
pub fn to_latex(&self, include_index: bool) -> String
Render the DataFrame as a LaTeX table.
Matches df.to_latex().
Sourcepub fn ndim(&self) -> usize
pub fn ndim(&self) -> usize
Return the number of dimensions.
Matches pd.DataFrame.ndim. Always returns 2.
Sourcepub fn axes(&self) -> (Vec<IndexLabel>, Vec<String>)
pub fn axes(&self) -> (Vec<IndexLabel>, Vec<String>)
Return a list of the row axis labels and column axis labels.
Matches pd.DataFrame.axes.
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Total number of cells in the DataFrame (rows × columns).
Matches pd.DataFrame.size. Equivalent to
len() * num_columns(), but follows pandas’ property naming so
callers can write size-generic code that works on both Series
and DataFrame.
Sourcepub fn to_html(&self, include_index: bool) -> String
pub fn to_html(&self, include_index: bool) -> String
Render the DataFrame as an HTML table.
Matches pd.DataFrame.to_html().
Sourcepub fn groupby(&self, by: &[&str]) -> Result<DataFrameGroupBy<'_>, FrameError>
pub fn groupby(&self, by: &[&str]) -> Result<DataFrameGroupBy<'_>, FrameError>
Group by one or more columns and aggregate.
Returns a DataFrameGroupBy for deferred aggregation.
Sourcepub fn groupby_with_as_index(
&self,
by: &[&str],
as_index: bool,
) -> Result<DataFrameGroupBy<'_>, FrameError>
pub fn groupby_with_as_index( &self, by: &[&str], as_index: bool, ) -> Result<DataFrameGroupBy<'_>, FrameError>
Group the DataFrame by one or more columns with explicit as_index.
When as_index is true (default), group keys become the index.
When as_index is false, group keys become regular columns and the
index is a default integer range. Matches df.groupby(by, as_index=...).
Sourcepub fn groupby_full(
&self,
by: &[&str],
as_index: bool,
sort: bool,
) -> Result<DataFrameGroupBy<'_>, FrameError>
pub fn groupby_full( &self, by: &[&str], as_index: bool, sort: bool, ) -> Result<DataFrameGroupBy<'_>, FrameError>
Group the DataFrame with full parameter control.
Matches df.groupby(by, as_index=..., sort=...).
When sort is true (default), groups are sorted by key.
When sort is false, groups appear in first-seen order.
Sourcepub fn groupby_full_options(
&self,
by: &[&str],
as_index: bool,
sort: bool,
dropna: bool,
) -> Result<DataFrameGroupBy<'_>, FrameError>
pub fn groupby_full_options( &self, by: &[&str], as_index: bool, sort: bool, dropna: bool, ) -> Result<DataFrameGroupBy<'_>, FrameError>
Group with all options including dropna.
When dropna is true (default), rows with NaN in any group key column
are excluded. When false, NaN keys form their own group.
Matches df.groupby(by, dropna=False).
Sourcepub fn groupby_full_options_with_observed(
&self,
by: &[&str],
as_index: bool,
sort: bool,
dropna: bool,
observed: bool,
) -> Result<DataFrameGroupBy<'_>, FrameError>
pub fn groupby_full_options_with_observed( &self, by: &[&str], as_index: bool, sort: bool, dropna: bool, observed: bool, ) -> Result<DataFrameGroupBy<'_>, FrameError>
Group with explicit observed control for categorical inputs.
The current DataFrame storage model materializes categorical columns to
their labels, so observed=true matches the pandas-observable result
surface for categorical groupers. observed=false still requires
DataFrame-level category metadata and is rejected for now.
Sourcepub fn info(&self) -> String
pub fn info(&self) -> String
Get summary info about the DataFrame: dtypes, non-null counts, memory.
Sourcepub fn to_dict(&self, orient: &str) -> Result<DataFrameDictResult, FrameError>
pub fn to_dict(&self, orient: &str) -> Result<DataFrameDictResult, FrameError>
Convert DataFrame to a nested dictionary.
Matches pd.DataFrame.to_dict(orient=...).
Supported orients:
"dict":{column -> {index -> value}}(default)"list":{column -> [values]}"records":[{column -> value}, ...]"index":{index -> {column -> value}}"series":{column -> Series}"split":{index, columns, data}
Sourcepub fn to_series_dict(&self) -> BTreeMap<String, Series>
pub fn to_series_dict(&self) -> BTreeMap<String, Series>
Convert DataFrame to a dict of Series (one per column).
Matches pd.DataFrame.to_dict(orient='series').
Returns {column_name -> Series} where each Series has the
DataFrame’s index.
§Panics
Panics if any column length no longer matches the DataFrame index length, which indicates internal DataFrame corruption.
Sourcepub fn to_xarray(&self) -> Result<DataFrameXArrayDataset, FrameError>
pub fn to_xarray(&self) -> Result<DataFrameXArrayDataset, FrameError>
Convert a flat-index DataFrame into an xarray-like Dataset snapshot.
Matches the practical pd.DataFrame.to_xarray() shape for scalar
columns: the row index becomes the single coordinate/dimension, and
each DataFrame column becomes one 1-D data variable.
Sourcepub fn to_csv(&self, sep: char, include_index: bool) -> String
pub fn to_csv(&self, sep: char, include_index: bool) -> String
Export DataFrame to CSV string.
Matches df.to_csv() returning a string representation.
Sourcepub fn to_csv_options(
&self,
sep: char,
include_index: bool,
na_rep: &str,
columns: Option<&[&str]>,
) -> Result<String, FrameError>
pub fn to_csv_options( &self, sep: char, include_index: bool, na_rep: &str, columns: Option<&[&str]>, ) -> Result<String, FrameError>
Export DataFrame to CSV string with additional formatting options.
Matches df.to_csv(sep, index, na_rep, columns).
na_rep: string to represent missing values (default empty)columns: optional subset of columns to include
Sourcepub fn to_csv_with_quoting(
&self,
sep: char,
include_index: bool,
na_rep: &str,
columns: Option<&[&str]>,
quoting: CsvQuoting,
) -> Result<String, FrameError>
pub fn to_csv_with_quoting( &self, sep: char, include_index: bool, na_rep: &str, columns: Option<&[&str]>, quoting: CsvQuoting, ) -> Result<String, FrameError>
Export DataFrame to CSV string with quoting control.
Matches df.to_csv(..., quoting=csv.QUOTE_*).
CsvQuoting::Minimal: Quote only when necessary (default pandas behavior)CsvQuoting::All: Quote all fields including headers, index, and valuesCsvQuoting::NonNumeric: Quote all non-numeric fieldsCsvQuoting::None: Never quote fieldsheader: if true (default), write column names as first row
Sourcepub fn to_csv_with_header(
&self,
sep: char,
include_index: bool,
na_rep: &str,
columns: Option<&[&str]>,
quoting: CsvQuoting,
header: bool,
) -> Result<String, FrameError>
pub fn to_csv_with_header( &self, sep: char, include_index: bool, na_rep: &str, columns: Option<&[&str]>, quoting: CsvQuoting, header: bool, ) -> Result<String, FrameError>
Export DataFrame to CSV string with full control over quoting and header.
header: if true, write column names as first row; if false, omit header
Sourcepub fn to_csv_full(
&self,
sep: char,
include_index: bool,
na_rep: &str,
columns: Option<&[&str]>,
quoting: CsvQuoting,
header: bool,
escapechar: Option<char>,
) -> Result<String, FrameError>
pub fn to_csv_full( &self, sep: char, include_index: bool, na_rep: &str, columns: Option<&[&str]>, quoting: CsvQuoting, header: bool, escapechar: Option<char>, ) -> Result<String, FrameError>
Export DataFrame to CSV string with full control over all options.
escapechar: when using CsvQuoting::None, escape special characters with this
Sourcepub fn to_json(&self, orient: &str) -> Result<String, FrameError>
pub fn to_json(&self, orient: &str) -> Result<String, FrameError>
Export DataFrame to JSON string.
Matches pd.DataFrame.to_json(orient=...).
Sourcepub fn to_numpy(&self) -> Vec<Vec<f64>>
pub fn to_numpy(&self) -> Vec<Vec<f64>>
Return the DataFrame values as a row-major 2D vector of f64.
Matches pd.DataFrame.to_numpy(). Non-numeric values become NaN.
Each inner vector is one row.
Sourcepub fn to_string(&self) -> String
pub fn to_string(&self) -> String
Render the DataFrame as a formatted plain-text table.
Matches df.to_string() with pandas’ default index=True behavior.
Sourcepub fn to_string_table(&self, include_index: bool) -> String
pub fn to_string_table(&self, include_index: bool) -> String
Render the DataFrame as a formatted plain-text table with explicit index-column control.
Matches df.to_string(). Columns are right-aligned for numeric data,
left-aligned for strings. Includes index column on the left.
Sourcepub fn to_string_truncated(
&self,
include_index: bool,
max_rows: Option<usize>,
max_cols: Option<usize>,
) -> String
pub fn to_string_truncated( &self, include_index: bool, max_rows: Option<usize>, max_cols: Option<usize>, ) -> String
Render the DataFrame as a string table with truncation.
Matches df.to_string(max_rows=N, max_cols=M). When the number
of rows exceeds max_rows, shows the first and last max_rows/2
rows with “…” in between. Similarly truncates columns.
Sourcepub fn to_markdown(
&self,
include_index: bool,
tablefmt: Option<&str>,
) -> Result<String, FrameError>
pub fn to_markdown( &self, include_index: bool, tablefmt: Option<&str>, ) -> Result<String, FrameError>
Render the DataFrame as a Markdown table.
Matches df.to_markdown().
Sourcepub fn sample(
&self,
n: Option<usize>,
frac: Option<f64>,
replace: bool,
seed: Option<u64>,
) -> Result<Self, FrameError>
pub fn sample( &self, n: Option<usize>, frac: Option<f64>, replace: bool, seed: Option<u64>, ) -> Result<Self, FrameError>
Randomly sample rows from the DataFrame.
n: number of rows to sample (mutually exclusive with frac).
frac: fraction of rows to sample.
replace: whether to sample with replacement.
seed: optional deterministic seed.
Examples found in repository?
37fn golden() -> String {
38 let mut out = String::new();
39 let df = frame(
40 vec![10, 11, 12, 13, 14],
41 vec![100, 200, 300, 400, 500],
42 vec![
43 Scalar::Float64(1.5),
44 Scalar::Float64(f64::NAN),
45 Scalar::Float64(-3.0),
46 Scalar::Float64(2.0),
47 Scalar::Float64(9.0),
48 ],
49 );
50
51 // iloc: reorder + negative + duplicate
52 out.push_str(&format!(
53 "iloc={}\n",
54 dump(&df.iloc(&[4, 0, -1, 2, 2]).unwrap())
55 ));
56 out.push_str(&format!("iloc_oob_err={}\n", df.iloc(&[99]).is_err()));
57 // take axis=0
58 out.push_str(&format!(
59 "take={}\n",
60 dump(&df.take(&[3, 1, 0], 0).unwrap())
61 ));
62 out.push_str(&format!("take_oob_err={}\n", df.take(&[99], 0).is_err()));
63 // sample deterministic (fixed seed)
64 out.push_str(&format!(
65 "sample={}\n",
66 dump(&df.sample(Some(3), None, false, Some(7)).unwrap())
67 ));
68 out
69}Sourcepub fn sample_weights(
&self,
n: usize,
weights: &[f64],
replace: bool,
seed: Option<u64>,
) -> Result<Self, FrameError>
pub fn sample_weights( &self, n: usize, weights: &[f64], replace: bool, seed: Option<u64>, ) -> Result<Self, FrameError>
Weighted sampling of rows.
Matches df.sample(n, weights=...). The weights slice must have the
same length as the DataFrame. Weights are normalized to sum to 1.
Sourcepub fn stack(&self) -> Result<Self, FrameError>
pub fn stack(&self) -> Result<Self, FrameError>
Stack: pivot columns into rows (wide-to-long).
Converts a DataFrame with columns [A, B, …] into a two-column
DataFrame with a multi-level index (original_index, column_name)
and a single value column. Similar to pandas DataFrame.stack().
Sourcepub fn unstack(&self) -> Result<Self, FrameError>
pub fn unstack(&self) -> Result<Self, FrameError>
Unstack: pivot rows into columns (long-to-wide).
Assumes the index contains composite labels in “row|col” format
(as produced by stack()). Produces a DataFrame with unique row
keys as index and unique column keys as columns.
Sourcepub fn apply_fn<F>(&self, func: F, axis: usize) -> Result<Self, FrameError>
pub fn apply_fn<F>(&self, func: F, axis: usize) -> Result<Self, FrameError>
Apply a closure to each column (axis=0) or each row (axis=1).
Unlike the string-based apply(), this takes a Rust closure.
Sourcepub fn apply_with_result_type<F>(
&self,
func: F,
result_type: &str,
) -> Result<Self, FrameError>
pub fn apply_with_result_type<F>( &self, func: F, result_type: &str, ) -> Result<Self, FrameError>
Row-wise apply with result_type control.
Matches pd.DataFrame.apply(func, axis=1, result_type=...).
"reduce": Each row produces a single scalar → returns a Series (default)."expand": Each row produces a Vec of scalars → columns of the output DataFrame."broadcast": Each row produces a scalar → broadcast to all columns, preserving shape.
Sourcepub fn apply_row<F>(&self, name: &str, func: F) -> Result<Series, FrameError>
pub fn apply_row<F>(&self, name: &str, func: F) -> Result<Series, FrameError>
Row-wise apply returning a Series (one value per row).
Convenience wrapper for apply_fn(func, 1) that directly returns
a Series instead of a single-column DataFrame.
Sourcepub fn apply_row_fn<F>(&self, name: &str, func: F) -> Result<Series, FrameError>
pub fn apply_row_fn<F>(&self, name: &str, func: F) -> Result<Series, FrameError>
Row-wise apply with failable closure returning a Series.
Like apply_row but the closure can return errors.
Sourcepub fn pivot(
&self,
index_col: &str,
columns_col: &str,
values_col: &str,
) -> Result<Self, FrameError>
pub fn pivot( &self, index_col: &str, columns_col: &str, values_col: &str, ) -> Result<Self, FrameError>
Simple pivot: reshape long to wide using column values.
Matches pd.DataFrame.pivot(index, columns, values).
Unlike pivot_table, no aggregation is performed; duplicate entries error.
Sourcepub fn squeeze_to_series(&self, axis: usize) -> Result<Series, Self>
pub fn squeeze_to_series(&self, axis: usize) -> Result<Series, Self>
Squeeze a single-column DataFrame to a Series, or single-row to a Series.
Matches pd.DataFrame.squeeze(axis).
- axis=1 (default): if single column, return as Series
- axis=0: if single row, return as Series
§Panics
Panics if the squeezed output cannot be represented as a valid Series because the DataFrame’s internal index or column metadata has already diverged from its column storage.
Sourcepub fn memory_usage(&self) -> Result<Series, FrameError>
pub fn memory_usage(&self) -> Result<Series, FrameError>
Approximate memory usage per column.
Matches pd.DataFrame.memory_usage(). Returns a Series with column
names as index and byte estimates as values. Includes the index.
Sourcepub fn memory_usage_with_options(
&self,
index: bool,
deep: bool,
) -> Result<Series, FrameError>
pub fn memory_usage_with_options( &self, index: bool, deep: bool, ) -> Result<Series, FrameError>
Matches pd.DataFrame.memory_usage(index=..., deep=...).
Sourcepub fn nunique(&self) -> Result<Series, FrameError>
pub fn nunique(&self) -> Result<Series, FrameError>
Count of unique non-null values per column.
Matches pd.DataFrame.nunique().
Sourcepub fn nunique_with_dropna(&self, dropna: bool) -> Result<Series, FrameError>
pub fn nunique_with_dropna(&self, dropna: bool) -> Result<Series, FrameError>
Count of unique values per column with explicit null counting control.
Matches pd.DataFrame.nunique(dropna=...).
Sourcepub fn nunique_axis(&self, axis: usize) -> Result<Series, FrameError>
pub fn nunique_axis(&self, axis: usize) -> Result<Series, FrameError>
Count unique non-null values with axis parameter.
Matches pd.DataFrame.nunique(axis).
- axis=0 (default): unique count per column (same as
nunique()) - axis=1: unique count per row
Sourcepub fn nunique_axis_with_dropna(
&self,
axis: usize,
dropna: bool,
) -> Result<Series, FrameError>
pub fn nunique_axis_with_dropna( &self, axis: usize, dropna: bool, ) -> Result<Series, FrameError>
Count unique values with axis parameter and explicit null counting control.
Matches pd.DataFrame.nunique(axis=..., dropna=...).
Sourcepub fn nunique_axis1(&self) -> Result<Series, FrameError>
pub fn nunique_axis1(&self) -> Result<Series, FrameError>
Count unique non-null values per row (axis=1).
Matches pd.DataFrame.nunique(axis=1).
Sourcepub fn nunique_axis1_with_dropna(
&self,
dropna: bool,
) -> Result<Series, FrameError>
pub fn nunique_axis1_with_dropna( &self, dropna: bool, ) -> Result<Series, FrameError>
Count unique values per row with explicit null counting control.
Matches pd.DataFrame.nunique(axis=1, dropna=...).
Sourcepub fn idxmin(&self) -> Result<Series, FrameError>
pub fn idxmin(&self) -> Result<Series, FrameError>
Index label of the minimum value per numeric column.
Matches pd.DataFrame.idxmin().
Sourcepub fn idxmax(&self) -> Result<Series, FrameError>
pub fn idxmax(&self) -> Result<Series, FrameError>
Index label of the maximum value per numeric column.
Matches pd.DataFrame.idxmax().
Sourcepub fn idxmin_axis1(&self) -> Result<Series, FrameError>
pub fn idxmin_axis1(&self) -> Result<Series, FrameError>
Column label of the minimum value per row (axis=1).
Matches pd.DataFrame.idxmin(axis=1). Returns a Series with one
entry per row, containing the column name of the minimum value.
Sourcepub fn idxmax_axis1(&self) -> Result<Series, FrameError>
pub fn idxmax_axis1(&self) -> Result<Series, FrameError>
Column label of the maximum value per row (axis=1).
Matches pd.DataFrame.idxmax(axis=1). Returns a Series with one
entry per row, containing the column name of the maximum value.
Sourcepub fn all(&self) -> Result<Series, FrameError>
pub fn all(&self) -> Result<Series, FrameError>
Whether all non-null values are truthy, per column.
Matches pd.DataFrame.all().
Sourcepub fn any(&self) -> Result<Series, FrameError>
pub fn any(&self) -> Result<Series, FrameError>
Whether any non-null value is truthy, per column.
Matches pd.DataFrame.any().
Sourcepub fn sum(&self) -> Result<Series, FrameError>
pub fn sum(&self) -> Result<Series, FrameError>
Sum of non-null values per column.
Matches pd.DataFrame.sum().
Sourcepub fn mean(&self) -> Result<Series, FrameError>
pub fn mean(&self) -> Result<Series, FrameError>
Mean of non-null values per column.
Matches pd.DataFrame.mean().
Sourcepub fn min_agg(&self) -> Result<Series, FrameError>
pub fn min_agg(&self) -> Result<Series, FrameError>
Min of non-null values per column.
Matches pd.DataFrame.min().
Sourcepub fn max_agg(&self) -> Result<Series, FrameError>
pub fn max_agg(&self) -> Result<Series, FrameError>
Max of non-null values per column.
Matches pd.DataFrame.max().
Sourcepub fn std_agg(&self) -> Result<Series, FrameError>
pub fn std_agg(&self) -> Result<Series, FrameError>
Standard deviation of non-null values per column.
Matches pd.DataFrame.std().
Sourcepub fn var_agg(&self) -> Result<Series, FrameError>
pub fn var_agg(&self) -> Result<Series, FrameError>
Variance of non-null values per column.
Matches pd.DataFrame.var().
Sourcepub fn std_agg_ddof(&self, ddof: usize) -> Result<Series, FrameError>
pub fn std_agg_ddof(&self, ddof: usize) -> Result<Series, FrameError>
Standard deviation per column with configurable degrees of freedom.
Matches pd.DataFrame.std(ddof=n).
Sourcepub fn var_agg_ddof(&self, ddof: usize) -> Result<Series, FrameError>
pub fn var_agg_ddof(&self, ddof: usize) -> Result<Series, FrameError>
Variance per column with configurable degrees of freedom.
Matches pd.DataFrame.var(ddof=n).
Sourcepub fn median_agg(&self) -> Result<Series, FrameError>
pub fn median_agg(&self) -> Result<Series, FrameError>
Median of non-null values per column.
Matches pd.DataFrame.median().
Sourcepub fn prod_agg(&self) -> Result<Series, FrameError>
pub fn prod_agg(&self) -> Result<Series, FrameError>
Product of non-null values per column.
Matches pd.DataFrame.prod().
Sourcepub fn mode(&self) -> Result<Self, FrameError>
pub fn mode(&self) -> Result<Self, FrameError>
Mode per column.
Matches pd.DataFrame.mode(). Returns a DataFrame where each column
contains its mode values, padded with NaN when columns have fewer modes.
Sourcepub fn mode_with_options(
&self,
axis: usize,
numeric_only: bool,
dropna: bool,
) -> Result<Self, FrameError>
pub fn mode_with_options( &self, axis: usize, numeric_only: bool, dropna: bool, ) -> Result<Self, FrameError>
Mode over columns or rows with pandas-compatible options.
Matches pd.DataFrame.mode(axis=..., numeric_only=..., dropna=...).
Sourcepub fn sum_skipna(&self, skipna: bool) -> Result<Series, FrameError>
pub fn sum_skipna(&self, skipna: bool) -> Result<Series, FrameError>
Sum per column with skipna control.
Matches pd.DataFrame.sum(skipna=True|False).
Sourcepub fn mean_skipna(&self, skipna: bool) -> Result<Series, FrameError>
pub fn mean_skipna(&self, skipna: bool) -> Result<Series, FrameError>
Mean per column with skipna control.
Sourcepub fn std_agg_skipna(&self, skipna: bool) -> Result<Series, FrameError>
pub fn std_agg_skipna(&self, skipna: bool) -> Result<Series, FrameError>
Std per column with skipna control.
Sourcepub fn var_agg_skipna(&self, skipna: bool) -> Result<Series, FrameError>
pub fn var_agg_skipna(&self, skipna: bool) -> Result<Series, FrameError>
Var per column with skipna control.
Sourcepub fn prod_agg_skipna(&self, skipna: bool) -> Result<Series, FrameError>
pub fn prod_agg_skipna(&self, skipna: bool) -> Result<Series, FrameError>
Prod per column with skipna control.
Sourcepub fn skew_agg(&self) -> Result<Series, FrameError>
pub fn skew_agg(&self) -> Result<Series, FrameError>
Skewness of non-null values per column.
Matches pd.DataFrame.skew().
Sourcepub fn kurtosis_agg(&self) -> Result<Series, FrameError>
pub fn kurtosis_agg(&self) -> Result<Series, FrameError>
Kurtosis of non-null values per column.
Matches pd.DataFrame.kurtosis().
Sourcepub fn kurt_agg(&self) -> Result<Series, FrameError>
pub fn kurt_agg(&self) -> Result<Series, FrameError>
Alias for kurtosis_agg() — pandas exposes df.kurt() and
df.kurtosis() as equivalents at the column-aggregate level.
Sourcepub fn sem_agg(&self) -> Result<Series, FrameError>
pub fn sem_agg(&self) -> Result<Series, FrameError>
Standard error of the mean per column.
Matches pd.DataFrame.sem().
Sourcepub fn min(&self) -> Result<Series, FrameError>
pub fn min(&self) -> Result<Series, FrameError>
Per-column min — pandas-parity alias for min_agg.
Sourcepub fn max(&self) -> Result<Series, FrameError>
pub fn max(&self) -> Result<Series, FrameError>
Per-column max — pandas-parity alias for max_agg.
Sourcepub fn std(&self) -> Result<Series, FrameError>
pub fn std(&self) -> Result<Series, FrameError>
Per-column std — pandas-parity alias for std_agg.
Sourcepub fn var(&self) -> Result<Series, FrameError>
pub fn var(&self) -> Result<Series, FrameError>
Per-column var — pandas-parity alias for var_agg.
Sourcepub fn median(&self) -> Result<Series, FrameError>
pub fn median(&self) -> Result<Series, FrameError>
Per-column median — pandas-parity alias for median_agg.
Sourcepub fn prod(&self) -> Result<Series, FrameError>
pub fn prod(&self) -> Result<Series, FrameError>
Per-column product — pandas-parity alias for prod_agg.
Sourcepub fn skew(&self) -> Result<Series, FrameError>
pub fn skew(&self) -> Result<Series, FrameError>
Per-column skewness — pandas-parity alias for skew_agg.
Sourcepub fn kurtosis(&self) -> Result<Series, FrameError>
pub fn kurtosis(&self) -> Result<Series, FrameError>
Per-column excess kurtosis — pandas-parity alias for
kurtosis_agg. Pandas uses both kurt and
kurtosis as aliases.
Sourcepub fn kurt(&self) -> Result<Series, FrameError>
pub fn kurt(&self) -> Result<Series, FrameError>
Per-column excess kurtosis (pandas alias for kurtosis).
Sourcepub fn sem(&self) -> Result<Series, FrameError>
pub fn sem(&self) -> Result<Series, FrameError>
Per-column standard error of the mean — pandas-parity alias for
sem_agg.
Sourcepub fn sum_axis1(&self) -> Result<Series, FrameError>
pub fn sum_axis1(&self) -> Result<Series, FrameError>
Sum across columns per row.
Matches pd.DataFrame.sum(axis=1).
Sourcepub fn mean_axis1(&self) -> Result<Series, FrameError>
pub fn mean_axis1(&self) -> Result<Series, FrameError>
Mean across columns per row.
Matches pd.DataFrame.mean(axis=1).
Sourcepub fn min_axis1(&self) -> Result<Series, FrameError>
pub fn min_axis1(&self) -> Result<Series, FrameError>
Minimum across columns per row.
Matches pd.DataFrame.min(axis=1).
Sourcepub fn apply_rows<F>(&self, func: F, name: &str) -> Result<Series, FrameError>
pub fn apply_rows<F>(&self, func: F, name: &str) -> Result<Series, FrameError>
Apply a custom function to each row of the DataFrame.
Matches pd.DataFrame.apply(func, axis=1). The function receives
a slice of Scalar values representing the row (in column_order)
and should return a single Scalar result.
Sourcepub fn max_axis1(&self) -> Result<Series, FrameError>
pub fn max_axis1(&self) -> Result<Series, FrameError>
Maximum across columns per row.
Matches pd.DataFrame.max(axis=1).
Sourcepub fn std_axis1(&self) -> Result<Series, FrameError>
pub fn std_axis1(&self) -> Result<Series, FrameError>
Standard deviation across columns per row.
Matches pd.DataFrame.std(axis=1).
Sourcepub fn var_axis1(&self) -> Result<Series, FrameError>
pub fn var_axis1(&self) -> Result<Series, FrameError>
Variance across columns per row.
Matches pd.DataFrame.var(axis=1).
Sourcepub fn sem_axis1(&self) -> Result<Series, FrameError>
pub fn sem_axis1(&self) -> Result<Series, FrameError>
Standard error of the mean across columns per row.
Matches pd.DataFrame.sem(axis=1).
Sourcepub fn skew_axis1(&self) -> Result<Series, FrameError>
pub fn skew_axis1(&self) -> Result<Series, FrameError>
Skewness across columns per row.
Matches pd.DataFrame.skew(axis=1).
Sourcepub fn kurtosis_axis1(&self) -> Result<Series, FrameError>
pub fn kurtosis_axis1(&self) -> Result<Series, FrameError>
Excess kurtosis across columns per row.
Matches pd.DataFrame.kurtosis(axis=1).
Sourcepub fn kurt_axis1(&self) -> Result<Series, FrameError>
pub fn kurt_axis1(&self) -> Result<Series, FrameError>
Alias for kurtosis_axis1() — pandas exposes
df.kurt(axis=1) and df.kurtosis(axis=1) as equivalents.
Sourcepub fn count_axis1(&self) -> Result<Series, FrameError>
pub fn count_axis1(&self) -> Result<Series, FrameError>
Count of non-null values across columns per row.
Matches pd.DataFrame.count(axis=1).
Sourcepub fn all_axis1(&self) -> Result<Series, FrameError>
pub fn all_axis1(&self) -> Result<Series, FrameError>
Whether all non-null values are truthy across columns per row.
Matches pd.DataFrame.all(axis=1).
Sourcepub fn any_axis1(&self) -> Result<Series, FrameError>
pub fn any_axis1(&self) -> Result<Series, FrameError>
Whether any non-null value is truthy across columns per row.
Matches pd.DataFrame.any(axis=1).
Sourcepub fn quantile_axis1(&self, q: f64) -> Result<Series, FrameError>
pub fn quantile_axis1(&self, q: f64) -> Result<Series, FrameError>
Median across columns per row.
Matches pd.DataFrame.median(axis=1).
Per-row quantile across numeric columns (axis=1).
Matches pd.DataFrame.quantile(q, axis=1). For each row the
numeric column values are collected (skipping non-numeric and
missing entries) and their linear-interpolation quantile is
returned. q must lie in [0.0, 1.0]. Rows with no numeric
entries emit Null(NaN).
Sourcepub fn argmin_axis1(&self) -> Result<Series, FrameError>
pub fn argmin_axis1(&self) -> Result<Series, FrameError>
Per-row index label of the first smallest numeric value.
Matches pd.DataFrame.idxmin(axis=1) combined with positional
column lookup. Returns the column-name Series entry for each
row’s argmin; rows with no numeric entries emit Null(NaN).
Sourcepub fn argmax_axis1(&self) -> Result<Series, FrameError>
pub fn argmax_axis1(&self) -> Result<Series, FrameError>
Per-row index label of the first largest numeric value.
Matches pd.DataFrame.idxmax(axis=1).
pub fn median_axis1(&self) -> Result<Series, FrameError>
Sourcepub fn prod_axis1(&self) -> Result<Series, FrameError>
pub fn prod_axis1(&self) -> Result<Series, FrameError>
Product across columns per row.
Matches pd.DataFrame.prod(axis=1).
Sourcepub fn cumsum(&self) -> Result<Self, FrameError>
pub fn cumsum(&self) -> Result<Self, FrameError>
Cumulative sum per column.
Matches pd.DataFrame.cumsum().
Sourcepub fn cumprod(&self) -> Result<Self, FrameError>
pub fn cumprod(&self) -> Result<Self, FrameError>
Cumulative product per column.
Matches pd.DataFrame.cumprod().
Sourcepub fn cummax(&self) -> Result<Self, FrameError>
pub fn cummax(&self) -> Result<Self, FrameError>
Cumulative maximum per column.
Matches pd.DataFrame.cummax().
Sourcepub fn cummin(&self) -> Result<Self, FrameError>
pub fn cummin(&self) -> Result<Self, FrameError>
Cumulative minimum per column.
Matches pd.DataFrame.cummin().
Sourcepub fn cumsum_axis1(&self) -> Result<Self, FrameError>
pub fn cumsum_axis1(&self) -> Result<Self, FrameError>
Cumulative sum across columns, computed row-wise.
Matches pd.DataFrame.cumsum(axis=1, skipna=True).
Sourcepub fn cumprod_axis1(&self) -> Result<Self, FrameError>
pub fn cumprod_axis1(&self) -> Result<Self, FrameError>
Cumulative product across columns, computed row-wise.
Matches pd.DataFrame.cumprod(axis=1, skipna=True).
Sourcepub fn cummin_axis1(&self) -> Result<Self, FrameError>
pub fn cummin_axis1(&self) -> Result<Self, FrameError>
Cumulative minimum across columns, computed row-wise.
Matches pd.DataFrame.cummin(axis=1, skipna=True).
Sourcepub fn cummax_axis1(&self) -> Result<Self, FrameError>
pub fn cummax_axis1(&self) -> Result<Self, FrameError>
Cumulative maximum across columns, computed row-wise.
Matches pd.DataFrame.cummax(axis=1, skipna=True).
Sourcepub fn diff(&self, periods: i64) -> Result<Self, FrameError>
pub fn diff(&self, periods: i64) -> Result<Self, FrameError>
First-order difference per column.
Matches pd.DataFrame.diff(periods).
Sourcepub fn diff_axis1(&self, periods: i64) -> Result<Self, FrameError>
pub fn diff_axis1(&self, periods: i64) -> Result<Self, FrameError>
First-order difference across columns per row.
Matches pd.DataFrame.diff(periods, axis=1).
Sourcepub fn pct_change_axis1(&self, periods: i64) -> Result<Self, FrameError>
pub fn pct_change_axis1(&self, periods: i64) -> Result<Self, FrameError>
Percentage change across columns per row.
Matches pd.DataFrame.pct_change(periods, axis=1).
Sourcepub fn shift(&self, periods: i64) -> Result<Self, FrameError>
pub fn shift(&self, periods: i64) -> Result<Self, FrameError>
Shift values per column.
Matches pd.DataFrame.shift(periods).
Sourcepub fn shift_axis1(&self, periods: i64) -> Result<Self, FrameError>
pub fn shift_axis1(&self, periods: i64) -> Result<Self, FrameError>
Shift index horizontally by desired number of periods.
Matches pd.DataFrame.shift(periods, axis=1).
Sourcepub fn abs(&self) -> Result<Self, FrameError>
pub fn abs(&self) -> Result<Self, FrameError>
Absolute value per column.
Matches pd.DataFrame.abs().
Sourcepub fn clip(
&self,
lower: Option<f64>,
upper: Option<f64>,
) -> Result<Self, FrameError>
pub fn clip( &self, lower: Option<f64>, upper: Option<f64>, ) -> Result<Self, FrameError>
Clip values per column.
Matches pd.DataFrame.clip(lower, upper).
Sourcepub fn clip_lower(&self, threshold: f64) -> Result<Self, FrameError>
pub fn clip_lower(&self, threshold: f64) -> Result<Self, FrameError>
Clip values below a threshold across all numeric columns.
Matches pd.DataFrame.clip(lower=threshold).
Sourcepub fn clip_upper(&self, threshold: f64) -> Result<Self, FrameError>
pub fn clip_upper(&self, threshold: f64) -> Result<Self, FrameError>
Clip values above a threshold across all numeric columns.
Matches pd.DataFrame.clip(upper=threshold).
Sourcepub fn clip_with_column_bounds(
&self,
lower: Option<&Series>,
upper: Option<&Series>,
) -> Result<Self, FrameError>
pub fn clip_with_column_bounds( &self, lower: Option<&Series>, upper: Option<&Series>, ) -> Result<Self, FrameError>
Clip each column to its own bound, matching df.clip(lower=s, upper=s, axis=1) where lower/upper are Series indexed by column name.
Each numeric column is clipped to the scalar bound looked up by its name.
Following pandas’ where-based broadcast, a column whose provided lower
or upper bound is absent from the Series (i.e. NaN) becomes all-NaN —
distinct from the scalar clip, where a NaN bound means “no clip”.
A bound Series passed as None applies no clipping on that side.
(Per-row bounds, axis=0, are tracked under br-frankenpandas-l4wfl.)
Sourcepub fn clip_with_row_bounds(
&self,
lower: Option<&Series>,
upper: Option<&Series>,
) -> Result<Self, FrameError>
pub fn clip_with_row_bounds( &self, lower: Option<&Series>, upper: Option<&Series>, ) -> Result<Self, FrameError>
Clip each row to its own bound, matching df.clip(lower=s, upper=s, axis=0) where lower/upper are Series indexed by row label.
Every numeric value in row i is clipped to the bound looked up by that
row’s label. Semantics verified against live pandas 2.2.3
(br-frankenpandas-l4wfl):
- A row label present in the bound Series with a finite value clips
that whole row to the value; dtype is preserved when the input is
Int64and every resulting value is integral (an integral float bound such as3.0keepsInt64; a fractional bound that actually clips demotes the column toFloat64). - A row label present but NaN applies no clipping on that side (NaN comparisons are false), leaving the value and dtype untouched.
- A row label absent from any provided bound Series forces that entire
row to NaN and demotes every column to
Float64— pandas reindexes the bound to the frame’s axis, and the introduced NaN propagates through the where-broadcast. This is distinct from a present-but-NaN bound. - Pre-existing data nulls are preserved (and, like pandas, keep the
column in
Float64).
A bound Series passed as None applies no clipping on that side.
(Per-column bounds, axis=1, are Self::clip_with_column_bounds.)
Sourcepub fn round(&self, decimals: i32) -> Result<Self, FrameError>
pub fn round(&self, decimals: i32) -> Result<Self, FrameError>
Round numeric columns to specified decimal places.
Matches pd.DataFrame.round(decimals).
Sourcepub fn floor(&self) -> Result<Self, FrameError>
pub fn floor(&self) -> Result<Self, FrameError>
Floor each numeric element (round toward negative infinity).
Matches np.floor(df). NaN values pass through.
Sourcepub fn ceil(&self) -> Result<Self, FrameError>
pub fn ceil(&self) -> Result<Self, FrameError>
Ceiling of each numeric element (round toward positive infinity).
Matches np.ceil(df). NaN values pass through.
Sourcepub fn trunc(&self) -> Result<Self, FrameError>
pub fn trunc(&self) -> Result<Self, FrameError>
Truncate each numeric element toward zero.
Matches np.trunc(df). NaN values pass through.
Sourcepub fn sqrt(&self) -> Result<Self, FrameError>
pub fn sqrt(&self) -> Result<Self, FrameError>
Element-wise square root.
Matches np.sqrt(df). NaN values pass through.
Sourcepub fn exp(&self) -> Result<Self, FrameError>
pub fn exp(&self) -> Result<Self, FrameError>
Element-wise exponential (e^x).
Matches np.exp(df). NaN values pass through.
Sourcepub fn log(&self) -> Result<Self, FrameError>
pub fn log(&self) -> Result<Self, FrameError>
Element-wise natural logarithm.
Matches np.log(df). NaN values pass through.
Sourcepub fn log10(&self) -> Result<Self, FrameError>
pub fn log10(&self) -> Result<Self, FrameError>
Element-wise base-10 logarithm.
Matches np.log10(df). NaN values pass through.
Sourcepub fn log2(&self) -> Result<Self, FrameError>
pub fn log2(&self) -> Result<Self, FrameError>
Element-wise base-2 logarithm.
Matches np.log2(df). NaN values pass through.
Sourcepub fn sin(&self) -> Result<Self, FrameError>
pub fn sin(&self) -> Result<Self, FrameError>
Element-wise sine.
Matches np.sin(df). NaN values pass through.
Sourcepub fn cos(&self) -> Result<Self, FrameError>
pub fn cos(&self) -> Result<Self, FrameError>
Element-wise cosine.
Matches np.cos(df). NaN values pass through.
Sourcepub fn tan(&self) -> Result<Self, FrameError>
pub fn tan(&self) -> Result<Self, FrameError>
Element-wise tangent.
Matches np.tan(df). NaN values pass through.
Sourcepub fn sinh(&self) -> Result<Self, FrameError>
pub fn sinh(&self) -> Result<Self, FrameError>
Element-wise hyperbolic sine.
Matches np.sinh(df). NaN values pass through.
Sourcepub fn cosh(&self) -> Result<Self, FrameError>
pub fn cosh(&self) -> Result<Self, FrameError>
Element-wise hyperbolic cosine.
Matches np.cosh(df). NaN values pass through.
Sourcepub fn tanh(&self) -> Result<Self, FrameError>
pub fn tanh(&self) -> Result<Self, FrameError>
Element-wise hyperbolic tangent.
Matches np.tanh(df). NaN values pass through.
Sourcepub fn arcsin(&self) -> Result<Self, FrameError>
pub fn arcsin(&self) -> Result<Self, FrameError>
Element-wise inverse sine.
Matches np.arcsin(df). NaN values pass through.
Sourcepub fn arccos(&self) -> Result<Self, FrameError>
pub fn arccos(&self) -> Result<Self, FrameError>
Element-wise inverse cosine.
Matches np.arccos(df). NaN values pass through.
Sourcepub fn arctan(&self) -> Result<Self, FrameError>
pub fn arctan(&self) -> Result<Self, FrameError>
Element-wise inverse tangent.
Matches np.arctan(df). NaN values pass through.
Sourcepub fn arcsinh(&self) -> Result<Self, FrameError>
pub fn arcsinh(&self) -> Result<Self, FrameError>
Element-wise inverse hyperbolic sine.
Matches np.arcsinh(df). NaN values pass through.
Sourcepub fn arccosh(&self) -> Result<Self, FrameError>
pub fn arccosh(&self) -> Result<Self, FrameError>
Element-wise inverse hyperbolic cosine.
Matches np.arccosh(df). NaN values pass through.
Sourcepub fn arctanh(&self) -> Result<Self, FrameError>
pub fn arctanh(&self) -> Result<Self, FrameError>
Element-wise inverse hyperbolic tangent.
Matches np.arctanh(df). NaN values pass through.
Sourcepub fn expm1(&self) -> Result<Self, FrameError>
pub fn expm1(&self) -> Result<Self, FrameError>
Element-wise exp(x) - 1 with improved precision for small x.
Matches np.expm1(df). NaN values pass through.
Sourcepub fn log1p(&self) -> Result<Self, FrameError>
pub fn log1p(&self) -> Result<Self, FrameError>
Element-wise log(1 + x) with improved precision for small x.
Matches np.log1p(df). NaN values pass through.
Sourcepub fn cbrt(&self) -> Result<Self, FrameError>
pub fn cbrt(&self) -> Result<Self, FrameError>
Element-wise cube root.
Matches np.cbrt(df). NaN values pass through.
Sourcepub fn sign(&self) -> Result<Self, FrameError>
pub fn sign(&self) -> Result<Self, FrameError>
Element-wise sign (-1, 0, or 1).
Matches np.sign(df). NaN values pass through.
Sourcepub fn signbit(&self) -> Result<Self, FrameError>
pub fn signbit(&self) -> Result<Self, FrameError>
Element-wise sign bit (true if negative).
Matches np.signbit(df). NaN values pass through.
Sourcepub fn radians(&self) -> Result<Self, FrameError>
pub fn radians(&self) -> Result<Self, FrameError>
Convert angles from degrees to radians.
Matches np.radians(df) / np.deg2rad(df).
Sourcepub fn deg2rad(&self) -> Result<Self, FrameError>
pub fn deg2rad(&self) -> Result<Self, FrameError>
Alias for radians(). Matches np.deg2rad(df).
Sourcepub fn degrees(&self) -> Result<Self, FrameError>
pub fn degrees(&self) -> Result<Self, FrameError>
Convert angles from radians to degrees.
Matches np.degrees(df) / np.rad2deg(df).
Sourcepub fn rad2deg(&self) -> Result<Self, FrameError>
pub fn rad2deg(&self) -> Result<Self, FrameError>
Alias for degrees(). Matches np.rad2deg(df).
Sourcepub fn reciprocal(&self) -> Result<Self, FrameError>
pub fn reciprocal(&self) -> Result<Self, FrameError>
Element-wise reciprocal (1/x).
Matches np.reciprocal(df). NaN values pass through.
Sourcepub fn square(&self) -> Result<Self, FrameError>
pub fn square(&self) -> Result<Self, FrameError>
Element-wise square (x^2).
Matches np.square(df). NaN values pass through.
Sourcepub fn rint(&self) -> Result<Self, FrameError>
pub fn rint(&self) -> Result<Self, FrameError>
Round to nearest integer (banker’s rounding).
Matches np.rint(df). NaN values pass through.
Sourcepub fn fix(&self) -> Result<Self, FrameError>
pub fn fix(&self) -> Result<Self, FrameError>
Round toward zero (alias for trunc).
Matches np.fix(df). NaN values pass through.
Sourcepub fn isfinite(&self) -> Result<Self, FrameError>
pub fn isfinite(&self) -> Result<Self, FrameError>
Element-wise check for finite values.
Matches np.isfinite(df). Returns boolean DataFrame.
Sourcepub fn isinf(&self) -> Result<Self, FrameError>
pub fn isinf(&self) -> Result<Self, FrameError>
Element-wise check for infinite values.
Matches np.isinf(df). Returns boolean DataFrame.
Sourcepub fn isnan(&self) -> Result<Self, FrameError>
pub fn isnan(&self) -> Result<Self, FrameError>
Element-wise check for NaN values.
Matches np.isnan(df). Returns boolean DataFrame.
Sourcepub fn isneginf(&self) -> Result<Self, FrameError>
pub fn isneginf(&self) -> Result<Self, FrameError>
Element-wise check for negative infinity.
Matches np.isneginf(df). Returns boolean DataFrame.
Sourcepub fn isposinf(&self) -> Result<Self, FrameError>
pub fn isposinf(&self) -> Result<Self, FrameError>
Element-wise check for positive infinity.
Matches np.isposinf(df). Returns boolean DataFrame.
Sourcepub fn nan_to_num(&self) -> Result<Self, FrameError>
pub fn nan_to_num(&self) -> Result<Self, FrameError>
Replace NaN with zero and infinity with large finite numbers.
Matches np.nan_to_num(df).
Sourcepub fn neg(&self) -> Result<Self, FrameError>
pub fn neg(&self) -> Result<Self, FrameError>
Element-wise negation (-x).
Matches np.negative(df) / -df.
Sourcepub fn negative(&self) -> Result<Self, FrameError>
pub fn negative(&self) -> Result<Self, FrameError>
Alias for neg(). Matches np.negative(df).
Sourcepub fn positive(&self) -> Result<Self, FrameError>
pub fn positive(&self) -> Result<Self, FrameError>
Element-wise identity (+x, no-op for numeric).
Matches np.positive(df) / +df.
Sourcepub fn reverse(&self) -> Result<Self, FrameError>
pub fn reverse(&self) -> Result<Self, FrameError>
Reverse the order of elements in each column.
Matches df[::-1] / np.flip(df, axis=0).
Sourcepub fn flip(&self) -> Result<Self, FrameError>
pub fn flip(&self) -> Result<Self, FrameError>
Alias for reverse(). Matches np.flip(df, axis=0).
Sourcepub fn roll(&self, shift: i64) -> Result<Self, FrameError>
pub fn roll(&self, shift: i64) -> Result<Self, FrameError>
Roll elements along axis 0 by shift positions.
Matches np.roll(df, shift, axis=0). Elements shifted off
one end wrap around to the other.
Sourcepub fn tile(&self, reps: usize) -> Result<Self, FrameError>
pub fn tile(&self, reps: usize) -> Result<Self, FrameError>
Tile (repeat) each column a given number of times.
Matches np.tile(df, (reps, 1)).
Sourcepub fn add_scalar(&self, value: f64) -> Result<Self, FrameError>
pub fn add_scalar(&self, value: f64) -> Result<Self, FrameError>
Add a scalar to all numeric columns.
Matches df + scalar or df.add(scalar).
Sourcepub fn sub_scalar(&self, value: f64) -> Result<Self, FrameError>
pub fn sub_scalar(&self, value: f64) -> Result<Self, FrameError>
Subtract a scalar from all numeric columns.
Sourcepub fn mul_scalar(&self, value: f64) -> Result<Self, FrameError>
pub fn mul_scalar(&self, value: f64) -> Result<Self, FrameError>
Multiply all numeric columns by a scalar.
Sourcepub fn div_scalar(&self, value: f64) -> Result<Self, FrameError>
pub fn div_scalar(&self, value: f64) -> Result<Self, FrameError>
Divide all numeric columns by a scalar.
Sourcepub fn pow_scalar(&self, value: f64) -> Result<Self, FrameError>
pub fn pow_scalar(&self, value: f64) -> Result<Self, FrameError>
Raise all numeric columns to a scalar power.
Sourcepub fn mod_scalar(&self, value: f64) -> Result<Self, FrameError>
pub fn mod_scalar(&self, value: f64) -> Result<Self, FrameError>
Modulo all numeric columns by a scalar.
Sourcepub fn add<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn add<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Add another DataFrame or scalar with pandas’ canonical method name.
Matches pd.DataFrame.add(other) for DataFrame and scalar operands.
Sourcepub fn sub<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn sub<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Subtract another DataFrame or scalar with pandas’ canonical method name.
Sourcepub fn subtract<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn subtract<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Alias for DataFrame::sub.
Sourcepub fn mul<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn mul<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Multiply by another DataFrame or scalar with pandas’ canonical method name.
Sourcepub fn multiply<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn multiply<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Alias for DataFrame::mul.
Sourcepub fn div<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn div<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Divide by another DataFrame or scalar with pandas’ canonical method name.
Sourcepub fn divide<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn divide<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Alias for DataFrame::div.
Sourcepub fn truediv<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn truediv<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Alias for DataFrame::div.
Sourcepub fn floordiv<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn floordiv<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Floor-divide by another DataFrame or scalar.
Sourcepub fn mod<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn mod<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Modulo by another DataFrame or scalar.
Rust callers use the raw identifier form: df.r#mod(other).
Sourcepub fn pow<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn pow<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Raise to the power of another DataFrame or scalar.
Sourcepub fn radd<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn radd<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Reverse add: other + self.
Sourcepub fn rsub<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn rsub<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Reverse subtract: other - self.
Sourcepub fn rmul<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn rmul<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Reverse multiply: other * self.
Sourcepub fn rdiv<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn rdiv<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Reverse true division: other / self.
Sourcepub fn rtruediv<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn rtruediv<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Alias for DataFrame::rdiv.
Sourcepub fn rfloordiv<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn rfloordiv<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Reverse floor division: other // self.
Sourcepub fn rmod<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn rmod<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Reverse modulo: other % self.
Sourcepub fn rpow<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
pub fn rpow<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameArithmeticOperand<'a>>,
Reverse power: other ** self.
Sourcepub fn add_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn add_df(&self, other: &Self) -> Result<Self, FrameError>
Add another DataFrame element-wise with index alignment.
Matches pd.DataFrame.add(other).
Sourcepub fn sub_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn sub_df(&self, other: &Self) -> Result<Self, FrameError>
Subtract another DataFrame element-wise with index alignment.
Matches pd.DataFrame.sub(other).
Sourcepub fn mul_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn mul_df(&self, other: &Self) -> Result<Self, FrameError>
Multiply another DataFrame element-wise with index alignment.
Matches pd.DataFrame.mul(other).
Sourcepub fn div_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn div_df(&self, other: &Self) -> Result<Self, FrameError>
Divide by another DataFrame element-wise with index alignment.
Matches pd.DataFrame.div(other).
Sourcepub fn floordiv_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn floordiv_df(&self, other: &Self) -> Result<Self, FrameError>
Floor-divide by another DataFrame element-wise with index alignment.
Matches pd.DataFrame.floordiv(other).
Sourcepub fn mod_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn mod_df(&self, other: &Self) -> Result<Self, FrameError>
Modulo with another DataFrame element-wise with index alignment.
Matches pd.DataFrame.mod(other).
Sourcepub fn pow_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn pow_df(&self, other: &Self) -> Result<Self, FrameError>
Raise another DataFrame element-wise to the power with index alignment.
Matches pd.DataFrame.pow(other) / df1 ** df2.
Sourcepub fn add_df_fill(
&self,
other: &Self,
fill_value: f64,
) -> Result<Self, FrameError>
pub fn add_df_fill( &self, other: &Self, fill_value: f64, ) -> Result<Self, FrameError>
Add another DataFrame element-wise with fill_value for NaN handling.
Matches pd.DataFrame.add(other, fill_value=X).
Sourcepub fn sub_df_fill(
&self,
other: &Self,
fill_value: f64,
) -> Result<Self, FrameError>
pub fn sub_df_fill( &self, other: &Self, fill_value: f64, ) -> Result<Self, FrameError>
Subtract another DataFrame element-wise with fill_value for NaN handling.
Matches pd.DataFrame.sub(other, fill_value=X).
Sourcepub fn mul_df_fill(
&self,
other: &Self,
fill_value: f64,
) -> Result<Self, FrameError>
pub fn mul_df_fill( &self, other: &Self, fill_value: f64, ) -> Result<Self, FrameError>
Multiply another DataFrame element-wise with fill_value for NaN handling.
Matches pd.DataFrame.mul(other, fill_value=X).
Sourcepub fn div_df_fill(
&self,
other: &Self,
fill_value: f64,
) -> Result<Self, FrameError>
pub fn div_df_fill( &self, other: &Self, fill_value: f64, ) -> Result<Self, FrameError>
Divide by another DataFrame element-wise with fill_value for NaN handling.
Matches pd.DataFrame.div(other, fill_value=X).
Sourcepub fn floordiv_df_fill(
&self,
other: &Self,
fill_value: f64,
) -> Result<Self, FrameError>
pub fn floordiv_df_fill( &self, other: &Self, fill_value: f64, ) -> Result<Self, FrameError>
Floor-divide by another DataFrame element-wise with fill_value for NaN handling.
Matches pd.DataFrame.floordiv(other, fill_value=X).
Sourcepub fn mod_df_fill(
&self,
other: &Self,
fill_value: f64,
) -> Result<Self, FrameError>
pub fn mod_df_fill( &self, other: &Self, fill_value: f64, ) -> Result<Self, FrameError>
Modulo with another DataFrame element-wise with fill_value for NaN handling.
Matches pd.DataFrame.mod(other, fill_value=X).
Sourcepub fn floordiv_scalar(&self, value: f64) -> Result<Self, FrameError>
pub fn floordiv_scalar(&self, value: f64) -> Result<Self, FrameError>
Floor-divide all numeric columns by a scalar.
Matches pd.DataFrame.floordiv(scalar).
Sourcepub fn eq_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn eq_df(&self, other: &Self) -> Result<Self, FrameError>
Element-wise equality with another DataFrame.
Matches pd.DataFrame.eq(other).
Sourcepub fn ne_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn ne_df(&self, other: &Self) -> Result<Self, FrameError>
Element-wise not-equal with another DataFrame.
Matches pd.DataFrame.ne(other).
Sourcepub fn gt_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn gt_df(&self, other: &Self) -> Result<Self, FrameError>
Element-wise greater-than with another DataFrame.
Matches pd.DataFrame.gt(other).
Sourcepub fn ge_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn ge_df(&self, other: &Self) -> Result<Self, FrameError>
Element-wise greater-or-equal with another DataFrame.
Matches pd.DataFrame.ge(other).
Sourcepub fn lt_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn lt_df(&self, other: &Self) -> Result<Self, FrameError>
Element-wise less-than with another DataFrame.
Matches pd.DataFrame.lt(other).
Sourcepub fn le_df(&self, other: &Self) -> Result<Self, FrameError>
pub fn le_df(&self, other: &Self) -> Result<Self, FrameError>
Element-wise less-or-equal with another DataFrame.
Matches pd.DataFrame.le(other).
Sourcepub fn compare_scalar_df(
&self,
scalar: &Scalar,
op: ComparisonOp,
) -> Result<Self, FrameError>
pub fn compare_scalar_df( &self, scalar: &Scalar, op: ComparisonOp, ) -> Result<Self, FrameError>
Compare each element in all columns against a scalar.
Matches pd.DataFrame.eq(scalar) etc.
Sourcepub fn eq_scalar_df(&self, scalar: &Scalar) -> Result<Self, FrameError>
pub fn eq_scalar_df(&self, scalar: &Scalar) -> Result<Self, FrameError>
Element-wise == scalar for all columns.
Sourcepub fn ne_scalar_df(&self, scalar: &Scalar) -> Result<Self, FrameError>
pub fn ne_scalar_df(&self, scalar: &Scalar) -> Result<Self, FrameError>
Element-wise != scalar for all columns.
Sourcepub fn gt_scalar_df(&self, scalar: &Scalar) -> Result<Self, FrameError>
pub fn gt_scalar_df(&self, scalar: &Scalar) -> Result<Self, FrameError>
Element-wise > scalar for all columns.
Sourcepub fn ge_scalar_df(&self, scalar: &Scalar) -> Result<Self, FrameError>
pub fn ge_scalar_df(&self, scalar: &Scalar) -> Result<Self, FrameError>
Element-wise >= scalar for all columns.
Sourcepub fn lt_scalar_df(&self, scalar: &Scalar) -> Result<Self, FrameError>
pub fn lt_scalar_df(&self, scalar: &Scalar) -> Result<Self, FrameError>
Element-wise < scalar for all columns.
Sourcepub fn le_scalar_df(&self, scalar: &Scalar) -> Result<Self, FrameError>
pub fn le_scalar_df(&self, scalar: &Scalar) -> Result<Self, FrameError>
Element-wise <= scalar for all columns.
Sourcepub fn eq<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameComparisonOperand<'a>>,
pub fn eq<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameComparisonOperand<'a>>,
Element-wise equality with another DataFrame or scalar.
Matches pd.DataFrame.eq(other).
Sourcepub fn ne<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameComparisonOperand<'a>>,
pub fn ne<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameComparisonOperand<'a>>,
Element-wise inequality with another DataFrame or scalar.
Matches pd.DataFrame.ne(other).
Sourcepub fn gt<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameComparisonOperand<'a>>,
pub fn gt<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameComparisonOperand<'a>>,
Element-wise greater-than comparison with another DataFrame or scalar.
Matches pd.DataFrame.gt(other).
Sourcepub fn ge<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameComparisonOperand<'a>>,
pub fn ge<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameComparisonOperand<'a>>,
Element-wise greater-or-equal comparison with another DataFrame or scalar.
Matches pd.DataFrame.ge(other).
Sourcepub fn lt<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameComparisonOperand<'a>>,
pub fn lt<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameComparisonOperand<'a>>,
Element-wise less-than comparison with another DataFrame or scalar.
Matches pd.DataFrame.lt(other).
Sourcepub fn le<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameComparisonOperand<'a>>,
pub fn le<'a, O>(&self, other: O) -> Result<Self, FrameError>where
O: Into<DataFrameComparisonOperand<'a>>,
Element-wise less-or-equal comparison with another DataFrame or scalar.
Matches pd.DataFrame.le(other).
Sourcepub fn get_dummies(&self, columns: &[&str]) -> Result<Self, FrameError>
pub fn get_dummies(&self, columns: &[&str]) -> Result<Self, FrameError>
One-hot encode specified columns.
Matches pd.get_dummies(df, columns). Creates indicator columns
for each unique value in the specified columns, prefixed with
{column_name}_{value}. Original columns are removed.
If columns is empty, all Utf8 columns are encoded.
Sourcepub fn get_dummies_with_options(
&self,
columns: &[&str],
prefix_sep: &str,
dummy_na: bool,
drop_first: bool,
) -> Result<Self, FrameError>
pub fn get_dummies_with_options( &self, columns: &[&str], prefix_sep: &str, dummy_na: bool, drop_first: bool, ) -> Result<Self, FrameError>
One-hot encode columns with full pandas 2.2 option parity.
Matches pd.get_dummies(df, columns=..., prefix_sep='_', dummy_na=False, drop_first=False).
prefix_sepjoins the source column name to the value (pandas default'_').dummy_naadds an{col}{sep}nanindicator column marking null values in the source column.drop_firstdrops the first indicator column for each encoded source column (discovery order), avoiding the dummy-variable trap.
Sourcepub fn squeeze(&self, axis: usize) -> Result<Series, Self>
pub fn squeeze(&self, axis: usize) -> Result<Series, Self>
Squeeze: pandas-named alias for squeeze_to_series.
Matches pd.DataFrame.squeeze(axis).
Sourcepub fn get_column(&self, key: &str) -> Series
pub fn get_column(&self, key: &str) -> Series
Get a column by name with a default if not found.
Matches pd.DataFrame.get(key, default). Returns the column
as a Series, or a default Series of NaN values.
Sourcepub fn where_mask_df(
&self,
cond_df: &Self,
other: &Scalar,
) -> Result<Self, FrameError>
pub fn where_mask_df( &self, cond_df: &Self, other: &Scalar, ) -> Result<Self, FrameError>
Replace values where condition DataFrame is True with other.
Matches pd.DataFrame.where(cond, other) with a DataFrame condition.
Where cond_df is True, keep the original value; where False, use other.
Sourcepub fn mask_df(
&self,
cond_df: &Self,
other: &Scalar,
) -> Result<Self, FrameError>
pub fn mask_df( &self, cond_df: &Self, other: &Scalar, ) -> Result<Self, FrameError>
Replace values where condition DataFrame is False with other.
Matches pd.DataFrame.mask(cond, other) with a DataFrame condition.
Inverse of where_mask_df: where cond_df is True, replace with other.
Sourcepub fn assign_column(
&self,
name: &str,
values: Vec<Scalar>,
) -> Result<Self, FrameError>
pub fn assign_column( &self, name: &str, values: Vec<Scalar>, ) -> Result<Self, FrameError>
Set or replace a column by name with given values.
Matches pd.DataFrame.assign(**kwargs) for single-column assignment.
If the column already exists, it is replaced. Otherwise it is appended.
Sourcepub fn pct_change(&self, periods: usize) -> Result<Self, FrameError>
pub fn pct_change(&self, periods: usize) -> Result<Self, FrameError>
Percentage change per column.
Matches pd.DataFrame.pct_change(periods).
Sourcepub fn ffill(&self, limit: Option<usize>) -> Result<Self, FrameError>
pub fn ffill(&self, limit: Option<usize>) -> Result<Self, FrameError>
Forward-fill missing values per column.
Matches pd.DataFrame.ffill(). Applies to all columns.
Sourcepub fn ffill_axis1(&self, limit: Option<usize>) -> Result<Self, FrameError>
pub fn ffill_axis1(&self, limit: Option<usize>) -> Result<Self, FrameError>
Forward-fill missing values across columns for each row.
Matches pd.DataFrame.ffill(axis=1).
Sourcepub fn bfill(&self, limit: Option<usize>) -> Result<Self, FrameError>
pub fn bfill(&self, limit: Option<usize>) -> Result<Self, FrameError>
Back-fill missing values per column.
Matches pd.DataFrame.bfill(). Applies to all columns.
Sourcepub fn pad(&self, limit: Option<usize>) -> Result<Self, FrameError>
pub fn pad(&self, limit: Option<usize>) -> Result<Self, FrameError>
Deprecated pandas alias for Self::ffill. Matches
pd.DataFrame.pad(limit=None). Per br-frankenpandas-qn0bj — pandas
kept pad for backwards compatibility after promoting ffill.
Sourcepub fn backfill(&self, limit: Option<usize>) -> Result<Self, FrameError>
pub fn backfill(&self, limit: Option<usize>) -> Result<Self, FrameError>
Deprecated pandas alias for Self::bfill. Matches
pd.DataFrame.backfill(limit=None). Per br-frankenpandas-qn0bj.
Sourcepub fn bool(&self) -> Result<bool, FrameError>
pub fn bool(&self) -> Result<bool, FrameError>
pandas-named alias for Self::bool_. Matches pd.DataFrame.bool().
Per br-frankenpandas-qn0bj. bool is a Rust keyword in type
position; the public name uses the raw-identifier form so callers
from Rust write df.r#bool(). The Python FFI surface exposes it as
bare bool.
Sourcepub fn bfill_axis1(&self, limit: Option<usize>) -> Result<Self, FrameError>
pub fn bfill_axis1(&self, limit: Option<usize>) -> Result<Self, FrameError>
Back-fill missing values across columns for each row.
Matches pd.DataFrame.bfill(axis=1).
Sourcepub fn interpolate(&self) -> Result<Self, FrameError>
pub fn interpolate(&self) -> Result<Self, FrameError>
Linearly interpolate missing values per numeric column.
Matches pd.DataFrame.interpolate(). Non-numeric columns are preserved.
Sourcepub fn interpolate_method(&self, method: &str) -> Result<Self, FrameError>
pub fn interpolate_method(&self, method: &str) -> Result<Self, FrameError>
Interpolate missing values per numeric column with the specified method.
Matches df.interpolate(method='linear'|'nearest'|'zero').
Sourcepub fn convert_dtypes(&self) -> Result<Self, FrameError>
pub fn convert_dtypes(&self) -> Result<Self, FrameError>
Convert dtypes to best-possible types.
Matches pd.DataFrame.convert_dtypes(). In our type system this
attempts to promote Int64 columns containing NaN to Float64, and
tries to parse Utf8 values as numbers where possible.
Sourcepub fn append(&self, other: &Self) -> Result<Self, FrameError>
pub fn append(&self, other: &Self) -> Result<Self, FrameError>
Append rows from another DataFrame.
Matches pd.DataFrame.append(other) (deprecated but common).
Uses outer join on columns, filling missing with NaN.
Sourcepub fn drop(&self, labels: &[&str], axis: usize) -> Result<Self, FrameError>
pub fn drop(&self, labels: &[&str], axis: usize) -> Result<Self, FrameError>
Drop labels from rows or columns.
Matches df.drop(labels, axis=0) for row removal or
df.drop(columns=['a','b']) for column removal.
When axis=0, removes rows whose index labels match the given labels.
When axis=1, removes columns by name.
Sourcepub fn drop_rows_int(&self, labels: &[i64]) -> Result<Self, FrameError>
pub fn drop_rows_int(&self, labels: &[i64]) -> Result<Self, FrameError>
Drop rows by integer index label (Int64).
Convenience for dropping rows with Int64 index labels.
Sourcepub fn truncate(
&self,
before: Option<&IndexLabel>,
after: Option<&IndexLabel>,
) -> Result<Self, FrameError>
pub fn truncate( &self, before: Option<&IndexLabel>, after: Option<&IndexLabel>, ) -> Result<Self, FrameError>
Truncate the DataFrame by index label range.
Matches df.truncate(before=..., after=...). Keeps rows where
the index label is >= before and <= after.
Sourcepub fn first(&self, offset: &str) -> Result<Self, FrameError>
pub fn first(&self, offset: &str) -> Result<Self, FrameError>
Select rows from the start of a DatetimeIndex up to an offset.
Matches pd.DataFrame.first(offset) where offset is a string like
“3D” (days), “1M” (months), “2Y” (years). Selects all rows whose
index label falls within the offset from the first index value.
Sourcepub fn first_offset(&self, offset: &str) -> Result<Self, FrameError>
pub fn first_offset(&self, offset: &str) -> Result<Self, FrameError>
Explicit alias for Self::first.
Sourcepub fn last(&self, offset: &str) -> Result<Self, FrameError>
pub fn last(&self, offset: &str) -> Result<Self, FrameError>
Select rows from the end of a DatetimeIndex backward by an offset.
Matches pd.DataFrame.last(offset) where offset is a string like
“3D” (days), “1M” (months), “2Y” (years).
§Panics
Panics if the DataFrame reports non-empty but its index has no last label, which indicates internal index corruption.
Sourcepub fn last_offset(&self, offset: &str) -> Result<Self, FrameError>
pub fn last_offset(&self, offset: &str) -> Result<Self, FrameError>
Explicit alias for Self::last.
Per br-frankenpandas-a79h9: the missing-last-label case is reported as a CompatibilityRejected error rather than a panic, so callers can recover from inconsistent frame state instead of crashing.
Sourcepub fn insert(
&self,
loc: usize,
name: impl Into<String>,
column: Column,
) -> Result<Self, FrameError>
pub fn insert( &self, loc: usize, name: impl Into<String>, column: Column, ) -> Result<Self, FrameError>
Insert a column at a specific position.
Matches df.insert(loc, column, value). The column is placed at
position loc (0-indexed) in the column order.
Sourcepub fn isetitem(&self, loc: usize, column: Column) -> Result<Self, FrameError>
pub fn isetitem(&self, loc: usize, column: Column) -> Result<Self, FrameError>
Replace the column at a specific integer position.
Matches pd.DataFrame.isetitem(loc, value) for a single column. This
keeps the existing column label at loc and installs a new column array
rather than mutating the old array in place.
Sourcepub fn isetitem_values(
&self,
loc: usize,
values: Vec<Scalar>,
) -> Result<Self, FrameError>
pub fn isetitem_values( &self, loc: usize, values: Vec<Scalar>, ) -> Result<Self, FrameError>
Replace the column at loc from scalar values.
Convenience arraylike form for Self::isetitem.
Sourcepub fn isetitem_scalar(
&self,
loc: usize,
value: Scalar,
) -> Result<Self, FrameError>
pub fn isetitem_scalar( &self, loc: usize, value: Scalar, ) -> Result<Self, FrameError>
Replace the column at loc with a scalar broadcast across every row.
Convenience scalar form for Self::isetitem.
Sourcepub fn pop(&self, name: &str) -> Result<(Series, Self), FrameError>
pub fn pop(&self, name: &str) -> Result<(Series, Self), FrameError>
Remove and return a column as a Series.
Matches col = df.pop('column_name'). Returns the removed column
as a Series and the modified DataFrame (since we use immutable semantics).
Sourcepub fn replace(
&self,
replacements: &[(Scalar, Scalar)],
) -> Result<Self, FrameError>
pub fn replace( &self, replacements: &[(Scalar, Scalar)], ) -> Result<Self, FrameError>
Replace values element-wise across all columns.
Matches df.replace(to_replace, value). Applies scalar-to-scalar
replacement to every cell in the DataFrame.
Sourcepub fn replace_dict(
&self,
per_column: &BTreeMap<String, Vec<(Scalar, Scalar)>>,
) -> Result<Self, FrameError>
pub fn replace_dict( &self, per_column: &BTreeMap<String, Vec<(Scalar, Scalar)>>, ) -> Result<Self, FrameError>
Replace values on a per-column basis.
Matches df.replace({'col': {old: new, ...}, ...}).
Each entry maps a column name to its replacement pairs. Columns not
listed in the map are left unchanged.
Sourcepub fn replace_regex(&self, pat: &str, repl: &str) -> Result<Self, FrameError>
pub fn replace_regex(&self, pat: &str, repl: &str) -> Result<Self, FrameError>
Replace string values matching a regex pattern across all columns.
Matches df.replace(regex=pat, value=repl). Only applies to
Utf8 columns; non-string columns are left unchanged.
Sourcepub fn align_on_index(
&self,
other: &Self,
mode: AlignMode,
) -> Result<(Self, Self), FrameError>
pub fn align_on_index( &self, other: &Self, mode: AlignMode, ) -> Result<(Self, Self), FrameError>
Align two DataFrames on their indices.
Matches df1.align(df2, join='outer'|'inner'|'left'|'right').
Returns a tuple of two DataFrames aligned to a common index.
Columns are unioned — missing columns filled with NaN.
Sourcepub fn align(
&self,
other: &Self,
mode: AlignMode,
) -> Result<(Self, Self), FrameError>
pub fn align( &self, other: &Self, mode: AlignMode, ) -> Result<(Self, Self), FrameError>
pandas-named alias for Self::align_on_index.
Matches pd.DataFrame.align(other, join=...) for index-axis alignment.
Sourcepub fn compare(&self, other: &Self) -> Result<Self, FrameError>
pub fn compare(&self, other: &Self) -> Result<Self, FrameError>
Compare two DataFrames element-wise, showing differences.
Matches df.compare(other). Returns a DataFrame with multi-level-like
columns showing self and other values where they differ.
Only rows and columns with at least one difference are included.
Sourcepub fn compare_with_result_names(
&self,
other: &Self,
result_names: (&str, &str),
) -> Result<Self, FrameError>
pub fn compare_with_result_names( &self, other: &Self, result_names: (&str, &str), ) -> Result<Self, FrameError>
Matches df.compare(other, result_names=(left, right)).
Sourcepub fn compare_with_options(
&self,
other: &Self,
result_names: (&str, &str),
keep_shape: bool,
keep_equal: bool,
) -> Result<Self, FrameError>
pub fn compare_with_options( &self, other: &Self, result_names: (&str, &str), keep_shape: bool, keep_equal: bool, ) -> Result<Self, FrameError>
Matches df.compare(other, keep_shape=..., keep_equal=..., result_names=(left, right)) for align_axis=1 (the default, columns
axis). keep_shape=true keeps every row and column (equal cells are
NaN, or the original value when keep_equal=true); keep_equal=true
renders equal cells as their value instead of NaN. (align_axis=0 row
stacking is tracked separately under br-frankenpandas-lqu84.)
Sourcepub fn compare_with_align_axis(
&self,
other: &Self,
result_names: (&str, &str),
keep_shape: bool,
keep_equal: bool,
align_axis: i64,
) -> Result<Self, FrameError>
pub fn compare_with_align_axis( &self, other: &Self, result_names: (&str, &str), keep_shape: bool, keep_equal: bool, align_axis: i64, ) -> Result<Self, FrameError>
Matches df.compare(other, align_axis=..., keep_shape=..., keep_equal=..., result_names=(left, right)).
align_axis=1 (default) lays self/other side by side as
col_self/col_other columns; align_axis=0 stacks them as a 2-level
row MultiIndex (label, result_name) over the original columns.
keep_shape/keep_equal behave as in pandas.
Sourcepub fn select_dtypes(
&self,
include: &[DType],
exclude: &[DType],
) -> Result<Self, FrameError>
pub fn select_dtypes( &self, include: &[DType], exclude: &[DType], ) -> Result<Self, FrameError>
Select columns by data type.
Matches df.select_dtypes(include=['float64'], exclude=['bool']).
Pass empty slices to not filter on that criterion.
Sourcepub fn select_dtypes_by_name(
&self,
include: &[&str],
exclude: &[&str],
) -> Result<Self, FrameError>
pub fn select_dtypes_by_name( &self, include: &[&str], exclude: &[&str], ) -> Result<Self, FrameError>
Select columns by pandas-style dtype alias names.
Matches df.select_dtypes(include='number', exclude='object') and
its list-of-strings form. Each alias expands to the corresponding
set of DType variants; unknown aliases return an error consistent
with pandas’ TypeError: data type '...' not understood.
Recognized aliases:
"number","numeric"→ Int64 + Float64"integer","int","int64"→ Int64"floating","float","float64"→ Float64"bool","boolean"→ Bool"object","string","str"→ Utf8"timedelta","timedelta64"→ Timedelta64
Sourcepub fn filter_labels(
&self,
items: Option<&[&str]>,
like: Option<&str>,
regex: Option<&str>,
axis: usize,
) -> Result<Self, FrameError>
pub fn filter_labels( &self, items: Option<&[&str]>, like: Option<&str>, regex: Option<&str>, axis: usize, ) -> Result<Self, FrameError>
Filter rows or columns by label.
Matches df.filter(items, like, regex, axis).
items: exact label matchlike: substring matchregex: regex match
Only one of items/like/regex should be provided at a time. axis=0 filters rows by index label, axis=1 filters columns.
Sourcepub fn take_columns(&self, indices: &[usize]) -> Result<Self, FrameError>
pub fn take_columns(&self, indices: &[usize]) -> Result<Self, FrameError>
Helper for selecting columns by normalized non-negative positional indices.
Used by df.take(indices, axis=1) after negative indices have been resolved.
Sourcepub fn isin(&self, values: &[Scalar]) -> Result<Self, FrameError>
pub fn isin(&self, values: &[Scalar]) -> Result<Self, FrameError>
Return a boolean DataFrame showing whether each element is in values.
Matches df.isin(values).
Sourcepub fn isin_dict(
&self,
per_column: &BTreeMap<String, Vec<Scalar>>,
) -> Result<Self, FrameError>
pub fn isin_dict( &self, per_column: &BTreeMap<String, Vec<Scalar>>, ) -> Result<Self, FrameError>
Element-wise membership test with per-column value sets.
Matches df.isin({'col': [v1, v2], ...}). Each column is tested
against its own set of allowed values. Columns not in per_column
get all-False.
Sourcepub fn equals(&self, other: &Self) -> bool
pub fn equals(&self, other: &Self) -> bool
Check whether this DataFrame is identical to another.
Matches df.equals(other). Compares shape, column names, index, and values.
Sourcepub fn first_valid_index(&self) -> Option<IndexLabel>
pub fn first_valid_index(&self) -> Option<IndexLabel>
Return the index label of the first non-null row (checks all columns).
Matches df.first_valid_index().
Sourcepub fn last_valid_index(&self) -> Option<IndexLabel>
pub fn last_valid_index(&self) -> Option<IndexLabel>
Return the index label of the last non-null row (checks all columns).
Matches df.last_valid_index().
Sourcepub fn asof(
&self,
label: &IndexLabel,
subset: Option<&[&str]>,
) -> Result<Series, FrameError>
pub fn asof( &self, label: &IndexLabel, subset: Option<&[&str]>, ) -> Result<Series, FrameError>
Return the last row(s) without any NaNs before where.
Matches df.asof(where, subset=...).
Sourcepub fn crosstab(
index_series: &Series,
columns_series: &Series,
) -> Result<Self, FrameError>
pub fn crosstab( index_series: &Series, columns_series: &Series, ) -> Result<Self, FrameError>
Compute a crosstab (contingency table) from two columns.
Matches pd.crosstab(index, columns). Counts occurrences of each
(row, col) combination.
Sourcepub fn crosstab_normalize(
index_series: &Series,
columns_series: &Series,
normalize: &str,
) -> Result<Self, FrameError>
pub fn crosstab_normalize( index_series: &Series, columns_series: &Series, normalize: &str, ) -> Result<Self, FrameError>
Crosstab with optional normalization.
Matches pd.crosstab(index, columns, normalize=...).
normalize: “all” divides by grand total, “index” divides by row totals,
“columns” divides by column totals.
Sourcepub fn explode(&self, column: &str, sep: &str) -> Result<Self, FrameError>
pub fn explode(&self, column: &str, sep: &str) -> Result<Self, FrameError>
Explode a column containing delimited strings into multiple rows.
Matches df.explode(column) for string columns. Splits the specified
column by sep and replicates other columns accordingly.
Sourcepub fn explode_with_ignore_index(
&self,
column: &str,
sep: &str,
ignore_index: bool,
) -> Result<Self, FrameError>
pub fn explode_with_ignore_index( &self, column: &str, sep: &str, ignore_index: bool, ) -> Result<Self, FrameError>
Explode a column containing delimited strings into multiple rows.
Matches df.explode(column, ignore_index=...) for the current
string-delimited explode surface.
Sourcepub fn xs(&self, key: &IndexLabel) -> Result<Self, FrameError>
pub fn xs(&self, key: &IndexLabel) -> Result<Self, FrameError>
Select a cross-section of rows by index label.
Matches df.xs(key). Returns all rows whose index matches key.
Sourcepub fn xs_level(
&self,
key: &IndexLabel,
level: usize,
) -> Result<Self, FrameError>
pub fn xs_level( &self, key: &IndexLabel, level: usize, ) -> Result<Self, FrameError>
Select a cross-section of rows by a specific row-MultiIndex level.
Matches df.xs(key, level=...) and drops the selected level from the
resulting row index.
Sourcepub fn droplevel(&self) -> Result<Self, FrameError>
pub fn droplevel(&self) -> Result<Self, FrameError>
Drop the index level (reset to default integer index).
Matches df.droplevel(0) for single-level index.
Sourcepub fn droplevel_level(&self, level: usize) -> Result<Self, FrameError>
pub fn droplevel_level(&self, level: usize) -> Result<Self, FrameError>
Drop a specific row-MultiIndex level.
Sourcepub fn swaplevel(&self) -> Self
pub fn swaplevel(&self) -> Self
Swap levels of a composite string index.
Matches df.swaplevel(). For indexes of the form “(a, b)”, swaps
the components to produce “(b, a)”. Non-composite labels are returned
unchanged.
Sourcepub fn swaplevel_levels(&self, i: usize, j: usize) -> Result<Self, FrameError>
pub fn swaplevel_levels(&self, i: usize, j: usize) -> Result<Self, FrameError>
Swap two row-MultiIndex levels.
Sourcepub fn reorder_levels(&self, order: &[usize]) -> Result<Self, FrameError>
pub fn reorder_levels(&self, order: &[usize]) -> Result<Self, FrameError>
Reorder row-MultiIndex levels.