Exponential of a column in pandas python is carried out using exp() function of numpy. Let’s see how to
- Get the exponential value of a column in pandas python.
With an example First let’s create a dataframe.
import pandas as pd import numpy as np #Create a DataFrame df1 = { 'Name':['George','Andrea','micheal','maggie','Ravi','Xien','Jalpa'], 'University_Rank':[6,47,21,74,32,77,8]} df1 = pd.DataFrame(df1,columns=['Name','University_Rank']) print(df1)
df1 will be
Exponential value of a column in pandas
Exponential value of the column (University_Rank) is computed using exp() and stored in a new column namely “exp_value” as shown below
df1['exp_value'] = np.exp(df1['University_Rank']) print(df1)
so the resultant dataframe will be