0

I have two dataframe as below:

      Background    Skin            Body               Face          Head
value   Beige     Light Gray   TribalNecklace        Beard          Bowl Cut
value   Blue      Normal        BowTie Pink         Blushing        Durag Red. 

and

          Link
0 https://example.com
1 httpsl//example2.com

when joing two using below code:

df5 = pd.concat([df1, linkdf], axis=1, ignore_index=True)
df5

gives an error:

ValueError: Shape of passed values is (6, 6), indices imply (4, 6)

How do I join two dataframe without getting that error? Thank you for helping in advance.

Raymond Toh
  • 779
  • 1
  • 8
  • 27
Zac
  • 323
  • 7
  • 14

2 Answers2

1

Try with assign:

df5 = df1.assign(links=linkdf.values)
>>> df5
      Background        Skin            Body      Face        Head                 links
value      Beige  Light Gray  TribalNecklace     Beard    Bowl Cut   https://example.com
value       Blue      Normal     BowTie Pink  Blushing  Durag Red.  httpsl//example2.com
Corralien
  • 109,409
  • 8
  • 28
  • 52
1

Try changing your code from:

df5 = pd.concat([df1, linkdf], axis=1, ignore_index=True)

To

df5 = pd.concat([df1.reset_index(), linkdf], axis=1)

Gives you:

   index Background        Skin  ...      Face        Head                  Link
0  value      Beige  Light Gray  ...     Beard    Bowl Cut   https://example.com
1  value       Blue      Normal  ...  Blushing  Durag Red.  httpsl//example2.com
sophocles
  • 13,593
  • 3
  • 14
  • 33
  • one more question is there a way to make the link clickable – Zac Sep 21 '21 at 09:03
  • perhaps [this](https://stackoverflow.com/questions/42263946/how-to-create-a-table-with-clickable-hyperlink-in-pandas-jupyter-notebook) will help you – sophocles Sep 21 '21 at 09:05