Answers for "create column with values mapped from another column python"

0

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]
Posted by: Guest on July-27-2020

Code answers related to "create column with values mapped from another column python"

Python Answers by Framework

Browse Popular Code Answers by Language