mirror of
https://github.com/Magnus167/msyrs.git
synced 2025-08-20 13:00:01 +00:00
feat: add utils/dftools, is_quantamental_dataframe function to validate DataFrame structure
This commit is contained in:
parent
4775e9e504
commit
abf699f38c
18
src/utils/dftools.rs
Normal file
18
src/utils/dftools.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
use polars::prelude::*;
|
||||||
|
|
||||||
|
const QDF_IDX_COLUMNS: [&str; 3] = ["real_date", "cid", "xcat"];
|
||||||
|
|
||||||
|
/// Check if a DataFrame is a quantamental DataFrame.
|
||||||
|
fn is_quantamental_dataframe(df: &DataFrame) -> bool {
|
||||||
|
let columns = df
|
||||||
|
.get_column_names()
|
||||||
|
.iter()
|
||||||
|
.map(|s| s.as_str())
|
||||||
|
.collect::<Vec<&str>>();
|
||||||
|
let has_idx_columns = QDF_IDX_COLUMNS.iter().all(|col| columns.contains(col));
|
||||||
|
|
||||||
|
// check if real_date is date-type
|
||||||
|
let real_date = df.column("real_date").unwrap();
|
||||||
|
|
||||||
|
has_idx_columns
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user