Skip to content

DOC: fill_value argument in Series.combine() #22953

Closed
@kaybhutani

Description

@kaybhutani

Series.combine() method is not handling NaN values correctly.
On running this code, NaN is still returned and isnt replaced by 5.

#importing pandas module
import pandas as pd

#importing numpy module
import numpy as np

#creating first series
first=[1,2,np.nan,5,6,3,np.nan,7,11,0,4,8]

#creating second series
second=[5,3,2,np.nan,1,3,9,21,3,np.nan,1,np.nan]

#making series
first=pd.Series(first)

#making seriesa
second=pd.Series(second)

#calling .combine() method
result=first.combine(second, (lambda x1, x2: x1 if x1 > x2 else x2) , fill_value=5)

#display
result

The NULL values in Caller series are replaced but the Null values in the passed series remain there. Unlike other similar methods like .add(), .sub() etc. this one isn't handling Null values of passed series correctly.

If this issue is approved, i would like to contribute and fix it

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions