@@ -71,9 +71,7 @@ def test_reset_index_tz(self, tz_aware_fixture):
71
71
# GH 3950
72
72
# reset_index with single level
73
73
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" )
77
75
df = DataFrame ({"a" : range (5 ), "b" : ["A" , "B" , "C" , "D" , "E" ]}, index = idx )
78
76
79
77
expected = DataFrame (
@@ -480,12 +478,9 @@ def test_reset_index_allow_duplicates_check(self, multiindex_df, allow_duplicate
480
478
def test_reset_index_datetime (self , tz_naive_fixture ):
481
479
# GH#3950
482
480
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" )
486
482
idx2 = Index (range (5 ), name = "idx2" , dtype = "int64" )
487
483
idx = MultiIndex .from_arrays ([idx1 , idx2 ])
488
- assert idx .levels [0 ].unit == "us"
489
484
df = DataFrame (
490
485
{"a" : np .arange (5 , dtype = "int64" ), "b" : ["A" , "B" , "C" , "D" , "E" ]},
491
486
index = idx ,
@@ -508,7 +503,7 @@ def test_reset_index_datetime2(self, tz_naive_fixture):
508
503
idx1 = date_range ("1/1/2011" , periods = 5 , freq = "D" , tz = tz , name = "idx1" )
509
504
idx2 = Index (range (5 ), name = "idx2" , dtype = "int64" )
510
505
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"
512
507
)
513
508
idx = MultiIndex .from_arrays ([idx1 , idx2 , idx3 ])
514
509
df = DataFrame (
@@ -532,7 +527,7 @@ def test_reset_index_datetime2(self, tz_naive_fixture):
532
527
def test_reset_index_datetime3 (self , tz_naive_fixture ):
533
528
# GH#7793
534
529
tz = tz_naive_fixture
535
- dti = date_range ("20130101" , periods = 3 , tz = tz , unit = "us" )
530
+ dti = date_range ("20130101" , periods = 3 , tz = tz )
536
531
idx = MultiIndex .from_product ([["a" , "b" ], dti ])
537
532
df = DataFrame (
538
533
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():
700
695
def test_reset_index_multiindex_nat ():
701
696
# GH 11479
702
697
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 )
704
699
df = DataFrame ({"id" : idx , "tstamp" : tstamp , "a" : list ("abc" )})
705
700
df .loc [2 , "tstamp" ] = pd .NaT
706
701
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
+ )
707
705
expected = DataFrame (
708
706
{"id" : range (3 ), "a" : list ("abc" )},
709
- index = pd . DatetimeIndex ([ "2015-07-01" , "2015-07-02" , "NaT" ], name = "tstamp" ) ,
707
+ index = dti ,
710
708
)
711
709
tm .assert_frame_equal (result , expected )
712
710
0 commit comments