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() |
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.
uv version --bump patch
git commit -am "Release $(uv version --short)" && git tag "v$(uv version --short)"
git push --follow-tags
Pushing the tag runs .github/workflows/release.yml, which builds and publishes
to PyPI with UV_PUBLISH_TOKEN from the repo secrets.
To publish locally (TestPyPI first):
rm -rf dist && uv build
uv publish --publish-url https://test.pypi.org/legacy/ --token "$UV_PUBLISH_TOKEN_TEST"
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
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 nsds-0.2.0.tar.gz.
File metadata
- Download URL: nsds-0.2.0.tar.gz
- Upload date:
- Size: 13.3 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79f25d5d735bb0ec1ddf0b92ac9ead80acd6ad3bae33a3d648a0bd0132cd83c0
|
|
| MD5 |
a775b202fc7834c275e1e2f1c594ebb5
|
|
| BLAKE2b-256 |
0f1f1259785c5dcf3acdcd02ff9cf9ffcd1a574427182cff36f93f5b547934fa
|
File details
Details for the file nsds-0.2.0-py3-none-any.whl.
File metadata
- Download URL: nsds-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.7 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57841da3dfc1923a27285d921a119d251fdce829a654654dfe93e00e8deae6a4
|
|
| MD5 |
c72d4b6519e91685e8e60026cd21ae72
|
|
| BLAKE2b-256 |
50156be707474795d119f2e604b009a2eb0ef782a99f961d71d20206ba77e89f
|