Skip to main content
HomeAbout PythonLearn Python

Lowercase in Python Tutorial

Learn to convert spreadsheet table column into lowercase using .str.lower().
Jun 2020  · 6 min read
Read the Spanish version 🇪🇸 of this article.

.lower() is a built-in Python method primarily used for string handling. The .lower() method takes no arguments and returns the lowercased strings from the given string by converting each uppercase character to lowercase. If there are no uppercase characters in the given string, it returns the original string.

Practice Case Conversion in Python with this hands-on exercise.

Run and edit the code from this tutorial online

Open Workspace

str.lower() method

In the below example, we will use the .str.lower() method which turns all column entries into lowercase characters. Here is what the list looks like to start with:

            name      price_usd
0          Apple           0.88
1         Banana           0.23
2         Orange           0.68
3     Watermelon           3.98
4           Plum           0.96
5    Blueberries           5.16
6    Dragonfruit           5.27
7           Kiwi           1.12 

Now, select the name column from the fruit_price dataframe and apply .str.lower() to convert the name column entries into lowercase, as shown below.

 fruit_price['name'] = fruit_price['name'].str.lower()


            name      price_usd
0          apple           0.88
1         banana           0.23
2         orange           0.68
3     watermelon           3.98
4           plum           0.96
5    blueberries           5.16
6    dragonfruit           5.27
7           kiwi           1.12

Master your data skills with DataCamp

Learn the skills you need at your own pace—from non-coding essentials to data science and machine learning.

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.

Interactive Example of str.lower()

In this example, all you need to do is use the right method to change the movie_title column to lower case using the .str.lower() method.

# Change movie_title column to lower lower case
movies['movie_title'] = movies['movie_title'].str.lower()

# Look at the change

When you run the above code, it produces the following result:

                        movie_title movie_genre  movie_length
0              the sumif all fears      Action           124
1             the seaborn identity      Action           119
2                     the matrices      Action           136
3  there's something about merging      Comedy           119
4                    mamma median!      Comedy           108
5                    harry plotter        Kids           159
6                   kung fu pandas        Kids            92
7           while you were sorting     Romance           103
8      10 things i hate about unix     Romance            97

Try it for yourself.

To learn more about putting pandas dataframe together in Python, please see this video from our course Python for Spreadsheet Users.

This content is taken from DataCamp's Python for Spreadsheet Users course by Chris Cardillo.

Get certified in your dream Data Analyst role

Our certification programs help you stand out and prove your skills are job-ready to potential employers.

Get Your Certification
Timeline mobile.png

Lowercase in Python FAQS

What is lowercase in Python?

It is a letter case when all the letters of a string are small. The opposite to lowercase is uppercase when all the letters of a string are capitals. Otherwise, if there are both small and capital letters in a string, it is called a mixed case.

How to make a string lowercase in Python?

Using a Python built-in string method lower() on the string or a variable representing it. For example, 'PythoN'.lower() will return 'python'. This method doesn't take in any arguments.

How to make all the strings in a Python list lowercase?

Using list comprehension. For example, [x.lower() for x in ['Python', 'R', 'SQL']] will return ['python', 'r', 'sql']. An important note here is that all the items in the list have to be of string type, otherwise the program will throw an error.

How to make all the strings in a Python Series lowercase?

It is possible to use list comprehension also on a Series ([x.lower() for x in pd.Series(['Python', 'R', 'SQL'])]), but a better approach here is to use the Series.str.lower() method. For example, pd.Series(['Python', 'R', 'SQL']).str.lower() will return:

0    python
1         r
2       sql
dtype: object

An important note here is that all the values of the Series object have to be of string type and no missing values are acceptable, otherwise the program will throw an error.

How to check if all the letters in a Python string are lowercase?

Using a Python built-in string method islower() on the string or a variable representing it. For example, 'Python'.islower() will return False since there is one uppercase letter in the string while 'python'.islower() will return True.

What type of data do the lower() and islower() methods return?

The lower() method returns a string while the islower() method returns a boolean.

Do the lower() and islower() methods work on numbers?

No. Applying these methods on numbers (e.g., 1.lower()) or any other data types that are not string will throw an error.

What happens if we apply the lower() or islower() methods on a string containing digits, white spaces, or special characters?

The lower() method leaves such characters as they are, the islower() ignore them. For example, 'Python1'.lower() will return 'python1', 'Python & R'.lower() will return 'python & r', and 'python & r'.islower() will return True. It works even for the strings containing emoji: 'I ❤️ Python'.lower() will return 'i ❤️ python'.

What are the opposite methods to lower() and islower() to make a string uppercase?

upper() and isupper(). The syntax and use cases of these methods are identical to lower() and islower(), they also work only on the string data type and ignore digits, white spaces, or special characters inside a string. To make all the strings in a Python Series uppercase, use the Series.str.upper() method.


Python Courses


Python for Spreadsheet Users

4 hr
Use your knowledge of common spreadsheet functions and techniques to explore Python!
See DetailsRight Arrow
Start Course
Certification available


Introduction to Python

4 hr
Master the basics of data analysis with Python in just four hours. This online course will introduce the Python interface and explore popular packages.
See MoreRight Arrow

A Data Science Roadmap for 2024

Do you want to start or grow in the field of data science? This data science roadmap helps you understand and get started in the data science landscape.
Mark Graus's photo

Mark Graus

10 min

Mastering the Pandas .explode() Method: A Comprehensive Guide

Learn all you need to know about the pandas .explode() method, covering single and multiple columns, handling nested data, and common pitfalls with practical Python code examples.
Adel Nehme's photo

Adel Nehme

5 min

Python NaN: 4 Ways to Check for Missing Values in Python

Explore 4 ways to detect NaN values in Python, using NumPy and Pandas. Learn key differences between NaN and None to clean and analyze data efficiently.
Adel Nehme's photo

Adel Nehme

5 min

Seaborn Heatmaps: A Guide to Data Visualization

Learn how to create eye-catching Seaborn heatmaps
Joleen Bothma's photo

Joleen Bothma

9 min

Test-Driven Development in Python: A Beginner's Guide

Dive into test-driven development (TDD) with our comprehensive Python tutorial. Learn how to write robust tests before coding with practical examples.
Amina Edmunds's photo

Amina Edmunds

7 min

Exponents in Python: A Comprehensive Guide for Beginners

Master exponents in Python using various methods, from built-in functions to powerful libraries like NumPy, and leverage them in real-world scenarios to gain a deeper understanding.
Satyam Tripathi's photo

Satyam Tripathi

9 min

See MoreSee More