Given a following dataframe:
import pandas as pd
df = pd.DataFrame({'month': [2, 2, 1, 1, 2, 10],
'year': [2017, 2017, 2020, 2020, 2018, 2019],
'sale': [60, 45, 90, 20, 28, 36],
'title': ['Ones', 'Twoes', 'Three', 'Four', 'Five', 'Six']})
I am trying to get duplicates in month columnn.
df[df.duplicated(subset=['month'])]
By default, keep="first"
But this is giving two occurrences for month 2.
month year sale title
1 2 2017 45 Twoes
3 1 2020 20 Four
4 2 2018 28 Five
I'm confused with the output. Am I missing something here?