Closed
Description
Unless I misunderstood what the documentation says, this is not the intended behavior:
df1 = pandas.DataFrame({'a':np.arange(5),'b':np.arange(5)},index=3+np.arange(5))
df2 = pandas.DataFrame({'c':np.arange(5),'d':np.arange(5)})
pandas.concat([df1,df2],axis=1,ignore_index=False)
a b c d
0 NaN NaN 0 0
1 NaN NaN 1 1
2 NaN NaN 2 2
3 0 0 3 3
4 1 1 4 4
5 2 2 NaN NaN
6 3 3 NaN NaN
7 4 4 NaN NaN
The following function does a work-around for this bug by explicitly re-setting the index:
def myConcat(df1,df2):
if df1.shape[0] != df2.shape[0]:
return False
else:
df2.index = df1.index
return pandas.concat((df1,df2),axis=1)
Pandas version: commit de6cce5