Skip to content

Conversation

@loicdiridollou
Copy link
Member

@loicdiridollou
Copy link
Member Author

/pandas_nightly

Copy link
Contributor

@cmp0xff cmp0xff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding mean, min, median. I think we just need to relax the type testing.

skipna: _bool | None = True,
numeric_only: _bool = False,
**kwargs: Any,
) -> Scalar: ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably further restrict to _OrderableT from pandas-stubs/_libs/intervals.pyi, instead of just Scalar. But this can be done in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a type that can be returned? I thought it was more of a generic for Interval or something like that. I have left it for later.

df = pd.DataFrame(data={"col1": [2, 1], "col2": [3, 4]})
check(assert_type(df.mean(), pd.Series), pd.Series)
check(assert_type(df.mean(axis=0), pd.Series), pd.Series)
check(assert_type(df.mean(axis=None), Scalar), np.float64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we usually just test for the more generic np.floating unless there is a reason to test for the specific np.float64.

Suggested change
check(assert_type(df.mean(axis=None), Scalar), np.float64)
check(assert_type(df.mean(axis=None), Scalar), np.floating)

df = pd.DataFrame(data={"col1": [2, 1], "col2": [3, 4]})
check(assert_type(df.median(), pd.Series), pd.Series)
check(assert_type(df.median(axis=0), pd.Series), pd.Series)
check(assert_type(df.median(axis=None), Scalar), np.float64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
check(assert_type(df.median(axis=None), Scalar), np.float64)
check(assert_type(df.median(axis=None), Scalar), np.floating)

df = pd.DataFrame(data={"col1": [2, 1], "col2": [3, 4]})
check(assert_type(df.min(), pd.Series), pd.Series)
check(assert_type(df.min(axis=0), pd.Series), pd.Series)
check(assert_type(df.min(axis=None), Scalar), np.int64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
check(assert_type(df.min(axis=None), Scalar), np.int64)
check(assert_type(df.min(axis=None), Scalar), np.integer)

df = pd.DataFrame(data={"col1": [2, 1], "col2": [3, 4]})
check(assert_type(df.max(), pd.Series), pd.Series)
check(assert_type(df.max(axis=0), pd.Series), pd.Series)
check(assert_type(df.max(axis=None), Scalar), np.int64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
check(assert_type(df.max(axis=None), Scalar), np.int64)
check(assert_type(df.max(axis=None), Scalar), np.integer)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All addressed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataFrame.max needs the same overloads as DataFrame.any has

2 participants