apply works on a row / column basis of a DataFrame
applymap works element-wise on a DataFrame
map works element-wise on a Series


Straight from Wes McKinney's Python for Data Analysis book, pg. 132 (I highly recommended this book):

Another frequent operation is applying a function on 1D arrays to each column or row. DataFrame’s apply method does exactly this:

In [116]: frame = DataFrame(np.random.randn(4, 3), columns=list('bde'), index=['Utah', 'Ohio', 'Texas', 'Oregon'])

In [117]: frame
Out[117]: 
               b         d         e
Utah   -0.029638  1.081563  1.280300
Ohio    0.647747  0.831136 -1.549481
Texas   0.513416 -0.884417  0.195343
Oregon -0.485454 -0.477388 -0.309548

In [118]: f = lambda x: x.max() - x.min()

In [119]: frame.apply(f)
Out[119]: 
b    1.133201
d    1.965980
e    2.829781
dtype: float64

Many of the most common array statistics (like sum and mean) are DataFrame methods, so using apply is not necessary.

Element-wise Python functions can be used, too. Suppose you wanted to compute a formatted string from each floating point value in frame. You can do this with applymap:

In [120]: format = lambda x: '%.2f' % x

In [121]: frame.applymap(format)
Out[121]: 
            b      d      e
Utah    -0.03   1.08   1.28
Ohio     0.65   0.83  -1.55
Texas    0.51  -0.88   0.20
Oregon  -0.49  -0.48  -0.31

The reason for the name applymap is that Series has a map method for applying an element-wise function:

In [122]: frame['e'].map(format)
Out[122]: 
Utah       1.28
Ohio      -1.55
Texas      0.20
Oregon    -0.31
Name: e, dtype: object
Answer from jeremiahbuddha on Stack Overflow
Top answer
1 of 12
755

apply works on a row / column basis of a DataFrame
applymap works element-wise on a DataFrame
map works element-wise on a Series


Straight from Wes McKinney's Python for Data Analysis book, pg. 132 (I highly recommended this book):

Another frequent operation is applying a function on 1D arrays to each column or row. DataFrame’s apply method does exactly this:

In [116]: frame = DataFrame(np.random.randn(4, 3), columns=list('bde'), index=['Utah', 'Ohio', 'Texas', 'Oregon'])

In [117]: frame
Out[117]: 
               b         d         e
Utah   -0.029638  1.081563  1.280300
Ohio    0.647747  0.831136 -1.549481
Texas   0.513416 -0.884417  0.195343
Oregon -0.485454 -0.477388 -0.309548

In [118]: f = lambda x: x.max() - x.min()

In [119]: frame.apply(f)
Out[119]: 
b    1.133201
d    1.965980
e    2.829781
dtype: float64

Many of the most common array statistics (like sum and mean) are DataFrame methods, so using apply is not necessary.

Element-wise Python functions can be used, too. Suppose you wanted to compute a formatted string from each floating point value in frame. You can do this with applymap:

In [120]: format = lambda x: '%.2f' % x

In [121]: frame.applymap(format)
Out[121]: 
            b      d      e
Utah    -0.03   1.08   1.28
Ohio     0.65   0.83  -1.55
Texas    0.51  -0.88   0.20
Oregon  -0.49  -0.48  -0.31

The reason for the name applymap is that Series has a map method for applying an element-wise function:

In [122]: frame['e'].map(format)
Out[122]: 
Utah       1.28
Ohio      -1.55
Texas      0.20
Oregon    -0.31
Name: e, dtype: object
2 of 12
373

Comparing map, applymap and apply: Context Matters

The major differences are:

Definition

  • map is defined on Series only
  • applymap is defined on DataFrames only
  • apply is defined on both

Input argument

  • map accepts dict, Series, or callable
  • applymap and apply accept callable only

Behavior

  • map is elementwise for Series
  • applymap is elementwise for DataFrames
  • apply also works elementwise but is suited to more complex operations and aggregation. The behaviour and return value depends on the function.

