mirror of
https://github.com/Magnus167/msyrs.git
synced 2025-08-19 23:20:01 +00:00
refactor: rename apply_blacklist_lazy to apply_blacklist and update documentation
This commit is contained in:
parent
0e4d58a9d8
commit
1275e7c2c9
@ -22,21 +22,41 @@ impl Blacklist {
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply a blacklist to a Quantamental DataFrame with Lazy API.
|
||||
/// Apply a blacklist to a Quantamental DataFrame.
|
||||
///
|
||||
/// * `blacklist` is a map from any “ticker‑like” key to a tuple of
|
||||
/// `(start_date, end_date)` in **inclusive** `"YYYY‑MM‑DD"` format.
|
||||
/// * `metrics` – if `None`, every metric from `get_unique_metrics(df)`
|
||||
/// is used.
|
||||
/// * `group_by_cid = Some(false)` is not implemented yet (parity with
|
||||
/// the eager version).
|
||||
pub fn apply_blacklist_lazy(
|
||||
/// * `group_by_cid = Some(false)` is not implemented yet.
|
||||
pub fn apply_blacklist(
|
||||
df: &mut DataFrame,
|
||||
blacklist: &BTreeMap<String, (String, String)>,
|
||||
metrics: Option<Vec<String>>,
|
||||
group_by_cid: Option<bool>,
|
||||
) -> Result<DataFrame, Box<dyn std::error::Error>> {
|
||||
check_quantamental_dataframe(df)?;
|
||||
// dataframe is like:
|
||||
// | cid | xcat | real_date | metric1 | metric2 |
|
||||
// |-----|------|-----------|---------|---------|
|
||||
// | A | B | 2023-01-01| 1.0 | 2.0 |
|
||||
// | A | B | 2023-01-02| 1.0 | 2.0 |
|
||||
// | A | C | 2023-01-01| 1.0 | 2.0 |
|
||||
// | A | C | 2023-01-02| 1.0 | 2.0 |
|
||||
// | D | E | 2023-01-01| 1.0 | 2.0 |
|
||||
// | D | E | 2023-01-02| 1.0 | 2.0 |
|
||||
|
||||
// (real date column is Naive date)
|
||||
|
||||
// blacklist is like:
|
||||
// {'A_B_1': ('2023-01-02', '2023-01-03'),
|
||||
// 'A_B_2': ('2023-01-04', '2023-01-05'),
|
||||
// 'A_C_1': ('2023-01-02', '2023-01-03'), }
|
||||
|
||||
// get_cid('A_B_1') = 'A'
|
||||
// get_cid('A_B_2') = 'A'
|
||||
// get_cid('D_E_1') = 'D'
|
||||
|
||||
Ok(df.clone())
|
||||
}
|
||||
/// Create a blacklist from a Quantamental DataFrame.
|
||||
|
Loading…
x
Reference in New Issue
Block a user