Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

creating new column with dictionary

In [248]:
dict_ = {112: 'en', 113: 'es', 114: 'es', 111: 'en'}
df['D'] = df['U'].map(dict_)
df

Out[248]:
     U   L   D
0  111  en  en
1  112  en  en
2  112  es  en
3  113  es  es
4  113  ja  es
5  113  zh  es
6  114  es  es
Comment

PREVIOUS NEXT
Code Example
Python :: import django concat 
Python :: quick sort python 
Python :: Converting categorical feature in to numerical features 
Python :: python check samplerate of mp3 
Python :: area of trapezium 
Python :: how to raise the exception in __exit__ python 
Python :: Pandas: How to Drop Rows that Contain a Specific String in 2 columns 
Python :: python if and 
Python :: python script in excel 
Python :: numpy copy array 
Python :: import tsv as dataframe python 
Python :: cli args python 
Python :: python datetime add 
Python :: github python api 
Python :: how to merge between two columns and make a new one in pandas dataframe 
Python :: how to check if number has decimals python 
Python :: unsigned int python 
Python :: python math operators 
Python :: Python Remove all occurrences of a character from a string 
Python :: python get dictionary keys as list 
Python :: catch error in mongo query python 
Python :: longest common subsequence python 
Python :: get all files in pc python 
Python :: create a empty dataframe 
Python :: install python3 in ubuntu 
Python :: python how to automatically restart flask sever 
Python :: How to store the input from the text box in python 
Python :: pillow python text example 
Python :: how to copy file from local to sftp using python 
Python :: flask session timeout 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =