Skip to content
Advertisement

Tag: data-cleaning

Delete rows where any column contains a certain string

I am dealing with a dataset that uses “..” as a placeholder for null values. These null values span across all of my columns. My dataset looks as follows: Country Code Year GDP growth (%) GDP (constant) AFG 2010 3.5 .. AFG 2011 .. 2345 AFG 2012 1.4 3372 ALB 2010 .. 4567 ALB 2011 .. 5678 ALB 2012 4.2

How to clean survey data in pandas

Input: Output: here’s the data: d = {‘Morning’: [“Didn’t answer”, “Didn’t answer”, “Didn’t answer”, ‘Morning’, “Didn’t answer”], ‘Afternoon’: [“Didn’t answer”, ‘Afternoon’, “Didn’t answer”, ‘Afternoon’, “Didn’t answer”], ‘Night’: [“Didn’t answer”, ‘Night’, “Didn’t answer”, ‘Night’, ‘Night’], ‘Sporadic’: [“Didn’t answer”, “Didn’t answer”, ‘Sporadic’, “Didn’t answer”, “Didn’t answer”], ‘Constant’: [“Didn’t answer”, “Didn’t answer”, “Didn’t answer”, ‘Constant’, “Didn’t answer”]} I want the output to be:

Advertisement