Excel to Python: EXP, POWER Function - A Complete Guide | Mito
Home Icon
divider

Functions

divider

Math

divider

EXP

How to Use Excel's EXP, POWER Function in Pandas

Excel's EXP function calculates the exponential of a given number, using the constant 'e' as the base. This function plays a vital role in various fields such as finance, engineering, and statistics.

This page explains how to use Excel's EXP function in Python using pandas.

Mito is an open source library that lets you write Excel formulas in Python. Either write the formula directly in Python or use the EXP, POWER formula in the Mito Spreadsheet and generate the equivalent Python code automatically.

Mito's EXP, POWER function works exactly like it does in Excel. That means you don't need worry about managing data types, handling errors, or the edge case differences between Excel and Python formulas.

Install Mito to start using Excel formulas in Python.

# Import the mitosheet Excel functions
from mitosheet.public.v3 import *;

# Use Mito's EXP, POWER function
df['Exponential'] = EXP(df['number'])
Copy!
Clipboard

To replicate the EXP or POWER function in Excel using Python and pandas, here are some common implementations:

To calculate the exponential of a single number in Excel, you would use the formula =EXP(number).

In pandas, you can use the numpy library's exp function to accomplish the same task

import numpy as np
result = np.exp(2)
Copy!
Clipboard

To calculate the exponential of an entire column in Excel, you would drag the EXP formula, =EXP(A1) dragged down the entire column.

In pandas, apply the numpy exp function to the whole column:

import numpy as np
df['Exponential'] = np.exp(df['number'])
Copy!
Clipboard

Unlike the EXP function, the POWER function in Excel allows you to specify the base of the exponent. To calculate the exponential of a single number in Excel, you would use the formula =POWER(number, power).

In Python, you can use the built in `**` operator. For example, to calculate 2 to the power of 3:

result = 2 ** 3
Copy!
Clipboard

To calculate the exponential of an entire column in Excel, you would drag the POWER formula, =POWER(A1, power) dragged down the entire column.

In pandas, apply the built in `pow` function to the whole column. For example, to calculate the cube of each number in the 'number' column:

df['Exponential'] = df['number'] ** 3
Copy!
Clipboard

If instead of using a constant value as the exponent, like 3, you want to use a value from another column, you can use the apply function to apply the `pow` function to each row of the dataframe.

df['Exponential'] = df['number'] ** df['power']
Copy!
Clipboard

While using the EXP function in pandas, certain mistakes are commonly made. Here are some and how to rectify them.

It's easy to confuse the natural logarithm (base 'e') with the logarithm base 10. Remember that np.exp uses base e, not base 10.

The EXP function in Excel takes a single argument and returns 'e' raised to the power of that number.

=EXP(number)

EXP, POWER Excel Syntax

ParameterDescriptionData Type
numberThe exponent to which the constant 'e' is raised.number

Examples

FormulaDescriptionResult
=EXP(1)Calculate the exponential of 1.2.71828182845905
=EXP(0)Calculate the exponential of 0.1

Don't re-invent the wheel. Use Excel formulas in Python.

Install Mito

Don't want to re-implement Excel's functionality in Python?

Automate analysis with Mito