Skip to content

Commit 1b270b1

Browse files
committed
fix(comment): #718 only drop TimestampSeries #1273 (review)
1 parent f6dd4a2 commit 1b270b1

File tree

14 files changed

+454
-282
lines changed

14 files changed

+454
-282
lines changed

pandas-stubs/_libs/interval.pyi

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ from pandas import (
1313
Timedelta,
1414
Timestamp,
1515
)
16-
from pandas.core.series import (
17-
TimedeltaSeries,
18-
TimestampSeries,
19-
)
16+
from pandas.core.series import TimedeltaSeries
2017

2118
from pandas._typing import (
2219
IntervalClosedType,
@@ -174,7 +171,7 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
174171
@overload
175172
def __gt__(
176173
self,
177-
other: Series[int] | Series[float] | TimestampSeries | TimedeltaSeries,
174+
other: Series[int] | Series[float] | Series[Timestamp] | TimedeltaSeries,
178175
) -> Series[bool]: ...
179176
@overload
180177
def __lt__(self, other: Interval[_OrderableT]) -> bool: ...
@@ -183,7 +180,7 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
183180
@overload
184181
def __lt__(
185182
self,
186-
other: Series[int] | Series[float] | TimestampSeries | TimedeltaSeries,
183+
other: Series[int] | Series[float] | Series[Timestamp] | TimedeltaSeries,
187184
) -> Series[bool]: ...
188185
@overload
189186
def __ge__(self, other: Interval[_OrderableT]) -> bool: ...
@@ -192,7 +189,7 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
192189
@overload
193190
def __ge__(
194191
self,
195-
other: Series[int] | Series[float] | TimestampSeries | TimedeltaSeries,
192+
other: Series[int] | Series[float] | Series[Timestamp] | TimedeltaSeries,
196193
) -> Series[bool]: ...
197194
@overload
198195
def __le__(self, other: Interval[_OrderableT]) -> bool: ...

pandas-stubs/_libs/tslibs/timedeltas.pyi

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ from pandas import (
1717
Series,
1818
TimedeltaIndex,
1919
)
20-
from pandas.core.series import (
21-
TimedeltaSeries,
22-
TimestampSeries,
23-
)
20+
from pandas.core.series import TimedeltaSeries
2421
from typing_extensions import (
2522
Self,
2623
TypeAlias,
@@ -167,7 +164,7 @@ class Timedelta(timedelta):
167164
other: TimedeltaSeries,
168165
) -> TimedeltaSeries: ...
169166
@overload
170-
def __add__(self, other: TimestampSeries) -> TimestampSeries: ...
167+
def __add__(self, other: Series[Timestamp]) -> Series[Timestamp]: ...
171168
@overload
172169
def __radd__(self, other: np.datetime64) -> Timestamp: ...
173170
@overload

pandas-stubs/_libs/tslibs/timestamps.pyi

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ from pandas import (
2525
from pandas.core.series import (
2626
Series,
2727
TimedeltaSeries,
28-
TimestampSeries,
2928
)
3029
from typing_extensions import (
3130
Never,
@@ -172,31 +171,31 @@ class Timestamp(datetime, SupportsIndex):
172171
self, other: DatetimeIndex | npt.NDArray[np.datetime64]
173172
) -> np_ndarray_bool: ...
174173
@overload
175-
def __le__(self, other: TimestampSeries) -> Series[bool]: ...
174+
def __le__(self, other: Series[Timestamp]) -> Series[bool]: ...
176175
@overload # type: ignore[override]
177176
def __lt__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc]
178177
@overload
179178
def __lt__(
180179
self, other: DatetimeIndex | npt.NDArray[np.datetime64]
181180
) -> np_ndarray_bool: ...
182181
@overload
183-
def __lt__(self, other: TimestampSeries) -> Series[bool]: ...
182+
def __lt__(self, other: Series[Timestamp]) -> Series[bool]: ...
184183
@overload # type: ignore[override]
185184
def __ge__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc]
186185
@overload
187186
def __ge__(
188187
self, other: DatetimeIndex | npt.NDArray[np.datetime64]
189188
) -> np_ndarray_bool: ...
190189
@overload
191-
def __ge__(self, other: TimestampSeries) -> Series[bool]: ...
190+
def __ge__(self, other: Series[Timestamp]) -> Series[bool]: ...
192191
@overload # type: ignore[override]
193192
def __gt__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[misc]
194193
@overload
195194
def __gt__(
196195
self, other: DatetimeIndex | npt.NDArray[np.datetime64]
197196
) -> np_ndarray_bool: ...
198197
@overload
199-
def __gt__(self, other: TimestampSeries) -> Series[bool]: ...
198+
def __gt__(self, other: Series[Timestamp]) -> Series[bool]: ...
200199
# error: Signature of "__add__" incompatible with supertype "date"/"datetime"
201200
@overload # type: ignore[override]
202201
def __add__(
@@ -205,7 +204,7 @@ class Timestamp(datetime, SupportsIndex):
205204
@overload
206205
def __add__(self, other: timedelta | np.timedelta64 | Tick) -> Self: ...
207206
@overload
208-
def __add__(self, other: TimedeltaSeries) -> TimestampSeries: ...
207+
def __add__(self, other: TimedeltaSeries) -> Series[Timestamp]: ...
209208
@overload
210209
def __add__(self, other: TimedeltaIndex) -> DatetimeIndex: ...
211210
@overload
@@ -224,25 +223,25 @@ class Timestamp(datetime, SupportsIndex):
224223
@overload
225224
def __sub__(self, other: TimedeltaIndex) -> DatetimeIndex: ...
226225
@overload
227-
def __sub__(self, other: TimedeltaSeries) -> TimestampSeries: ...
226+
def __sub__(self, other: TimedeltaSeries) -> Series[Timestamp]: ...
228227
@overload
229-
def __sub__(self, other: TimestampSeries) -> TimedeltaSeries: ...
228+
def __sub__(self, other: Series[Timestamp]) -> TimedeltaSeries: ...
230229
@overload
231230
def __sub__(
232231
self, other: npt.NDArray[np.timedelta64]
233232
) -> npt.NDArray[np.datetime64]: ...
234233
@overload
235234
def __eq__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
236235
@overload
237-
def __eq__(self, other: TimestampSeries) -> Series[bool]: ... # type: ignore[overload-overlap]
236+
def __eq__(self, other: Series[Timestamp]) -> Series[bool]: ... # type: ignore[overload-overlap]
238237
@overload
239238
def __eq__(self, other: npt.NDArray[np.datetime64] | Index) -> np_ndarray_bool: ... # type: ignore[overload-overlap]
240239
@overload
241240
def __eq__(self, other: object) -> Literal[False]: ...
242241
@overload
243242
def __ne__(self, other: Timestamp | datetime | np.datetime64) -> bool: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
244243
@overload
245-
def __ne__(self, other: TimestampSeries) -> Series[bool]: ... # type: ignore[overload-overlap]
244+
def __ne__(self, other: Series[Timestamp]) -> Series[bool]: ... # type: ignore[overload-overlap]
246245
@overload
247246
def __ne__(self, other: npt.NDArray[np.datetime64] | Index) -> np_ndarray_bool: ... # type: ignore[overload-overlap]
248247
@overload

pandas-stubs/core/indexes/accessors.pyi

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ from datetime import (
44
tzinfo as _tzinfo,
55
)
66
from typing import (
7+
Any,
78
Generic,
89
Literal,
910
TypeVar,
11+
overload,
1012
)
1113

1214
import numpy as np
@@ -17,6 +19,7 @@ from pandas import (
1719
PeriodIndex,
1820
Timedelta,
1921
TimedeltaIndex,
22+
Timestamp,
2023
)
2124
from pandas.core.accessor import PandasDelegate
2225
from pandas.core.arrays import (
@@ -29,12 +32,12 @@ from pandas.core.series import (
2932
PeriodSeries,
3033
Series,
3134
TimedeltaSeries,
32-
TimestampSeries,
3335
)
3436

3537
from pandas._libs.tslibs import BaseOffset
3638
from pandas._libs.tslibs.offsets import DateOffset
3739
from pandas._typing import (
40+
S1,
3841
TimeAmbiguous,
3942
TimeNonexistent,
4043
TimestampConvention,
@@ -155,14 +158,13 @@ class _DatetimeLikeOps(
155158
],
156159
): ...
157160

158-
# Ideally, the rounding methods would return TimestampSeries when `Series.dt.method`
161+
# Ideally, the rounding methods would return Series[Timestamp] when `Series.dt.method`
159162
# is invoked, but because of how Series.dt is hooked in and that we may not know the
160163
# type of the series, we don't know which kind of series was ...ed
161164
# in to the dt accessor
162165

163166
_DTTimestampTimedeltaReturnType = TypeVar(
164-
"_DTTimestampTimedeltaReturnType",
165-
bound=Series | TimestampSeries | TimedeltaSeries | DatetimeIndex | TimedeltaIndex,
167+
"_DTTimestampTimedeltaReturnType", bound=Series | DatetimeIndex | TimedeltaIndex
166168
)
167169

168170
class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]):
@@ -198,7 +200,7 @@ class _DatetimeRoundingMethods(Generic[_DTTimestampTimedeltaReturnType]):
198200
) -> _DTTimestampTimedeltaReturnType: ...
199201

