Question:
I have a dataframe:I am just putting one column of my dataframe, but I actually have eleven columns where all values outside the specific column range must be replaced by np.nan. All in place within the original df.
Is there a simple way of doing this? I have tried to use lambda functions with where, but it doesn’t work.
Answer:
UseDataFrame.mask
If you have better answer, please add a comment about this, thank you!