pandas create dataframe from column mapping code example

Example 1: maping value to data in pandas dataframe

note: u can assigne values in each of the common values in the dataframe 

df['new_coloum'] = df['coloum'].map({'value_1':1,'value_2':0})

Example 2: create column with values mapped from another column python

In [55]:

import pandas as pd
equiv = {7001:1, 8001:2, 9001:3}
df = pd.DataFrame( {"A": [7001, 8001, 9001]} )
df["B"] = df["A"].map(equiv)
print(df)
      A  B
0  7001  1
1  8001  2
2  9001  3

[3 rows x 2 columns]