Python Forum

Full Version: Data Loops
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.