问题
The following 2 series of stocks in a single excel file:
Can be combined using the date as index?
The result should be like this:
回答1:
You need a simple df.merge()
here:
df = pd.merge(df1, df2, left_index=True, right_index=True, how='outer')
OR
df = df1.join(df2, how='outer')
回答2:
I am trying this:
df3 = pd.concat([df1, df2]).sort_values('Date').reset_index(drop=True)
or
df3 = df1.append(df2).sort_values('Date').reset_index(drop=True)
来源:https://stackoverflow.com/questions/64212463/combine-series-by-date