How to Manipulate Strings in Pandas? Last Updated : 05 Sep, 2020 Comments Improve Suggest changes Like Article Like Report 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.DataFrame(data, columns = ["SN", "FirstName", "LastName"]) cfile Output: "Pandas" library provides a ".str()" method that can be used to create any data of the data frame into a string, After that any string operation defined in python documentation or in this article can be used on that data. Below is the code that illustrates some examples Python3 # find firstname starting with 'D' result = cfile.FirstName.str.startswith('D') print(result) # find lasttname containing 'XX' result = cfile.LastName.str.contains('XX') print(result) # split FirstName on the basis of ' ' result = cfile.FirstName.str.split() print(result) # find length of lasttname result = cfile.LastName.str.len() print(result) # Capitalize the first Letter of LastName result = cfile.LastName.str.capitalize() print(result) # Capitalize all Letter of LastName result = cfile.LastName.str.upper() print(result) # Convert all Letter of LastName to lowercase result = cfile.LastName.str.lower() print(result) Output: 0 False 1 False 2 False 3 True Name: FirstName, dtype: bool 0 False 1 True 2 True 3 False Name: LastName, dtype: bool 0 [ABC, KUMAR] 1 [BCD] 2 [CDE, KUMAR] 3 [DEF] Name: FirstName, dtype: object 0 3 1 3 2 3 3 4 Name: LastName, dtype: int64 0 Xyz 1 Xxy 2 Zxx 3 Xyzz Name: LastName, dtype: object 0 XYZ 1 XXY 2 ZXX 3 XYZZ Name: LastName, dtype: object 0 xyz 1 xxy 2 zxx 3 xyzz Name: LastName, dtype: object Comment More infoAdvertise with us Next Article How to Manipulate Strings in Pandas? I iamjpsonkar Follow Improve Article Tags : Python Python-pandas Python pandas-dataFrame Python Pandas-exercise Practice Tags : python Similar Reads 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 Top 10 String methods in Pandas 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 throu 3 min read How to remove numbers from string in Python - Pandas? In this article, let's see how to remove numbers from string in Pandas. Currently, we will be using only the .csv file for demonstration purposes, but the process is the same for other types of files. The function read_csv() is used to read CSV files. Syntax: Â for the method 'replace()': str.replace 2 min read How to lowercase strings in a column in Pandas dataframe Analyzing real-world data is somewhat difficult because we need to take various things into consideration. Apart from getting the useful data from large datasets, keeping data in required format is also very important. One might encounter a situation where we need to lowercase each letter in any spe 2 min read How to Convert Integers to Strings in Pandas DataFrame? In this article, we'll look at different methods to convert an integer into a string in a Pandas dataframe. In Pandas, there are different functions that we can use to achieve this task : map(str)astype(str)apply(str)applymap(str) Example 1 : In this example, we'll convert each value of a column of 3 min read Like