0

I have the first Dataframe:

+-------+-------+--------+
| index | Nodes | CapLiv |
+-------+-------+--------+
|     0 |     0 |  -0.75 |
|     1 |     2 |   0.65 |
|     2 |     3 |   0.50 |
|     3 |     4 |   0.85 |
+-------+-------+--------+

Then I need to pass the CapLiv value of each node to the second Dataframe.


+-------+--------+-------+-----------+--------+
| index | origem | Nodes | n saltos  | CapLiv |
+-------+--------+-------+-----------+--------+
|     0 |     15 |     0 |         1 |        |
|     1 |     16 |     0 |         2 |        |
|     2 |     17 |     0 |         2 |        |
|     3 |     18 |     0 |         2 |        |
|     4 |     19 |     0 |         2 |        |
|     5 |     18 |     2 |         1 |        |
|     6 |     16 |     3 |         1 |        |
|     7 |     19 |     3 |         1 |        |
|     8 |     17 |     4 |         1 |        |
+-------+--------+-------+-----------+--------+

How is the best way I can do this?

Thanks in advance.

Ps: After not being able to explain myself better, I found the solution.

cap_liv_dict = pd.Series(dl.CapLiv.values, index=dl.Nodes).to_dict()

dh['cap_liv_node'] = dh['destino'].map(cap_liv_dict)

´´´

0 Answers0