Skip to content

Commit b1e1245

Browse files
author
zbigniewkrolikowski
committed
Review by @jreback
1 parent a767611 commit b1e1245

File tree

2 files changed

+4
-113
lines changed

2 files changed

+4
-113
lines changed

doc/source/ecosystem.rst

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -576,74 +576,16 @@ Library Accessor Classes Description
576576
.. _datatest: https://datatest.readthedocs.io/
577577
.. _woodwork: https://github.com/alteryx/woodwork
578578

579-
580579
Development tools
581580
----------------------------
582581

583582
`pandas-stubs <https://github.com/VirtusLab/pandas-stubs>`__
584583
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
585584

586-
pandas doesn't expose any type information to the user by itself.
585+
While pandas repository is partially typed, the package itself doesn't expose this information for external use.
587586
Install pandas-stubs to enable basic type coverage of pandas API.
588587

589588
Learn more by reading through these issues `14468 <https://github.com/pandas-dev/pandas/issues/14468>`_,
590589
`26766 <https://github.com/pandas-dev/pandas/issues/26766>`_, `28142 <https://github.com/pandas-dev/pandas/issues/28142>`_.
591590

592-
Installation
593-
^^^^^^^^^^^^
594-
595-
Using pip:
596-
597-
.. code:: bash
598-
599-
pip install pandas-stubs
600-
601-
Using conda:
602-
603-
.. code:: bash
604-
605-
conda install -c conda-forge pandas-stubs
606-
607-
Alternatively the manual options are:
608-
609-
* cloning the repository along with the files, or
610-
* including it as a submodule to your project repository,
611-
612-
and then configuring a type checker with the correct paths.
613-
614-
Usage
615-
^^^^^
616-
617-
Let’s take this piece of code as an example in file round.py
618-
619-
.. code:: python
620-
621-
import pandas as pd
622-
623-
decimals = pd.DataFrame({'TSLA': 2, 'AMZN': 1})
624-
prices = pd.DataFrame(data={'date': ['2021-08-13', '2021-08-07', '2021-08-21'],
625-
'TSLA': [720.13, 716.22, 731.22], 'AMZN': [3316.50, 3200.50, 3100.23]})
626-
rounded_prices = prices.round(decimals=decimals)
627-
628-
629-
mypy won't see any issues with that but after installing pandas-stubs and running it again
630-
631-
.. code:: bash
632-
633-
mypy round.py
634-
635-
636-
we get the following error message
637-
638-
.. code:: bash
639-
640-
round.py:6: error: Argument "decimals" to "round" of "DataFrame" has incompatible type "DataFrame";
641-
expected "Union[int, Dict[Union[int, str], int], Series]"
642-
643-
644-
And after confirming with the `docs <https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.round.html>`_
645-
we can fix the code
646-
647-
.. code:: python
648-
649-
decimals = pd.Series({'TSLA': 2, 'AMZN': 1})
591+
See installation and usage instructions on the `github page <https://github.com/VirtusLab/pandas-stubs>`__.

web/pandas/community/ecosystem.md

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -388,65 +388,14 @@ authors to coordinate on the namespace.
388388
| [pint-pandas](https://github.com/hgrecco/pint-pandas) | `pint` | `Series`, `DataFrame` |
389389
| [composeml](https://github.com/alteryx/compose) | `slice` | `DataFrame` |
390390
| [woodwork](https://github.com/alteryx/woodwork) | `slice` | `Series`, `DataFrame` |
391-
392391
## Development tools
393392

394393
### [pandas-stubs](https://github.com/VirtusLab/pandas-stubs)
395394

396-
pandas doesn't expose any type information to the user by itself.
395+
While pandas repository is partially typed, the package itself doesn't expose this information for external use.
397396
Install pandas-stubs to enable basic type coverage of pandas API.
398397

399398
Learn more by reading through these issues [14468](https://github.com/pandas-dev/pandas/issues/14468),
400399
[26766](https://github.com/pandas-dev/pandas/issues/26766), [28142](https://github.com/pandas-dev/pandas/issues/28142).
401400

402-
#### Installation
403-
404-
Using pip:
405-
```
406-
pip install pandas-stubs
407-
```
408-
409-
Using conda:
410-
411-
```
412-
conda install -c conda-forge pandas-stubs
413-
```
414-
415-
Alternatively the manual install options are:
416-
417-
* cloning the repository along with the files, or
418-
* including it as a submodule to your project repository,
419-
420-
and then configuring a type checker with the correct paths.
421-
422-
#### Usage
423-
424-
Let’s take this piece of code as an example in file round.py
425-
426-
```
427-
import pandas as pd
428-
429-
decimals = pd.DataFrame({'TSLA': 2, 'AMZN': 1})
430-
prices = pd.DataFrame(data={'date': ['2021-08-13', '2021-08-07', '2021-08-21'],
431-
'TSLA': [720.13, 716.22, 731.22], 'AMZN': [3316.50, 3200.50, 3100.23]})
432-
rounded_prices = prices.round(decimals=decimals)
433-
```
434-
435-
mypy won't see any issues with that but after installing pandas-stubs and running it again
436-
437-
```
438-
mypy round.py
439-
```
440-
441-
we get the following error message
442-
443-
```
444-
round.py:6: error: Argument "decimals" to "round" of "DataFrame" has incompatible type "DataFrame"; expected "Union[int, Dict[Union[int, str], int], Series]"
445-
```
446-
447-
And after confirming with the [docs](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.round.html)
448-
we can fix the code
449-
450-
```
451-
decimals = pd.Series({'TSLA': 2, 'AMZN': 1})
452-
```
401+
See installation and usage instructions on the [github page](https://github.com/VirtusLab/pandas-stubs).

0 commit comments

Comments
 (0)