'A better way to loop through 2 Dataframes
I have 2 Dataframes. i am trying to find corresponding row values based on filter values. At the end, i want to add some columns in df2 to df1. The problem with the example below is that it is nor efficient when dealing with large dataset.
selected_rows = pd.Dataframe()
for i, rowi in df1.iterrows():
for j, rowj in df2.iterrows():
if (rowi['Customer'] == rowj['Customer']) & (rowi['CaseID'] == rowj['CaseID']):
rowi['Resolution'] = rowj['Resolution']
rowi['Diagnostic'] = rowj['Diagnostic']
selected_rows = selected_rows.append(rowi)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
