I got an unexpected result when using funciton "replace" to replace "np.nan"
>>> import numpy as np
>>> import databricks.koalas as ks
>>> df = ks.DataFrame([[1, np.inf], [2, -np.inf], [3, np.nan]], columns=['c1', 'c2'])
>>> print(df)
c1 c2
0 1 inf
1 2 -inf
2 3 NaN
>>> print(df.replace([np.inf, -np.inf, np.nan], 0))
c1 c2
0 1 0
1 2 0
2 3 NaN
>>> print(df.mask(df['c2'].isin([np.inf, -np.inf, np.nan]), 0))
c1 c2
0 1 0
1 2 0
2 3 0
Hi, I think it may come from the fact that np.nan is not equal to itself. I am interested in working on this issue if it is free. :)
Please go ahead, @LucasG0 ! :)
Most helpful comment
Hi, I think it may come from the fact that
np.nanis not equal to itself. I am interested in working on this issue if it is free. :)