Skip to main content

Fyrefly

A quant-based library to compute mathematical operations, run SQL queries, get AI-powered insights, and visualize your data.

Installation

pip install fyrefly

Usage — Math functions

from fyrefly import add, mul, div, mod, diff

add(5, 4, 6, 10)     # 25
mul(5, 4, 6, 10)     # 1200
div(100, 5, 2)       # 10.0
mod(17, 5)           # 2
diff(10, 3, 2)       # 5

Each function accepts any number of arguments:

add(1)                # 1
add(1, 2, 3, 4, 5)    # 15
mul()                  # 1 (identity)
diff(10, 3)            # 7

Usage — Data functions

from fyrefly import load, loadh, loadc, loads, sql, xtract, clean

c = load("data.csv")                 # loads a CSV/Excel/Google Sheet, previews it
loadh(c)                             # preview column headers
loadc(c)                             # preview record count
loads(c)                             # preview schema (columns + datatypes)

c = clean(c)                         # dedupe, strip whitespace, standardize column names

d = sql("select * from c where age > 30")   # run ANY SQL query on loaded data
xtract(d)                                    # export the result to CSV
xtract(sql("select * from c"), filename="all.csv")  # chained form also works

Note: for Google Sheets, the sheet must be shared as "Anyone with the link – Viewer" for load() to access it.

Usage — AI functions (require an API key)

from fyrefly import ask, insights

c = load("sales.csv")

# Ask questions in plain English — converted to SQL and run automatically
ask(c, "what were total sales by region last quarter?", api_key="AIza...")

# Query across multiple datasets (e.g. a join) — scales to any count
ask((c, d), "who are our top customers by total sales?", api_key="AIza...")
ask((c, d, e), "...", api_key="AIza...")

# Get a plain-English summary of a dataset
insights(c, api_key="AIza...")

The provider (Anthropic, OpenAI, Gemini, or any OpenAI-compatible API like Groq/Mistral) is auto-detected from your API key's format — you usually don't need to specify it. API keys can also be set via environment variables instead of passing them directly: ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY.

⚠️ Never commit an API key into a script you push to GitHub. Use an environment variable instead:

export GEMINI_API_KEY="AIza..."
ask(c, "what were total sales by region?")   # picked up automatically from the env var

Usage — Visualization (no AI, no API key needed)

from fyrefly import viz

viz(c)                                          # auto -> correlation heatmap
viz(c, x="department")                          # auto -> bar chart of counts
viz(c, x="age")                                 # auto -> histogram
viz(c, kind="scatter", x="age", y="salary")
viz(c, kind="box", x="department", y="salary")
viz(c, kind="pie", x="department")
viz(c, kind="line", x="date", y="revenue")
viz(c, kind="pairplot", hue="department")
viz(c, kind="bar", x="department", y="salary", save="chart.png")   # also saves a file

Supported chart types: line, bar, barh, scatter, hist, box, violin, kde, pie, heatmap, pairplot, area, plus "auto" which picks a sensible chart based on your data.

Functions

Function Description Needs API key?
add(*nos) Adds all given numbers No
mul(*nos) Multiplies all given numbers No
div(*nos) Divides left to right: first ÷ second ÷ third ... No
mod(*nos) Finds remainder left to right: first % second % third ... No
diff(*nos) Subtracts left to right: first − second − third ... No
load(path) Loads a CSV/Excel/Google Sheet into a DataFrame and previews it No
loadh(df) Previews just the column headers No
loadc(df) Previews the record count No
loads(df) Previews the schema (columns + datatypes) No
sql(query) Runs any SQL query against a loaded DataFrame, by variable name No
xtract(df, filename=None) Exports a DataFrame to CSV in the current directory No
clean(df) Dedupes, strips whitespace, standardizes column names No
ask(data, question, api_key=...) Converts a plain-English question into SQL and runs it Yes
insights(df, api_key=...) Generates a plain-English summary of a dataset Yes
viz(df, kind="auto", ...) Visualizes a DataFrame — 12+ chart types No

Development

pip install -e ".[dev]"
pytest

License

MIT

Release files for fyrefly 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fyrefly 0.3.1
File Size Uploaded
fyrefly-0.3.1.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fyrefly 0.3.1
File Interpreter ABI Platform
fyrefly-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 24.8 kB

Release files / fyrefly-0.3.1.tar.gz

Download URL fyrefly-0.3.1.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3d266f35fb7c9dfc62c7cc85bc2a9e5e69b0b684bca7c4fb14a5cb4f2bf602a8
BLAKE2b-256 checksum
How to use checksums
8d07c5183892aa6c7a1b5d9f76d25809fded527a7211c691d02032fdf2d60bad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release files / fyrefly-0.3.1-py3-none-any.whl

Download URL fyrefly-0.3.1-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6c36bbce5b23dea00cb5df7d0b3480e173e6729e0d9b3bc0b9e9d63e5231b18
BLAKE2b-256 checksum
How to use checksums
936420e51b39ccdaa5f34e7368b867f145560fda9c42ef7be6164cba51b4196b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.2

2 release files

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page