@@ -1146,7 +1146,8 @@ def test_setitem_frame_mixed(self, float_string_frame):
1146
1146
f .loc [key ] = piece
1147
1147
tm .assert_almost_equal (f .loc [f .index [0 :2 ], ["A" , "B" ]].values , piece .values )
1148
1148
1149
- # rows unaligned
1149
+ def test_setitem_frame_mixed_rows_unaligned (self , float_string_frame ):
1150
+ # GH#3216 rows unaligned
1150
1151
f = float_string_frame .copy ()
1151
1152
piece = DataFrame (
1152
1153
[[1.0 , 2.0 ], [3.0 , 4.0 ], [5.0 , 6.0 ], [7.0 , 8.0 ]],
@@ -1159,7 +1160,8 @@ def test_setitem_frame_mixed(self, float_string_frame):
1159
1160
f .loc [f .index [0 :2 :], ["A" , "B" ]].values , piece .values [0 :2 ]
1160
1161
)
1161
1162
1162
- # key is unaligned with values
1163
+ def test_setitem_frame_mixed_key_unaligned (self , float_string_frame ):
1164
+ # GH#3216 key is unaligned with values
1163
1165
f = float_string_frame .copy ()
1164
1166
piece = f .loc [f .index [:2 ], ["A" ]]
1165
1167
piece .index = f .index [- 2 :]
@@ -1168,7 +1170,8 @@ def test_setitem_frame_mixed(self, float_string_frame):
1168
1170
piece ["B" ] = np .nan
1169
1171
tm .assert_almost_equal (f .loc [f .index [- 2 :], ["A" , "B" ]].values , piece .values )
1170
1172
1171
- # ndarray
1173
+ def test_setitem_frame_mixed_ndarray (self , float_string_frame ):
1174
+ # GH#3216 ndarray
1172
1175
f = float_string_frame .copy ()
1173
1176
piece = float_string_frame .loc [f .index [:2 ], ["A" , "B" ]]
1174
1177
key = (f .index [slice (- 2 , None )], ["A" , "B" ])
@@ -1471,28 +1474,14 @@ def test_loc_setitem_datetimeindex_tz(self, idxer, tz_naive_fixture):
1471
1474
result .loc [:, idxer ] = expected
1472
1475
tm .assert_frame_equal (result , expected )
1473
1476
1474
- def test_at_time_between_time_datetimeindex (self ):
1477
+ def test_loc_setitem_time_key (self ):
1475
1478
index = date_range ("2012-01-01" , "2012-01-05" , freq = "30min" )
1476
1479
df = DataFrame (np .random .randn (len (index ), 5 ), index = index )
1477
1480
akey = time (12 , 0 , 0 )
1478
1481
bkey = slice (time (13 , 0 , 0 ), time (14 , 0 , 0 ))
1479
1482
ainds = [24 , 72 , 120 , 168 ]
1480
1483
binds = [26 , 27 , 28 , 74 , 75 , 76 , 122 , 123 , 124 , 170 , 171 , 172 ]
1481
1484
1482
- result = df .at_time (akey )
1483
- expected = df .loc [akey ]
1484
- expected2 = df .iloc [ainds ]
1485
- tm .assert_frame_equal (result , expected )
1486
- tm .assert_frame_equal (result , expected2 )
1487
- assert len (result ) == 4
1488
-
1489
- result = df .between_time (bkey .start , bkey .stop )
1490
- expected = df .loc [bkey ]
1491
- expected2 = df .iloc [binds ]
1492
- tm .assert_frame_equal (result , expected )
1493
- tm .assert_frame_equal (result , expected2 )
1494
- assert len (result ) == 12
1495
-
1496
1485
result = df .copy ()
1497
1486
result .loc [akey ] = 0
1498
1487
result = result .loc [akey ]
@@ -1529,26 +1518,11 @@ def test_loc_getitem_index_namedtuple(self):
1529
1518
result = df .loc [IndexType ("foo" , "bar" )]["A" ]
1530
1519
assert result == 1
1531
1520
1532
- @pytest .mark .parametrize (
1533
- "tpl" ,
1534
- [
1535
- (1 ,),
1536
- (
1537
- 1 ,
1538
- 2 ,
1539
- ),
1540
- ],
1541
- )
1521
+ @pytest .mark .parametrize ("tpl" , [(1 ,), (1 , 2 )])
1542
1522
def test_loc_getitem_index_single_double_tuples (self , tpl ):
1543
1523
# GH 20991
1544
1524
idx = Index (
1545
- [
1546
- (1 ,),
1547
- (
1548
- 1 ,
1549
- 2 ,
1550
- ),
1551
- ],
1525
+ [(1 ,), (1 , 2 )],
1552
1526
name = "A" ,
1553
1527
tupleize_cols = False ,
1554
1528
)
0 commit comments