You can use the Series method str.startswith (which takes a regex):

In [11]: s = pd.Series(['aa', 'ab', 'ca', np.nan])

In [12]: s.str.startswith('a', na=False)
Out[12]: 
0     True
1     True
2    False
3    False
dtype: bool

You can also do the same with str.contains (using a regex):

In [13]: s.str.contains('^a', na=False)
Out[13]: 
0     True
1     True
2    False
3    False
dtype: bool

So you can do df[col].str.startswith...

See also the SQL comparison section of the docs.

Note: (as pointed out by OP) by default NaNs will propagate (and hence cause an indexing error if you want to use the result as a boolean mask), we use this flag to say that NaN should map to False.

In [14]: s.str.startswith('a')  # can't use as boolean mask
Out[14]:
0     True
1     True
2    False
3      NaN
dtype: object
Answer from Andy Hayden on Stack Overflow
🌐
Medium
medium.com › @whyamit101 › understanding-the-pandas-like-operator-c9a52704e807
Understanding the Pandas Like Operator | by why amit | Medium
April 12, 2025 - It’s almost like searching for a word in a document, but in your DataFrame. This operator can be especially handy when you're dealing with large datasets where you need precise control over your text data. ... import pandas as pd # Sample DataFrame data = { 'Name': ['Alice', 'Bob', 'Charlie', 'Diana'], 'Age': [24, 30, 22, 25] } df = pd.DataFrame(data) # Using the like operator result = df[df['Name'].str.contains('A')] print(result)
Discussions

Modern alternatives to Data Science Libraries like Polars with Pandas?
Pystore - data storage for pandas. NiceGUI - Excellent frontend for Python. KVRocks - On disk K/V store with a Redis API. More on reddit.com
🌐 r/Python
68
211
January 14, 2024
python - USING LIKE inside pandas.query() - Stack Overflow
I have been using Pandas for more than 3 months and I have an fair idea about the dataframes accessing and querying etc. I have got an requirement wherein I wanted to query the dataframe using LIKE More on stackoverflow.com
🌐 stackoverflow.com
packages similar to Pandas
Numpy functionality is largely covered by https://www.gonum.org/ but for pandas I'm not sure if there is an equivalent as widely accepted. However, you might try https://github.com/rocketlaunchr/dataframe-go which I have not tried but it looks like it covers some of what you're looking for More on reddit.com
🌐 r/golang
24
19
May 11, 2023
A Dependencyless Pure-Python Pandas-like DataFrame (for Lambdas)
This is really cool and I'm sure it has been a lot of work, but I'm curious what your need is here? I'm using Pandas in Lambdas all the time right now and it hasn't been an issue. More on reddit.com
🌐 r/Python
8
3
November 3, 2020
🌐
Softhints
softhints.com › how-to-use-like-operator-in-pandas-dataframe
How to Use Like Operator in Pandas DataFrame - Softhints
February 10, 2022 - Looking for SQL like operator in Pandas? If so, let's check several examples of Pandas text matching simulating Like operator. To start, here is a sample DataFrame which will be used in the next examples: data = {'num_legs': [4, 2, 0, 4, 2, 2], 'num_wings': [0, 2, 0,
🌐
Statology
statology.org › home › pandas: how to use like inside query()
Pandas: How to Use LIKE inside query()
August 31, 2022 - You can use the following methods to use LIKE (similar to SQL) inside a pandas query() function to find rows that contain a particular pattern:
🌐
Linux find Examples
queirozf.com › entries › pandas-query-examples-sql-like-syntax-queries-in-dataframes
Pandas Query Examples: SQL-like queries in dataframes
September 17, 2022 - import pandas as pd import numpy as np df = pd.DataFrame({ 'name':['john','david','anna'], 'country':['USA','UK',np.nan] }) df.query('country.notnull()', engine='python') ... Although like is not supported as a keyword in query, we can simulate it using col.str.contains("pattern"):
🌐
YouTube
youtube.com › automate with rakesh
SQL Like Query in Python Pandas - YouTube
Master SQL-like query capabilities in Python Pandas. Discover how to filter and manipulate your data with SQL-like syntax, unleashing the full power of Panda...
Published   September 20, 2023
Views   768
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.reindex_like.html
pandas.DataFrame.reindex_like — pandas 3.0.5 documentation
List-like includes list, tuple, array, Series, and must be the same size as the index and its dtype must exactly match the index’s type.
Find elsewhere
🌐
IncludeHelp
includehelp.com › python › using-like-inside-pandas-query.aspx
Python - USING LIKE inside pandas query
The LIKE keyword is used as a condition where if a particular value is similar to some condition, it returns that value. There is a myth that pandas DataFrame query also contains the Like keyword which is exactly like SQL.
🌐
IncludeHelp
includehelp.com › python › pandas-text-matching-like-sqls-like.aspx
Python - Pandas text matching like SQL's LIKE?
With SQL like we can match any number of characters and even zero characters by using '%' and also, we can match exactly 1 character by using '_'. Similarly, we can use the series method string.startswith and pass any of the required strings inside it as a parameter so that it returns a list of Booleans. Pandas also offer a series method string.contains() which works similarly to the startswith method but it takes a regular expression as a parameter.
🌐
Pythonanywhere
sql2pandas.pythonanywhere.com › cookbook › sql-where-like-in-pandas
SQL2pandas | SQL's WHERE column LIKE in pandas
--Filtering on a substring in a value: SELECT * FROM table WHERE column_1 LIKE '%xampl%'; In pandas: #Filtering on the end of a value: table[table['column_1'] .str .endswith('xample')] #Filtering on the start of a value: table[table['column_1'] .str .startswith('Exampl')] #Filtering on a substring in a value: table[table['column_1'] .str .contains('xampl')] In SQL: --Filtering on the end of a value: SELECT * FROM table WHERE column_1 NOT LIKE '%xample'; In pandas, using ~: #Filtering on the end of a value: table[~table['column_1'] .str .endswith('xample')] pandas .str.endswith() documentation ·
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.filter.html
pandas.DataFrame.filter — pandas 3.0.5 documentation
>>> # select rows containing 'bbi' >>> df.filter(like="bbi", axis=0) one two three rabbit 4 5 6
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.api.types.is_list_like.html
pandas.api.types.is_list_like — pandas 3.0.5 documentation
Objects that are considered list-like are for example Python lists, tuples, sets, NumPy arrays, and Pandas Series.
🌐
LinkedIn
linkedin.com › pulse › pandas-like-sql-sakshyam-ghimire
Pandas like an SQL
July 30, 2023 - Everyone is pretty much aware about the fact that pandas is an amazing python library for data manipulation, but more often than not people associate pandas with vast universe of machine learning overlooking it's simpler use cases. So in this article I will be using pandas like an small SQL database
🌐
Reddit
reddit.com › r/python › a dependencyless pure-python pandas-like dataframe (for lambdas)
r/Python on Reddit: A Dependencyless Pure-Python Pandas-like DataFrame (for Lambdas)
November 3, 2020 -

