What is Pandas applymap() method
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.
Python3
# The code below illustrates how applymap # method works on pandas Dataframe: # Importing pandas import pandas as pd # DataFrame generation gfg_string = 'w3wiki' gfg_list = 5 * [pd.Series( list (gfg_string))] gfg_df = pd.DataFrame(data = gfg_list) print ( "Original dataframe:\n" + gfg_df.to_string(index = False , header = False ), end = '\n\n' ) # Using applymap method for transforming # characters into uppercase characters # present in the original dataframe new_gfg_df = gfg_df.applymap( str .upper) print ( "Transformed dataframe:\n" + new_gfg_df.to_string(index = False , header = False ), end = '\n\n' ) |
Output: