Query dataframes with GitHub search syntax
Project description
Frame Search
A GitHub search inspired interface to DataFrames.
Powered by narwhals.
Installation
Install from PyPI:
uv add frame-search
Usage
# Import to add `search` property to DataFrames
import frame_search # noqa: F401
import polars as pl
df = pl.DataFrame({
"name": ["Alice Smith", "Bob J. Dawkins", "Charlie Brown"],
"age": [25, 30, 35],
"hometown": ["New York", "New York", "Chicago"]
})
df.search('age:<30 hometown:"New York"')
shape: (1, 3)
┌─────────────┬─────┬──────────┐
│ name ┆ age ┆ hometown │
│ --- ┆ --- ┆ --- │
│ str ┆ i64 ┆ str │
╞═════════════╪═════╪══════════╡
│ Alice Smith ┆ 25 ┆ New York │
└─────────────┴─────┴──────────┘
Use with marimo to create a search interface for DataFrames:
import marimo as mo
search = mo.ui.text(label="DataFrame Search Query:")
search
Then use on a DataFrame:
import polars as pl
import frame_search # noqa: F401
df = pl.DataFrame({
"name": ["Alice Smith", "Bob J. Dawkins", "Charlie Brown"],
"age": [25, 30, 35],
"hometown": ["New York", "Los Angeles", "Chicago"]
})
df_filter = df.search(search.value)
df_filter
Here is another example in a Marimo notebook:
Internal API
from frame_search import create_search
search = create_search("Name", {"name": "Full Name", "age": "Current Age", "Hometown": "city"})
This search function will work on any DataFrame library supported by narwhals. For example, pandas:
import pandas as pd
df = pd.DataFrame({
"Full Name": ["Alice Smith", "Bob J. Dawkins", "Charlie Brown"],
"Current Age": [25, 30, 35],
"Hometown": ["New York", "Los Angeles", "Chicago"]
})
df.pipe(search, "name:alice age:>30 hometown:miami")
Or use the search property of pandas and polars Frames:
import pandas as pd
# Adds `search` property to DataFrames
import frame_search # noqa: F401
df = pd.DataFrame({
"Full Name": ["Alice Smith", "Bob J. Dawkins", "Charlie Brown"],
"Current Age": [25, 30, 35],
"Hometown": ["New York", "Los Angeles", "Chicago"]
})
query = "name:alice age:>30 hometown:miami"
df.search(query)
df_pl = pl.DataFrame(df)
df_pl.search(query)
df_pl.lazy().search(query).collect()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file frame_search-0.1.0.tar.gz.
File metadata
- Download URL: frame_search-0.1.0.tar.gz
- Upload date:
- Size: 195.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57ea288d940f7e037001015d336053288de25f8d8b4d82292d08562b0db123b8
|
|
| MD5 |
abc96bbf314e3007a0f3ed886fe49789
|
|
| BLAKE2b-256 |
cb9b9d19f9b3797959671546603cdbd2e16d965950118a8924d3df7f348d57bd
|
File details
Details for the file frame_search-0.1.0-py3-none-any.whl.
File metadata
- Download URL: frame_search-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01738bf58745805e03b12faed2c0a96b0232ce889fe4809bf58ca25ed644a4cd
|
|
| MD5 |
0f3f8f6617483026c8b84a20d87fe1d4
|
|
| BLAKE2b-256 |
4d6e460f6a6f79c071a685c1dfce17f033a687f0f090c714aefcbed8a423be93
|