Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

map vs apply pandas

difference between map and apply

map is defined on Series ONLY
applymap is defined on DataFrames ONLY
apply is defined on BOTH

map is meant for mapping values from one domain to another, 
so is optimised for performance (e.g., df['A'].map({1:'a', 2:'b', 3:'c'}))
apply is for applying any function that cannot be vectorised
(e.g., df['sentences'].apply(nltk.sent_tokenize)
Comment

PREVIOUS NEXT
Code Example
Python :: python code variable declaration 
Python :: python class getters and setters 
Python :: Example of floor method in python 
Python :: how to store categorical variables in separate dataframe 
Python :: pandas take entries from other column if column is nan 
Python :: matplotlib.plot python 
Python :: python turtle tutorial 
Python :: percentage plot of categorical variable in python woth hue 
Python :: run pyinstaller from python 
Python :: numpy datatime object 
Python :: python rounding numbers to n digits 
Python :: How to solve not in base 10 in python when using decimals 
Python :: youtube mp3 downloader python 
Python :: python in line elif 
Python :: write hexadecimal in python 
Python :: 3d graph python 
Python :: TypeError: create_superuser() missing 1 required positional argument: 
Python :: what is self 
Python :: args in python 
Python :: python print array 
Python :: custom permission class django rest framework 
Python :: self object 
Python :: python string 
Python :: how to add number in tuple 
Python :: python pandas how to check in what columns there are empty values(NaN) 
Python :: spread in python 
Python :: spreadsheet worksheet counter 
Python :: convert string input into a nested tuple in python 
Python :: how to set default value in many2one 
Python :: how to save xml file in python 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =