File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ the following example that creates two series of datetimes with corresponding ar
37
37
38
38
``` python
39
39
import pandas as pd
40
+ from typing import reveal_type
40
41
41
42
s1 = pd.Series(pd.to_datetime([" 2022-05-01" , " 2022-06-01" ]))
42
43
reveal_type(s1)
@@ -51,14 +52,14 @@ reveal_type(ssum)
51
52
The above code (without the ` reveal_type() ` statements) will get a ` Never `
52
53
on the computation of ` ssum ` because it is
53
54
inappropriate to add two series containing ` Timestamp ` values. The types will be
54
- revealed as follows:
55
+ revealed by ` mypy ` as follows:
55
56
56
57
``` text
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]"
59
- ttest.py:8 : note: Revealed type is "pandas.core.series.TimedeltaSeries"
60
- ttest.py:9 : error: Need type annotation for "ssum" [var-annotated]
61
- ttest.py:10 : note: Revealed type is "Never"
58
+ ttest.py:5 : note: Revealed type is "pandas.core.series.Series[pandas._libs.tslibs.timestamps.Timestamp]"
59
+ ttest.py:7 : note: Revealed type is "pandas.core.series.Series[pandas._libs.tslibs.timestamps.Timestamp]"
60
+ ttest.py:9 : note: Revealed type is "pandas.core.series.TimedeltaSeries"
61
+ ttest.py:10 : error: Need type annotation for "ssum" [var-annotated]
62
+ ttest.py:11 : note: Revealed type is "Never"
62
63
```
63
64
64
65
The type ` Series[Timestamp] ` is the result of creating a series from ` pd.to_datetime() ` , while
You can’t perform that action at this time.
0 commit comments