Skip to content

GH: 624 - added new is_any_real_numeric_dtype function #715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pandas-stubs/core/dtypes/common.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ def is_float_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_bool_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_extension_array_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_complex_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def is_any_real_numeric_dtype(arr_or_dtype: _ArrayOrDtype) -> bool: ...
def pandas_dtype(dtype: object) -> DtypeObj: ...
6 changes: 3 additions & 3 deletions pandas-stubs/io/parsers/readers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def read_csv(
skiprows: int | Sequence[int] | Callable[[int], bool] = ...,
skipfooter: int = ...,
nrows: int | None = ...,
na_values: Sequence[str] | Mapping[str, Sequence[str]] = ...,
na_values: Sequence[str] | Mapping[str, Sequence[str]] | None = ...,
keep_default_na: bool = ...,
na_filter: bool = ...,
verbose: bool = ...,
Expand Down Expand Up @@ -117,7 +117,7 @@ def read_csv(
skiprows: int | Sequence[int] | Callable[[int], bool] = ...,
skipfooter: int = ...,
nrows: int | None = ...,
na_values: Sequence[str] | Mapping[str, Sequence[str]] = ...,
na_values: Sequence[str] | Mapping[str, Sequence[str]] | None = ...,
keep_default_na: bool = ...,
na_filter: bool = ...,
verbose: bool = ...,
Expand Down Expand Up @@ -177,7 +177,7 @@ def read_csv(
skiprows: int | Sequence[int] | Callable[[int], bool] = ...,
skipfooter: int = ...,
nrows: int | None = ...,
na_values: Sequence[str] | Mapping[str, Sequence[str]] = ...,
na_values: Sequence[str] | Mapping[str, Sequence[str]] | None = ...,
keep_default_na: bool = ...,
na_filter: bool = ...,
verbose: bool = ...,
Expand Down
8 changes: 8 additions & 0 deletions tests/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from pandas._libs.missing import NAType
from pandas._typing import Scalar

from pandas.core.dtypes.common import is_any_real_numeric_dtype

from tests import (
TYPE_CHECKING_INVALID_USAGE,
check,
Expand Down Expand Up @@ -144,3 +146,9 @@ def test_arrow_dtype() -> None:
a_dt = pd.ArrowDtype(pa.int64())
check(assert_type(a_dt, pd.ArrowDtype), pd.ArrowDtype)
check(assert_type(a_dt.pyarrow_dtype, pa.DataType), pa.DataType)


def test_is_any_real_numeric_dtype() -> None:
check(assert_type(is_any_real_numeric_dtype(np.array([1, 2])), bool), bool)
check(assert_type(is_any_real_numeric_dtype(int), bool), bool)
check(assert_type(is_any_real_numeric_dtype(float), bool), bool)
6 changes: 6 additions & 0 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1506,3 +1506,9 @@ def test_added_date_format() -> None:
),
pd.DataFrame,
)


def test_read_csv_name_none() -> None:
with ensure_clean() as path:
check(assert_type(DF.to_csv(path), None), type(None))
check(assert_type(read_csv(path, na_values=None), DataFrame), DataFrame)