Koalas: Function "replace" Case

Created on 12 Nov 2020  路  2Comments  路  Source: databricks/koalas

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
bug

Most helpful comment

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. :)

All 2 comments

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 ! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shril picture shril  路  5Comments

patryk-oleniuk picture patryk-oleniuk  路  3Comments

rodneyjoyce picture rodneyjoyce  路  4Comments

akhilanandbv003 picture akhilanandbv003  路  5Comments

ueshin picture ueshin  路  4Comments