Skip to content

Pandas stub fixes #129

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 7 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ bld/
[Ll]og/
[Ll]ogs/

# JetBrains
.idea

# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
!.vscode/settings.json
.vscode

# Visual Studio 2017 auto generated files
Generated\ Files/
Expand Down Expand Up @@ -351,4 +354,9 @@ MigrationBackup/
.ionide/

# Python virtual environment
.venv/
.venv

# Build files from utils
utils/stubsplit/.eggs
utils/stubsplit/build
utils/stubsplit/stubsplit.egg-info
3 changes: 2 additions & 1 deletion doc/pandas/core/frame.pyi.ds
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,8 @@ sorted_obj : DataFrame or None
group_keys: _bool = ...,
squeeze: _bool = ...,
observed: _bool = ...,
) -> DataFrameGroupBy:
dropna: _bool = ...,
) -> DataFrameGroupBy: ...
"""Group DataFrame using a mapper or by a Series of columns.

A groupby operation involves some combination of splitting the
Expand Down
7 changes: 4 additions & 3 deletions doc/pandas/core/series.pyi.ds
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ starting from the end of the object, just like with Python lists.
3 lion mammal 80.5
"""
pass
def to_markdown(self, buf: Optional[FilePathOrBuffer], mode: Optional[_str] = ..., **kwargs) -> None:
def to_markdown(self, buf: Optional[FilePathOrBuffer], mode: Optional[_str] = ..., index: _bool = ..., storage_options: Optional[dict] = ..., **kwargs) -> None:
"""Print Series in Markdown-friendly format.

.. versionadded:: 1.0.0
Expand Down Expand Up @@ -150,7 +150,8 @@ Index : 2, Value : C
group_keys: _bool = ...,
squeeze: _bool = ...,
observed: _bool = ...,
) -> SeriesGroupBy:
dropna: _bool = ...
) -> SeriesGroupBy: ...
"""Group Series using a mapper or by a Series of columns.

