Reputation: 97
I am trying to remove a duplicate column value in a pandas dataframe. So for example:
2019-03-31
2019-06-30
2019-09-30
2019-12-31
2020-03-31
2020-03-31
notice 2020-03-31 is duplicated. I would like to find the duplicated date and rename it as last quarter
conversely, If the column has no duplicates I want to leave as is. Can someone guide me in the right direction to do so?
Upvotes: 1
Views: 80
Reputation: 22031
without loops
series = pd.Series(['2019-03-31',
'2019-06-30',
'2019-09-30',
'2019-12-31',
'2020-03-31',
'2020-03-31'])
series.loc[series.duplicated()] = 'last quarter'
Upvotes: 2