A Pandas solution to get result Dataframe when values B are not same for same A value
IN:
colA colB
a 1 <--
b 2
a 1 <--
a 0 <-- different
OUT:
colA colB
a 1 <--
a 1 <--
a 0 <-- different
SOLUTION:
Pandas Groupby Select Groups that Have More Than One Unique Values in a Column
out = df.groupby(['a']).filter(lambda x: x['b'].nunique() > 1)
@mozway comment works too
out = df[df.groupby('colA')['colB'].transform('nunique').gt(1)]