Skip to main content

nsds

Personal toolkit for DataScience tasks, runs locally and on Databricks.

Install

pip install nsds                # core: pandas helpers, metrics, utils
pip install 'nsds[notebook]'    # plotly, itables, tqdm, IPython, dotenv
pip install 'nsds[sql]'         # databricks-sql-connector
pip install 'nsds[gsheets]'     # gspread
pip install 'nsds[all]'

Everything outside the core is imported lazily, so a bare install stays small and nsds never pulls in a pyspark that would shadow the one on a cluster.

Quickstart

import nsds

nsds.setup()

setup() is the only thing in the package with side effects: importing any module does nothing on its own. It installs the pandas extensions, sets display options, selects the compact plotly renderer and loads a .env. The last two only apply locally and are skipped on a Databricks cluster.

nsds.setup(itables=True, logging=True)   # opt in
nsds.setup(plotly=False, dotenv=False)   # opt out

What is in it

Module Contents
nsds.frame install(), read_csvs, read_csv_pyarrow, merge_insert_at, dt_group, percentiles
nsds.charts prediction_scatter_plot, dual_y_figure, calculate_axis_range, Colors
nsds.tables show() — itables with sensible defaults
nsds.io.sql read_sql()
nsds.io.gsheets get_gspread_client(), overwrite_worksheet, spark_df_to_rows
nsds.metrics r2_score, r2_adjusted, smape
nsds.utils datetime_utils, round_half_up, gini_inequality_coefficient, parameter_names, show_mac_notification
nsds.runtime RUNTIME_ENV, IS_DATABRICKS

DataFrame extensions

nsds.setup() attaches these to both pd.DataFrame and pd.Series, without ever shadowing an existing pandas attribute:

df.vc(show_cumulative=True)        # value_counts with percentages
df.missing()                       # NaN / zero / empty-string report
df.sortd("amount")                 # sort_values, descending
df.preview()                       # display a few rows
df.show(nrows=50)                  # display without truncating columns
df.explode_all()
df.memory_mb()
df.to_csv_("out.csv", add_date_to_filename="day")
df.apply_row_wise(func)            # columns inferred from the signature

Static analysers cannot see monkey-patched attributes, so an editor will not autocomplete these on a DataFrame — Jupyter's runtime completion will. Everything else in the package is normally typed and ships py.typed.

Reading SQL

Same call in both environments. On a cluster it uses the active SparkSession; locally it opens a databricks-sql-connector connection from DATABRICKS_SERVER_HOSTNAME, DATABRICKS_HTTP_PATH and DATABRICKS_TOKEN, or from arguments you pass directly.

from nsds.io.sql import read_sql

df = read_sql("SELECT * FROM t WHERE day = :day", {"day": "2026-01-01"})

On Databricks

%pip install 'nsds[gsheets]'

get_gspread_client() can take its service-account JSON from a Databricks secret:

from nsds.io.gsheets import get_gspread_client

client = get_gspread_client(secret_scope="my-scope", secret_key="gcp-service-account")

or from the GSPREAD_SECRET_SCOPE and GSPREAD_SECRET_KEY environment variables.

Development

uv sync --all-extras
uv run pytest
uv run ruff check src tests --fix

Releasing

Versions live in pyproject.toml and are read back at runtime via package metadata. Publish is local for now (UV_PUBLISH_TOKEN / UV_PUBLISH_TOKEN_TEST in a gitignored .envrc). Later: restore a tag-triggered workflow and set UV_PUBLISH_TOKEN as a repo Action secret once 2FA is available on the personal GitHub account.

uv version --bump patch
git commit -am "Release $(uv version --short)" && git tag "v$(uv version --short)"
git push --follow-tags

rm -rf dist && uv build
uv publish --publish-url https://test.pypi.org/legacy/ --token "$UV_PUBLISH_TOKEN_TEST"  # optional smoke
uv publish --token "$UV_PUBLISH_TOKEN"

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nsds-0.3.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

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

nsds-0.3.0-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file nsds-0.3.0.tar.gz.

File metadata

  • Download URL: nsds-0.3.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for nsds-0.3.0.tar.gz
Algorithm Hash digest
SHA256 02c112e0fd8a6c8a904d2bf91cb809ae15d5a58abf9f137f0d2972e496ef5923
MD5 7ea704b23d036826d30e53492ffa786a
BLAKE2b-256 a919ed1a505b12d1859331f4a9202001910ae8b5d9222c500d0e8105d06defa8

See more details on using hashes here.

File details

Details for the file nsds-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: nsds-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for nsds-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95d2e877139e97cb6e06bae0df74ec445b5cbaad3f1c67dfe7f57188ef52b029
MD5 535f0b7c5d1853292884c1bb2162ec4a
BLAKE2b-256 8cde4d61c32e299b6d2fcbb6c5e390d2d3bf1dc4b1f8bb34a7426e1f0446fe1d

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4.1

2 files

0.4.0

2 files

This release

0.3.0 This release

2 files

0.2.0

2 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