create column with values mapped from another column python

Solutions on MaxInterview for create column with values mapped from another column python by the best coders in the world

showing results for - "create column with values mapped from another column python"
Cyprien
24 Apr 2020
1In [55]:
2
3import pandas as pd
4equiv = {7001:1, 8001:2, 9001:3}
5df = pd.DataFrame( {"A": [7001, 8001, 9001]} )
6df["B"] = df["A"].map(equiv)
7print(df)
8      A  B
90  7001  1
101  8001  2
112  9001  3
12
13[3 rows x 2 columns]