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.

🌐
Medium
medium.com › @amit25173 › pandas-map-vs-apply-practical-guide-51f046a15cd9
pandas map vs apply (Practical Guide) | by Amit Yadav | Medium
March 6, 2025 - With map(), you can only do this on a single column at a time. import pandas as pd # Sample Data df = pd.DataFrame({'Numbers': [1, 2, 3, 4, 5]}) # Using map() to double the values df['Doubled'] = df['Numbers'].map(lambda x: x * 2) print(df)
🌐
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.
🌐
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
🌐
Towards Data Science
towardsdatascience.com › home › latest › pandas: apply, map or transform?
Pandas: apply, map or transform? | Towards Data Science
January 23, 2025 - * map * transform * agg * apply * Unexpected behavior · Let’s take a data frame comprising the scores of three students in two subjects. We’ll work with this example as we go.
🌐
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 - Additionally, the method can also be applied over pandas Series (see [pandas.Series.apply](https://pandas.pydata.org/docs/reference/api/pandas.Series.apply.html)). [pandas.Series.map](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.map.html) method can applied only over pandas Series objects and is used to map the values of the Series based on the input which is used to substitute each value with the specified value that is derived from a dictionary, a function or even another Series object.
🌐
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 the map() method, you cannot use aggregate functions as the function is applied to each element of the series. If we pass an aggregate function such as sum() to the map() method, the program will run into an error. You can observe this in the following example. import pandas as pd series=pd.Series([1,2,3,4,5,6,7]) print("The series is:") print(series) series=series.map(sum) print("The modified series is:") print(series)
🌐
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 with the apply() method can be applied to all the elements of DataFrame or Series, and hence apply() method is defined for both Series and DataFrame objects. The map() method can only be defined for Series objects in Pandas. import pandas as pd df = pd.DataFrame( { "Col 1": [30, 40, 50, 60], "Col 2": [23, 35, 65, 45], "Col 3": [85, 87, 90, 89], }, index=["A", "B", "C", "D"], ) print(df, "\n") ... We will use the DataFrame df displayed in the above example to explain the difference between apply(), map(), and applymap() methods in Pandas.
Find elsewhere
🌐
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.
🌐
Medium
chrisyandata.medium.com › understanding-apply-vs-map-methods-in-pandas-dataframes-and-series-e05ae4678a13
Understanding apply vs. map Methods in Pandas DataFrames and Series | by Chris Yan | Medium
June 19, 2024 - import pandas as pd # Create a Series s = pd.Series([1, 2, 3, 4, 5]) # Define a function def square(x): return x ** 2 # Apply the function to each element of the Series squared = s.apply(square) # Apply a lambda function to square each element ...
🌐
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 - ... map() can only operate on series and not on whole dataframes. Hence we can either replace all the values of a series or of a column in the dataframe or of a homogeneous dataframe row, using the map() functionality.
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas apply map (applymap()) explained
Pandas apply map (applymap()) Explained - Spark By {Examples}
December 9, 2024 - # Create a dataframe form numerical ... the pandas apply map, apply(), and map() function is that, applymap is defined on DataFrames, map() is defined on Series while df.apply() work on both....
🌐
Medium
medium.com › @vivekmcm1 › a-guide-to-applying-functions-in-pandas-apply-map-and-applymap-54165aa509f8
A Guide to Applying Functions in Pandas: apply(), map(), and applymap() | by Vivek | Medium
January 6, 2025 - For instance, if you wanted to square each number in a Series, you could use map(). Alternatively, if you had a dictionary of mappings and wanted to replace each value in a Series with the corresponding mapped value, map() would come in handy. ...
🌐
Google Sites
sites.google.com › site › prgrammnote › python › difference-between-map-applymap-and-apply-methods-in-pandas
Difference between map, applymap and apply methods in Pandas - prgrammnote
Map: It iterates over each element of a series. df[‘column1’].map(lambda x: 10+x), this will add 10 to each element of column1. df[‘column2’].map(lambda x: ‘AV’+x), this will concatenate “AV“ at the beginning of each element of column2 (column format is string) · Apply: As ...
🌐
Studymachinelearning
studymachinelearning.com › pandas-applymap
Pandas – Applymap – Study Machine Learning
If you want to work with the entire axis either row/column, use apply() function. Let’s see the example of subtracting each value from the max value of its column.
🌐
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 - As mentioned later, DataFrame and Series already include methods for common operations. Additionally, you can apply NumPy functions to DataFrame and Series. Using dedicated methods or NumPy functions is preferable to map() or apply() due to better performance. The pandas and NumPy versions ...
🌐
Medium
jramirezcubeiro.medium.com › apply-vs-map-vs-applymap-cfba212ff4a7
Apply vs Map vs ApplyMap - Joe Ramirez - Medium
March 30, 2021 - Apply vs Map vs ApplyMap One of the most fundamental things a person trying to learn Pandas in Python must grasp is the differences between apply vs map vs applymap. Although the differences might …