Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Top 10 String methods in Pandas
Next article icon

Top 10 String methods in Pandas

Last Updated : 12 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In simple terms, string methods in Pandas are a set of tools that help us manipulate and work with text (also known as strings) in our data. Pandas, which is a powerful Python library for data manipulation, provides a variety of built-in tools to make that job easier. Instead of manually going through each piece of text and making changes, these string methods allow us to do things like:

  • Convert all text to lowercase or uppercase
  • Remove extra spaces or unwanted characters
  • Extract parts of text based on patterns
  • Find and replace certain words or characters

String Methods in Pandas

These string methods work in a very efficient way on entire columns of data, so you can modify thousands or even millions of text entries at once without breaking a sweat.

MethodDescription
upper()Converts a string into uppercase
lower()Converts a string into lowercase
isupper()Checks whether the character is uppercase or not
islower()Checks whether the character is lowercase or not
len()Identifies the length of the string.
startswith() Returns true if the element starts with the pattern
split()Splits the string at a particular index or character
find()Returns the index at where the given string is found
strip()Strips whitespaces from each string from both sides.
replace() Replaces a part of the string with another one.

Let's explore each method in detail with example:

We will be using the below data frame for the purpose of the illustration.

Python
import pandas as pd sports = pd.Series(['Virat', 'azam', 'fiNch', 'ShakiB', 'STOKES', 'KAne']) print(sports) 

Output:

Screenshot-2025-03-12-123419

1.) DataFrame.upper()

Convert each string to upper case. This method is useful when normalizing text data for consistency (e.g., converting names or categories to uppercase).

Python
print("Upper Case:") print(sports.str.upper()) 

Output:

Screenshot-2025-03-12-123706

2.) DataFrame.lower()

It converts all characters to lowercase and ensure consistency in text data.

Python
print("Lower Case:") print(s.str.lower()) 

Output:

Screenshot-2025-03-12-123842

3.) DataFrame.isupper()

It returns boolean values based on whether each character present in the string is in upper case or not.

Python
print("Checks whether string is in Upper Case:") print(sports.str.isupper()) 

Output:

Screenshot-2025-03-12-124058

4.) DataFrame.islower()

It returns boolean values based on whether each character present in the string is in lowercase or not.

Python
print("Checks whether string is in Lower Case:") print(s.str.islower()) 

Output:

Screenshot-2025-03-12-124259

5.) DataFrame.len()

This function returns the length of each string.

Python
print("Length of strings:") print(sports.str.len()) 

Output:

Screenshot-2025-03-12-124433

6.) DataFrame.startswith()

It returns boolean values based on whether the string starts with a certain character sequence or not.

Python
print("Checks whether string starts with certain substring:") print(sports.str.startswith('a')) 

Output:

7.) DataFrame.split()

This function helps to split the string by a certain character or symbols at once.

Python
print("Splits string by character 'a':") print(sports.str.split('a')) 

Output:

Screenshot-2025-03-12-124745

8.) DataFrame.find()

This function finds the index of the occurrence of a certain character sequence.

Python
print("Find the index of the searched character or substring:") print(sports.str.find('a')) 

Output:

9.) DataFrame.strip()

It helps to remove the extra trailing spaces from the start and the end.

Python
print("Remove extra space from the starting and the end of the string:") print(s.str.strip()) 

Output:

10.) DataFrame.replace()

This function helps to remove certain character sequence sometimes which are present in all the strings and is undesired.

Python
print("Replace a particular substring by desired pattern:") print(sports.str.replace('a', '')) 

Output:


Next Article
Top 10 String methods in Pandas

S

shreyasnaphad
Improve
Article Tags :
  • Technical Scripter
  • Python
  • Technical Scripter 2022
Practice Tags :
  • python

Similar Reads

    How to Manipulate Strings in Pandas?
    Pandas Library provides multiple methods that can be used to manipulate string according to the required output. But first, let's create a Pandas dataframe. Python3 import pandas as pd data = [[1, "ABC KUMAR", "xYZ"], [2, "BCD", "XXY"], [3, "CDE KUMAR", "ZXX"], [3, "DEF", "xYZZ"]] cfile = pd.DataFra
    2 min read
    Pandas Convert Column To String Type
    Pandas is a Python library widely used for data analysis and manipulation of huge datasets. One of the major applications of the Pandas library is the ability to handle and transform data. Mostly during data preprocessing, we are required to convert a column into a specific data type. In this articl
    4 min read
    How to Convert Pandas Columns to String
    Converting columns to strings allows easier manipulation when performing string operations such as pattern matching, formatting or concatenation. Pandas provides multiple ways to achieve this conversion and choosing the best method can depend on factors like the size of your dataset and the specific
    3 min read
    Python String Methods
    Python string methods is a collection of in-built Python functions that operates on strings.Note: Every string method in Python does not change the original string instead returns a new string with the changed attributes. Python string is a sequence of Unicode characters that is enclosed in quotatio
    5 min read
    String manipulations in Pandas DataFrame
    String manipulation is the process of changing, parsing, splicing, pasting or analyzing strings. As we know that sometimes data in the string is not suitable for manipulating the analysis or get a description of the data. But Python is known for its ability to manipulate strings. In this article we
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences