1

I have two series which have the same index. Their basic format is

a =

Index Data_Value
date1  3
date2  56
.      .
.      .
.      .

b =

Index Data_Value
date1  22
date2  34
.      . 
.      .
.      .

Based on previous question answered here, I am trying to join them using:

a.to_frame().join(b.to_frame())

but I get the error:

ValueError: columns overlap but no suffix specified: Index(['Data_Value'], dtype='object')

I thought it might be an issue with the field name,because 'b.name' returns 'Data_Value', so I tried:

a.to_frame().join(b.to_frame(),on='Data_Value' ) but still the same error.

Any guidance very welcome.

ZakS
  • 921
  • 2
  • 12
  • 25

2 Answers2

2

There is same names, simpliest is change it in to_frame:

c = a.to_frame('a').join(b.to_frame('b'))
print (c)
        a   b
Index        
date1   3  22
date2  56  34
jezrael
  • 729,927
  • 78
  • 1,141
  • 1,090
1

If you want to both value same name using concat

pd.concat([a,b],1)
Out[129]: 
       Data_Value  Data_Value
Index                        
date1           3          22
date2          56          34
BENY
  • 296,997
  • 19
  • 147
  • 204