@@ -71,9 +71,7 @@ def test_reset_index_tz(self, tz_aware_fixture):
7171 # GH 3950
7272 # reset_index with single level
7373 tz = tz_aware_fixture
74- idx = date_range ("1/1/2011" , periods = 5 , freq = "D" , tz = tz , name = "idx" ).as_unit (
75- "us"
76- )
74+ idx = date_range ("1/1/2011" , periods = 5 , freq = "D" , tz = tz , name = "idx" )
7775 df = DataFrame ({"a" : range (5 ), "b" : ["A" , "B" , "C" , "D" , "E" ]}, index = idx )
7876
7977 expected = DataFrame (
@@ -480,12 +478,9 @@ def test_reset_index_allow_duplicates_check(self, multiindex_df, allow_duplicate
480478 def test_reset_index_datetime (self , tz_naive_fixture ):
481479 # GH#3950
482480 tz = tz_naive_fixture
483- idx1 = date_range (
484- "1/1/2011" , periods = 5 , freq = "D" , tz = tz , name = "idx1" , unit = "us"
485- )
481+ idx1 = date_range ("1/1/2011" , periods = 5 , freq = "D" , tz = tz , name = "idx1" )
486482 idx2 = Index (range (5 ), name = "idx2" , dtype = "int64" )
487483 idx = MultiIndex .from_arrays ([idx1 , idx2 ])
488- assert idx .levels [0 ].unit == "us"
489484 df = DataFrame (
490485 {"a" : np .arange (5 , dtype = "int64" ), "b" : ["A" , "B" , "C" , "D" , "E" ]},
491486 index = idx ,
@@ -508,7 +503,7 @@ def test_reset_index_datetime2(self, tz_naive_fixture):
508503 idx1 = date_range ("1/1/2011" , periods = 5 , freq = "D" , tz = tz , name = "idx1" )
509504 idx2 = Index (range (5 ), name = "idx2" , dtype = "int64" )
510505 idx3 = date_range (
511- "1/1/2012" , periods = 5 , freq = "MS" , tz = "Europe/Paris" , name = "idx3" , unit = "us"
506+ "1/1/2012" , periods = 5 , freq = "MS" , tz = "Europe/Paris" , name = "idx3"
512507 )
513508 idx = MultiIndex .from_arrays ([idx1 , idx2 , idx3 ])
514509 df = DataFrame (
@@ -532,7 +527,7 @@ def test_reset_index_datetime2(self, tz_naive_fixture):
532527 def test_reset_index_datetime3 (self , tz_naive_fixture ):
533528 # GH#7793
534529 tz = tz_naive_fixture
535- dti = date_range ("20130101" , periods = 3 , tz = tz , unit = "us" )
530+ dti = date_range ("20130101" , periods = 3 , tz = tz )
536531 idx = MultiIndex .from_product ([["a" , "b" ], dti ])
537532 df = DataFrame (
538533 np .arange (6 , dtype = "int64" ).reshape (6 , 1 ), columns = ["a" ], index = idx
@@ -700,13 +695,16 @@ def test_reset_index_empty_frame_with_datetime64_multiindex_from_groupby():
700695def test_reset_index_multiindex_nat ():
701696 # GH 11479
702697 idx = range (3 )
703- tstamp = date_range ("2015-07-01" , freq = "D" , periods = 3 , unit = "s" )
698+ tstamp = date_range ("2015-07-01" , freq = "D" , periods = 3 )
704699 df = DataFrame ({"id" : idx , "tstamp" : tstamp , "a" : list ("abc" )})
705700 df .loc [2 , "tstamp" ] = pd .NaT
706701 result = df .set_index (["id" , "tstamp" ]).reset_index ("id" )
702+ dti = pd .DatetimeIndex (
703+ ["2015-07-01" , "2015-07-02" , "NaT" ], dtype = "M8[ns]" , name = "tstamp"
704+ )
707705 expected = DataFrame (
708706 {"id" : range (3 ), "a" : list ("abc" )},
709- index = pd . DatetimeIndex ([ "2015-07-01" , "2015-07-02" , "NaT" ], name = "tstamp" ) ,
707+ index = dti ,
710708 )
711709 tm .assert_frame_equal (result , expected )
712710
0 commit comments