Skip to content

Tag: pandas

Conditional lambda in pandas returns ValueError

In a df comprised of the columns asset_id, event_start_date, event_end_date, I wish to add a forth column datediff that for each asset_id will capture how many days passed between a end_date and the following start_date for the same asset_id, but in case that following start_date is earlier than the current e…

Rename column containing substring – Pandas

I need to rename columns in containing specific substring. In my case I am using data with columns that are named a specific date dd/mm/yyyy. I want to rename the column based on the yyyy of the column name (eg. 30/06/2020 rename FY1920). Approach I have tried is as follows: also tried: I am sure there is an …

Handling duplicate values in pandas

I have a dataframe ,that looks like this 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,l…