Let's say I have main df:
ID title grade1 grade2 "1111" "something" 1 2 "2222" "something1" 2 2 "3333" "something2" 1 1 "something3" "8865" 1 1 "4444" "something3" 1 2 "5555" "something4" 1 1 "6666" "something5" 2 2 "somethingX" "8888" 1 1 And as u can see it's thera are mixed up values in columns 1 and 2
So what I do:
- put all wrong names to new df:
temp = df[df['ID'].str.len() > 4] - create list from new df:
listToMove = temp['ID].unique() - delete all records from df by for:
df = df[df['ID'] != listToMove[i]) - change column plce in temp
df - append temp df to df.
But i think it's not the best practice. it's work fine... but that for... i think it's slow, and I can do it faster.
Any suggestion?
Result shoud be:
ID title grade1 grade2 "1111" "something" 1 2 "2222" "something1" 2 2 "3333" "something2" 1 1 "8865" "something3" 1 1 "4444" "something3" 1 2 "5555" "something4" 1 1 "6666" "something5" 2 2 "8888" "somethingX" 1 1