Python: ufunc 'add' no contenía un bucle con tipos de concordancia de firma dtype ('S21') dtype ('S21') dtype ('S21')

Tengo dos marcos de datos, ambos tienen unOrder ID y undate.

Quería agregar una bandera en el primer marco de datosdf1: si un registro con el mismoorder id ydate está en el marco de datosdf2, luego agregue unY:

[ df1['R'] = np.where(orders['key'].isin(df2['key']), 'Y', 0)]

Para lograr eso, iba a crear una clave, que sería la concatenación deorder_id ydate, pero cuando intento el siguiente código:

df1['key']=df1['Order_ID']+'_'+df1['Date']

Me sale este error

ufunc 'add' did not contain a loop with signature matching types dtype('S21') dtype('S21') dtype('S21')

df1 se ve así:

Date | Order_ID | other data points ... 
201751 4395674  ...
201762 3487535  ...

Estos son los tipos de datos:

df1.info()
RangeIndex: 157443 entries, 0 to 157442
Data columns (total 6 columns):
Order_ID                                 157429 non-null object
Date                                     157443 non-null int64
...
dtypes: float64(2), int64(2), object(2)
memory usage: 7.2+ MB

df1['Order_ID'].values
array(['782833030', '782834969', '782836416', ..., '783678018',
       '783679806', '783679874'], dtype=object)

Respuestas a la pregunta(1)

Su respuesta a la pregunta