Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #create #column #values #mapped #column #python
ADD COMMENT
Topic
Name
1+9 =