Python | Pandas DataFrame.transform Last Updated : 21 Feb, 2019 Comments Improve Suggest changes Like Article Like Report Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. It can be thought of as a dict-like container for Series objects. This is the primary data structure of the Pandas. Pandas DataFrame.transform() function call func on self producing a DataFrame with transformed values and that has the same axis length as self. Syntax: DataFrame.transform(func, axis=0, *args, **kwargs) Parameter : func : Function to use for transforming the data axis : {0 or ‘index’, 1 or ‘columns’}, default 0 *args : Positional arguments to pass to func. **kwargs : Keyword arguments to pass to func. Returns : DataFrame Example #1 : Use DataFrame.transform() function to add 10 to each element in the dataframe. Python3 # importing pandas as pd import pandas as pd # Creating the DataFrame df = pd.DataFrame({"A":[12, 4, 5, None, 1], "B":[7, 2, 54, 3, None], "C":[20, 16, 11, 3, 8], "D":[14, 3, None, 2, 6]}) # Create the index index_ = ['Row_1', 'Row_2', 'Row_3', 'Row_4', 'Row_5'] # Set the index df.index = index_ # Print the DataFrame print(df) Output : Now we will use DataFrame.transform() function to add 10 to each element of the dataframe. Python3 1== # add 10 to each element of the dataframe result = df.transform(func = lambda x : x + 10) # Print the result print(result) Output : As we can see in the output, the DataFrame.transform() function has successfully added 10 to each element of the given Dataframe. Example #2 : Use DataFrame.transform() function to find the square root and the result of euler's number raised to each element of the dataframe. Python3 # importing pandas as pd import pandas as pd # Creating the DataFrame df = pd.DataFrame({"A":[12, 4, 5, None, 1], "B":[7, 2, 54, 3, None], "C":[20, 16, 11, 3, 8], "D":[14, 3, None, 2, 6]}) # Create the index index_ = ['Row_1', 'Row_2', 'Row_3', 'Row_4', 'Row_5'] # Set the index df.index = index_ # Print the DataFrame print(df) Output : Now we will use DataFrame.transform() function to find the square root and the result of euler's number raised to each element of the dataframe. Python3 1== # pass a list of functions result = df.transform(func = ['sqrt', 'exp']) # Print the result print(result) Output : As we can see in the output, the DataFrame.transform() function has successfully performed the desired operation on the given dataframe. Comment More infoAdvertise with us Next Article Python | Pandas DataFrame.transform S Shubham__Ranjan Follow Improve Article Tags : Python Python-pandas Python pandas-dataFrame Pandas-DataFrame-Methods Practice Tags : python Similar Reads Python | Pandas Series.iteritems() Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index. Pandas Series.iteritems() function iterates 2 min read Pandas.to_datetime()-Python pandas.to_datetime() converts argument(s) to datetime. This function is essential for working with date and time data, especially when parsing strings or timestamps into Python's datetime64 format used in Pandas. For Example:Pythonimport pandas as pd d = ['2025-06-21', '2025-06-22'] res = pd.to_date 3 min read Python | pandas.to_numeric method 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. pandas.to_numeric() is one of the general functions in Pandas which is used to convert 2 min read Pandas DataFrame.to_string-Python Pandas is a powerful Python library for data manipulation, with DataFrame as its key two-dimensional, labeled data structure. It allows easy formatting and readable display of data. DataFrame.to_string() function in Pandas is specifically designed to render a DataFrame into a console-friendly tabula 5 min read pandas.concat() function in Python pandas.concat() function concatenate two or more pandas objects like DataFrames or Series along a particular axis. It is especially useful when combining datasets either vertically (row-wise) or horizontally (column-wise). Example:Pythonimport pandas as pd df1 = pd.DataFrame({'A': ['A0', 'A1'], 'B': 3 min read Python | Pandas dataframe.cov() 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. Pandas dataframe.cov() is used to compute pairwise covariance of columns. If some of t 2 min read Pandas DataFrame duplicated() Method - Python Pandas is widely used library in Python used for tasks like cleaning, analyzing and transforming data. One important part of cleaning data is identifying and handling duplicate rows which can lead to incorrect results if left unchecked.The duplicated() method in Pandas helps us to find these duplica 2 min read Pandas dataframe.drop_duplicates() When working with data in Pandas one common task is removing duplicate rows to ensure clean and accurate datasets. The drop_duplicates() method in Pandas is designed to make this process quick and easy. It allows us to remove duplicate rows from a DataFrame based on all columns or specific ones. By 4 min read Pandas DataFrame.dropna() Method DataFrame.dropna() function remove missing values (NaN or None) from a DataFrame. It can drop entire rows or columns depending on the axis and threshold you specify. This method is commonly used during data cleaning to eliminate incomplete data before analysis. For Example:Pythonimport pandas as pd 3 min read Python | Pandas dataframe.diff() 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. Pandas dataframe.diff() is used to find the first discrete difference of objects over 2 min read Like