I have a dataset with missing values, I determined the best way to approach this problem is to find the median of the row and replace the NaN values with the median value. However, the code runs but values are not replaced.
medianinf= inflation_data.iloc[:, 4:-1].median(axis=1) filledinfdata= inflation_data.replace(to_replace= np.nan, value= medianinf) medianinf= inflation_data.iloc[:, 4:-1].median(axis=1) filled_inf_data=inflation_data.fillna(medianinf) I tried both of these code, a median value is produced of each row but the Nan Values in the dataset are not getting replaced
df.meanwithdf.medianinplace=Truein the original dataframe? Try doinginflation_data.fillna(medianinf, inplace=True)after your second piece of code, without assigning it to "filled_inf_data".