Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
x = pd.Series([1, 2, 2, np.nan], index=['p', 'q', 'r', 's'])
x
Out[2]:
p    1.0
q    2.0
r    2.0
s    NaN
dtype: float64

In [3]:
y = pd.Series([2, np.nan, 2, np.nan], index=['p', 'q', 's', 't'])
y
Out[3]:
p    2.0
q    NaN
s    2.0
t    NaN
dtype: float64

In [5]:
x.rsub(y, fill_value=0)
Out[5]:
p    1.0
q   -2.0
r   -2.0
s    2.0
t    NaN
dtype: float64