Skip to content

Commit 0677a2c

Browse files
author
Kevin Sheppard
committed
MAINT: Merge master
2 parents 9a9462b + b072842 commit 0677a2c

23 files changed

+449
-841
lines changed

.github/setup/action.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Install project dependencies
2+
3+
inputs:
4+
python-version:
5+
required: true
6+
os:
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: ${{ inputs.python-version }}
17+
18+
- name: Install Poetry
19+
shell: bash
20+
run: python -m pip install poetry
21+
22+
- name: Determine poetry version
23+
shell: bash
24+
run: echo "::set-output name=VERSION::$(poetry --version)"
25+
id: poetry_version
26+
27+
- name: Cache poetry.lock
28+
uses: actions/cache@v3
29+
with:
30+
path: poetry.lock
31+
key: ${{ inputs.os }}-${{ inputs.python-version }}-poetry-${{ steps.poetry_version.outputs.VERSION }}-${{ hashFiles('pyproject.toml') }}
32+
33+
- name: Install project dependencies
34+
shell: bash
35+
run: poetry install -vvv --no-root

.github/workflows/test.yml

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: 'Test'
33
on:
44
[push, pull_request, workflow_dispatch]
55
jobs:
6-
test:
6+
released:
77
runs-on: ${{ matrix.os }}
88
timeout-minutes: 10
99
strategy:
@@ -13,34 +13,17 @@ jobs:
1313
python-version: ['3.8', '3.9', '3.10']
1414

1515
steps:
16-
1716
- uses: actions/checkout@v3
1817

19-
- name: Set up Python ${{ matrix.python-version }}
20-
uses: actions/setup-python@v4
18+
- name: Install project dependencies
19+
uses: ./.github/setup
2120
with:
21+
os: ${{ matrix.os }}
2222
python-version: ${{ matrix.python-version }}
2323

24-
- name: Install Poetry
25-
run: pip install poetry
26-
27-
- name: Determine poetry version
28-
run: echo "::set-output name=VERSION::$(poetry --version)"
29-
id: poetry_version
30-
31-
- name: Cache poetry.lock
32-
uses: actions/cache@v3
33-
with:
34-
path: poetry.lock
35-
key: ${{ matrix.os }}-${{ matrix.python-version }}-poetry-${{ steps.poetry_version.outputs.VERSION }}-${{ hashFiles('pyproject.toml') }}
36-
37-
- name: Install project dependencies
38-
run: poetry install -vvv --no-root
39-
4024
- name: Show poetry python location (Windows)
4125
shell: pwsh
42-
run: |
43-
poetry run where python
26+
run: poetry run where python
4427
if: matrix.os == 'windows-latest'
4528

4629
- name: Run mypy on 'tests' (using the local stubs) and on the local stubs
@@ -52,8 +35,30 @@ jobs:
5235
- name: Run pytest
5336
run: poetry run poe pytest
5437

