Check if a column ends with given string in Pandas DataFrame Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In this program, we are trying to check whether the specified column in the given data frame ends with the specified string or not. Pandas endswith() is yet another method to search and filter text data in a DataFrame. This method is similar to Pandas.startwith() method. Syntax: string.endswith(value) Creating Dataframe to Check If a Column Ends with a given String or Not Let's try to understand this using an example suppose we have an employee dataset named Company_id, Joining_Date, Company, companyEmp_id. Python3 # importing library pandas as pd import pandas as pd # creating data frame for employee df = pd.DataFrame({ 'Company_id': ['IF101', 'IF103', 'GFG671', 'GFG881', 'CAPG961', 'WPR981'], 'Company': ['Infosys', 'Infosys', 'GeeksforGeeks', 'GeeksforGeeks', 'Capgemini', 'Wipro'], 'Joining_Date': ['12/12/2011', '07/12/2012', '11/11/2014', '09/12/2015', '01/01/2016', '01/01/2009'], 'Company_Emp_id': ['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]'] }) # printing the given data frame print("Printing Original Student DataFrame:") df Output: Example 1: The endswith() method in Python returns True if the string ends with the gfg.com, if not it returns False. Python3 # joining new column in dataframe # endwith function used to check df['GFG_Emp'] = list( map(lambda x: x.endswith('gfg.com'), df['Company_Emp_id'])) # printing new data frame df Output: Example 2: The endswith() method in Python returns True if the string ends with infosys.com, if not it returns False. Python3 # joining new column in dataframe # .startswith function used to check df['GFG_Emp'] = list( map(lambda x: x.endswith('Infosys'), df['Company'])) # printing new data frame df Output: RECOMMENDED ARTICLES - Check if a column starts with given string in Pandas DataFrame Comment More infoAdvertise with us Next Article Get all rows in a Pandas DataFrame containing given substring A Akashkumar17 Follow Improve Article Tags : Python Practice Tags : python Similar Reads Check if a column starts with given string in Pandas DataFrame? In this program, we are trying to check whether the specified column in the given data frame starts with specified string or not. Let us try to understand this using an example suppose we have a dataset named student_id, date_of_joining, branch. Example: Python3 #importing library pandas as pd impor 2 min read Check whether a given column is present in a Pandas DataFrame or not Consider a Dataframe with 4 columns : 'ConsumerId', 'CarName', CompanyName, and 'Price'. We have to determine whether a particular column is present in the DataFrame or not in Pandas Dataframe using Python. Creating a Dataframe to check if a column exists in DataframePython3 # import pandas library 2 min read Get all rows in a Pandas DataFrame containing given substring Let's see how to get all rows in a Pandas DataFrame containing given substring with the help of different examples. Code #1: Check the values PG in column Position Python3 1== # importing pandas import pandas as pd # Creating the dataframe with dict of lists df = pd.DataFrame({'Name': ['Geeks', 'Pet 3 min read Select all columns, except one given column in a Pandas DataFrame DataFrame Data structure are the heart of Pandas library. DataFrames are basically two dimension Series object. They have rows and columns with rows representing the index and columns representing the content. Now, let's see how to Select all columns, except one given column in Pandas DataFrame in P 2 min read Check if dataframe contains infinity in Python - Pandas When working with data, you may encounter infinity values (positive or negative), represented as np.inf and -np.inf in Python using the NumPy library. It's important to check if your Pandas DataFrame contains any infinity values before proceeding with analysis. Let's explore different methods to det 3 min read How to Check if a Pandas Column Has a Value from a List of Strings? We are given a DataFrame and a list of strings, and our task is to check if any value in a specific column exists in that list. This is useful when filtering rows based on exact or partial matches. For example, if we have a list like ['java', 'c'] and want to find all rows in the subjects column con 3 min read Like