title: Reading csv using pandas. Reassigning values 1 to 40 for soil types, and 1 to 7 for forest cover types
body: <p>In the csv input file there are 56 columns below. The sample data is as shown below. Please bear with my formatting.</p>
  
  <pre><code>Id,Elevation,Aspect,Slope,Horizontal_Distance_To_Hydrology,Vertical_Distance_To_Hydrology,Horizontal_Distance_To_Roadways,Hillshade_9am,Hillshade_Noon,Hillshade_3pm,Horizontal_Distance_To_Fire_Points,Wilderness_Area1,Wilderness_Area2,Wilderness_Area3,Wilderness_Area4,Soil_Type1,Soil_Type2,Soil_Type3,Soil_Type4,Soil_Type5,Soil_Type6,Soil_Type7,Soil_Type8,Soil_Type9,Soil_Type10,Soil_Type11,Soil_Type12,Soil_Type13,Soil_Type14,Soil_Type15,Soil_Type16,Soil_Type17,Soil_Type18,Soil_Type19,Soil_Type20,Soil_Type21,Soil_Type22,Soil_Type23,Soil_Type24,Soil_Type25,Soil_Type26,Soil_Type27,Soil_Type28,Soil_Type29,Soil_Type30,Soil_Type31,Soil_Type32,Soil_Type33,Soil_Type34,Soil_Type35,Soil_Type36,Soil_Type37,Soil_Type38,Soil_Type39,Soil_Type40,Cover_Type
  1,2596,51,3,258,0,510,221,232,148,6279,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,5
  2,2590,56,2,212,-6,390,220,235,151,6225,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,5
  3,2804,139,9,268,65,3180,234,238,135,6121,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2
  4,2785,155,18,242,118,3090,238,238,122,6211,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,2
  5,2595,45,2,153,-1,391,220,234,150,6172,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,5
  6,2579,132,6,300,-15,67,230,237,140,6031,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,2
  7,2606,45,7,270,5,633,222,225,138,6256,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,5
  8,2605,49,4,234,7,573,222,230,144,6228,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,5
  9,2617,45,9,240,56,666,223,221,133,6244,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,5
  10,2612,59,10,247,11,636,228,219,124,6230,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,5
  </code></pre>
  
  <p>I need to convert that data. Following are the requirements.
   - Remove multiple columns with binary values (0 or 1) and assign the new column with range of value. For Wilderness_Ares it is from 1 to 4. For Soil_Types it is from 1 to 40.</p>
  
  <ul>
  <li><p>Remove columns Wilderness_Area1 to Wilderness_Area4. Add a single column Wilderness_Area. Assign 1 to 4 based on the input row. Example - Previously the first row in the sample input above had </p>
  
  <ul>
  <li>Wilderness_Area1 = 1, now it should be Wilderness_Area = 1.</li>
  <li>Wilderness_Area2 = 1, now it should be Wilderness_Area = 2.</li>
  <li>Wilderness_Area3 = 1, now it should be Wilderness_Area = 3.</li>
  <li><p>Wilderness_Area4 = 1, now it should be Wilderness_Area = 4.</p>
  
  <ol start="2">
  <li>Remove columns Soil_Type1 to Soil_Type40. Add a single column Soil_Type. Assign 1 to 40 based on the input row. Example - Previously the first row in the sample input above had </li>
  </ol></li>
  <li>Soil_Type1 = 1, now it should be Soil_Type = 1.</li>
  <li>Soil_Type2 = 1, now it should be Soil_Type = 2.</li>
  <li>Soil_Type3 = 1, now it should be Soil_Type = 3.</li>
  <li>Soil_Type4 = 1, now it should be Soil_Type = 4.</li>
  </ul></li>
  </ul>
  
  <p>I used the following code, yet I still get the 40 soil types in my data frame. I need to remove those columns from df. How do I do all the above?</p>
  
  <pre><code>df = pandas.read_csv(ifname)
  df['Soil'] = 0
  for i in range(1,41):
      df['Soil'] = df['Soil'] + i*df['Soil_Type'+str(i)]
  
  print(df)
  </code></pre>
  
  <p>Following is the example of what I need.</p>
  
  <pre><code>Id,Elevation,Aspect,Slope,Horizontal_Distance_To_Hydrology,Vertical_Distance_To_Hydrology,Horizontal_Distance_To_Roadways,Hillshade_9am,Hillshade_Noon,Hillshade_3pm,Horizontal_Distance_To_Fire_Points,Cover_Type,Soil,Wilderness_Area
  1,2596,51,3,258,0,510,221,232,148,6279,5,29,1
  2,2590,56,2,212,-6,390,220,235,151,6225,5,29,1
  3,2804,139,9,268,65,3180,234,238,135,6121,2,12,1
  4,2785,155,18,242,118,3090,238,238,122,6211,2,30,1
  5,2595,45,2,153,-1,391,220,234,150,6172,5,29,1
  6,2579,132,6,300,-15,67,230,237,140,6031,2,29,1
  7,2606,45,7,270,5,633,222,225,138,6256,5,29,1
  8,2605,49,4,234,7,573,222,230,144,6228,5,29,1
  9,2617,45,9,240,56,666,223,221,133,6244,5,29,1
  10,2612,59,10,247,11,636,228,219,124,6230,5,29,1
  </code></pre>