Exponential of a column in pandas python

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 of a column in pandas python 1

 

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

Exponential of a column in pandas python 2

 

Exponential of a column in pandas python prev                                                                                                           Exponential of a column in pandas python next

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.

    View all posts