Skip to content

Commit b9f5adb

Browse files
committed
added any to list of args for astype
1 parent f46cc52 commit b9f5adb

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

pandas-stubs/_typing.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class FulldatetimeDict(YearMonthDayDict, total=False):
7676
# dtypes
7777
NpDtype: TypeAlias = str | np.dtype[np.generic] | type[str | complex | bool | object]
7878
Dtype: TypeAlias = ExtensionDtype | NpDtype
79+
DtypeArg: TypeAlias = Dtype | dict[Any, Dtype]
7980
AstypeArg: TypeAlias = (
8081
BooleanDtypeArg
8182
| IntDtypeArg
@@ -89,7 +90,6 @@ AstypeArg: TypeAlias = (
8990
| ExtensionDtype
9091
)
9192
# DtypeArg specifies all allowable dtypes in a functions its dtype argument
92-
DtypeArg: TypeAlias = Dtype | dict[Any, Dtype]
9393
DtypeObj: TypeAlias = np.dtype[np.generic] | ExtensionDtype
9494

9595
# filenames and file-like-objects

pandas-stubs/core/frame.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,8 +1441,7 @@ class DataFrame(NDFrame, OpsMixin):
14411441
) -> DataFrame: ...
14421442
def astype(
14431443
self,
1444-
dtype: AstypeArg | Mapping[Hashable, AstypeArg] | Series,
1445-
# dtype: AstypeArg | dict[Any, AstypeArg],
1444+
dtype: AstypeArg | Mapping[Hashable, AstypeArg] | Series | Any,
14461445
copy: _bool = ...,
14471446
errors: IgnoreRaise = ...,
14481447
) -> DataFrame: ...

tests/test_frame.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,6 +2296,9 @@ def test_axes_as_tuple() -> None:
22962296
def test_astype_dict() -> None:
22972297
# GH 447
22982298
df = pd.DataFrame({"a": [1, 2, 3], 43: [4, 5, 6]})
2299+
columns_types = {"a": "int", 43: "float"}
2300+
de = df.astype(columns_types)
2301+
check(assert_type(de, pd.DataFrame), pd.DataFrame)
22992302
check(assert_type(df.astype({"a": "int", 43: "float"}), pd.DataFrame), pd.DataFrame)
23002303

23012304

0 commit comments

Comments
 (0)