Skip to content

Commit 289b9ec

Browse files
MarcoGorelliproost
authored andcommitted
Add simple test for GH 28448 (pandas-dev#29269)
1 parent 0700bfe commit 289b9ec

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pandas/tests/extension/test_categorical.py

+20
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,26 @@ def test_cast_category_to_extension_dtype(self, expected):
223223

224224
tm.assert_series_equal(result, expected)
225225

226+
@pytest.mark.parametrize(
227+
"dtype, expected",
228+
[
229+
(
230+
"datetime64[ns]",
231+
np.array(["2015-01-01T00:00:00.000000000"], dtype="datetime64[ns]"),
232+
),
233+
(
234+
"datetime64[ns, MET]",
235+
pd.DatetimeIndex(
236+
[pd.Timestamp("2015-01-01 00:00:00+0100", tz="MET")]
237+
).array,
238+
),
239+
],
240+
)
241+
def test_consistent_casting(self, dtype, expected):
242+
# GH 28448
243+
result = pd.Categorical("2015-01-01").astype(dtype)
244+
assert result == expected
245+
226246

227247
class TestArithmeticOps(base.BaseArithmeticOpsTests):
228248
def test_arith_series_with_scalar(self, data, all_arithmetic_operators):

0 commit comments

Comments
 (0)