Python Apply vs Map methods

Last Updated : 29 May, 2026

Pandas is widely used for data manipulation and analysis in Python. The map() and apply() methods allow users to transform data, but they differ in scope, behaviour and use cases. The output of each method depends on both the input object and the function provided.

apply() method

The apply() method can be applied both to series and Dataframes where a function can be applied to both series and individual elements based on the type of function provided.

1. Using DataFrame

This method can be used on both a pandas Dataframe and series. The function passed as an argument typically works on rows/columns. The code below illustrates how apply() method works on Pandas Dataframe. 

Python
import pandas as pd
s = 'geeksforgeeks'
df = pd.DataFrame([list(s)] * 5)

print("Original dataFrame:\n")
print(df.to_string(index=False, header=False))

new_df = df.apply(lambda x: ''.join(x), axis=1)

print("\nTransformed dataFrame:\n")
print('\n'.join(new_df.tolist()))

Output

Screenshot-2026-05-19-181736

2. Using Series

The below Code illustrates how to apply() method to the Pandas series: 

Python
import pandas as pd
s = pd.Series(list("geeksforgeeks"))

print("Original series:\n")
print('\n'.join(s.tolist()))

new_s = s.apply(str.upper)

print("\nTransformed series:\n")
print('\n'.join(new_s.tolist()))

Output:

Original series: g e e k s f o r g e e k s

Transformed series: G E E K S F O R G E E K S

map() method 

The map() method is used to transform values by applying a function, dictionary, or Series mapping. In recent Pandas versions, map() works on both Series and DataFrame, making it a unified alternative for element-wise operations.

1. Using DataFrame

When used with a DataFrame, map() applies the given function to each individual element, similar to the earlier applymap() method. 

Python
import pandas as pd

df = pd.DataFrame([list("geeksforgeeks")] * 5)
print("Original DataFrame:\n")
print(df.to_string(index=False, header=False))

new_df = df.map(str.upper)

print("\nTransformed DataFrame:\n")
print(new_df.to_string(index=False, header=False))

Output

Screenshot-2026-05-20-142841

2. Using Series

When used with a Series, map() applies the function or mapping element-wise and is commonly used for value transformation or replacement.

Python
import pandas as pd

s = pd.Series(list("geeksforgeeks"))
print("Original series:\n")
print('\n'.join(s.tolist()))

new_s = s.map(str.upper)

print("\nTransformed series:\n")
print('\n'.join(new_s.tolist()))

Output

Original series: g e e k s f o r g e e k s

Transformed series: G E E K S F O R G E E K S

Comparison Table

Featuremap()apply()
Works OnSeries and DataFrameSeries and DataFrame
Operation LevelElement-wiseRow-wise / Column-wise (DataFrame) or element-wise (Series)
Acceptsfunction, dict or Seriesfunction only
Best Use CaseSimple value mapping or replacementComplex operations, aggregations, or custom row/column logic
Comment