mirror of
https://github.com/Magnus167/msyrs.git
synced 2025-11-24 02:56:11 +00:00
python working with notebook!
This commit is contained in:
@@ -17,11 +17,11 @@ const QDF_INDEX_COLUMNS: [&str; 3] = ["real_date", "cid", "xcat"];
|
||||
/// If no filters are provided, the original DataFrame is returned.
|
||||
pub fn reduce_dataframe(
|
||||
df: DataFrame,
|
||||
cids: Option<Vec<&str>>,
|
||||
xcats: Option<Vec<&str>>,
|
||||
cids: Option<Vec<String>>,
|
||||
xcats: Option<Vec<String>>,
|
||||
metrics: Option<Vec<String>>,
|
||||
start: Option<&str>,
|
||||
end: Option<&str>,
|
||||
start: Option<String>,
|
||||
end: Option<String>,
|
||||
intersect: bool,
|
||||
) -> Result<DataFrame, Box<dyn Error>> {
|
||||
check_quantamental_dataframe(&df)?;
|
||||
@@ -36,10 +36,10 @@ pub fn reduce_dataframe(
|
||||
let u_xcats: Vec<String> = get_unique_xcats(&new_df)?;
|
||||
let u_tickers: Vec<String> = _get_unique_strs_from_str_column_object(&ticker_col)?;
|
||||
|
||||
let specified_cids: Vec<&str> =
|
||||
cids.unwrap_or_else(|| u_cids.iter().map(AsRef::as_ref).collect());
|
||||
let specified_xcats: Vec<&str> =
|
||||
xcats.unwrap_or_else(|| u_xcats.iter().map(AsRef::as_ref).collect());
|
||||
let cids_vec = cids.unwrap_or_else(|| u_cids.clone());
|
||||
let specified_cids: Vec<&str> = cids_vec.iter().map(AsRef::as_ref).collect();
|
||||
let xcats_vec = xcats.unwrap_or_else(|| u_xcats.clone());
|
||||
let specified_xcats: Vec<&str> = xcats_vec.iter().map(AsRef::as_ref).collect();
|
||||
|
||||
let non_idx_cols: Vec<String> = new_df
|
||||
.get_column_names()
|
||||
@@ -107,7 +107,7 @@ pub fn reduce_dataframe(
|
||||
// Apply date filtering if `start` or `end` is provided
|
||||
|
||||
if let Some(start) = start {
|
||||
let start_date = chrono::NaiveDate::parse_from_str(start, "%Y-%m-%d")?;
|
||||
let start_date = chrono::NaiveDate::parse_from_str(&start, "%Y-%m-%d")?;
|
||||
new_df = new_df
|
||||
.lazy()
|
||||
.filter(
|
||||
@@ -120,7 +120,7 @@ pub fn reduce_dataframe(
|
||||
}
|
||||
|
||||
if let Some(end) = end {
|
||||
let end_date = chrono::NaiveDate::parse_from_str(end, "%Y-%m-%d")?;
|
||||
let end_date = chrono::NaiveDate::parse_from_str(&end, "%Y-%m-%d")?;
|
||||
new_df = new_df
|
||||
.lazy()
|
||||
.filter(
|
||||
|
||||
Reference in New Issue
Block a user