I have a dataframe where i have repeated column headers in rows. I need to drop only duplicated header name and not duplicated values. Please note header is None in this case
Input:
0. Gender age occu name
1. F 21 A B
2. Gender age occu name
3. M 22 C D
4. Gender age occu name
5. M 23 F E
6. M 23 F E
Required output:
0. Gender age occu name
1. F 21 A B
2. M 22 C D
3. M 23 F E
5. M 23 F E
For this i'm trying:
for i in range(0,len(a)-1):
print(a.iloc[i])
if(a.loc[0] == a.loc[i+1]).all() == True:
print('yes')
a.drop(i)
Please note i can't take the row name(0th row directly as it may changes and that's why i have to compare all the other rows with 0th row using loop and have to drop that row where ever there is a match). Consider 0th row as primary row.