I am bit puzzled because I would expect the following code to produce a Pandas DataFrame or Series and instead returns a tuple.
import pandas_datareader.data as web
import random
import pandas as pd
start_date = '2018-01-01'
end_date = '2018-06-06'
SPY = web.DataReader('SPY', 'yahoo', start_date, end_date)
SPY = SPY[['Adj Close']]
SPY.columns = ['Price']
SPY1 = SPY.iloc[random.sample(range(len(SPY.index)), 80), ]
SPY2 = SPY.iloc[random.sample(range(len(SPY.index)), 80), ]
SPY3 = SPY1.align(SPY2, join = 'inner', axis = 0)
type(SPY3)
tuple
I can transform the tuple to a Series as follows:
SPY3 = pd.Series(SPY3[0])
Still I wonder why a tuple is returned in the first place.