I need to concatenate columns from df1 and df2. for each row in df2, df1 columns will be concatenated
Asked
Active
Viewed 28 times
-1
-
Please don't post images of code, data, or Tracebacks. Copy and paste it as text then format it as code (select it and type `ctrl-k`) ... [Discourage screenshots of code and/or errors](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors)...[Why not upload images of code on SO when asking a question?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question) ... [You should not post code as an image because:...](https://meta.stackoverflow.com/a/285557/2823755) – wwii Feb 09 '21 at 19:18
-
[How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – wwii Feb 09 '21 at 19:19
-
Your question is too broad. Welcome to SO. This isn't a discussion forum or tutorial. Please take the [tour] and take the time to read [ask] and the other links found on that page. – wwii Feb 09 '21 at 19:19
-
Please include [minimal-reproducible-example](https://stackoverflow.com/help/minimal-reproducible-example) it to the question. Also make sure to read [How do I ask good question](https://stackoverflow.com/help/how-to-ask) – Ahmet Feb 09 '21 at 19:36
1 Answers
0
Assuming that these are represented as Pandas data frames, the following should return the concatenated data frame you're looking for:
result = pd.concat([df1, df2], axis=1, join="inner")

magmacollaris
- 79
- 7
-
It is printing only 1 row. Needs to concat df1 with all rows in df2 – Kaushik Dey Feb 10 '21 at 06:42