Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Dataframe.applymap() method applies a function that accepts and returns a scalar to every element of a DataFrame.
Syntax: DataFrame.applymap(func) Parameters: func: Python function, returns a single value from a single value. Returns: Transformed DataFrame.
For link to CSV file Used in Code, click here
Example #1: Apply the
applymap() function on the dataframe to find the no. of characters in all cells.
Notice how all nan value has been converted to string nan and their length is evaluated to be 3.
Example #2: Append
_X in each cell using
In order to append
_X in each cell, first convert each cell into a string.
- Python | pandas.map()
- Python | Pandas.factorize()
- Python | Pandas Series.agg()
- Python | Pandas dataframe.mean()
- Python | Pandas.melt()
- Python | Pandas.pivot()
- Python | Pandas dataframe.max()
- Python | Pandas dataframe.pow()
- Python | Pandas dataframe.div()
- Python | Pandas TimedeltaIndex.name
- Python | Pandas Series.min()
- Python | Pandas.CategoricalDtype()
- Python | Pandas Series.pop()
- Python | Pandas Series.max()
- Python | Pandas.pivot_table()
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.