Given:
DF1 = pd.DataFrame({'Val':[5, 5, 5, 5, 5, 5, 5]}, index=[0, 1, 2, 3, 4, 5, 6])
DF2 = pd.DataFrame({'Val':[2, 2, 2, 2]}, index=[0, 1, 2, 3])
DF3 = pd.DataFrame({'Val':[5, 5, 5, 5, 5, 5, 5, 5]}, index=[0, 1, 2, 3, 4, 5, 6, 7])
You can do:
DF1['Val'].subtract(DF2['Val'].reindex(DF1.index, fill_value=0))
0 3
1 3
2 3
3 3
4 5
5 5
6 5
Name: Val, dtype: int64
For your second question, it's the opposite:
DF1['Val'].reindex(DF2.index, fill_value=0).subtract(DF2['Val'])
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 -5
Name: Val, dtype: int64
EDIT:
For the more complex case (where there is an index overlap but one is not a subset of the other):
DF4 = pd.DataFrame({'Val':[5, 5]}, index=[4, 5])
DF5 = pd.DataFrame({'Val':[5, 5, 5]}, index=[5, 6, 7])
common_index = DF4.index.union(DF5.index)
DF4['Val'].reindex(common_index, fill_value=0).subtract(DF5['Val'].reindex(common_index, fill_value=0))
4 5
5 0
6 -5
7 -5
Name: Val, dtype: int64