python - Add pandas Series to a DataFrame, preserving index -
i have been having problems adding contents of pandas series pandas dataframe. start empty dataframe, initialised several columns (corresponding consecutive dates).
i sequentially fill dataframe using different pandas series, each 1 corresponding different date. however, each series has (potentially) different index.
i resulting dataframe have index union of each of series indices.
i have been doing far:
for date in dates: df[date] = series_for_date
however, df index corresponds of first series , data in successive series correspond index 'key' not in first series lost.
any appreciated!
ben
if understand can use concat
:
pd.concat([series1,series2,series3],axis=1)
Comments
Post a Comment