<p align="center">
<img src="https://raw.githubusercontent.com/VirtusLab/pandas-stubs/master/logo.png"
alt="Logo"
width="60%"/>
</p>
# Pandas Stubs
Collection of pandas [stub files](https://www.python.org/dev/peps/pep-0484/#stub-files>) initially generated using [stubgen](https://github.com/python/mypy/blob/master/mypy/stubgen.py), fixed when necessary and then partially completed.
|CI|PyPi version | PyPI Downloads | Conda Downloads | Python support | License
|--|--|--|--|--|--|
| [![VirtusLab](https://circleci.com/gh/VirtusLab/pandas-stubs.svg?style=svg)]() | [![PyPI package](https://img.shields.io/pypi/v/pandas-stubs.svg)](https://pypi.org/project/pandas-stubs) | [![PyPI download month](https://img.shields.io/pypi/dm/pandas-stubs.svg)](https://pypi.python.org/pypi/pandas-stubs/) | [![PyPI download month](https://anaconda.org/conda-forge/pandas-stubs/badges/downloads.svg)](https://anaconda.org/conda-forge/pandas-stubs) | [![PyPI pyversions](https://img.shields.io/pypi/pyversions/pandas-stubs.svg)](https://pypi.python.org/pypi/pandas-stubs/)|[![GitHub license](https://img.shields.io/github/license/VirtusLab/pandas-stubs.svg)](https://github.com/VirtusLab/pandas-stubs/blob/master/LICENSE)
## Motivation
Provide rudimentary coverage of pandas code by static type checking, to alleviate problems mentioned in the following issues [14468](https://github.com/pandas-dev/pandas/issues/14468), [26766](https://github.com/pandas-dev/pandas/issues/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](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.round.html)
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](https://pandas.pydata.org/docs/index.html) library. Pandas is available under it's own [license](https://github.com/pandas-dev/pandas/blob/master/LICENSE).
This project is not owned, endorsed, or sponsored by any of AQR Capital Management, NumFOCUS, LLC, Lambda Foundry, Inc. and PyData Development Team.
没有合适的资源?快使用搜索试试~ 我知道了~
pandas-stubs-1.2.0.18.tar.gz
需积分: 1 0 下载量 109 浏览量
2024-03-08
15:36:50
上传
评论
收藏 90KB GZ 举报
温馨提示
Python库是一组预先编写的代码模块,旨在帮助开发者实现特定的编程任务,无需从零开始编写代码。这些库可以包括各种功能,如数学运算、文件操作、数据分析和网络编程等。Python社区提供了大量的第三方库,如NumPy、Pandas和Requests,极大地丰富了Python的应用领域,从数据科学到Web开发。Python库的丰富性是Python成为最受欢迎的编程语言之一的关键原因之一。这些库不仅为初学者提供了快速入门的途径,而且为经验丰富的开发者提供了强大的工具,以高效率、高质量地完成复杂任务。例如,Matplotlib和Seaborn库在数据可视化领域内非常受欢迎,它们提供了广泛的工具和技术,可以创建高度定制化的图表和图形,帮助数据科学家和分析师在数据探索和结果展示中更有效地传达信息。
资源推荐
资源详情
资源评论
收起资源包目录
pandas-stubs-1.2.0.18.tar.gz (248个子文件)
setup.cfg 312B
MANIFEST.in 16B
LICENSE 1KB
README.md 5KB
PKG-INFO 7KB
PKG-INFO 7KB
setup.py 1KB
frame.pyi 21KB
pytables.pyi 20KB
generic.pyi 15KB
series.pyi 14KB
blocks.pyi 13KB
_testing.pyi 9KB
format.pyi 8KB
offsets.pyi 8KB
multi.pyi 7KB
base.pyi 7KB
categorical.pyi 7KB
managers.pyi 6KB
groupby.pyi 6KB
strings.pyi 6KB
rolling.pyi 5KB
sql.pyi 5KB
_typing.pyi 5KB
timestamps.pyi 5KB
stata.pyi 5KB
_base.pyi 5KB
numpy_.pyi 5KB
datetimelike.pyi 4KB
ops.pyi 4KB
parsers.pyi 4KB
_json.pyi 4KB
interval.pyi 4KB
resample.pyi 4KB
dtypes.pyi 4KB
pytables.pyi 4KB
__init__.pyi 4KB
base.pyi 4KB
cast.pyi 4KB
merge.pyi 4KB
algorithms.pyi 4KB
core.pyi 4KB
array.pyi 4KB
common.pyi 4KB
style.pyi 3KB
interval.pyi 3KB
period.pyi 3KB
generic.pyi 3KB
datetimelike.pyi 3KB
datetimes.pyi 3KB
concat.pyi 3KB
datetimes.pyi 3KB
converter.pyi 3KB
expr.pyi 3KB
_core.pyi 3KB
ops.pyi 3KB
conftest.pyi 3KB
range.pyi 3KB
sas_constants.pyi 3KB
apply.pyi 3KB
category.pyi 3KB
base.pyi 3KB
grouper.pyi 2KB
timedeltas.pyi 2KB
holiday.pyi 2KB
nanops.pyi 2KB
excel.pyi 2KB
api.pyi 2KB
period.pyi 2KB
common.pyi 2KB
numeric.pyi 2KB
timedeltas.pyi 2KB
__init__.pyi 2KB
construction.pyi 2KB
html.pyi 2KB
indexing.pyi 2KB
integer.pyi 2KB
_misc.pyi 2KB
array_ops.pyi 2KB
csvs.pyi 2KB
common.pyi 2KB
construction.pyi 2KB
config.pyi 2KB
config_init.pyi 2KB
boolean.pyi 2KB
extension.pyi 2KB
missing.pyi 2KB
parquet.pyi 2KB
expanding.pyi 1KB
string_.pyi 1KB
html.pyi 1KB
misc.pyi 1KB
missing.pyi 1KB
hist.pyi 1KB
boxplot.pyi 1KB
ewm.pyi 1KB
pivot.pyi 1KB
reshape.pyi 1KB
sorting.pyi 1KB
accessors.pyi 1KB
共 248 条
- 1
- 2
- 3
资源评论
程序员Chino的日记
- 粉丝: 3712
- 资源: 5万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 报表例题答案汇总.zip
- POI 工具类,Excel的快速导入导出,Excel模板导出,Word模板导出,可以仅仅5行代码就可以完成Excel的导入导出,修改导出格式简单粗暴,快速有效,easypoi值得你尝试
- python设计成绩管理系统
- 带有智能视觉功能的智能小车源代码100%好用.zip
- python实现飞机大战游戏
- C#实现桌面提醒工具项目
- SwiftLanguageWeather.zip
- MATLAB Simulink电动汽车转弯制动ABS模型,联合直接横摆力矩DYC 转向制动稳定性控制 软件使用:Matlab Simulink 适用场景:轮毂电机分布式驱动电动汽车防抱死控制ABS
- 风机变桨控制基于FAST与MATLAB SIMULINK联合仿真模型非线性风力发电机的 PID独立变桨和统一变桨控制下仿真模型,对于5WM非线性风机风机进行控制 链接simulink的scope出转速
- Spring+Spring MVC+MyBatis实现敛书网
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功