I am dealing with a large medical dataset, and I want to see if there are some rows that corresponds to the same patient. The column that corresponds to the patient's ID is ID Patient
.
I want to create a new column where it will be "yes"
if that patient appears in more than one row, or "no"
if it only appears once.
This is the code that I did:
df['Repeated'] = 'No' # New Column
for i in range(0,len(df)):
for f in range(0,len(df)):
if df['ID NP'].iloc[i] == df['ID NP'].iloc[f]:
df['ID NP'].iloc[i] = 'Yes'
else:
df['ID NP'].iloc[i] = 'No'
However this operation is taking too much time. Is there any way to do it faster?