mirror of
https://github.com/Magnus167/msyrs.git
synced 2025-08-20 13:10:00 +00:00
adding docs
This commit is contained in:
parent
03b94fa462
commit
e8b5cc4354
@ -1,15 +1,27 @@
|
||||
use polars::prelude::*;
|
||||
|
||||
const QDF_IDX_COLUMNS: [&str; 3] = ["real_date", "cid", "xcat"];
|
||||
/// The standard metrics provided by JPMaQS (`value`, `grading`, `eop_lag`, `mop_lag`).
|
||||
pub const DEFAULT_JPMAQS_METRICS: [&str; 4] = ["value", "grading", "eop_lag", "mop_lag"];
|
||||
|
||||
/// The required columns for a Quantamental DataFrame.
|
||||
pub const QDF_INDEX_COLUMNS: [&str; 3] = ["real_date", "cid", "xcat"];
|
||||
|
||||
|
||||
/// Check if a DataFrame is a quantamental DataFrame.
|
||||
/// A standard Quantamental DataFrame has the following columns:
|
||||
/// - `real_date`: Date column as a date type
|
||||
/// - `cid`: Column of cross-sectional identifiers
|
||||
/// - `xcat`: Column of extended categories
|
||||
///
|
||||
/// Additionally, the DataFrame should have atleast 1 more column.
|
||||
/// Typically, this is one (or more) of the default JPMaQS metics.
|
||||
pub 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));
|
||||
let has_idx_columns = QDF_INDEX_COLUMNS.iter().all(|col| columns.contains(col));
|
||||
if !has_idx_columns {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user