@@ -1283,87 +1283,56 @@ def test_constructor_manager_resize(self):
1283
1283
1284
1284
def test_constructor_from_items (self ):
1285
1285
items = [(c , self .frame [c ]) for c in self .frame .columns ]
1286
- with tm .assert_produces_warning (FutureWarning ,
1287
- check_stacklevel = False ):
1288
- recons = DataFrame .from_items (items )
1286
+ recons = DataFrame .from_items (items )
1289
1287
tm .assert_frame_equal (recons , self .frame )
1290
1288
1291
1289
# pass some columns
1292
- with tm .assert_produces_warning (FutureWarning ,
1293
- check_stacklevel = False ):
1294
- recons = DataFrame .from_items (items , columns = ['C' , 'B' , 'A' ])
1290
+ recons = DataFrame .from_items (items , columns = ['C' , 'B' , 'A' ])
1295
1291
tm .assert_frame_equal (recons , self .frame .loc [:, ['C' , 'B' , 'A' ]])
1296
1292
1297
1293
# orient='index'
1298
1294
1299
1295
row_items = [(idx , self .mixed_frame .xs (idx ))
1300
1296
for idx in self .mixed_frame .index ]
1301
- with tm .assert_produces_warning (FutureWarning ,
1302
- check_stacklevel = False ):
1303
- recons = DataFrame .from_items (row_items ,
1304
- columns = self .mixed_frame .columns ,
1305
- orient = 'index' )
1297
+ recons = DataFrame .from_items (row_items ,
1298
+ columns = self .mixed_frame .columns ,
1299
+ orient = 'index' )
1306
1300
tm .assert_frame_equal (recons , self .mixed_frame )
1307
1301
assert recons ['A' ].dtype == np .float64
1308
1302
1309
1303
with tm .assert_raises_regex (TypeError ,
1310
1304
"Must pass columns with "
1311
1305
"orient='index'" ):
1312
- with tm .assert_produces_warning (FutureWarning ,
1313
- check_stacklevel = False ):
1314
- DataFrame .from_items (row_items , orient = 'index' )
1306
+ DataFrame .from_items (row_items , orient = 'index' )
1315
1307
1316
1308
# orient='index', but thar be tuples
1317
1309
arr = construct_1d_object_array_from_listlike (
1318
1310
[('bar' , 'baz' )] * len (self .mixed_frame ))
1319
1311
self .mixed_frame ['foo' ] = arr
1320
1312
row_items = [(idx , list (self .mixed_frame .xs (idx )))
1321
1313
for idx in self .mixed_frame .index ]
1322
- with tm .assert_produces_warning (FutureWarning ,
1323
- check_stacklevel = False ):
1324
- recons = DataFrame .from_items (row_items ,
1325
- columns = self .mixed_frame .columns ,
1326
- orient = 'index' )
1314
+ recons = DataFrame .from_items (row_items ,
1315
+ columns = self .mixed_frame .columns ,
1316
+ orient = 'index' )
1327
1317
tm .assert_frame_equal (recons , self .mixed_frame )
1328
1318
assert isinstance (recons ['foo' ][0 ], tuple )
1329
1319
1330
- with tm .assert_produces_warning (FutureWarning ,
1331
- check_stacklevel = False ):
1332
- rs = DataFrame .from_items ([('A' , [1 , 2 , 3 ]), ('B' , [4 , 5 , 6 ])],
1333
- orient = 'index' ,
1334
- columns = ['one' , 'two' , 'three' ])
1320
+ rs = DataFrame .from_items ([('A' , [1 , 2 , 3 ]), ('B' , [4 , 5 , 6 ])],
1321
+ orient = 'index' ,
1322
+ columns = ['one' , 'two' , 'three' ])
1335
1323
xp = DataFrame ([[1 , 2 , 3 ], [4 , 5 , 6 ]], index = ['A' , 'B' ],
1336
1324
columns = ['one' , 'two' , 'three' ])
1337
1325
tm .assert_frame_equal (rs , xp )
1338
1326
1339
1327
def test_constructor_from_items_scalars (self ):
1340
1328
# GH 17312
1341
1329
with tm .assert_raises_regex (ValueError ,
1342
- r'The value in each \(key, value\) '
1343
- 'pair must be an array, Series, or dict' ):
1344
- with tm .assert_produces_warning (FutureWarning ,
1345
- check_stacklevel = False ):
1346
- DataFrame .from_items ([('A' , 1 ), ('B' , 4 )])
1347
-
1348
- with tm .assert_raises_regex (ValueError ,
1349
- r'The value in each \(key, value\) '
1350
- 'pair must be an array, Series, or dict' ):
1351
- with tm .assert_produces_warning (FutureWarning ,
1352
- check_stacklevel = False ):
1353
- DataFrame .from_items ([('A' , 1 ), ('B' , 2 )], columns = ['col1' ],
1354
- orient = 'index' )
1355
-
1356
- def test_from_items_deprecation (self ):
1357
- # GH 17320
1358
- with tm .assert_produces_warning (FutureWarning ,
1359
- check_stacklevel = False ):
1360
- DataFrame .from_items ([('A' , [1 , 2 , 3 ]), ('B' , [4 , 5 , 6 ])])
1330
+ r'If using all scalar values, '
1331
+ 'you must pass an index' ):
1332
+ DataFrame .from_items ([('A' , 1 ), ('B' , 4 )])
1361
1333
1362
- with tm .assert_produces_warning (FutureWarning ,
1363
- check_stacklevel = False ):
1364
- DataFrame .from_items ([('A' , [1 , 2 , 3 ]), ('B' , [4 , 5 , 6 ])],
1365
- columns = ['col1' , 'col2' , 'col3' ],
1366
- orient = 'index' )
1334
+ DataFrame .from_items ([('A' , 1 ), ('B' , 2 )], columns = ['col1' ],
1335
+ orient = 'index' )
1367
1336
1368
1337
def test_constructor_mix_series_nonseries (self ):
1369
1338
df = DataFrame ({'A' : self .frame ['A' ],
0 commit comments