-
-
Notifications
You must be signed in to change notification settings - Fork 153
Open
Labels
ConstructorsSeries/DataFrame/Index/pd.array ConstructorsSeries/DataFrame/Index/pd.array ConstructorsNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further actionReduction Operationssum, mean, min, max, etc.sum, mean, min, max, etc.SeriesSeries data structureSeries data structure
Description
Describe the bug
At runtime, Series.sum returns a np.int64 or np.float64 when summing numbers. Yet the typing says we should get an int or a float.
The issue arises when we use method on that result that are only defined on np.int64 or np.float64 (for example the clip method).
How would we want to handle those cases, are we open to adjusting the stubs to better type the behavior?
To Reproduce
- Provide a minimal runnable
pandasexample that is not properly checked by the stubs. - Indicate which type checker you are using (
mypyorpyright). - Show the error message received from that type checker while checking your example.
import pandas as pd
import numpy as np
a = pd.Series([1.,1.])
b = pd.Series([2.,2.])
a.mul(b).sum().clip(max=3)The error we get is Cannot access attribute "clip" for class "float"
Please complete the following information:
- OS: MacOS
- OS Version latest
- python version 3.13
- version of type checker 1.18
- version of installed
pandas-stubsmain
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
ConstructorsSeries/DataFrame/Index/pd.array ConstructorsSeries/DataFrame/Index/pd.array ConstructorsNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further actionReduction Operationssum, mean, min, max, etc.sum, mean, min, max, etc.SeriesSeries data structureSeries data structure