pandas - Array length does not match index length -
i'm looking combine few time series varying dates single dataframe.
each time series' column names date
, px
i've created date index dates
, tried combine time series doing:
dates = pd.date_range('01/01/2017', periods=12, freq='m')
df = pd.dataframe({ 'date': dates, 'a': df2['px'], 'b': df3['px'] . . etc })
expected output:
date b c d e 2017-01-31 -0.4579 nan . . . 2017-02-28 0.5787 nan . . . 2017-03-31 -2.2319 -1.0244 etc etc etc 2017-04-30 -2.0713 -2.1069 2017-05-31 nan 2.0158 2017-06-30 nan 1.0541 2017-07-31 nan 1.8901 2017-08-31 nan nan 2017-09-30 nan nan . . etc
iiuc:
dfs = [df1,df2,df3] pd.concat([df.set_index('date') df in dfs], axis=1).reset_index()
Comments
Post a Comment