adding docs

This commit is contained in:
Palash Tyagi 2024-11-14 17:08:57 +00:00
parent 03b94fa462
commit e8b5cc4354

View File

@ -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;
}