0

I have dataframe scrapped from the web with features that come from user inputed data. However, some of my columns which include features about cars have different capitalizations for the same feature i.e. 'Heated Seats' and 'heated seats'. These are dummy variables, so a car with heated seats will have a zero for one column and a 1 for the other. The end goal is to add all columns with the same feature, just different capitalization. Does anyone know of any libraries that can help with looping through hundreds of features to check for pairs in mismatched capitalization like this?

Thanks

itmc238
  • 1
  • 2

1 Answers1

0

Let us take two columns in python dict format. Ex:

 python_dict = {'Heated Seats':0, 'heated seats':1}
 sum = 0
 reference_string = 'HEATED SEATS'  #Take the reference string here just to compare. In your case no need to take.
 for key in python_dict.keys():
     if key.lower() == reference_string.lower():
        #Adding the values of Heated seats car values
        sum = sum + python_dict[key]
 print sum
Kashi
  • 11
  • 2