From 9c91759471f76f6ea9dab371d39028ce8ebbdd1b Mon Sep 17 00:00:00 2001 From: micchu Date: Wed, 9 Oct 2024 14:57:26 +0900 Subject: [PATCH] [fix] fix replace nan method --- bdpy/fig/makeplots2.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bdpy/fig/makeplots2.py b/bdpy/fig/makeplots2.py index 04915da..d2c8883 100644 --- a/bdpy/fig/makeplots2.py +++ b/bdpy/fig/makeplots2.py @@ -593,9 +593,10 @@ def __weird_form_to_long(df, target_col, identify_cols=[]): identify_cols: list of str A list of columns to keep in the decomposed dataframe, other than target_col. """ - # replace NaN to [np.nan] - nans = df[target_col].isna() - df[target_col][nans] = [np.nan] + # # replace NaN to [np.nan] + nan_index = np.where(df[target_col].isna())[0] + for i in nan_index: + df.at[i, target_col] = [np.nan] # Weird form df_result = pd.DataFrame() for i, row in df.iterrows():