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():