What is Pandas map() method

The map() method only works on a pandas series where the type of operation to be applied depends on the argument passed as a function, dictionary, or list. This method is generally used to map values from two series having one column the same.  

Python3




# The code below illustrates how the
# map method works on the Pandas series:
# Importing pandas
import pandas as pd
 
# Series generation
gfg_string = 'w3wiki'
gfg_series = pd.Series(list(gfg_string))
print("Original series\n" +
      gfg_series.to_string(index=False,
                           header=False), end='\n\n')
 
# Using apply method for converting characters
# present in the original series
new_gfg_series = gfg_series.map(str.upper)
print("Transformed series:\n" +
      new_gfg_series.to_string(index=False,
                               header=False), end='\n\n')


Output: 

 

Difference between map, applymap and apply methods in Pandas

Pandas library is extensively used for data manipulation and analysis. map(), applymap(), and apply() methods are methods of Pandas library in Python. The type of Output totally depends on the type of function used as an argument with the given method. 

Similar Reads

What is Pandas 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....

What is Pandas applymap() method

...

What is Pandas map() method

...

Difference between map, applymap and apply in Pandas

The applymap() method only works on a pandas Dataframe where a function is applied to every element individually. The function passed as an argument typically works on elements of the Dataframe applymap() and is typically used for elementwise operations....

Contact Us