koalas icon indicating copy to clipboard operation
koalas copied to clipboard

DataFrame reindex(fill_value) fails when containing NaNs

Open LucasG0 opened this issue 6 years ago • 0 comments

In pandas we have :

>>> pdf = pd.DataFrame({"numbers": [1.0, 2.0, None]}, index=['A', 'B', 'C'])
>>> pdf
   numbers
A      1.0
B      2.0
C      NaN
>>> pdf.reindex(index=["A", "C", "E"], fill_value=0).sort_index()
   numbers
A      1.0
C      NaN
E      0.0

But with koalas :

>>> kdf = ks.from_pandas(pdf)
>>> kdf.reindex(index=["A", "C", "E"], fill_value=0).sort_index()
   numbers
A      1.0
C      0.0
E      0.0

All NaNs are replaced why only those inserted by new index values should be replaced.

Also, I think the parameter copy introduces an extra copy around line 7808. One should copy here only if no copy was performed before.

I am working on this issue.

LucasG0 avatar Aug 20 '20 21:08 LucasG0