From bc917101f67cd49333642a76070376328661d831 Mon Sep 17 00:00:00 2001 From: Michael McKinsey Date: Wed, 10 Jul 2024 21:37:40 -0500 Subject: [PATCH] Remove Optional Argument from _fill_perfdata (#194) * Remove optional argument from _fill_perfdata to always fill with NaN * Fix spelling --- thicket/utils.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/thicket/utils.py b/thicket/utils.py index 22defa23..4373cf01 100644 --- a/thicket/utils.py +++ b/thicket/utils.py @@ -260,27 +260,28 @@ def validate_nodes(tk): ) -def _fill_perfdata(df, numerical_fill_value=np.nan): - """Create full index for DataFrame and fill created rows with NaN's or None's where applicable. +def _fill_perfdata(df): + """Create full index for DataFrame and fill created rows with NaN's or Nones where applicable. Arguments: df (DataFrame): DataFrame to fill missing rows in - numerical_fill_value (any): value to fill numerical rows with Returns: (DataFrame): filled DataFrame """ new_df = df.copy(deep=True) try: + # Value used to fill new rows + fill_value = np.nan # Fill missing rows in dataframe with NaN's new_df = new_df.reindex( pd.MultiIndex.from_product(new_df.index.levels), - fill_value=numerical_fill_value, + fill_value=fill_value, ) # Replace "NaN" with "None" in columns of string type for col in new_df.columns: if pd.api.types.is_string_dtype(new_df[col].dtype): - new_df[col] = new_df[col].replace({numerical_fill_value: None}) + new_df[col] = new_df[col].replace({fill_value: None}) except ValueError as e: estr = str(e) if estr == "cannot handle a non-unique multi-index!":