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:

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s