TransWikia.com

replacing last duplicate values in pandas

Data Science Asked by shabu shankar on January 22, 2021

I have a dataframe ,that looks like this

  | **site**  |  **Active**|

0 |: deals| Active:|
1 |: deals | InActive:|
2 | : deals | Active:|
3 |:discount | InActive:|
4 |:discount| Active:|
i don’t want to drop the duplicate items, but i want to change the Active columns value based on Site column,for example Active has to change inactive based on duplicate item in site column,Inactive also have to change based on number of duplicate items present,last duplicate item has to Active, other than that Inactive, If it is already inactive it also have to change

Expected

   site    Active

0 deals InActive
1 deals InActive
2 deals Active
3 discount InActive
4 discount Active

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP