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






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.

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

Mito's UPPER 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 UPPER function
df['name'] = UPPER(df['name'])

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()

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

# Correct approach

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


UPPER Excel Syntax

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


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

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