My dataframe looks like
Name score
A;A;B 5
C;C;A 6
I want to make it without using any for loop
Name score
A 5
B 5
C 6
A 6
Please help. Thanks in advance.
Use DataFrame.explode with splitted values by ; and then DataFrame.drop_duplicates:
df = (df.assign(Name = df['Name'].str.split(';'))
.explode('Name')
.drop_duplicates(['Name','score'], ignore_index=True))
print (df)
Name score
0 A 5
1 B 5
2 C 6
3 A 6
print (df.head().to_dict()) ?