Skip to content

Commit 6d013b4

Browse files
bashtageKevin Sheppard
and
Kevin Sheppard
authored
BUG: Correct read_stata (#251)
* TYP: Remove deprecated inplace for set_index * TYP: Make read_stata position only and fix arg name * MAINT: Silence warning about rank and object array * TYP: Simplify types * MAINT: Remove warning checks * MAINT: Restore positional version Restore positional for 1.4, and note removal in 1.5 * MAINT: Restore inplace * BUG: Correct read_stata Co-authored-by: Kevin Sheppard <[email protected]>
1 parent 7b84785 commit 6d013b4

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

pandas-stubs/core/frame.pyi

-15
Original file line numberDiff line numberDiff line change
@@ -730,24 +730,9 @@ class DataFrame(NDFrame, OpsMixin):
730730
| list[HashableT],
731731
drop: _bool = ...,
732732
append: _bool = ...,
733-
*,
734733
verify_integrity: _bool = ...,
735734
) -> DataFrame: ...
736735
@overload
737-
def set_index(
738-
self,
739-
keys: Label
740-
| Series
741-
| Index
742-
| np.ndarray
743-
| Iterator[HashableT]
744-
| list[HashableT],
745-
drop: _bool = ...,
746-
append: _bool = ...,
747-
inplace: _bool | None = ...,
748-
verify_integrity: _bool = ...,
749-
) -> DataFrame | None: ...
750-
@overload
751736
def reset_index(
752737
self,
753738
level: Level | Sequence[Level] = ...,

pandas-stubs/io/stata.pyi

+10-10
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ from pandas._typing import (
2525

2626
@overload
2727
def read_stata(
28-
path: FilePath | ReadBuffer[bytes],
28+
filepath_or_buffer: FilePath | ReadBuffer[bytes],
2929
*,
3030
convert_dates: bool = ...,
3131
convert_categoricals: bool = ...,
@@ -41,23 +41,23 @@ def read_stata(
4141
) -> StataReader: ...
4242
@overload
4343
def read_stata(
44-
path: FilePath | ReadBuffer[bytes],
44+
filepath_or_buffer: FilePath | ReadBuffer[bytes],
4545
*,
46-
convert_dates: bool,
47-
convert_categoricals: bool,
48-
index_col: str | None,
49-
convert_missing: bool,
50-
preserve_dtypes: bool,
51-
columns: list[HashableT] | None,
52-
order_categoricals: bool,
46+
convert_dates: bool = ...,
47+
convert_categoricals: bool = ...,
48+
index_col: str | None = ...,
49+
convert_missing: bool = ...,
50+
preserve_dtypes: bool = ...,
51+
columns: list[HashableT] | None = ...,
52+
order_categoricals: bool = ...,
5353
chunksize: int,
5454
iterator: bool = ...,
5555
compression: CompressionOptions = ...,
5656
storage_options: StorageOptions = ...,
5757
) -> StataReader: ...
5858
@overload
5959
def read_stata(
60-
path: FilePath | ReadBuffer[bytes],
60+
filepath_or_buffer: FilePath | ReadBuffer[bytes],
6161
*,
6262
convert_dates: bool = ...,
6363
convert_categoricals: bool = ...,

tests/test_io.py

+2
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ def test_read_stata_iterator():
196196
check(
197197
assert_type(read_stata(str_path, iterator=True), StataReader), StataReader
198198
)
199+
reader = read_stata(str_path, chunksize=1)
200+
check(assert_type(reader, StataReader), StataReader)
199201

200202

201203
def test_clipboard():

tests/test_series.py

+2
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ def test_types_rank() -> None:
266266
s.rank(method="dense", ascending=True)
267267
with pytest.warns(FutureWarning, match="Calling Series.rank with numeric_only"):
268268
s.rank(method="first", numeric_only=True)
269+
s2 = pd.Series([1, 1, 2, 5, 6, np.nan])
270+
s2.rank(method="first", numeric_only=True)
269271

270272

271273
def test_types_mean() -> None:

0 commit comments

Comments
 (0)