Skip to content

Commit 6f8f8b1

Browse files
committed
document _display_counts_and_dtypes and _get_header_and_spaces
1 parent 669ff38 commit 6f8f8b1

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

pandas/io/formats/info.py

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,33 @@ def _display_counts_and_dtypes(
133133
space_num: int = 0,
134134
) -> None:
135135
"""
136-
Display count and dtype of Series (or of each column of Frame).
136+
Append count and dtype of Series (or of each column of Frame) to `lines`.
137+
138+
Parameters
139+
----------
140+
lines : List[str]
141+
At this stage, this contains the main header and the info table headers.
142+
ids : Index
143+
Series name (or names of DataFrame columns).
144+
dtypes : Series
145+
Series dtype (or dtypes of DataFrame columns).
146+
show_counts : bool
147+
Whether to show non-null counts.
148+
counts : Series
149+
Non-null counts of Series (or of each of DataFrame's columns).
150+
count_temp : str
151+
String that can be formatted to include non-null count.
152+
space_count : int
153+
Number of spaces that count_header should occupy
154+
(including space before `dtypes` column).
155+
space_dtype : int
156+
Number of spaces that `dtypes` column should occupy.
157+
space : int = 0
158+
Number of spaces that `Column` header should occupy
159+
(including space before `non-null count` column).
160+
space_num : int = 0
161+
Number of spaces that ` # ` header should occupy (including space
162+
before `Column` column), only applicable for `DataFrame.info`.
137163
"""
138164
for i, col in enumerate(ids):
139165
dtype = dtypes[i]
@@ -157,12 +183,35 @@ def _get_header_and_spaces(
157183
) -> Tuple[int, str, int]:
158184
"""
159185
Append extra columns (count and type) to header, if applicable.
186+
187+
Parameters
188+
----------
189+
dtypes : Series
190+
Series dtype (or dtypes of DataFrame columns).
191+
space_count : int
192+
Number of spaces that count_header should occupy
193+
(including space before `dtypes` column).
194+
count_header : str
195+
Header that will be printed out above non-null counts in output.
196+
header : str
197+
Current header.
198+
199+
Returns
200+
-------
201+
space_dtype : int
202+
Number of spaces that `dtypes` column should occupy.
203+
header : str
204+
Header with extra columns (count and type) appended.
205+
len_dtype : int
206+
Length of dtype header.
160207
"""
208+
breakpoint()
161209
dtype_header = "Dtype"
162210
len_dtype = len(dtype_header)
163211
max_dtypes = max(len(pprint_thing(k)) for k in dtypes)
164212
space_dtype = max(len_dtype, max_dtypes)
165213
header += _put_str(count_header, space_count) + _put_str(dtype_header, space_dtype)
214+
breakpoint()
166215
return space_dtype, header, len_dtype
167216

168217

0 commit comments

Comments
 (0)