55-
- if: matrix.python-version == '3.8' && matrix.os == 'ubuntu-latest'
56-
uses: pre-commit/action@v3.0.0
57-
5838
- name: Install pandas-stubs and run tests on the installed stubs
5939
run: poetry run poe test_dist
40+
41+
nightly:
42+
runs-on: ubuntu-latest
43+
timeout-minutes: 10
44+
45+
steps:
46+
- uses: actions/checkout@v3
47+
48+
- name: Install project dependencies
49+
uses: ./.github/setup
50+
with:
51+
os: ubuntu-latest
52+
python-version: '3.10'
53+
54+
- name: Run pytest (against pandas nightly)
55+
run: poetry run poe pytest --nightly
56+
57+
precommit:
58+
runs-on: ubuntu-latest
59+
timeout-minutes: 10
60+
61+
steps:
62+
- uses: actions/checkout@v3
63+
64+
- uses: pre-commit/action@v3.0.0

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ ci:
33
autofix_prs: false
44
repos:
55
- repo: https://github.com/python/black
6-
rev: 22.6.0
6+
rev: 22.8.0
77
hooks:
88
- id: black
99
- repo: https://github.com/PyCQA/isort
1010
rev: 5.10.1
1111
hooks:
1212
- id: isort
1313
- repo: https://github.com/asottile/pyupgrade
14-
rev: v2.34.0
14+
rev: v2.37.3
1515
hooks:
1616
- id: pyupgrade
1717
types_or: [python, pyi]
1818
types: [text] # overwrite types: [python]
1919
args: [--py38-plus]
2020
- repo: https://github.com/PyCQA/flake8
21-
rev: 4.0.1
21+
rev: 5.0.4
2222
hooks:
2323
- id: flake8
2424
name: flake8 (py)
@@ -27,7 +27,7 @@ repos:
2727
- id: flake8
2828
name: flake8 (pyi)
2929
additional_dependencies:
30-
- flake8-pyi==22.7.0
30+
- flake8-pyi==22.8.2
3131
types: [pyi]
3232
args: [
3333
--ignore=E301 E302 E305 E402 E501 E701 E704 F401 F811 W503 Y019 Y026 Y027 Y034 Y037,

pandas-stubs/core/frame.pyi

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ from pandas.core.window.rolling import (
3838
Rolling,
3939
Window,
4040
)
41+
import xarray as xr
4142

4243
from pandas._typing import (
4344
S1,
@@ -87,6 +88,7 @@ from pandas._typing import (
8788
XMLParsers,
8889
np_ndarray_bool,
8990
np_ndarray_str,
91+
npt,
9092
num,
9193
)
9294

@@ -228,15 +230,32 @@ class DataFrame(NDFrame, OpsMixin):
228230
@overload
229231
def to_dict(
230232
self,
231-
orient: Literal["records"],
232-
into: Hashable = ...,
233-
) -> list[dict[_str, Any]]: ...
233+
orient: Literal["dict", "list", "series", "split", "tight", "index"],
234+
into: Mapping | type[Mapping],
235+
) -> Mapping[Hashable, Any]: ...
236+
@overload
237+
def to_dict(
238+
self,
239+
orient: Literal["dict", "list", "series", "split", "tight", "index"] = ...,
240+
*,
241+
into: Mapping | type[Mapping],
242+
) -> Mapping[Hashable, Any]: ...
234243
@overload
235244
def to_dict(
236245
self,
237246
orient: Literal["dict", "list", "series", "split", "tight", "index"] = ...,
238-
into: Hashable = ...,
239-
) -> dict[_str, Any]: ...
247+
into: None = ...,
248+
) -> dict[Hashable, Any]: ...
249+
@overload
250+
def to_dict(
251+
self,
252+
orient: Literal["records"],
253+
into: Mapping | type[Mapping],
254+
) -> list[Mapping[Hashable, Any]]: ...
255+
@overload
256+
def to_dict(
257+
self, orient: Literal["records"], into: None = ...
258+
) -> list[dict[Hashable, Any]]: ...
240259
def to_gbq(
241260
self,
242261
destination_table: str,
@@ -258,8 +277,14 @@ class DataFrame(NDFrame, OpsMixin):
258277
def to_records(
259278
self,
260279
index: _bool = ...,
261-
columnDTypes: _str | dict | None = ...,
262-
indexDTypes: _str | dict | None = ...,
280+
column_dtypes: _str
281+
| npt.DTypeLike
282+
| Mapping[HashableT, npt.DTypeLike]
283+
| None = ...,
284+
index_dtypes: _str
285+
| npt.DTypeLike
286+
| Mapping[HashableT, npt.DTypeLike]
287+
| None = ...,
263288
) -> np.recarray: ...
264289
def to_stata(
265290
self,
@@ -279,12 +304,6 @@ class DataFrame(NDFrame, OpsMixin):
279304
) -> None: ...
280305
def to_feather(self, path: FilePath | WriteBuffer[bytes], **kwargs) -> None: ...
281306
@overload
282-
def to_markdown(
283-
self, buf: FilePathOrBuffer | None, mode: _str | None = ..., **kwargs
284-
) -> None: ...
285-
@overload
286-
def to_markdown(self, mode: _str | None = ..., **kwargs) -> _str: ...
287-
@overload
288307
def to_parquet(
289308
self,
290309
path: FilePath | WriteBuffer[bytes],
@@ -1932,18 +1951,6 @@ class DataFrame(NDFrame, OpsMixin):
19321951
compression: CompressionOptions = ...,
19331952
protocol: int = ...,
19341953
) -> None: ...
1935-
def to_sql(
1936-
self,
1937-
name: _str,
1938-
con,
1939-
schema: _str | None = ...,
1940-
if_exists: _str = ...,
1941-
index: _bool = ...,
1942-
index_label: _str | Sequence[_str] | None = ...,
1943-
chunksize: int | None = ...,
1944-
dtype: dict | Scalar | None = ...,
1945-
method: _str | Callable | None = ...,
1946-
) -> None: ...
19471954
@overload
19481955
def to_string(
19491956
self,
@@ -1989,7 +1996,7 @@ class DataFrame(NDFrame, OpsMixin):
19891996
max_colwidth: int | None = ...,
19901997
encoding: _str | None = ...,
19911998
) -> _str: ...
1992-
def to_xarray(self): ...
1999+
def to_xarray(self) -> xr.Dataset: ...
19932000
def truediv(
19942001
self,
19952002
other: num | ListLike | DataFrame,

pandas-stubs/core/generic.pyi

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import sqlite3
12
from typing import (
23
Any,
34
Callable,
45
ClassVar,
56
Hashable,
7+
Iterable,
68
Literal,
79
Mapping,
810
Sequence,
@@ -13,13 +15,15 @@ import numpy as np
1315
from pandas.core.base import PandasObject
1416
from pandas.core.indexes.base import Index
1517
import pandas.core.indexing as indexing
18+
import sqlalchemy.engine
1619

1720
from pandas._typing import (
1821
S1,
1922
ArrayLike,
2023
Axis,
2124
CompressionOptions,
2225
Dtype,
26+
DtypeArg,
2327
FilePath,
2428
FilePathOrBuffer,
2529
FileWriteMode,
@@ -29,17 +33,18 @@ from pandas._typing import (
2933
HashableT,
3034
HDFCompLib,
3135
IgnoreRaise,
36+
IndexLabel,
3237
Level,
3338
NDFrameT,
3439
ReplaceMethod,
35-
Scalar,
3640
SeriesAxisType,
3741
SortKind,
3842
StorageOptions,
3943
T,
4044
)
4145

4246
from pandas.io.pytables import HDFStore
47+
from pandas.io.sql import SQLTable
4348

4449
_bool = bool
4550
_str = str
@@ -131,18 +136,38 @@ class NDFrame(PandasObject, indexing.IndexingMixin):
131136
] = ...,
132137
encoding: _str = ...,
133138
) -> None: ...
139+
@overload
140+
def to_markdown(
141+
self,
142+
buf: FilePathOrBuffer,
143+
mode: FileWriteMode | None = ...,
144+
index: _bool = ...,
145+
storage_options: StorageOptions = ...,
146+
**kwargs: Any,
147+
) -> None: ...
148+
@overload
149+
def to_markdown(
150+
self,
151+
buf: None = ...,
152+
mode: FileWriteMode | None = ...,
153+
index: _bool = ...,
154+
storage_options: StorageOptions = ...,
155+
**kwargs: Any,
156+
) -> _str: ...
134157
def to_sql(
135158
self,
136159
name: _str,
137-
con,
160+
con: str | sqlalchemy.engine.Connection | sqlite3.Connection,
138161
schema: _str | None = ...,
139-
if_exists: _str = ...,
162+
if_exists: Literal["fail", "replace", "append"] = ...,
140163
index: _bool = ...,
141-
index_label: _str | Sequence[_str] | None = ...,
164+
index_label: IndexLabel = ...,
142165
chunksize: int | None = ...,
143-
dtype: dict | Scalar | None = ...,
144-
method: _str | Callable | None = ...,
145-
) -> None: ...
166+
dtype: DtypeArg | None = ...,
167+
method: Literal["multi"]
168+
| Callable[[SQLTable, Any, list[str], Iterable], int | None]
169+
| None = ...,
170+
) -> int | None: ...
146171
def to_pickle(
147172
self,
148173
path: _str,
@@ -152,7 +177,6 @@ class NDFrame(PandasObject, indexing.IndexingMixin):
152177
def to_clipboard(
153178
self, excel: _bool = ..., sep: _str | None = ..., **kwargs
154179
) -> None: ...
155-
def to_xarray(self): ...
156180
@overload
157181
def to_latex(
158182
self,

0 commit comments

Comments
 (0)