{"id":13869903,"url":"https://github.com/wearepal/data-science-types","last_synced_at":"2025-10-01T06:32:13.148Z","repository":{"id":43750758,"uuid":"209777731","full_name":"wearepal/data-science-types","owner":"wearepal","description":"Mypy stubs, i.e., type information, for numpy, pandas and matplotlib","archived":true,"fork":false,"pushed_at":"2021-02-16T17:29:01.000Z","size":453,"stargazers_count":202,"open_issues_count":39,"forks_count":51,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-01-08T15:21:54.916Z","etag":null,"topics":["matplotlib","mypy","mypy-stubs","numpy","pandas","python","stubs","type-stubs"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wearepal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-20T11:45:49.000Z","updated_at":"2024-04-14T01:02:33.000Z","dependencies_parsed_at":"2022-09-14T00:31:19.073Z","dependency_job_id":null,"html_url":"https://github.com/wearepal/data-science-types","commit_stats":null,"previous_names":["predictive-analytics-lab/data-science-types"],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wearepal%2Fdata-science-types","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wearepal%2Fdata-science-types/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wearepal%2Fdata-science-types/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wearepal%2Fdata-science-types/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wearepal","download_url":"https://codeload.github.com/wearepal/data-science-types/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234837149,"owners_count":18894547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["matplotlib","mypy","mypy-stubs","numpy","pandas","python","stubs","type-stubs"],"created_at":"2024-08-05T20:01:21.434Z","updated_at":"2025-10-01T06:32:07.732Z","avatar_url":"https://github.com/wearepal.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Mypy type stubs for NumPy, pandas, and Matplotlib\n\n[![Join the chat at https://gitter.im/data-science-types/community](https://badges.gitter.im/data-science-types/community.svg)](https://gitter.im/data-science-types/community?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n⚠️  **this project has mostly stopped development** ⚠️\n\nThe pandas team and the numpy team are both in the process of integrating type stubs into their codebases,\nand we don't see the point of competing with them.\n\n---\n\nThis is a [PEP-561][pep-561]-compliant stub-only package\nwhich provides type information for [matplotlib][matplotlib], [numpy][numpy] and [pandas][pandas].\nThe [mypy][mypy] type checker (or pytype or PyCharm) can [recognize][mypy-docs] the types in these packages by installing this package.\n\n### NOTE: This is a work in progress\n\nMany functions are already typed, but a *lot* is still missing (NumPy and pandas are *huge* libraries).\nChances are, you will see a message from Mypy claiming that a function does not exist when it does exist.\nIf you encounter missing functions, we would be delighted for you to send a PR.\nIf you are unsure of how to type a function, we can discuss it.\n\n## Installing\n\nYou can get this package from PyPI:\n\n```bash\npip install data-science-types\n```\n\nTo get the most up-to-date version, install it directly from GitHub:\n\n```bash\npip install git+https://github.com/predictive-analytics-lab/data-science-types\n```\n\nOr clone the repository somewhere and do `pip install -e .`.\n\n## Examples\n\nThese are the kinds of things that can be checked:\n\n### Array creation\n\n```python\nimport numpy as np\n\narr1: np.ndarray[np.int64] = np.array([3, 7, 39, -3])  # OK\narr2: np.ndarray[np.int32] = np.array([3, 7, 39, -3])  # Type error\narr3: np.ndarray[np.int32] = np.array([3, 7, 39, -3], dtype=np.int32)  # OK\narr4: np.ndarray[float] = np.array([3, 7, 39, -3], dtype=float)  # Type error: the type of ndarray can not be just \"float\"\narr5: np.ndarray[np.float64] = np.array([3, 7, 39, -3], dtype=float)  # OK\n```\n\n### Operations\n\n```python\nimport numpy as np\n\narr1: np.ndarray[np.int64] = np.array([3, 7, 39, -3])\narr2: np.ndarray[np.int64] = np.array([4, 12, 9, -1])\n\nresult1: np.ndarray[np.int64] = np.divide(arr1, arr2)  # Type error\nresult2: np.ndarray[np.float64] = np.divide(arr1, arr2)  # OK\n\ncompare: np.ndarray[np.bool_] = (arr1 == arr2)\n```\n\n### Reductions\n\n```python\nimport numpy as np\n\narr: np.ndarray[np.float64] = np.array([[1.3, 0.7], [-43.0, 5.6]])\n\nsum1: int = np.sum(arr)  # Type error\nsum2: np.float64 = np.sum(arr)  # OK\nsum3: float = np.sum(arr)  # Also OK: np.float64 is a subclass of float\nsum4: np.ndarray[np.float64] = np.sum(arr, axis=0)  # OK\n\n# the same works with np.max, np.min and np.prod\n```\n\n## Philosophy\n\nThe goal is not to recreate the APIs exactly.\nThe main goal is to have *useful* checks on our code.\nOften the actual APIs in the libraries is more permissive than the type signatures in our stubs;\nbut this is (usually) a feature and not a bug.\n\n## Contributing\n\nWe always welcome contributions.\nAll pull requests are subject to CI checks.\nWe check for compliance with Mypy and that the file formatting conforms to our Black specification.\n\nYou can install these dev dependencies via\n\n```bash\npip install -e '.[dev]'\n```\n\nThis will also install NumPy, pandas, and Matplotlib to be able to run the tests.\n\n### Running CI locally (recommended)\n\nWe include a script for running the CI checks that are triggered when a PR is opened.\nTo test these out locally, you need to install the type stubs in your environment.\nTypically, you would do this with\n\n```bash\npip install -e .\n```\n\nThen use the `check_all.sh` script to run all tests:\n\n```bash\n./check_all.sh\n```\n\nBelow we describe how to run the various checks individually,\nbut `check_all.sh` should be easier to use.\n\n### Checking compliance with Mypy\n\nThe settings for Mypy are specified in the `mypy.ini` file in the repository.\nJust running\n\n```bash\nmypy tests\n```\n\nfrom the base directory should take these settings into account.\nWe enforce 0 Mypy errors.\n\n### Formatting with black\n\nWe use [Black][black] to format the stub files.\nFirst, install `black` and then run\n\n```bash\nblack .\n```\nfrom the base directory.\n\n### Pytest\n\n```bash\npython -m pytest -vv tests/\n```\n\n### Flake8\n\n```bash\nflake8 *-stubs\n```\n\n## License\n\n[Apache 2.0](LICENSE)\n\n\n[pep-561]: https://www.python.org/dev/peps/pep-0561/\n[matplotlib]: https://matplotlib.org\n[numpy]: https://numpy.org\n[pandas]: https://pandas.pydata.org\n[mypy]: http://www.mypy-lang.org/\n[mypy-docs]: https://mypy.readthedocs.io/en/latest/installed_packages.html\n[black]: https://github.com/psf/black\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwearepal%2Fdata-science-types","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwearepal%2Fdata-science-types","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwearepal%2Fdata-science-types/lists"}