Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #map #apply #pandas
ADD COMMENT
Topic
Name
9+7 =