I've written the following simple function, but it's running rather slow. For df1 I'm using a dataframe without any column (only index) and for df2 I'm using a dataframe with 10 columns and trying to add one df2's columns along with it's value to df1 if the indices match.
def add_labels_column(df1, df2):
for idx1 in df1.index:
for idx2 in df2.index:
if idx1 == idx2:
df1['Finding Labels'] = df2['Finding Labels']
return df1
I'm looking for a faster solution, perhaps using pandas and/or numpy. I'm a new to Python, pandas or numpy.