Back to TILs.

Calmcode TIL

Vetting Pandas Style logoVetting Pandas Style

We have flake8 for general python code but it can be extended for pandas too via pandas-vet. It works via flake8, check out our guide if you aren't familiar with it yet. It can be downloaded via:

python -m pip install pandas-vet

Once it's installed you can simply flake8 just like you're used to.

python -m flake8

This will check ensure that modern commands are favored deprecated alternatives. You can read more details on the checks on GitHub. It's especially powerful when it's used in combination with pre-commit hooks.

Annoy Flag

You can get it to throw extra errors by setting the --annoy flag.

python -m flake8 --annoy

This flag will raise errors if the df variable is used to refer to a dataframe. It may be a strongly opinionated check, but to quote the readme:

df is a bad variable name. Be kinder to your future self.

Back to TILs.