I am trying an algorithm to test the sensitivity of a simple machine learning model. For that I need to change all the values of one column to a value that has occured at least once in that column, while keeping the other columns unchanged. This will be then be passed into the model to make a prediction and then we repeat the procedure again for another value that has occured (until all values have been tried). And this we do for all columns.
Now, I would like to know if there is an efficient way to change the values of an entire column to a specific value?
Now, I thought about creating a for loop to go over the columns and nest within that a for loop that goes over the rows (to get a value from that column to change all other values to). I am a bit new to DataFrames so all I can think of is yet another for loop to go over all rows once again to change them one by one. But then I would have 3 nested for loops and second for loop already is not efficient since there are probably values that occurs multiple times, so I really want to avoid this 3rd for loop. Is there a quick way to change the whole column of a DataFrame to a certain value?