-
-
Notifications
You must be signed in to change notification settings - Fork 145
Improvements to arguments, types with stubtest #1294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7c201ba
Improvements to arguments, types with stubtest
loicdiridollou 63fc9fa
More changes for hist
loicdiridollou 95e7f11
More improvements in the indexes
loicdiridollou 2b64e3b
GH1294 PR feedback
loicdiridollou c07bab7
Merge branch 'main' of github.com:loicdiridollou/pandas-stubs into st…
loicdiridollou 903f7e6
GH1294 Fix formatting and tests
loicdiridollou d38f988
Update pandas-stubs/core/frame.pyi
loicdiridollou 49334e6
Merge branch 'main' into stubtest_improv_p2
loicdiridollou c8d2a5d
Fix order
loicdiridollou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,6 +164,7 @@ from pandas._typing import ( | |
|
||
from pandas.io.formats.style import Styler | ||
from pandas.plotting import PlotAccessor | ||
from pandas.plotting._core import hist_frame | ||
|
||
class _iLocIndexerFrame(_iLocIndexer, Generic[_T]): | ||
@overload | ||
|
@@ -308,6 +309,21 @@ else: | |
@overload | ||
def __getitem__(self, key: Hashable) -> Series: ... | ||
|
||
AstypeArgExt: TypeAlias = ( | ||
AstypeArg | ||
| Literal[ | ||
"number", | ||
"datetime64", | ||
"datetime", | ||
"integer", | ||
"timedelta", | ||
"timedelta64", | ||
"datetimetz", | ||
"datetime64[ns]", | ||
] | ||
) | ||
AstypeArgExtList: TypeAlias = AstypeArgExt | list[AstypeArgExt] | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
class DataFrame(NDFrame, OpsMixin, _GetItemHack): | ||
|
||
__hash__: ClassVar[None] # type: ignore[assignment] # pyright: ignore[reportIncompatibleMethodOverride] | ||
|
@@ -458,6 +474,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
def to_gbq( | ||
self, | ||
destination_table: str, | ||
*, | ||
project_id: str | None = ..., | ||
chunksize: int | None = ..., | ||
reauth: bool = ..., | ||
|
@@ -524,6 +541,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
def to_parquet( | ||
self, | ||
path: FilePath | WriteBuffer[bytes], | ||
*, | ||
engine: ParquetEngine = ..., | ||
compression: Literal["snappy", "gzip", "brotli", "lz4", "zstd"] | None = ..., | ||
index: bool | None = ..., | ||
|
@@ -535,6 +553,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
def to_parquet( | ||
self, | ||
path: None = ..., | ||
*, | ||
engine: ParquetEngine = ..., | ||
compression: Literal["snappy", "gzip", "brotli", "lz4", "zstd"] | None = ..., | ||
index: bool | None = ..., | ||
|
@@ -564,6 +583,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
def to_html( | ||
self, | ||
buf: FilePath | WriteBuffer[str], | ||
*, | ||
columns: SequenceNotStr[Hashable] | Index | Series | None = ..., | ||
col_space: ColspaceArgType | None = ..., | ||
header: _bool = ..., | ||
|
@@ -611,6 +631,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
def to_html( | ||
self, | ||
buf: None = ..., | ||
*, | ||
columns: Sequence[Hashable] | None = ..., | ||
col_space: ColspaceArgType | None = ..., | ||
header: _bool = ..., | ||
|
@@ -746,20 +767,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
def eval( | ||
self, expr: _str, *, inplace: Literal[False] = ..., **kwargs: Any | ||
) -> Scalar | np.ndarray | Self | Series: ... | ||
AstypeArgExt: TypeAlias = ( | ||
AstypeArg | ||
| Literal[ | ||
"number", | ||
"datetime64", | ||
"datetime", | ||
"integer", | ||
"timedelta", | ||
"timedelta64", | ||
"datetimetz", | ||
"datetime64[ns]", | ||
] | ||
) | ||
AstypeArgExtList: TypeAlias = AstypeArgExt | list[AstypeArgExt] | ||
@overload | ||
def select_dtypes( | ||
self, include: StrDtypeArg, exclude: AstypeArgExtList | None = ... | ||
|
@@ -810,6 +817,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
def reindex( | ||
self, | ||
labels: Axes | None = ..., | ||
*, | ||
index: Axes | None = ..., | ||
columns: Axes | None = ..., | ||
axis: Axis | None = ..., | ||
|
@@ -1301,8 +1309,8 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
def pivot( | ||
self, | ||
*, | ||
columns: IndexLabel, | ||
index: IndexLabel = ..., | ||
columns: IndexLabel = ..., | ||
values: IndexLabel = ..., | ||
) -> Self: ... | ||
def pivot_table( | ||
|
@@ -1320,11 +1328,19 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
) -> Self: ... | ||
@overload | ||
def stack( | ||
self, level: IndexLabel = ..., dropna: _bool = ..., sort: _bool = ... | ||
self, | ||
level: IndexLabel = ..., | ||
dropna: _bool = ..., | ||
sort: _bool = ..., | ||
future_stack: Literal[False] = ..., | ||
) -> Self | Series: ... | ||
@overload | ||
def stack( | ||
self, level: IndexLabel = ..., future_stack: _bool = ... | ||
self, | ||
level: IndexLabel = ..., | ||
dropna: _NoDefaultDoNotUse = ..., | ||
sort: _NoDefaultDoNotUse = ..., | ||
future_stack: Literal[True] = ..., | ||
) -> Self | Series: ... | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def explode( | ||
self, column: Sequence[Hashable], ignore_index: _bool = ... | ||
|
@@ -1360,9 +1376,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
**kwargs: Any, | ||
) -> Self: ... | ||
@overload | ||
def aggregate( # pyright: ignore[reportOverlappingOverload] | ||
def aggregate( | ||
self, | ||
func: AggFuncTypeBase | AggFuncTypeDictSeries, | ||
func: AggFuncTypeBase | AggFuncTypeDictSeries = ..., | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not valid. If you don't specify the value of |
||
axis: Axis = ..., | ||
**kwargs: Any, | ||
) -> Series: ... | ||
|
@@ -1576,14 +1592,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
method: Literal["pearson", "kendall", "spearman"] = ..., | ||
numeric_only: _bool = ..., | ||
) -> Series: ... | ||
@overload | ||
def count( | ||
self, axis: Axis = ..., numeric_only: _bool = ..., *, level: Level | ||
) -> Self: ... | ||
@overload | ||
def count( | ||
self, axis: Axis = ..., level: None = ..., numeric_only: _bool = ... | ||
) -> Series: ... | ||
def count(self, axis: Axis = ..., numeric_only: _bool = ...) -> Self: ... | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def nunique(self, axis: Axis = ..., dropna: bool = ...) -> Series: ... | ||
def idxmax( | ||
self, axis: Axis = ..., skipna: _bool = ..., numeric_only: _bool = ... | ||
|
@@ -1628,24 +1637,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
def isin(self, values: Iterable | Series | DataFrame | dict) -> Self: ... | ||
@property | ||
def plot(self) -> PlotAccessor: ... | ||
def hist( | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self, | ||
column: _str | list[_str] | None = ..., | ||
by: _str | ListLike | None = ..., | ||
grid: _bool = ..., | ||
xlabelsize: float | str | None = ..., | ||
xrot: float | None = ..., | ||
ylabelsize: float | str | None = ..., | ||
yrot: float | None = ..., | ||
ax: PlotAxes | None = ..., | ||
sharex: _bool = ..., | ||
sharey: _bool = ..., | ||
figsize: tuple[float, float] | None = ..., | ||
layout: tuple[int, int] | None = ..., | ||
bins: int | list = ..., | ||
backend: _str | None = ..., | ||
**kwargs: Any, | ||
): ... | ||
hist = hist_frame | ||
def boxplot( | ||
self, | ||
column: _str | list[_str] | None = ..., | ||
|
@@ -1780,6 +1772,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
self, | ||
start_time: _str | dt.time, | ||
end_time: _str | dt.time, | ||
inclusive: IntervalClosedType = ..., | ||
axis: Axis | None = ..., | ||
) -> Self: ... | ||
@overload | ||
|
@@ -1980,8 +1973,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
@final | ||
def head(self, n: int = ...) -> Self: ... | ||
@final | ||
def infer_objects(self) -> Self: ... | ||
# def info | ||
def infer_objects(self, copy: _bool | None = ...) -> Self: ... | ||
@overload | ||
def interpolate( | ||
self, | ||
|
@@ -2077,15 +2069,13 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
self, | ||
axis: Axis | None = ..., | ||
skipna: _bool | None = ..., | ||
level: None = ..., | ||
numeric_only: _bool = ..., | ||
**kwargs: Any, | ||
) -> Series: ... | ||
def min( | ||
self, | ||
axis: Axis | None = ..., | ||
skipna: _bool | None = ..., | ||
level: None = ..., | ||
numeric_only: _bool = ..., | ||
**kwargs: Any, | ||
) -> Series: ... | ||
|
@@ -2117,8 +2107,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
periods: int = ..., | ||
fill_method: None = ..., | ||
freq: DateOffset | dt.timedelta | _str | None = ..., | ||
*, | ||
axis: Axis = ..., | ||
fill_value: Scalar | NAType | None = ..., | ||
) -> Self: ... | ||
def pop(self, item: _str) -> Series: ... | ||
|
@@ -2133,7 +2121,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
self, | ||
axis: Axis | None = ..., | ||
skipna: _bool | None = ..., | ||
level: None = ..., | ||
numeric_only: _bool = ..., | ||
min_count: int = ..., | ||
**kwargs: Any, | ||
|
@@ -2142,7 +2129,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
self, | ||
axis: Axis | None = ..., | ||
skipna: _bool = ..., | ||
level: None = ..., | ||
numeric_only: _bool = ..., | ||
min_count: int = ..., | ||
**kwargs: Any, | ||
|
@@ -2305,18 +2291,16 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
self, | ||
axis: Axis | None = ..., | ||
skipna: _bool | None = ..., | ||
level: None = ..., | ||
ddof: int = ..., | ||
numeric_only: _bool = ..., | ||
**kwargs: Any, | ||
) -> Series: ... | ||
# Not actually positional, but used to handle removal of deprecated | ||
def set_axis(self, labels, *, axis: Axis, copy: _bool = ...) -> Self: ... | ||
def set_axis(self, labels, *, axis: Axis = ..., copy: _bool = ...) -> Self: ... | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def skew( | ||
self, | ||
axis: Axis | None = ..., | ||
skipna: _bool | None = ..., | ||
level: None = ..., | ||
numeric_only: _bool = ..., | ||
**kwargs: Any, | ||
) -> Series: ... | ||
|
@@ -2326,7 +2310,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
self, | ||
axis: Axis = ..., | ||
skipna: _bool = ..., | ||
level: None = ..., | ||
ddof: int = ..., | ||
numeric_only: _bool = ..., | ||
**kwargs: Any, | ||
|
@@ -2347,9 +2330,8 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
) -> Self: ... | ||
def sum( | ||
self, | ||
axis: Axis | None = ..., | ||
axis: Axis = ..., | ||
skipna: _bool | None = ..., | ||
level: None = ..., | ||
numeric_only: _bool = ..., | ||
min_count: int = ..., | ||
**kwargs: Any, | ||
|
@@ -2434,6 +2416,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
def to_string( | ||
self, | ||
buf: FilePath | WriteBuffer[str], | ||
*, | ||
columns: SequenceNotStr[Hashable] | Index | Series | None = ..., | ||
col_space: int | list[int] | dict[HashableT, int] | None = ..., | ||
header: _bool | list[_str] | tuple[str, ...] = ..., | ||
|
@@ -2457,6 +2440,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
def to_string( | ||
self, | ||
buf: None = ..., | ||
*, | ||
columns: Sequence[Hashable] | Index | Series | None = ..., | ||
col_space: int | list[int] | dict[Hashable, int] | None = ..., | ||
header: _bool | Sequence[_str] = ..., | ||
|
@@ -2513,9 +2497,8 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
) -> Self: ... | ||
def var( | ||
self, | ||
axis: Axis | None = ..., | ||
axis: Axis = ..., | ||
skipna: _bool | None = ..., | ||
level: None = ..., | ||
ddof: int = ..., | ||
numeric_only: _bool = ..., | ||
**kwargs: Any, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.