From e8b5cc4354f03a7fa1b9fce249a1d6df1195dd8f Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Thu, 14 Nov 2024 17:08:57 +0000 Subject: [PATCH] adding docs --- src/utils/dftools.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/utils/dftools.rs b/src/utils/dftools.rs index 6d38743..83c68c9 100644 --- a/src/utils/dftools.rs +++ b/src/utils/dftools.rs @@ -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::>(); - 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; }