[英]A better way to loop through 2 Dataframes
I have 2 Dataframes.我有 2 个数据框。 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.
最后,我想将 df2 中的一些列添加到 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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.