Excel to Python: UPPER Function - A Complete Guide | Mito
Mito Logo
Home Icon
divider

Functions

divider

Text

divider

UPPER

How to Use Excel's UPPER Function in Pandas

Excel's UPPER function is used to change all letters in a given text to uppercase. This function can be particularly useful for normalizing data entries or ensuring data consistency before merging or grouping data.

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

The UPPER function in Excel requires only one argument: the text you want to convert to uppercase.

=UPPER(text)

UPPER Excel Syntax

ParameterDescriptionData Type
textThe text you want to convert to uppercase.string

Examples

FormulaDescriptionResult
=UPPER("hello")Converts the word 'hello' to uppercase.HELLO

To replicate the UPPER function in Excel using Python and pandas, you can utilize the `.str.upper()` method. Here's how you can use it:

In Excel, you would use the UPPER function on each cell of a column to convert the entire column's text to uppercase.

In pandas, to achieve the same effect, apply the `.str.upper()` method to the desired column. The following code demonstrates how to convert the 'name' column to uppercase:

df['name'] = df['name'].str.upper()
Copy!
Clipboard

When using the `.str.upper()` method in pandas to replicate Excel's UPPER function, the most common source of error is forgetting to use the `.str` accessor.

A frequent oversight is forgetting to use the `.str` accessor before applying string functions to a pandas Series.

If you mistakenly use `df['column'].upper()` instead of the correct `df['column'].str.upper()`, you'll encounter an AttributeError.

# Incorrect approach
df['column'].upper()

# Correct approach
df['column'].str.upper()
Copy!
Clipboard

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