A groupby operation involves some combination of splitting the
Expand Down Expand Up @@ -550,7 +551,7 @@ Returns
pass
def fillna(
self,
value: Union[S1, Dict, Series[S1], DataFrame],
value: Optional[Scalar|Dict|Series[S1]|DataFrame] = ...,
method: Optional[Union[_str, Literal["backfill", "bfill", "pad", "ffill"]]] = ...,
axis: SeriesAxisType = ...,
limit: Optional[int] = ...,
Expand Down
3 changes: 2 additions & 1 deletion pandas/_libs/tslibs/timedeltas.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import annotations
from datetime import timedelta
from typing import Any, Union, Tuple, Type, Optional, Sequence

import numpy as np
from pandas._typing import Dtype

class _Timedelta:
class _Timedelta(timedelta):
def __hash__(self) -> int: ...
def __richcmp__(self, other, op: int) -> Any: ...
def to_timedelta64(self) -> np.timedelta64: ...
Expand Down
9 changes: 5 additions & 4 deletions pandas/_libs/tslibs/timestamps.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import annotations
from datetime import datetime, timestamp
import sys
from typing import Any, Optional, Union

Expand All @@ -7,7 +8,7 @@ if sys.version_info >= (3, 8):
else:
from typing_extensions import Literal

class Timestamp(datetime.datetime):
class Timestamp(datetime):
def __init__(
self,
ts_input: Any,
Expand Down Expand Up @@ -35,7 +36,7 @@ class Tick(SingleConstructorOffset):
def delta(self) -> int: ...
@property
def nanos(self) -> int: ...
def is_on_offset(self, dt: datetime.datetime) -> bool: ...
def is_on_offset(self, dt: datetime) -> bool: ...
def is_anchored(self) -> bool: ...
def __eq__(self, other) -> bool: ...
def __ne__(self, other) -> bool: ...
Expand All @@ -49,7 +50,7 @@ class Tick(SingleConstructorOffset):
def apply(self, other) -> Any: ...
def __setstate__(self, state: Mapping) -> None: ...

class Timestamp:
class Timestamp(timestamp):
@staticmethod
def combine(date, time) -> Timestamp: ...
@staticmethod
Expand Down Expand Up @@ -108,7 +109,7 @@ class Timestamp:
def to_datetime64(self) -> _np.datetime64: ...
def to_numpy(self) -> _np.datetime64: ...
def to_period(self, freq: Optional[str] = ...) -> Any: ...
def to_pydatetime(self) -> datetime.datetime: ...
def to_pydatetime(self, warn: bool = ...) -> datetime: ...
def toordinal(self) -> Any: ...
def tz_convert(self, tz: Any) -> Timestamp: ...
def tz_localize(self, tz: Any, ambiguous: Any = ..., nonexistent: Any = ...) -> Timestamp: ...
Expand Down
18 changes: 17 additions & 1 deletion pandas/_testing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,23 @@ def assert_numpy_array_equal(left, right, strict_nan: bool = ..., check_dtype: b
def assert_extension_array_equal(
left, right, check_dtype: bool = ..., check_less_precise: bool = ..., check_exact: bool = ...,
) -> None: ...
def assert_series_equal(left: Series, right: Series) -> None: ...
def assert_series_equal(left: Series, right: Series,
check_dtype: bool = ...,
check_index_type: bool|str = ...,
check_series_type: bool = ...,
check_less_precise: bool|int = ...,
check_names : bool = ...,
check_exact: bool = ...,
check_datetimelike_compat: bool = ...,
check_categorical: bool = ...,
check_category_order: bool = ...,
check_freq: bool = ...,
check_flags: bool = ...,
rtol: float = ...,
atol: float = ...,
obj: str = ...,
*,
check_index: bool = ...) -> None: ...
def assert_frame_equal(left: DataFrame, right: DataFrame, check_like: Optional[bool] = ...) -> None: ...
def assert_equal(left, right, **kwargs) -> None: ...
def box_expected(expected, box_cls, transpose: bool = ...): ...
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/reshape/merge.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ from pandas import DataFrame as DataFrame, Series as Series
from pandas._typing import Label
from typing import Optional, Sequence, Union

def merge(left: Union[DataFrame, Series],
right: Union[DataFrame, Series],
def merge(left: DataFrame,
right: DataFrame|Series,
how: str = ...,
on: Optional[Union[Label, Sequence]] = ...,
left_on: Optional[Union[Label, Sequence]] = ...,
Expand Down
92 changes: 60 additions & 32 deletions pandas/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ from pandas.core.window.rolling import Rolling, Window
from pandas._typing import ArrayLike as ArrayLike, AxisType as AxisType, Dtype as Dtype, DtypeNp as DtypeNp, \
FilePathOrBuffer as FilePathOrBuffer, Level as Level, MaskType as MaskType, S1 as S1, Scalar as Scalar, \
SeriesAxisType as SeriesAxisType, num as num, Label
from typing import Any, Callable, Dict, Generic, Hashable, Iterable, List, Optional, Sequence, Tuple, Type, Union, overload
from typing import Any, Callable, Dict, Generic, Hashable, Iterable, List, Mapping, Optional, Sequence, Tuple, Type, Union, overload
if sys.version_info >= (3, 8):
from typing import Literal
else:
Expand Down Expand Up @@ -162,9 +162,9 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
encoding: Optional[_str] = ...,
) -> _str: ...
@overload
def to_markdown(self, buf: Optional[FilePathOrBuffer], mode: Optional[_str] = ..., **kwargs) -> None: ...
def to_markdown(self, buf: Optional[FilePathOrBuffer], mode: Optional[_str] = ..., index: _bool = ..., storage_options: Optional[dict] = ..., **kwargs) -> None: ...
@overload
def to_markdown(self, mode: Optional[_str] = ...,) -> _str: ...
def to_markdown(self, mode: Optional[_str] = ..., index: _bool = ..., storage_options: Optional[dict] = ...) -> _str: ...
def items(self) -> Iterable[Tuple[Union[int, _str], S1]]: ...
def iteritems(self) -> Iterable[Tuple[Label, S1]]: ...
def keys(self) -> List: ...
Expand All @@ -180,6 +180,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
group_keys: _bool = ...,
squeeze: _bool = ...,
observed: _bool = ...,
dropna: _bool = ...
) -> SeriesGroupBy: ...
@overload
def count(self, level: None = ...) -> int: ...
Expand All @@ -203,11 +204,13 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
def corr(
self, other: Series[S1], method: Literal["pearson", "kendall", "spearman"] = ..., min_periods: int = ...,
) -> float: ...
def cov(self, other: Series[S1], min_periods: Optional[int] = ...) -> float: ...
def cov(self, other: Series[S1], min_periods: Optional[int] = ..., ddof: int = ...) -> float: ...
def diff(self, periods: int = ...) -> Series[S1]: ...
def autocorr(self, lag: int = ...) -> float: ...
@overload
def dot(self, other: Union[DataFrame, Series[S1]]) -> Series[S1]: ...
def dot(self, other: Series[S1]) -> Scalar: ...
@overload
def dot(self, other: DataFrame) -> Series[S1]: ...
@overload
def dot(self, other: _ListLike) -> np.ndarray: ...
def __matmul__(self, other): ...
Expand All @@ -230,7 +233,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
self, other: Series[S1], func: Callable, fill_value: Optional[Scalar] = ...
) -> Series[S1]: ...
def combine_first(self, other: Series[S1]) -> Series[S1]: ...
def update(self, other: Series[S1]) -> None: ...
def update(self, other: Series[S1]|Sequence[S1]|Mapping[int, S1]) -> None: ...
def sort_values(
self,
axis: SeriesAxisType = ...,
Expand Down Expand Up @@ -297,6 +300,18 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
fill_axis: SeriesAxisType = ...,
broadcast_axis: Optional[SeriesAxisType] = ...,
) -> Tuple[Series, Series]: ...
@overload
def rename(
self,
index = ...,
*,
inplace: Literal[True],
axis: Optional[SeriesAxisType] = ...,
copy: _bool = ...,
level: Optional[Level] = ...,
errors: _str|Literal["raise", "ignore"] = ...
) -> None: ...
@overload
def rename(
self,
index = ...,
Expand All @@ -305,30 +320,43 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
copy: _bool = ...,
inplace: _bool = ...,
level: Optional[Level] = ...,
errors: Union[_str, Literal["raise", "ignore"]] = ...
errors: _str|Literal["raise", "ignore"] = ...
) -> Series: ...
def reindex_like(
self,
other: Series[S1],
method: Optional[Union[_str, Literal["backfill", "bfill", "pad", "ffill", "nearest"]]] = ...,
method: Optional[_str|Literal["backfill", "bfill", "pad", "ffill", "nearest"]] = ...,
copy: _bool = ...,
limit: Optional[int] = ...,
tolerance: Optional[float] = ...,
) -> Series: ...
@overload
def drop(
self,
labels: Optional[Union[_str, List]] = ...,
labels: Optional[_str|int|List] = ...,
axis: SeriesAxisType = ...,
index: Optional[Union[List[_str], List[int], Index]] = ...,
columns: Optional[Union[_str, List]] = ...,
index: Optional[List[_str]|List[int]|Index] = ...,
columns: Optional[_str|List] = ...,
level: Optional[Level] = ...,
errors: Literal["ignore", "raise"] = ...,
*,
inplace: Literal[True]
) -> None: ...
@overload
def drop(
self,
labels: Optional[_str|int|List] = ...,
axis: SeriesAxisType = ...,
index: Optional[List[_str]|List[int]|Index] = ...,
columns: Optional[_str|List] = ...,
level: Optional[Level] = ...,
inplace: _bool = ...,
errors: Literal["ignore", "raise"] = ...,
) -> Series: ...
@overload
def fillna(
self,
value: Union[Scalar, Dict, Series[S1], DataFrame],
value: Optional[Scalar|Dict|Series[S1]|DataFrame] = ...,
method: Optional[Union[_str, Literal["backfill", "bfill", "pad", "ffill"]]] = ...,
axis: SeriesAxisType = ...,
limit: Optional[int] = ...,
Expand All @@ -339,7 +367,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
@overload
def fillna(
self,
value: Union[Scalar, Dict, Series[S1], DataFrame],
value: Optional[Scalar|Dict|Series[S1]|DataFrame] = ...,
method: Optional[Union[_str, Literal["backfill", "bfill", "pad", "ffill"]]] = ...,
axis: SeriesAxisType = ...,
*,
Expand All @@ -349,7 +377,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
@overload
def fillna(
self,
value: Union[Scalar, Dict, Series[S1], DataFrame],
value: Optional[Scalar|Dict|Series[S1]|DataFrame] = ...,
method: Optional[Union[_str, Literal["backfill", "bfill", "pad", "ffill"]]] = ...,
axis: SeriesAxisType = ...,
inplace: _bool = ...,
Expand Down Expand Up @@ -381,6 +409,11 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
def isnull(self) -> Series[_bool]: ...
def notna(self) -> Series[_bool]: ...
def notnull(self) -> Series[_bool]: ...
@overload
def dropna(
self, axis: SeriesAxisType = ..., how: Optional[_str] = ..., *, inplace: Literal[True]
) -> None: ...
@overload
def dropna(
self, axis: SeriesAxisType = ..., inplace: _bool = ..., how: Optional[_str] = ...,
) -> Series[S1]: ...
Expand Down Expand Up @@ -453,33 +486,27 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
@overload
def ffill(
self,
value: Union[S1, Dict, Series[S1], DataFrame],
axis: SeriesAxisType,
inplace: Literal[True],
value: Union[S1, Dict, Series[S1], DataFrame] = ...,
axis: SeriesAxisType = ...,
limit: Optional[int] = ...,
downcast: Optional[Dict] = ...,
) -> Series[S1]: ...
@overload
def ffill(
self,
value: Union[S1, Dict, Series[S1], DataFrame],
*,
inplace: Literal[True],
limit: Optional[int] = ...,
downcast: Optional[Dict] = ...,
) -> None: ...
@overload
def ffill(
self,
value: Union[S1, Dict, Series[S1], DataFrame],
value: Union[S1, Dict, Series[S1], DataFrame] = ...,
axis: SeriesAxisType = ...,
*,
limit: Optional[int] = ...,
downcast: Optional[Dict] = ...,
) -> Series[S1]: ...
*,
inplace: Literal[False],
) -> Series[S1]: ...
@overload
def ffill(
self,
value: Union[S1, Dict, Series[S1], DataFrame],
value: Union[S1, Dict, Series[S1], DataFrame] = ...,
axis: SeriesAxisType = ...,
inplace: _bool = ...,
limit: Optional[int] = ...,
Expand All @@ -488,7 +515,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
@overload
def bfill(
self,
value: Union[S1, Dict, Series[S1], DataFrame],
value: Union[S1, Dict, Series[S1], DataFrame] = ...,
axis: SeriesAxisType = ...,
limit: Optional[int] = ...,
downcast: Optional[Dict] = ...,
Expand All @@ -498,12 +525,13 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
@overload
def bfill(
self,
value: Union[S1, Dict, Series[S1], DataFrame],
value: Union[S1, Dict, Series[S1], DataFrame] = ...,
axis: SeriesAxisType = ...,
*,
limit: Optional[int] = ...,
downcast: Optional[Dict] = ...,
) -> Series[S1]: ...
*,
inplace: Literal[False]
) -> Series[S1]: ...
@overload
def bfill(
self,
Expand Down
1 change: 0 additions & 1 deletion pandas/core/strings.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,3 @@ class StringMethods(NoNewAttributesMixin, Generic[RT]):
isnumeric = ...
isdecimal = ...


2 changes: 1 addition & 1 deletion pandas/core/tools/datetimes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def to_datetime(
unit: Optional[str] = ...,
infer_datetime_format: bool = ...,
origin: Scalar = ...,
cache: bool = ...) -> datetime: ...
cache: bool = ...) -> Timestamp: ...
@overload
def to_datetime(
arg: Union[list, tuple, ArrayLike],
Expand Down
Loading