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

Function _pprint_seq

pandas/io/formats/printing.py:103–140  ·  view source on GitHub ↗

internal. pprinter for iterables. you should probably use pprint_thing() rather than calling this directly. bounds length of printed sequence, depending on options

(
    seq: ListLike, _nest_lvl: int = 0, max_seq_items: int | None = None, **kwds: Any
)

Source from the content-addressed store, hash-verified

101
102
103def _pprint_seq(
104 seq: ListLike, _nest_lvl: int = 0, max_seq_items: int | None = None, **kwds: Any
105) -> str:
106 """
107 internal. pprinter for iterables. you should probably use pprint_thing()
108 rather than calling this directly.
109
110 bounds length of printed sequence, depending on options
111 """
112 if isinstance(seq, set):
113 fmt = "{{{body}}}"
114 elif isinstance(seq, frozenset):
115 fmt = "frozenset({{{body}}})"
116 else:
117 fmt = "[{body}]" if hasattr(seq, "__setitem__") else "({body})"
118
119 if max_seq_items is False:
120 max_items = None
121 else:
122 max_items = max_seq_items or get_option("max_seq_items") or len(seq)
123
124 s = iter(seq)
125 # handle sets, no slicing
126 r = []
127 max_items_reached = False
128 for i, item in enumerate(s):
129 if (max_items is not None) and (i >= max_items):
130 max_items_reached = True
131 break
132 r.append(pprint_thing(item, _nest_lvl + 1, max_seq_items=max_seq_items, **kwds))
133 body = ", ".join(r)
134
135 if max_items_reached:
136 body += ", ..."
137 elif isinstance(seq, tuple) and len(seq) == 1:
138 body += ","
139
140 return fmt.format(body=body)
141
142
143def _pprint_dict(

Callers 2

pprint_thingFunction · 0.85
format_object_summaryFunction · 0.85

Calls 5

get_optionFunction · 0.90
pprint_thingFunction · 0.85
appendMethod · 0.45
joinMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected