Skip to content

Commit c527bc0

Browse files
use correct typing
1 parent 747e8bc commit c527bc0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pandas/core/frame.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@
144144
PeriodArray,
145145
TimedeltaArray,
146146
)
147+
from pandas.core.arrays.integer import (
148+
Int64Dtype,
149+
UInt64Dtype,
150+
)
147151
from pandas.core.arrays.sparse import SparseFrameAccessor
148152
from pandas.core.arrays.string_ import StringDtype
149153
from pandas.core.construction import (
@@ -9031,12 +9035,12 @@ def combine(
90319035
# int64 and uint64 to their nullable ExtensionDtypes, Int64 and UInt64.
90329036
def _ensure_nullable_int64_dtypes(df: DataFrame) -> DataFrame:
90339037
"""Promote int64/uint64 DataFrame columns to Int64/UInt64."""
9034-
cast_map: dict[str, str] = {}
9038+
cast_map: dict[IndexLabel, DtypeObj] = {}
90359039
for col, dt in df.dtypes.items():
90369040
if dt == np.int64:
9037-
cast_map[col] = "Int64"
9041+
cast_map[col] = Int64Dtype()
90389042
elif dt == np.uint64:
9039-
cast_map[col] = "UInt64"
9043+
cast_map[col] = UInt64Dtype()
90409044

90419045
if cast_map:
90429046
df = df.astype(cast_map)
@@ -9049,7 +9053,7 @@ def _revert_int64_dtype_promotion(
90499053
self_orig: DataFrame, other_orig: DataFrame, combined_df: DataFrame
90509054
) -> DataFrame:
90519055
"""Resolve the combined dtypes according to the original dtypes."""
9052-
cast_map: dict[str, str] = {}
9056+
cast_map: dict[IndexLabel, DtypeObj] = {}
90539057
for col in combined_df.columns:
90549058
ser = combined_df[col]
90559059
orig_dt_self = self_orig.dtypes.get(col)
@@ -9072,7 +9076,7 @@ def _revert_int64_dtype_promotion(
90729076
# obvious (since we don't cast back). Consider
90739077
# embracing nullable ExtensionDtypes instead
90749078
# and dropping this whole restoration step.
9075-
dtypes_to_resolve.append(np.dtype("float64"))
9079+
dtypes_to_resolve.append(np.dtype(np.float64))
90769080
target_type = find_common_type(dtypes_to_resolve)
90779081
cast_map[col] = target_type
90789082

0 commit comments

Comments
 (0)