Python Forum
Data Loops - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Data Loops (/thread-31597.html)



Data Loops - ZairaRosas - Dec-21-2020

0


I have two dataframes:

df_id:

Output:
name id region 01 850 region 01 15062 region 02 851
df_combination:

Output:
Origin destination total region 01 region 01 1954 region 01 region 02 39
I have to perform all the possible combinations between region 01 and region 02 and divide the total between the total number of combinations.

Something like this output:

Output:
Origin_id Destination_id Total_division 850 850 488.5 850 15062 488.5 15062 850 488.5 15062 15062 488.5 850 851 19.5 15062 851 19.5
I have more than 300 regions, so I wonder if do it by python code (maybe loop) would be possible.