Align the indices of two
pd.Serieses
Align the indices of the two Series.
"Add two Serieses to create a third Series."
import sys
import numpy as np
import pandas as pd
data = [10.00, 20.00, 30.00, 40.00, 50.00]
prices = pd.Series(data = data, name = "prices") #born with a pd.RangeIndex(1, 5)
prices.index.name = "day"
print(prices)
print()
index = pd.RangeIndex(1, 6, name = "day")
data = [2.00, 3.00, 4.00, 5.00, 6.00]
taxes = pd.Series(data = data, index = index, name = "taxes")
print(taxes)
print()
totalPrices = prices + taxes
totalPrices.name = "total prices"
print(totalPrices)
print()
totalPrices = prices.add(taxes, fill_value = 0.0)
totalPrices.name = "total prices"
print(totalPrices)
sys.exit(0)
day
0 10.0
1 20.0
2 30.0
3 40.0
4 50.0
Name: prices, dtype: float64
day
1 2.0
2 3.0
3 4.0
4 5.0
5 6.0
Name: taxes, dtype: float64
day
0 NaN
1 22.0
2 33.0
3 44.0
4 55.0
5 NaN
Name: total prices, dtype: float64
day
0 10.0
1 22.0
2 33.0
3 44.0
4 55.0
5 6.0
Name: total prices, dtype: float64