After dealing with AWS Lambda layers and Python libraries (specifically, Pandas, Numpy, and PyArrow), I decided to try making my own dependency-less pure-python implementation of Pandas. The goal was to make is as identical as possible to Pandas, and even have it replicate the behavior of shared underlying data between Frames and slices/Series.

With this built, if I just needed the convenience of Pandas for dealing with a (small) dataset, but didn't want the headache of installing all the dependencies, I could just do a quick pip install pambdas. All under 1MB (or 188 KB).

Currently supported:

  • Indexing/assignment by .loc and .iloc

  • Unary operators for Series

  • Boolean Indexing

  • Apply and ApplyMap

  • Append

  • GroupBy

  • pambdas.concat

  • pambdas.read_csv

The underlying data type is a simple Python list, and views are created but adjusting the slice (start, stop, and step). It was a bit of a pain, but oddly satisfying! It's not optimized, quite verbose (I handle each .iloc/.loc case independently), and is certainly very buggy. And since it's uses only pure-python, it is obviously much slower.

A couple of comments about the process:

  1. My test file is over 1000 lines, and I'm still finding bugs.

  2. It was important to get the indexing right.

  3. It was fun developing the very basic functions (indexing, values, operators), and then bootstrapping with these to make much higher complexity processes.

  4. Should have gotten the nans right from the start.

  5. Testing square dataframes (e.g. 4x4, 5x5) was a bad idea...

There is still al lot of work to be done, so I'll collect some feedback while I take a break from this project. And if you're interested in contributing let me know! Lots of low hanging fruit. And some higher hanging fruit, like garbage collection.

Check out the github (https://github.com/danhitchcock/pambdas) and the example (https://github.com/danhitchcock/pambdas/blob/master/example.py), and feel free to install and find all the bugs try it out with `pip install pambdas`! Also, let me know if there are any killer features you'd like to see.

🌐
Pandas
pandas.pydata.org › docs › getting_started › comparison › comparison_with_sql.html
Comparison with SQL — pandas 3.0.5 documentation - PyData |
Since many potential pandas users have some familiarity with SQL, this page is meant to provide some examples of how various SQL operations would be performed using pandas.
🌐
Reddit
reddit.com › r/datascience › best alternative to pandas 2023?
r/datascience on Reddit: Best alternative to Pandas 2023?
January 13, 2023 -

I'm sick of Pandas and want to use something faster and more intuitive for data wrangling.

I've been given the green light at work to try out whatever package/language I want, so open to any suggestions.

I was considering something like DataFrames.jl, Tidyverse, Polars, TidyPolars, etc. but wondered what people thought was best nowadays?