Use case (the most important difference)

  • 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'})
    
  • applymap is good for elementwise transformations across multiple rows/columns, e.g.,

    df[['A', 'B', 'C']].applymap(str.strip)
    
  • apply is for applying any function that cannot be vectorised, e.g.,

    df['sentences'].apply(nltk.sent_tokenize)
    

Also see When should I (not) want to use pandas apply() in my code? for a writeup I made a while back on the most appropriate scenarios for using apply. (Note that there aren't many, but there are a few— apply is generally slow.)


Summarising

map applymap apply
Defined on Series? Yes No Yes
Defined on DataFrame? No Yes Yes
Argument dict, Series, or callable1 callable2 callable
Elementwise? Yes Yes Yes
Aggregation? No No Yes
Use Case Transformation/mapping3 Transformation More complex functions
Returns Series DataFrame scalar, Series, or DataFrame4

Footnotes

  1. map when passed a dictionary/Series will map elements based on the keys in that dictionary/Series. Missing values will be recorded as NaN in the output.

  2. applymap in more recent versions has been optimised for some operations. You will find applymap slightly faster than apply in some cases. My suggestion is to test them both and use whatever works better.

  3. map is optimised for elementwise mappings and transformation. Operations that involve dictionaries or Series will enable pandas to use faster code paths for better performance.

  4. Series.apply returns a scalar for aggregating operations, Series otherwise. Similarly for DataFrame.apply. Note that apply also has fastpaths when called with certain NumPy functions such as mean, sum, etc.

🌐
GeeksforGeeks
geeksforgeeks.org › python › difference-between-map-applymap-and-apply-methods-in-pandas
Difference between Map, Applymap and Apply Methods in Pandas - GeeksforGeeks
February 9, 2026 - In recent Pandas versions, map() works on both Series and DataFrame, making it a unified alternative for element-wise operations. When used with a DataFrame, map() applies the given function to each individual element, similar to the earlier applymap() method.
🌐
Towards Data Science
towardsdatascience.com › home › latest › apply() vs map() vs applymap() in pandas
apply() vs map() vs applymap() in Pandas | Towards Data Science
January 16, 2025 - First, let’s create an example DataFrame that we will use throughout this article in order to demonstrate a few concepts that will help us highlight the difference between apply(), map() and applymap(). ... df = pd.DataFrame( [ (1, 521, True, 10.1, 'Hello'), (2, 723, False, 54.2, 'Hey'), (3, 123, False, 33.2, 'Howdy'), (4, 641, True, 48.6, 'Hi'), (5, 467, False, 98.1, 'Hey'), ], columns=['colA', 'colB', 'colC', 'colD', 'colE'] ) print(df) colA colB colC colD colE 0 1 521 True 10.1 Hello 1 2 723 False 54.2 Hey 2 3 123 False 33.2 Howdy 3 4 641 True 48.6 Hi 4 5 467 False 98.1 Hey · [pandas.DataFrame.apply](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.apply.html) method is used to apply a function along the specified axis of the pandas DataFrame.
🌐
PythonForBeginners.com
pythonforbeginners.com › home › pandas map vs apply method in python
Pandas Map vs Apply Method in Python - PythonForBeginners.com
May 22, 2023 - In this example, we passed the sum() function to the map() method. You can observe that the program runs into a Python TypeError exception saying that the element of the series is not iterable. We use the pandas apply method to apply functions on a series or a dataframe.
🌐
Medium
medium.com › @amit25173 › pandas-map-vs-apply-practical-guide-51f046a15cd9
pandas map vs apply (Practical Guide) | by Amit Yadav | Medium
March 6, 2025 - You need to apply a function across multiple columns or rows. You need row-wise operations, where each row’s values are used together. ... Let’s say you have a DataFrame with numbers and you want to double them.
🌐
Note.nkmk.me
note.nkmk.me › home › python › pandas
pandas: Apply functions to values, rows, columns with map(), apply() | note.nkmk.me
January 17, 2024 - In pandas, you can use map(), apply(), and applymap() methods to apply functions to values (element-wise), rows, or columns in DataFrames and Series. Apply functions to values in Series: map(), apply( ...
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas difference between map, applymap and apply methods
Pandas Difference Between map, applymap and apply Methods - Spark By {Examples}
March 27, 2024 - What is the difference between map(), applymap() and apply() methods in pandas? - In padas, all these methods are used to perform either to modify the
Find elsewhere
🌐
Towards Data Science
towardsdatascience.com › home › latest › pandas: apply, map or transform?
Pandas: apply, map or transform? | Towards Data Science
January 23, 2025 - While this isn’t an issue on smaller datasets, the performance issues caused by this become a lot more noticeable when working with larger amounts of data. While apply‘s flexibility makes it an easy choice, this article introduces other Pandas’ functions as potential alternatives. In this post, we’ll discuss the intended use for apply, agg, map and transform, with a few examples.
🌐
Esq
esq.io › 2024 › 01 › using-python-map-instead-of-pandas-.apply
Using python map() instead of pandas .apply() | Dave Zvenyach's website
June 30, 2025 - While reaching for the multiprocessing library, I learned about one small way to improve performance and improve the readability of my code: use map instead of apply. ... import numpy as np import pandas as pd # Let's create a random dataframe df = pd.DataFrame(np.random.randint(0,100,size=(10, 3)), columns=list('ABC')) # Normal approach: Use .apply() to iterate through the rows df["D"] = df.apply(lambda x: x["A"] ** 2, axis=1) # The new approach: Use python map() to iterate through the rows def power(x): return x ** 2 df["E"] = list(map(power, df["A"]))
🌐
Kaggle
kaggle.com › general › 516360
Speed of for-loop vs apply() vs map()
Checking your browser before accessing www.kaggle.com · Click here if you are not automatically redirected after 5 seconds
🌐
Medium
medium.com › analytics-vidhya › no-more-confusion-between-apply-map-and-applymap-f982bb98c099
No more confusion between apply(), map() and applymap() | by Sayantanee Sen | Analytics Vidhya | Medium
May 27, 2022 - Do you find yourself often confused between Python’s apply() , map() and applymap() functions? Well, let us spend few minutes to understand these functions. The pandas apply() function operates on both dataframes and series. We can use it on either columns of the dataframes (axis=1) or on rows of the dataframes (axis=0).
🌐
Analyticsvidhya
discuss.analyticsvidhya.com › tools
Difference between Map, Apply and Applymap in Pandas - tools - Data Science, Analytics and Big Data discussions
July 20, 2015 - Hi, Please help me with an example to know the difference between Map, Apply and Applymap in Python Pandas? Also guide, when should I use which one? Regards, Imran
🌐
Medium
medium.com › @ayeshasidhikha188 › apply-map-applymap-functions-in-pandas-d39b17655278
Apply, Map, ApplyMap -Functions in Pandas | by Ayesha sidhikha | Medium
February 4, 2025 - To change any one row into upper case, we operate on the index level. We can also use apply() on the entire dataframe. ... map() can only operate on series and not on whole dataframes.
🌐
GitHub
gist.github.com › zdebeer99 › 8843289
python pandas the difference between map(), apply(), applymap() · GitHub
python pandas the difference between map(), apply(), applymap() - pandas_example02.py
🌐
Delft Stack
delftstack.com › home › howto › python pandas › difference between pandas apply map and applymap
Difference Between Pandas apply, map and applymap | Delft Stack
January 30, 2023 - Similarly, the function associated ... method is defined for both Series and DataFrame objects. The map() method can only be defined for Series objects in Pandas....
🌐
Stuff by Yuki
stuffbyyuki.com › home › python pandas .apply() function – how does it differ from .applymap() and .map()?
Python Pandas .apply() function - how does it differ from .applymap() and .map()?
November 19, 2021 - .map() and .applymap() are similar to .apply(), but .map() only works on Series and .applymap() only works on Dataframes. So I’d usually go ahead and use .apply() than these other two functions · I used .apply() for this small project as ...
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.applymap.html
pandas.DataFrame.applymap — pandas 2.3.3 documentation
Deprecated since version 2.1.0: DataFrame.applymap has been deprecated. Use DataFrame.map instead. This method applies a function that accepts and returns a scalar to every element of a DataFrame. ... Python function, returns a single value from a single value.