Search
 
SCRIPT & CODE EXAMPLE
 

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]
Comment

PREVIOUS NEXT
Code Example
Python :: pandas dataframe any along row 
Python :: python anytree 
Python :: pytthon how many fridays´ between two dates 
Python :: python obfuscator github 
Python :: python if true 
Python :: xarray get number of lat lon 
Python :: python 3 tkinter treeview example 
Python :: super in django manager 
Python :: print without newline 
Python :: binary to octal in python 
Python :: matrix multiplication nupy 
Python :: django channel 
Python :: oops concept in python 
Python :: anagrams string python 
Python :: append 1 colimn in pandas df 
Python :: how to write a dataframe to s3 object in python 
Python :: separate words in a text to make a list python 
Python :: yml anaconda 
Python :: flask app with spark 
Python :: transform image to rgb python 
Python :: How to install a python packagae 
Python :: confusion matrix with seaborn heatmap 
Python :: python A string float numeral into integer 
Python :: python conditions 
Python :: dict in dict in python 
Python :: Adding new column to existing DataFrame in Pandas using concat method 
Python :: qt setfocus 
Python :: how to serach for multiple attributes in xpath selenium python 
Python :: smtp django 
Python :: dtype array 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =