how should we write the code that tell python to leave empty cell in dataframe when the condition is not meet?
I tries " " like excel but it does not work. I tried 'space' also not work either.
eg. np.where((df['Adj Close']> df['signal']), 1, 'what should be the sign here? ' )
Thanks in advance.
I am expecting the code to return blank cell in pandas dataframe when I run the code.
CodePudding user response:
If need empty numeric value use missing value NaN
:
np.where(df['Adj Close']> df['signal'], 1, np.nan)