All Projects → VirtusLab → pandas-stubs

VirtusLab / pandas-stubs

Licence: MIT License
Pandas type stubs. Helps you type-check your code.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to pandas-stubs

com2ann
Tool for translation type comments to type annotations in Python
Stars: ✭ 115 (+36.9%)
Mutual labels:  annotations, type-annotations
Machine-Learning
This repository contains notebooks that will help you in understanding basic ML algorithms as well as basic numpy excercise. 💥 🌈 🌈
Stars: ✭ 15 (-82.14%)
Mutual labels:  pandas
monthly-returns-heatmap
Python Monthly Returns Heatmap (DEPRECATED! Use QuantStats instead)
Stars: ✭ 23 (-72.62%)
Mutual labels:  pandas
pandas-cheat-sheet-ja
pandas 公式チートシートの非公式翻訳版
Stars: ✭ 74 (-11.9%)
Mutual labels:  pandas
GitHub-Stalker
track your GitHub statistics with Pandas
Stars: ✭ 31 (-63.1%)
Mutual labels:  pandas
grizzly
A Python-to-SQL transpiler as replacement for Python Pandas
Stars: ✭ 27 (-67.86%)
Mutual labels:  pandas
pyfinmod
Financial modeling with Python and Pandas
Stars: ✭ 39 (-53.57%)
Mutual labels:  pandas
open-data-anonimizer
Python Data Anonymization & Masking Library For Data Science Tasks
Stars: ✭ 36 (-57.14%)
Mutual labels:  pandas
DataSciPy
Data Science with Python
Stars: ✭ 15 (-82.14%)
Mutual labels:  pandas
SingleFile-Lite
Feel the power of the Manifest V3. The future, right now!
Stars: ✭ 55 (-34.52%)
Mutual labels:  annotations
Python-camp
No description or website provided.
Stars: ✭ 34 (-59.52%)
Mutual labels:  pandas
spring4-hibernate5-example
Spring 4 and Hibernate 5 integration example using annotations.
Stars: ✭ 16 (-80.95%)
Mutual labels:  annotations
skippa
SciKIt-learn Pipeline in PAndas
Stars: ✭ 33 (-60.71%)
Mutual labels:  pandas
videojs-annotation-comments
A plugin for video.js to add support for timeline moment/range comments and annotations
Stars: ✭ 129 (+53.57%)
Mutual labels:  annotations
Arch-Data-Science
Archlinux PKGBUILDs for Data Science, Machine Learning, Deep Learning, NLP and Computer Vision
Stars: ✭ 92 (+9.52%)
Mutual labels:  pandas
dagger2-ktx
Kotlin extension bridge library for Dagger2 (proof-of-concept)
Stars: ✭ 41 (-51.19%)
Mutual labels:  annotations
stream2segment
A Python project to download, process and visualize medium-to-massive amount of seismic waveforms and metadata
Stars: ✭ 18 (-78.57%)
Mutual labels:  pandas
py2puml
Generate PlantUML class diagrams to document your Python application.
Stars: ✭ 51 (-39.29%)
Mutual labels:  annotations
sklearn-predict
机器学习数据,预测趋势并画图
Stars: ✭ 16 (-80.95%)
Mutual labels:  pandas
Dominando-Pandas
Este repositório está destinado ao processo de aprendizagem da biblioteca Pandas.
Stars: ✭ 22 (-73.81%)
Mutual labels:  pandas

Logo

Pandas Stubs

Collection of pandas stub files initially generated using stubgen, fixed when necessary and then partially completed.

CI PyPi version PyPI Downloads Conda Downloads Python support License
VirtusLab PyPI package PyPI download month PyPI download month PyPI pyversions GitHub license

Motivation

Provide rudimentary coverage of pandas code by static type checking, to alleviate problems mentioned in the following issues 14468, 26766. This approach was taken to achieve accelerated development - compared to refactoring existing Pandas codebase creating stub files is relatively uninhibited.

Due to extensive pandas API, quality of the proposed annotations is, for the most part, not suitable for integration into original codebase, but they can be very useful as a way of achieving some type safety during development.

Installation

The easiest way is using PyPI. This will add .pyi files to pandas package location, which will be removed when uninstalling:

pip install pandas-stubs

Another way to install is using Conda:

conda install -c conda-forge pandas-stubs 

Alternatively, if you want a cleaner PYTHONPATH or wish to modify the annotations, manual options are:

  • cloning the repository along with the files, or
  • including it as a submodule to your project repository,

and then configuring a type checker with the correct paths.

Usage

Let’s take this example piece of code in file round.py

import pandas as pd

decimals = pd.DataFrame({'TSLA': 2, 'AMZN': 1})
prices = pd.DataFrame(data={'date': ['2021-08-13', '2021-08-07', '2021-08-21'],
                            'TSLA': [720.13, 716.22, 731.22], 'AMZN': [3316.50, 3200.50, 3100.23]})
rounded_prices = prices.round(decimals=decimals)

Mypy won't see any issues with that, but after installing pandas-stubs and running it again:

mypy round.py

we get the following error message:

round.py:6: error: Argument "decimals" to "round" of "DataFrame" has incompatible type "DataFrame"; expected "Union[int, Dict[Union[int, str], int], Series]"

And after confirming with the docs we can fix the code:

decimals = pd.Series({'TSLA': 2, 'AMZN': 1})

Version Compatibility

The aim of the current release is to cover the most common parts of the 1.2.0 API, however it can provide partial functionality for other version as well. Future versions will cover new Pandas releases.

Versioning

The versions follow a pattern MAJOR.MINOR.PATCH.STUB_VERSION where the first three parts correspond to a specific pandas API version, while STUB_VERSION is used to distinguish between the versions of the stubs themselves.

Type checkers

As of now mypy is the only type checker the stubs were tested with.

Development

Testing using tox

Tox will automatically run all types of tests mentioned further. It will create isolated temporary environments for each declared version of Python and install pandas-stubs like it would normally be installed when using pip or conda.

Usage is as simple as:

tox

Last few lines of the output should look like this (assuming all Python versions are available):

  pep8: commands succeeded
  py36: commands succeeded
  py37: commands succeeded
  py38: commands succeeded
  py39: commands succeeded

Partial testing

Test the stub files internal consistency:

mypy --config-file mypy.ini third_party/3/pandas

Test the stub files against actual code examples (this will use the stubs from the third_party/3/pandas dir):

mypy --config-file mypy.ini tests/snippets

Test the installed stub files against actual code examples. You'll need to install the library beforehand - the .pyi files from your env will be used:

mypy --config-file mypy_env.ini tests/snippets

Test if the code examples work, when actually ran with pandas:

pytests tests/snippets

Disclaimer

This project provides additional functionality for pandas library. Pandas is available under it's own license.

This project is not owned, endorsed, or sponsored by any of AQR Capital Management, NumFOCUS, LLC, Lambda Foundry, Inc. and PyData Development Team.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].