flasc.utilities.energy_ratio_utilities.bin_and_group_dataframe#
- flasc.utilities.energy_ratio_utilities.bin_and_group_dataframe(df_: DataFrame, ref_cols: List, test_cols: List, wd_cols: List, ws_cols: List, wd_step: float = 2.0, wd_min: float = 0.0, wd_max: float = 360.0, ws_step: float = 1.0, ws_min: float = 0.0, ws_max: float = 50.0, wd_bin_overlap_radius: float = 0.0, remove_all_nulls: bool = False, bin_cols_without_df_name: List | None = None, num_df: int = 0)[source]#
Bin and aggregate a DataFrame based on wind direction and wind speed parameters.
This function takes a Polars DataFrame (df_) and performs binning and aggregation operations based on wind direction (wd) and wind speed (ws). It allows for optional handling of reflected rows and grouping by specific columns. The resulting DataFrame contains aggregated statistics for reference and test power columns within specified bins.
- Parameters:
df (DataFrame) -- The input Polars DataFrame to be processed.
ref_cols (List[str]) -- List of columns containing reference power data.
test_cols (List[str]) -- List of columns containing test power data.
wd_cols (List[str]) -- List of columns containing wind direction data.
ws_cols (List[str]) -- List of columns containing wind speed data.
wd_step (float, optional) -- Step size for wind direction binning. Defaults to 2.0.
wd_min (float, optional) -- Minimum wind direction value. Defaults to 0.0.
wd_max (float, optional) -- Maximum wind direction value. Defaults to 360.0.
ws_step (float, optional) -- Step size for wind speed binning. Defaults to 1.0.
ws_min (float, optional) -- Minimum wind speed value. Defaults to 0.0.
ws_max (float, optional) -- Maximum wind speed value. Defaults to 50.0.
wd_bin_overlap_radius (float, optional) -- Radius for overlapping wind direction bins. Defaults to 0.0.
remove_all_nulls (bool, optional) -- If True, remove rows unless all valid instead of any. Defaults to False.
bin_cols_without_df_name (List[str], optional) -- List of columns used for grouping without 'df_name'.
num_df (int, optional) -- Number of dataframes required for each bin combination.
df_ (DataFrame)
- Returns:
The resulting Polars DataFrame with aggregated statistics.
- Return type:
DataFrame