forked from pandas-dev/pandas-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresample.pyi
207 lines (194 loc) · 6.63 KB
/
resample.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
from collections.abc import (
Callable,
Hashable,
Mapping,
)
from typing import (
Literal,
overload,
)
import numpy as np
from pandas import (
DataFrame,
DatetimeIndex,
Index,
PeriodIndex,
Series,
Timedelta,
TimedeltaIndex,
)
from pandas.core.groupby.generic import SeriesGroupBy
from pandas.core.groupby.groupby import BaseGroupBy
from pandas.core.groupby.grouper import Grouper
from pandas.core.groupby.ops import BinGrouper
from typing_extensions import (
Self,
TypeAlias,
)
from pandas._libs.lib import NoDefault
from pandas._typing import (
S1,
Axis,
InterpolateOptions,
NDFrameT,
Scalar,
TimeGrouperOrigin,
TimestampConvention,
npt,
)
_FrameGroupByFunc: TypeAlias = (
Callable[[DataFrame], Scalar]
| Callable[[DataFrame], Series]
| Callable[[DataFrame], DataFrame]
| np.ufunc
)
_FrameGroupByFuncTypes: TypeAlias = (
_FrameGroupByFunc | str | list[_FrameGroupByFunc | str]
)
_FrameGroupByFuncArgs: TypeAlias = (
_FrameGroupByFuncTypes | Mapping[Hashable, _FrameGroupByFuncTypes]
)
_SeriesGroupByFunc: TypeAlias = (
Callable[[Series], Scalar] | Callable[[Series], Series] | np.ufunc
)
_SeriesGroupByFuncTypes: TypeAlias = (
_SeriesGroupByFunc | str | list[_SeriesGroupByFunc | str]
)
_SeriesGroupByFuncArgs: TypeAlias = (
_SeriesGroupByFuncTypes | Mapping[Hashable, _SeriesGroupByFunc | str]
)
class Resampler(BaseGroupBy[NDFrameT]):
grouper: BinGrouper # pyright: ignore[reportIncompatibleVariableOverride] # variance incompatibility
binner: DatetimeIndex | TimedeltaIndex | PeriodIndex
exclusions: frozenset[Hashable]
ax: Index
def __getattr__(self, attr: str) -> SeriesGroupBy: ...
@overload
def aggregate(
self: Resampler[DataFrame],
func: _FrameGroupByFuncArgs | None = ...,
*args,
**kwargs,
) -> DataFrame: ...
@overload
def aggregate(
self: Resampler[Series],
func: _SeriesGroupByFuncArgs | None = ...,
*args,
**kwargs,
) -> Series | DataFrame: ...
agg = aggregate
apply = aggregate
@overload
def transform(
self: Resampler[Series], arg: Callable[[Series], Series[S1]], *args, **kwargs
) -> Series[S1]: ...
@overload
def transform(
self: Resampler[DataFrame], arg: Callable[[Series], Series[S1]], *args, **kwargs
) -> DataFrame: ...
def ffill(self, limit: int | None = ...) -> NDFrameT: ...
def nearest(self, limit: int | None = ...) -> NDFrameT: ...
def bfill(self, limit: int | None = ...) -> NDFrameT: ...
@overload
def interpolate(
self,
method: InterpolateOptions = ...,
*,
axis: Axis = ...,
limit: int | None = ...,
inplace: Literal[True],
limit_direction: Literal["forward", "backward", "both"] = ...,
limit_area: Literal["inside", "outside"] | None = ...,
downcast: Literal["infer"] | None | NoDefault = ...,
**kwargs,
) -> None: ...
@overload
def interpolate(
self,
method: InterpolateOptions = ...,
*,
axis: Axis = ...,
limit: int | None = ...,
inplace: Literal[False] = ...,
limit_direction: Literal["forward", "backward", "both"] = ...,
limit_area: Literal["inside", "outside"] | None = ...,
downcast: Literal["infer"] | None | NoDefault = ...,
**kwargs,
) -> NDFrameT: ...
def asfreq(self, fill_value: Scalar | None = ...) -> NDFrameT: ...
def sum(
self, numeric_only: bool = ..., min_count: int = ..., *args, **kwargs
) -> NDFrameT: ...
def prod(
self, numeric_only: bool = ..., min_count: int = ..., *args, **kwargs
) -> NDFrameT: ...
def min(
self, numeric_only: bool = ..., min_count: int = ..., *args, **kwargs
) -> NDFrameT: ...
def max(
self, numeric_only: bool = ..., min_count: int = ..., *args, **kwargs
) -> NDFrameT: ...
def first(
self, numeric_only: bool = ..., min_count: int = ..., *args, **kwargs
) -> NDFrameT: ...
def last(
self, numeric_only: bool = ..., min_count: int = ..., *args, **kwargs
) -> NDFrameT: ...
def median(self, numeric_only: bool = ..., *args, **kwargs) -> NDFrameT: ...
def mean(self, numeric_only: bool = ..., *args, **kwargs) -> NDFrameT: ...
def std(
self, ddof: int = ..., numeric_only: bool = ..., *args, **kwargs
) -> NDFrameT: ...
def var(
self, ddof: int = ..., numeric_only: bool = ..., *args, **kwargs
) -> NDFrameT: ...
def sem(
self, ddof: int = ..., numeric_only: bool = ..., *args, **kwargs
) -> NDFrameT: ...
def ohlc(self, *args, **kwargs) -> DataFrame: ...
@overload
def nunique(self: Resampler[Series], *args, **kwargs) -> Series[int]: ...
@overload
def nunique(self: Resampler[DataFrame], *args, **kwargs) -> DataFrame: ...
def size(self) -> Series[int]: ...
@overload
def count(self: Resampler[Series]) -> Series[int]: ...
@overload
def count(self: Resampler[DataFrame]) -> DataFrame: ...
def quantile(
self,
q: float | list[float] | npt.NDArray[np.double] | Series[float] = ...,
**kwargs,
) -> NDFrameT: ...
# We lie about inheriting from Resampler because at runtime inherits all Resampler
# attributes via setattr
class _GroupByMixin(Resampler[NDFrameT]):
key: str | list[str] | None
def __getitem__(self, key) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
class DatetimeIndexResampler(Resampler[NDFrameT]): ...
class DatetimeIndexResamplerGroupby(
_GroupByMixin[NDFrameT], DatetimeIndexResampler[NDFrameT]
):
def __getattr__(self, attr: str) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
class PeriodIndexResampler(DatetimeIndexResampler[NDFrameT]): ...
class PeriodIndexResamplerGroupby(
_GroupByMixin[NDFrameT], PeriodIndexResampler[NDFrameT]
):
def __getattr__(self, attr: str) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
class TimedeltaIndexResampler(DatetimeIndexResampler[NDFrameT]): ...
class TimedeltaIndexResamplerGroupby(
_GroupByMixin[NDFrameT], TimedeltaIndexResampler[NDFrameT]
):
def __getattr__(self, attr: str) -> Self: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
class TimeGrouper(Grouper):
closed: Literal["left", "right"]
label: Literal["left", "right"]
kind: str | None
convention: TimestampConvention
how: str
fill_method: str | None
limit: int | None
group_keys: bool
origin: TimeGrouperOrigin
offset: Timedelta | None