Skip to content

Commit c81cd6e

Browse files
committed
doc(series): #718 examples
1 parent 386e309 commit c81cd6e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

docs/philosophy.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ This also allows type checking for operations on series that contain date/time d
3636
the following example that creates two series of datetimes with corresponding arithmetic.
3737

3838
```python
39+
import pandas as pd
40+
3941
s1 = pd.Series(pd.to_datetime(["2022-05-01", "2022-06-01"]))
4042
reveal_type(s1)
4143
s2 = pd.Series(pd.to_datetime(["2022-05-15", "2022-06-15"]))
@@ -46,19 +48,21 @@ ssum = s1 + s2
4648
reveal_type(ssum)
4749
```
4850

49-
The above code (without the `reveal_type()` statements) will raise an `Exception` on the computation of `ssum` because it is
51+
The above code (without the `reveal_type()` statements) will get a `Never`
52+
on the computation of `ssum` because it is
5053
inappropriate to add two series containing `Timestamp` values. The types will be
5154
revealed as follows:
5255

5356
```text
54-
ttest.py:4: note: Revealed type is "pandas.core.series.TimestampSeries"
55-
ttest.py:6: note: Revealed type is "pandas.core.series.TimestampSeries"
57+
ttest.py:4: note: Revealed type is "pandas.core.series.Series[pandas._libs.tslibs.timestamps.Timestamp]"
58+
ttest.py:6: note: Revealed type is "pandas.core.series.Series[pandas._libs.tslibs.timestamps.Timestamp]"
5659
ttest.py:8: note: Revealed type is "pandas.core.series.TimedeltaSeries"
57-
ttest.py:10: note: Revealed type is "builtins.Exception"
60+
ttest.py:9: error: Need type annotation for "ssum" [var-annotated]
61+
ttest.py:10: note: Revealed type is "Never"
5862
```
5963

60-
The type `TimestampSeries` is the result of creating a series from `pd.to_datetime()`, while
61-
the type `TimedeltaSeries` is the result of subtracting two `TimestampSeries` as well as
64+
The type `Series[Timestamp]` is the result of creating a series from `pd.to_datetime()`, while
65+
the type `TimedeltaSeries` is the result of subtracting two `Series[Timestamp]` as well as
6266
the result of `pd.to_timedelta()`.
6367

6468
### Interval is Generic

0 commit comments

Comments
 (0)