How to drop duplicates from a subset of rows in a pandas dataframe?
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Meditation
--
Chapters
00:00 Question
00:52 Accepted answer (Score 10)
01:09 Answer 2 (Score 5)
01:20 Thank you
--
Full question
https://stackoverflow.com/questions/4893...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pandas
#avk47
    --
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Meditation
--
Chapters
00:00 Question
00:52 Accepted answer (Score 10)
01:09 Answer 2 (Score 5)
01:20 Thank you
--
Full question
https://stackoverflow.com/questions/4893...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #pandas
#avk47
ACCEPTED ANSWER
Score 11
You can sue pd.concat split the df by B 
df=pd.concat([df.loc[df.B!=True],df.loc[df.B==True].drop_duplicates(['A'],keep='first')]).sort_index()
df
Out[1593]: 
    A     B  C
0  12  True  1
2   3   NaN  2
3   3   NaN  3
ANSWER 2
Score 5
df[df.B.ne(True) | ~df.A.duplicated()]
    A     B  C
0  12  True  1
2   3   NaN  2
3   3   NaN  3