I have 2 pandas dfs (df1 & df2) as seen here:
df1 | col1 | col2 | col3 | col4 | col5 |
---|---|---|---|---|---|
row1 | Dog | Cat | Bird | Tree | Lion |
row2 | Cat | Dragon | Bird | Dog | Tree |
row3 | Cat | Dog | Bird | Tree | Hippo |
row4 | Cat | Tree | Bird | Ant | Fish |
row5 | Cat | Tree | Monkey | Dragon | Ant |
df2 | col1 | col2 | col3 | col4 | col5 |
---|---|---|---|---|---|
row1 | 3.219843 | 1.3631996 | 1.0051135 | 0.89303696 | 0.4313375 |
row2 | 2.8661892 | 1.4396228 | 0.7863044 | 0.539315 | 0.48167187 |
row3 | 2.5679462 | 1.3657334 | 0.9470184 | 0.79186934 | 0.48637152 |
row4 | 3.631389 | 0.94815284 | 0.7561722 | 0.6743943 | 0.5441728 |
row5 | 2.4727197 | 1.5941181 | 1.4069512 | 1.064051 | 0.48297918 |
The string elements of the df1 correspond to the values of df2. For both dataframes the condition exists that an element (or a value) does not repeat on the same row. But can be repeated on different rows.
For example Dog of row1 = 3.219843, bird of row3 = 0.9470184, bird of row4 = 0.7561722 etc.
I would like to extract the values for all unique elements of the 1st df into different arrays. Like:
Dog = [3.219843, 0.539315, 1.3657334]
Cat = [1.3631996, 2.8661892, 2.5679462, 3.631389, 2.4727197]
etc...
Any ideas?
Many thanks!