MCPcopy
hub / github.com/pandas-dev/pandas / test_info_max_cols

Function test_info_max_cols

pandas/tests/frame/methods/test_info.py:284–315  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

282
283
284def test_info_max_cols():
285 df = DataFrame(np.random.default_rng(2).standard_normal((10, 5)))
286 for len_, verbose in [(5, None), (5, False), (12, True)]:
287 # For verbose always ^ setting ^ summarize ^ full output
288 with option_context("max_info_columns", 4):
289 buf = StringIO()
290 df.info(buf=buf, verbose=verbose)
291 res = buf.getvalue()
292 assert len(res.strip().split("\n")) == len_
293
294 for len_, verbose in [(12, None), (5, False), (12, True)]:
295 # max_cols not exceeded
296 with option_context("max_info_columns", 5):
297 buf = StringIO()
298 df.info(buf=buf, verbose=verbose)
299 res = buf.getvalue()
300 assert len(res.strip().split("\n")) == len_
301
302 for len_, max_cols in [(12, 5), (5, 4)]:
303 # setting truncates
304 with option_context("max_info_columns", 4):
305 buf = StringIO()
306 df.info(buf=buf, max_cols=max_cols)
307 res = buf.getvalue()
308 assert len(res.strip().split("\n")) == len_
309
310 # setting wouldn't truncate
311 with option_context("max_info_columns", 5):
312 buf = StringIO()
313 df.info(buf=buf, max_cols=max_cols)
314 res = buf.getvalue()
315 assert len(res.strip().split("\n")) == len_
316
317
318def test_info_memory_usage():

Callers

nothing calls this directly

Calls 5

infoMethod · 0.95
DataFrameClass · 0.90
option_contextFunction · 0.90
splitMethod · 0.80
stripMethod · 0.80

Tested by

no test coverage detected