Google While Coding – 3 : Mapping Pandas columns

There was this requirement to map the values of a column into a new column. e.g 0->0, 1->0, 2->1, 3->1

Some would look to excel. I looked towards pandas.

Some queries that came out:

  1. “pandas map”
  2. “python pandas map column to another”
  3. “pandas write to csv”

it surprises me how much of learning comes out from something as simple as this. For instance here are new things that came out of this :

  1. Pythons lambda, filter, map, reduce operations
  2. Pandas function mapping
  3. apply, applymap and map for pandas
  4. replace, update, put
  5. Another example of adding an existing dataframe in pandas

 

Code: