Skip to main content

Polars-first financial statement Sankey visualization library

Project description

FinFlow Sankey

PyPI version Python Tests Docs

Polars-first financial statement Sankey visualization library.

import polars as pl
from finflow_sankey import FinancialSankey

df = pl.DataFrame({
    "account": ["Revenue", "Cost of Revenue", "Operating Expenses", "Tax", "Net Income"],
    "value": [100_000_000.0, -40_000_000.0, -30_000_000.0, -10_000_000.0, 20_000_000.0],
    "period": ["FY2025"] * 5,
    "currency": ["USD"] * 5,
    "statement": ["income_statement"] * 5,
    "section": ["revenue", "cost_of_revenue", "operating_expenses", "tax", "profit"],
})

FinancialSankey.income_statement(df, period="FY2025", currency="USD").validate().export_html(
    "income_statement.html", title="FY2025 Income Statement"
)

Installation

pip install finflow-sankey

Requires Python 3.9 or later.

Features

  • Polars-first: Native pl.DataFrame / pl.LazyFrame support. No pandas required.
  • Accounting-aware validation: Period/currency checks, reconciliation validation.
  • Role-based color palette: Revenue, costs, profit, cash flow each have distinct colors.
  • Customizable themes: default, monochrome, colorblind_safe, minimal, dark, plus custom YAML palettes.
  • Runtime palette override: Change colors via dict or YAML without modifying source.
  • Account mapping: Map raw account names to standard sections via dict or YAML.
  • Reference layout (opt-in): Detailed account nodes with fixed layout for presentations.
  • HTML export: One-line export helper.
  • Multi-period comparison: Compare two periods in a single Sankey.

Input Format

Your DataFrame must contain these columns:

Column Type Description
account str Account name shown on nodes.
value float Signed numeric value. Expenses are typically negative.
period str Period label (e.g. FY2025, 2024-12-31).
currency str Currency label (e.g. USD, KRW tn).
statement str One of income_statement, cash_flow_statement, balance_sheet.
section str Standard section. See table below.

Supported Sections

Statement Sections
Income statement revenue, cost_of_revenue, cost, expense, operating_expenses, tax, non_operating_items, profit
Cash flow beginning_cash, operating_cash_flow, investing_cash_flow, financing_cash_flow, fx_effect, ending_cash
Balance sheet asset, current_asset, non_current_asset, liability, current_liability, non_current_liability, equity

Quick Examples

Income Statement

fig = FinancialSankey.income_statement(df, period="FY2025", currency="USD").validate().render(
    title="FY2025 Income Statement"
)
fig.show()

Reference Layout (Detailed View)

fig = FinancialSankey.income_statement(df, layout="reference").validate().render(
    title="Detailed Income Statement"
)

Cash Flow Statement

fig = FinancialSankey.cash_flow_statement(df_cf, period="FY2025", currency="USD").validate().render(
    title="Cash Flow Bridge"
)

Balance Sheet Reconciliation

fig = FinancialSankey.balance_sheet_reconciliation(df_bs, as_of="2025-12-31", currency="USD").validate().render(
    title="Balance Sheet"
)

Multi-Period Comparison

fig = FinancialSankey.multi_period_compare(df_multi, currency="USD").validate().render(
    title="YoY Comparison"
)

Themes & Palettes

# Built-in theme
fig = FinancialSankey.income_statement(df).validate().render(theme="dark")

# Custom YAML palette
fig = FinancialSankey.income_statement(df).validate().render(palette="./my_palette.yaml")

# Runtime dict override
fig = FinancialSankey.income_statement(df).validate().render(
    palette={"revenue": "#0055FF", "profit": "#00AA55"}
)

Account Mapping

Map raw account names to standard sections when your data uses different labels:

mapping = {
    "revenue": ["Net Sales", "Sales Revenue"],
    "cost_of_revenue": ["COGS", "Cost of Goods Sold"],
    "operating_expenses": ["SG&A", "R&D"],
    "tax": ["Income Tax Expense"],
    "profit": ["Net Income"],
}

fig = FinancialSankey.income_statement(df, mapping=mapping).validate().render()

HTML Export

FinancialSankey.income_statement(df).validate().export_html(
    "income_statement.html", title="FY2025 Income Statement"
)

Real-World Data

See examples/dartlab_integration.py for fetching live Samsung Electronics data via Dartlab CLI.

Documentation

Full documentation is available at https://min9lin9.github.io/finflow-sankey/.

Roadmap

See ROADMAP.md for planned features and the path to v1.0.

Community

Development

pip install -e ".[dev]"
python -m pytest tests/ -q
ruff check finflow_sankey tests

Project Structure

finflow_sankey/
  core/           # schema, validation, normalization, graph, palette, mapper
  templates/      # income_statement, cash_flow, balance_sheet, multi_period
  renderers/      # plotly renderer
  palettes/       # YAML color palettes
  mappings/       # YAML account mappings
  examples/       # usage examples
tests/            # pytest suite
docs/             # mkdocs documentation

License

MIT

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

finflow_sankey-0.1.16.tar.gz (31.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

finflow_sankey-0.1.16-py3-none-any.whl (36.9 kB view details)

Uploaded Python 3

File details

Details for the file finflow_sankey-0.1.16.tar.gz.

File metadata

  • Download URL: finflow_sankey-0.1.16.tar.gz
  • Upload date:
  • Size: 31.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for finflow_sankey-0.1.16.tar.gz
Algorithm Hash digest
SHA256 a715bd031d0363f7bd47fb5ca0d415adf56419f17aedcead342c9dbc807ab0a2
MD5 a7622ea2d40b5ec08875af611b8223ad
BLAKE2b-256 885e01c05cd60a89b74ad5a432ea438e797f27ae0e1eb5edcae531690ab76fe4

See more details on using hashes here.

Provenance

The following attestation bundles were made for finflow_sankey-0.1.16.tar.gz:

Publisher: publish.yml on min9lin9/finflow-sankey

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file finflow_sankey-0.1.16-py3-none-any.whl.

File metadata

  • Download URL: finflow_sankey-0.1.16-py3-none-any.whl
  • Upload date:
  • Size: 36.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for finflow_sankey-0.1.16-py3-none-any.whl
Algorithm Hash digest
SHA256 f0a84b803dc39541bfbcf0707042bbc6b4c94baad352f953203e50252ba54d43
MD5 d845838c79ddb8f10733edba989b124e
BLAKE2b-256 7699998b75a2348b9a3a4fddb7da6af0874105883829180dcde812b015b970be

See more details on using hashes here.

Provenance

The following attestation bundles were made for finflow_sankey-0.1.16-py3-none-any.whl:

Publisher: publish.yml on min9lin9/finflow-sankey

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page