Skip to main content

I love Pandas! But in production code I’m always a bit wary when I see:

import pandas as pd

def foo(df: pd.DataFrame) -> pd.DataFrame:
    # do stuff
    return df

Because… How do I know which columns are supposed to be in df?

Using strictly_typed_pandas, we can be more explicit about what these data should look like.

from strictly_typed_pandas import DataSet

class Schema:
    id: int
    name: str

def foo(df: DataSet[Schema]) -> DataSet[Schema]:
    # do stuff
    return df
Where DataSet:
  • is a subclass of pd.DataFrame and hence has the same functionality as DataFrame.

  • validates whether the data adheres to the provided schema upon its initialization.

  • is immutable, so its schema cannot be changed using inplace modifications.

The DataSet[Schema] annotations are compatible with:
  • mypy for type checking during linting-time (i.e. while you write your code).

  • typeguard (<v3.0) for type checking during run-time (i.e. while you run your unit tests).

To get the most out of strictly_typed_pandas, be sure to:
  • set up mypy in your IDE.

  • run your unit tests with pytest –stp-typeguard-packages=foo.bar (where foo.bar is your package name).

Installation

pip install strictly-typed-pandas

Documentation

For example notebooks and API documentation, please see our ReadTheDocs.

FAQ

Do you know of something similar for pyspark?
Yes! Check out our package typedspark.

Why use Python if you want static typing?
There are just so many good packages for data science in Python. Rather than sacrificing all of that by moving to a different language, I’d like to make the Pythonverse a little bit better.

I found a bug! What should I do?
Great! Contact me and I’ll look into it.

I have a great idea to improve strictly_typed_pandas! How can we make this work?
Awesome, drop me a line!

Metadata

Release files for strictly-typed-pandas 0.3.7

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

Source distribution (sdist)

Source distribution for strictly-typed-pandas 0.3.7
File Size Uploaded
strictly_typed_pandas-0.3.7.tar.gz 24.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for strictly-typed-pandas 0.3.7
File Interpreter ABI Platform
strictly_typed_pandas-0.3.7-py3-none-any.whl Python 3 none any Details

Total release size: 50.1 kB

Release files / strictly_typed_pandas-0.3.7.tar.gz

Download URL strictly_typed_pandas-0.3.7.tar.gz
Size 24.6 kB
Tags Source
SHA-256 checksum
How to use checksums
516eaf52762d5c6b1a787b7bc7b40a88d3bc61fd28743d7a71ffd6e29a0adb39
BLAKE2b-256 checksum
How to use checksums
50463e17cf0200a5329491e823bb26581e411db322781ff0a2c118ed36fba364
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / strictly_typed_pandas-0.3.7-py3-none-any.whl

Download URL strictly_typed_pandas-0.3.7-py3-none-any.whl
Size 25.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e17eaf9067fe74be421132d33ce05be5d29717cec305694c27db0e4b9c035ea
BLAKE2b-256 checksum
How to use checksums
7e6d19cb138f19ba6fff4d5de7f3343eab44893ae9b5d8a75a6b58504af73180
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.3.7 This release

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.23

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.19

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.1

2 release files

0.0.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