Skip to main content

pandas-vet

pandas-vet is a plugin for flake8 that provides opinionated linting for pandas code.

Documentation Status

Test and lint Code style: black PyPI - License

PyPI PyPI - Status PyPI - Downloads

Conda Version Conda Downloads

Basic usage

Take the following script, drop_column.py, which contains valid pandas code:

# drop_column.py
import pandas

df = pandas.DataFrame({
    'col_a': [i for i in range(20)],
    'col_b': [j for j in range(20, 40)]
})
df.drop(columns='col_b', inplace=True)

With pandas-vet installed, if we run Flake8 on this script, we will see three warnings raised.

$ flake8 drop_column.py

./drop_column.py:2:1: PD001 pandas should always be imported as 'import pandas as pd'
./drop_column.py:4:1: PD901 'df' is a bad variable name. Be kinder to your future self.
./drop_column.py:7:1: PD002 'inplace = True' should be avoided; it has inconsistent behavior

We can use these to improve the code.

# pandastic_drop_column.py
import pandas as pd

ab_dataset = pd.DataFrame({
    'col_a': [i for i in range(20)],
    'col_b': [j for j in range(20, 40)]
})
a_dataset = ab_dataset.drop(columns='col_b')

For a full list, see the Supported warnings page of the documentation.

Motivation

Starting with pandas can be daunting. The usual internet help sites are littered with different ways to do the same thing and some features that the pandas docs themselves discourage live on in the API. pandas-vet is (hopefully) a way to help make pandas a little more friendly for newcomers by taking some opinionated stances about pandas best practices. It is designed to help users reduce the pandas universe.

The idea to create a linter was sparked by Ania Kapuścińska's talk at PyCascades 2019, "Lint your code responsibly!". The package was largely developed at the PyCascades 2019 sprints.

Many of the opinions stem from Ted Petrou's excellent Minimally Sufficient Pandas. Other ideas are drawn from pandas docs or elsewhere. The Pandas in Black and White flashcards have a lot of the same opinions too.

Metadata

Release files for pandas-vet 2023.8.2

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

Source distribution (sdist)

Source distribution for pandas-vet 2023.8.2
File Size Uploaded
pandas_vet-2023.8.2.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pandas-vet 2023.8.2
File Interpreter ABI Platform
pandas_vet-2023.8.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / pandas_vet-2023.8.2.tar.gz

Download URL pandas_vet-2023.8.2.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ee6b80b40f5a74de41c29393e4dce373447b363faaa3e0677e4f36799ea865c3
BLAKE2b-256 checksum
How to use checksums
f5572c8350ff48cece1f6009012a0f42413e9e6d5ca54bec7f3b5726b6e33e1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.24.0

Release files / pandas_vet-2023.8.2-py3-none-any.whl

Download URL pandas_vet-2023.8.2-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
761c07b4479f24fc507465047111c7d21374ec678b7aba58e454fd5d3f8055fe
BLAKE2b-256 checksum
How to use checksums
17dd128ade78c67d4ac1a6202f320112aaa7934eaf8f7b0d861517e7c960dd3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.24.0

Release history Release notifications | RSS feed

This release

2023.8.2 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.1

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