@@ -411,7 +411,14 @@ def test_pivot_no_values(self):
411
411
res = df .pivot_table (index = df .index .month , columns = df .index .day )
412
412
413
413
exp_columns = MultiIndex .from_tuples ([("A" , 1 ), ("A" , 2 )])
414
- exp = DataFrame ([[2.5 , 4.0 ], [2.0 , np .nan ]], index = [1 , 2 ], columns = exp_columns )
414
+ exp_columns = exp_columns .set_levels (
415
+ exp_columns .levels [1 ].astype (np .int32 ), level = 1
416
+ )
417
+ exp = DataFrame (
418
+ [[2.5 , 4.0 ], [2.0 , np .nan ]],
419
+ index = Index ([1 , 2 ], dtype = np .int32 ),
420
+ columns = exp_columns ,
421
+ )
415
422
tm .assert_frame_equal (res , exp )
416
423
417
424
df = DataFrame (
@@ -424,7 +431,9 @@ def test_pivot_no_values(self):
424
431
res = df .pivot_table (index = df .index .month , columns = Grouper (key = "dt" , freq = "M" ))
425
432
exp_columns = MultiIndex .from_tuples ([("A" , pd .Timestamp ("2011-01-31" ))])
426
433
exp_columns .names = [None , "dt" ]
427
- exp = DataFrame ([3.25 , 2.0 ], index = [1 , 2 ], columns = exp_columns )
434
+ exp = DataFrame (
435
+ [3.25 , 2.0 ], index = Index ([1 , 2 ], dtype = np .int32 ), columns = exp_columns
436
+ )
428
437
tm .assert_frame_equal (res , exp )
429
438
430
439
res = df .pivot_table (
@@ -1604,7 +1613,7 @@ def test_pivot_dtaccessor(self):
1604
1613
expected = DataFrame (
1605
1614
{7 : [0 , 3 ], 8 : [1 , 4 ], 9 : [2 , 5 ]},
1606
1615
index = exp_idx ,
1607
- columns = Index ([7 , 8 , 9 ], name = "dt1" ),
1616
+ columns = Index ([7 , 8 , 9 ], dtype = np . int32 , name = "dt1" ),
1608
1617
)
1609
1618
tm .assert_frame_equal (result , expected )
1610
1619
@@ -1614,8 +1623,8 @@ def test_pivot_dtaccessor(self):
1614
1623
1615
1624
expected = DataFrame (
1616
1625
{7 : [0 , 3 ], 8 : [1 , 4 ], 9 : [2 , 5 ]},
1617
- index = Index ([1 , 2 ], name = "dt2" ),
1618
- columns = Index ([7 , 8 , 9 ], name = "dt1" ),
1626
+ index = Index ([1 , 2 ], dtype = np . int32 , name = "dt2" ),
1627
+ columns = Index ([7 , 8 , 9 ], dtype = np . int32 , name = "dt1" ),
1619
1628
)
1620
1629
tm .assert_frame_equal (result , expected )
1621
1630
@@ -1627,10 +1636,16 @@ def test_pivot_dtaccessor(self):
1627
1636
)
1628
1637
1629
1638
exp_col = MultiIndex .from_arrays (
1630
- [[7 , 7 , 8 , 8 , 9 , 9 ], [1 , 2 ] * 3 ], names = ["dt1" , "dt2" ]
1639
+ [
1640
+ np .array ([7 , 7 , 8 , 8 , 9 , 9 ], dtype = np .int32 ),
1641
+ np .array ([1 , 2 ] * 3 , dtype = np .int32 ),
1642
+ ],
1643
+ names = ["dt1" , "dt2" ],
1631
1644
)
1632
1645
expected = DataFrame (
1633
- np .array ([[0 , 3 , 1 , 4 , 2 , 5 ]], dtype = "int64" ), index = [2013 ], columns = exp_col
1646
+ np .array ([[0 , 3 , 1 , 4 , 2 , 5 ]], dtype = "int64" ),
1647
+ index = Index ([2013 ], dtype = np .int32 ),
1648
+ columns = exp_col ,
1634
1649
)
1635
1650
tm .assert_frame_equal (result , expected )
1636
1651
0 commit comments