final_df = g.agg({'col3': 'size', 'col4': 'nunique'})
final_df.insert(1, 'result_col', g.col4.apply(lambda x: x.eq(3).sum()))
How to do group by and take count of unique and count of some value as aggregate on same column in python pandas?