File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,19 @@ def test_object_factorize(self, writable):
252
252
tm .assert_numpy_array_equal (codes , expected_codes )
253
253
tm .assert_numpy_array_equal (uniques , expected_uniques )
254
254
255
+ def test_datetime64_factorize (self , writable ):
256
+ # GH35650 Verify whether read-only datetime64 array can be factorized
257
+ data = np .array ([np .datetime64 ("2020-01-01T00:00:00.000" )])
258
+ data .setflags (write = writable )
259
+ expected_codes = np .array ([0 ], dtype = np .int64 )
260
+ expected_uniques = np .array (
261
+ ["2020-01-01T00:00:00.000000000" ], dtype = "datetime64[ns]"
262
+ )
263
+
264
+ codes , uniques = pd .factorize (data )
265
+ tm .assert_numpy_array_equal (codes , expected_codes )
266
+ tm .assert_numpy_array_equal (uniques , expected_uniques )
267
+
255
268
def test_deprecate_order (self ):
256
269
# gh 19727 - check warning is raised for deprecated keyword, order.
257
270
# Test not valid once order keyword is removed.
You can’t perform that action at this time.
0 commit comments