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:
- “pandas map”
- “python pandas map column to another”
- “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 :
- Pythons lambda, filter, map, reduce operations
- Pandas function mapping
- apply, applymap and map for pandas
applyworks on a row / column basis of a DataFrame
applymapworks element-wise on a DataFrame
mapworks element-wise on a Series –> So for my problem this is what i had to use.
- replace, update, put
- http://stackoverflow.com/questions/20250771/remap-values-in-pandas-column-with-a-dict –> haven’t tried this out yet
- Another example of adding an existing dataframe in pandas