@@ -1201,9 +1201,8 @@ def test_pprint_thing(self):
1201
1201
1202
1202
def test_wide_repr (self ):
1203
1203
with option_context ('mode.sim_interactive' , True , 'display.show_dimensions' , True ):
1204
- col = lambda l , k : [tm .rands (k ) for _ in range (l )]
1205
1204
max_cols = get_option ('display.max_columns' )
1206
- df = DataFrame ([ col ( max_cols - 1 , 25 ) for _ in range ( 10 )] )
1205
+ df = DataFrame (tm . rands_array ( 25 , size = ( 10 , max_cols - 1 )) )
1207
1206
set_option ('display.expand_frame_repr' , False )
1208
1207
rep_str = repr (df )
1209
1208
@@ -1227,9 +1226,8 @@ def test_wide_repr_wide_columns(self):
1227
1226
1228
1227
def test_wide_repr_named (self ):
1229
1228
with option_context ('mode.sim_interactive' , True ):
1230
- col = lambda l , k : [tm .rands (k ) for _ in range (l )]
1231
1229
max_cols = get_option ('display.max_columns' )
1232
- df = DataFrame ([ col ( max_cols - 1 , 25 ) for _ in range ( 10 )] )
1230
+ df = DataFrame (tm . rands_array ( 25 , size = ( 10 , max_cols - 1 )) )
1233
1231
df .index .name = 'DataFrame Index'
1234
1232
set_option ('display.expand_frame_repr' , False )
1235
1233
@@ -1249,11 +1247,10 @@ def test_wide_repr_named(self):
1249
1247
1250
1248
def test_wide_repr_multiindex (self ):
1251
1249
with option_context ('mode.sim_interactive' , True ):
1252
- col = lambda l , k : [tm .rands (k ) for _ in range (l )]
1253
- midx = pandas .MultiIndex .from_arrays ([np .array (col (10 , 5 )),
1254
- np .array (col (10 , 5 ))])
1250
+ midx = pandas .MultiIndex .from_arrays (
1251
+ tm .rands_array (5 , size = (2 , 10 )))
1255
1252
max_cols = get_option ('display.max_columns' )
1256
- df = DataFrame ([ col ( max_cols - 1 , 25 ) for _ in range ( 10 )] ,
1253
+ df = DataFrame (tm . rands_array ( 25 , size = ( 10 , max_cols - 1 )) ,
1257
1254
index = midx )
1258
1255
df .index .names = ['Level 0' , 'Level 1' ]
1259
1256
set_option ('display.expand_frame_repr' , False )
@@ -1274,12 +1271,11 @@ def test_wide_repr_multiindex(self):
1274
1271
def test_wide_repr_multiindex_cols (self ):
1275
1272
with option_context ('mode.sim_interactive' , True ):
1276
1273
max_cols = get_option ('display.max_columns' )
1277
- col = lambda l , k : [tm .rands (k ) for _ in range (l )]
1278
- midx = pandas .MultiIndex .from_arrays ([np .array (col (10 , 5 )),
1279
- np .array (col (10 , 5 ))])
1280
- mcols = pandas .MultiIndex .from_arrays ([np .array (col (max_cols - 1 , 3 )),
1281
- np .array (col (max_cols - 1 , 3 ))])
1282
- df = DataFrame ([col (max_cols - 1 , 25 ) for _ in range (10 )],
1274
+ midx = pandas .MultiIndex .from_arrays (
1275
+ tm .rands_array (5 , size = (2 , 10 )))
1276
+ mcols = pandas .MultiIndex .from_arrays (
1277
+ tm .rands_array (3 , size = (2 , max_cols - 1 )))
1278
+ df = DataFrame (tm .rands_array (25 , (10 , max_cols - 1 )),
1283
1279
index = midx , columns = mcols )
1284
1280
df .index .names = ['Level 0' , 'Level 1' ]
1285
1281
set_option ('display.expand_frame_repr' , False )
@@ -1296,9 +1292,8 @@ def test_wide_repr_multiindex_cols(self):
1296
1292
1297
1293
def test_wide_repr_unicode (self ):
1298
1294
with option_context ('mode.sim_interactive' , True ):
1299
- col = lambda l , k : [tm .randu (k ) for _ in range (l )]
1300
1295
max_cols = get_option ('display.max_columns' )
1301
- df = DataFrame ([ col ( max_cols - 1 , 25 ) for _ in range ( 10 )] )
1296
+ df = DataFrame (tm . rands_array ( 25 , size = ( 10 , max_cols - 1 )) )
1302
1297
set_option ('display.expand_frame_repr' , False )
1303
1298
rep_str = repr (df )
1304
1299
set_option ('display.expand_frame_repr' , True )
@@ -1877,30 +1872,31 @@ def test_repr_html(self):
1877
1872
self .reset_display_options ()
1878
1873
1879
1874
def test_repr_html_wide (self ):
1880
- row = lambda l , k : [tm .rands (k ) for _ in range (l )]
1881
1875
max_cols = get_option ('display.max_columns' )
1882
- df = DataFrame ([ row ( max_cols - 1 , 25 ) for _ in range ( 10 )] )
1876
+ df = DataFrame (tm . rands_array ( 25 , size = ( 10 , max_cols - 1 )) )
1883
1877
reg_repr = df ._repr_html_ ()
1884
1878
assert "..." not in reg_repr
1885
1879
1886
- wide_df = DataFrame ([ row ( max_cols + 1 , 25 ) for _ in range ( 10 )] )
1880
+ wide_df = DataFrame (tm . rands_array ( 25 , size = ( 10 , max_cols + 1 )) )
1887
1881
wide_repr = wide_df ._repr_html_ ()
1888
1882
assert "..." in wide_repr
1889
1883
1890
1884
def test_repr_html_wide_multiindex_cols (self ):
1891
- row = lambda l , k : [tm .rands (k ) for _ in range (l )]
1892
1885
max_cols = get_option ('display.max_columns' )
1893
1886
1894
- tuples = list (itertools .product (np .arange (max_cols // 2 ), ['foo' , 'bar' ]))
1895
- mcols = pandas .MultiIndex .from_tuples (tuples , names = ['first' , 'second' ])
1896
- df = DataFrame ([row (len (mcols ), 25 ) for _ in range (10 )], columns = mcols )
1887
+ mcols = pandas .MultiIndex .from_product ([np .arange (max_cols // 2 ),
1888
+ ['foo' , 'bar' ]],
1889
+ names = ['first' , 'second' ])
1890
+ df = DataFrame (tm .rands_array (25 , size = (10 , len (mcols ))),
1891
+ columns = mcols )
1897
1892
reg_repr = df ._repr_html_ ()
1898
1893
assert '...' not in reg_repr
1899
1894
1900
-
1901
- tuples = list (itertools .product (np .arange (1 + (max_cols // 2 )), ['foo' , 'bar' ]))
1902
- mcols = pandas .MultiIndex .from_tuples (tuples , names = ['first' , 'second' ])
1903
- df = DataFrame ([row (len (mcols ), 25 ) for _ in range (10 )], columns = mcols )
1895
+ mcols = pandas .MultiIndex .from_product ((np .arange (1 + (max_cols // 2 )),
1896
+ ['foo' , 'bar' ]),
1897
+ names = ['first' , 'second' ])
1898
+ df = DataFrame (tm .rands_array (25 , size = (10 , len (mcols ))),
1899
+ columns = mcols )
1904
1900
wide_repr = df ._repr_html_ ()
1905
1901
assert '...' in wide_repr
1906
1902
0 commit comments