200202
_DTNormalizeReturnType = TypeVar(
201-
"_DTNormalizeReturnType", TimestampSeries, DatetimeIndex
203+
"_DTNormalizeReturnType", Series[Timestamp], DatetimeIndex
202204
)
203205
_DTStrKindReturnType = TypeVar("_DTStrKindReturnType", bound=Series[str] | Index)
204206
_DTToPeriodReturnType = TypeVar(
@@ -320,7 +322,7 @@ class TimedeltaProperties(
320322
def as_unit(self, unit: TimeUnit) -> TimedeltaSeries: ...
321323

322324
_PeriodDTReturnTypes = TypeVar(
323-
"_PeriodDTReturnTypes", bound=TimestampSeries | DatetimeIndex
325+
"_PeriodDTReturnTypes", bound=Series[Timestamp] | DatetimeIndex
324326
)
325327
_PeriodIntReturnTypes = TypeVar("_PeriodIntReturnTypes", bound=Series[int] | Index[int])
326328
_PeriodStrReturnTypes = TypeVar("_PeriodStrReturnTypes", bound=Series[str] | Index)
@@ -363,7 +365,7 @@ class PeriodIndexFieldOps(
363365
class PeriodProperties(
364366
Properties,
365367
_PeriodProperties[
366-
TimestampSeries, Series[int], Series[str], DatetimeArray, PeriodArray
368+
Series[Timestamp], Series[int], Series[str], DatetimeArray, PeriodArray
367369
],
368370
_DatetimeFieldOps[Series[int]],
369371
_IsLeapYearProperty,
@@ -377,7 +379,7 @@ class CombinedDatetimelikeProperties(
377379
Series[dt.date],
378380
Series[dt.time],
379381
str,
380-
TimestampSeries,
382+
Series[Timestamp],
381383
Series[str],
382384
PeriodSeries,
383385
],
@@ -388,11 +390,11 @@ class TimestampProperties(
388390
DatetimeProperties[
389391
Series[int],
390392
Series[bool],
391-
TimestampSeries,
393+
Series[Timestamp],
392394
Series[dt.date],
393395
Series[dt.time],
394396
str,
395-
TimestampSeries,
397+
Series[Timestamp],
396398
Series[str],
397399
PeriodSeries,
398400
]
@@ -427,3 +429,44 @@ class TimedeltaIndexProperties(
427429
_TimedeltaPropertiesNoRounding[Index, Index],
428430
_DatetimeRoundingMethods[TimedeltaIndex],
429431
): ...
432+
433+
class _dtDescriptor(CombinedDatetimelikeProperties, Generic[S1]):
434+
@overload
435+
def __get__(
436+
self, instance: Series[Timestamp], owner: Any
437+
) -> TimestampProperties: ...
438+
@overload
439+
def __get__(
440+
self, instance: Series[S1], owner: Any
441+
) -> CombinedDatetimelikeProperties: ...
442+
def round(
443+
self,
444+
freq: str | BaseOffset | None,
445+
ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = ...,
446+
nonexistent: (
447+
Literal["shift_forward", "shift_backward", "NaT", "raise"]
448+
| timedelta
449+
| Timedelta
450+
) = ...,
451+
) -> Series[S1]: ...
452+
def floor(
453+
self,
454+
freq: str | BaseOffset | None,
455+
ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = ...,
456+
nonexistent: (
457+
Literal["shift_forward", "shift_backward", "NaT", "raise"]
458+
| timedelta
459+
| Timedelta
460+
) = ...,
461+
) -> Series[S1]: ...
462+
def ceil(
463+
self,
464+
freq: str | BaseOffset | None,
465+
ambiguous: Literal["raise", "infer", "NaT"] | bool | np_ndarray_bool = ...,
466+
nonexistent: (
467+
Literal["shift_forward", "shift_backward", "NaT", "raise"]
468+
| timedelta
469+
| Timedelta
470+
) = ...,
471+
) -> Series[S1]: ...
472+
def as_unit(self, unit: TimeUnit) -> Series[S1]: ...

pandas-stubs/core/indexes/datetimes.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ from pandas import (
2020
from pandas.core.indexes.accessors import DatetimeIndexProperties
2121
from pandas.core.indexes.datetimelike import DatetimeTimedeltaMixin
2222
from pandas.core.series import (
23+
Series,
2324
TimedeltaSeries,
24-
TimestampSeries,
2525
)
2626
from typing_extensions import Self
2727

@@ -57,13 +57,13 @@ class DatetimeIndex(DatetimeTimedeltaMixin[Timestamp], DatetimeIndexProperties):
5757
# various ignores needed for mypy, as we do want to restrict what can be used in
5858
# arithmetic for these types
5959
@overload
60-
def __add__(self, other: TimedeltaSeries) -> TimestampSeries: ...
60+
def __add__(self, other: TimedeltaSeries) -> Series[Timestamp]: ...
6161
@overload
6262
def __add__(
6363
self, other: timedelta | Timedelta | TimedeltaIndex | BaseOffset
6464
) -> DatetimeIndex: ...
6565
@overload
66-
def __sub__(self, other: TimedeltaSeries) -> TimestampSeries: ...
66+
def __sub__(self, other: TimedeltaSeries) -> Series[Timestamp]: ...
6767
@overload
6868
def __sub__(
6969
self, other: timedelta | Timedelta | TimedeltaIndex | BaseOffset
@@ -72,7 +72,7 @@ class DatetimeIndex(DatetimeTimedeltaMixin[Timestamp], DatetimeIndexProperties):
7272
def __sub__(
7373
self, other: datetime | Timestamp | DatetimeIndex
7474
) -> TimedeltaIndex: ...
75-
def to_series(self, index=..., name: Hashable = ...) -> TimestampSeries: ...
75+
def to_series(self, index=..., name: Hashable = ...) -> Series[Timestamp]: ...
7676
def snap(self, freq: str = ...): ...
7777
def slice_indexer(self, start=..., end=..., step=...): ...
7878
def searchsorted(self, value, side: str = ..., sorter=...): ...

pandas-stubs/core/indexes/interval.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ from pandas import Index
1414
from pandas.core.indexes.extension import ExtensionIndex
1515
from pandas.core.series import (
1616
TimedeltaSeries,
17-
TimestampSeries,
1817
)
1918
from typing_extensions import TypeAlias
2019

@@ -52,7 +51,7 @@ _EdgesFloat: TypeAlias = (
5251
_EdgesTimestamp: TypeAlias = (
5352
Sequence[DatetimeLike]
5453
| npt.NDArray[np.datetime64]
55-
| TimestampSeries
54+
| pd.Series[pd.Timestamp]
5655
| pd.DatetimeIndex
5756
)
5857
_EdgesTimedelta: TypeAlias = (

pandas-stubs/core/reshape/tile.pyi

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ from pandas import (
1212
Index,
1313
Interval,
1414
IntervalIndex,
15-
Series,
1615
Timestamp,
1716
)
18-
from pandas.core.series import TimestampSeries
17+
from pandas.core.series import Series
1918

2019
from pandas._typing import (
2120
IntervalT,
@@ -51,10 +50,10 @@ def cut(
5150
) -> tuple[npt.NDArray[np.intp], IntervalIndex[IntervalT]]: ...
5251
@overload
5352
def cut( # pyright: ignore[reportOverlappingOverload]
54-
x: TimestampSeries,
53+
x: Series[Timestamp],
5554
bins: (
5655
int
57-
| TimestampSeries
56+
| Series[Timestamp]
5857
| DatetimeIndex
5958
| Sequence[Timestamp]
6059
| Sequence[np.datetime64]
@@ -70,7 +69,7 @@ def cut( # pyright: ignore[reportOverlappingOverload]
7069
) -> tuple[Series, DatetimeIndex]: ...
7170
@overload
7271
def cut(
73-
x: TimestampSeries,
72+
x: Series[Timestamp],
7473
bins: IntervalIndex[Interval[Timestamp]],
7574
right: bool = ...,
7675
labels: Sequence[Label] | None = ...,
@@ -156,10 +155,10 @@ def cut(
156155
) -> npt.NDArray[np.intp]: ...
157156
@overload
158157
def cut(
159-
x: TimestampSeries,
158+
x: Series[Timestamp],
160159
bins: (
161160
int
162-
| TimestampSeries
161+
| Series[Timestamp]
163162
| DatetimeIndex
164163
| Sequence[Timestamp]
165164
| Sequence[np.datetime64]

0 commit comments

Comments
 (0)