0

I have a few files that I've read into pandas dataframes that share the same values for the 0 column, but have differing values for the 1 column.

How can I iterate over multiple dataframes, pull out just the 1 column, and add each one to the first pandas dataframe after its 1 column. Example:

df1

0     1
-10   5
-9.95 2
-9.8  3

df2

0     1
-10   2
-9.95 4
-9.8  7

df3

0     1
-10   6
-9.95 8
-9.8  5

What I want as a final df (column names could be changed to 0123 or something)

0     1 1 1
-10   5 2 6
-9.95 2 4 8
-9.8  3 7 5

I'm new to python and pandas so I'm not really sure how to approach this.

NaN
  • 643
  • 1
  • 8
  • 21

0 Answers0