So I am editing a dataframe for a project and I need to replace null values in 105 columns with ‘No answer’
in order to do this I wrote the following code but it only created a view of the updated dataframe. when I look at the actual dataframe nothing has actually changed. I find this odd because im using loc method and fillna('No answer',interface=True). I thought by making interface = True it meant the actual dataframe would be updated and the same for loc function.
Code I used:
candy.loc[:,'Q6 | 100 Grand Bar':'Q11: DAY'].fillna('NO_ANSWER', inplace=True)
candy.loc[:,'Q6 | 100 Grand Bar':'Q11: DAY']
Second code just prints out the original dataframe for the columns I wanted to edited
You can see in the image that the Nan values are still there after running first code
Can any one explain my error in logic and why its not working as intended
and possible solutions. Pic below is what Im getting

>Solution :
When you are using .loc, you are generating a new object, which is a slice of the original dataframe. inplace=True is applied to this new object, not the original dataframe, hence you see no changes in the original dataframe. So what you want to do is the following:
candy.loc[:,'Q6 | 100 Grand Bar':'Q11: DAY'] = candy.loc[:,'Q6 | 100 Grand Bar':'Q11: DAY'].fillna('NO_ANSWER')