|
54 | 54 | )
|
55 | 55 |
|
56 | 56 |
|
| 57 | +return_dict_sub = dedent( |
| 58 | + """\ |
| 59 | + return_dict : bool, optional |
| 60 | + Whether to return the summary as a dictionary. If True, the method |
| 61 | + returns a dictionary containing information about the DataFrame. |
| 62 | + If False, the summary is printed and None is returned.""" |
| 63 | +) |
| 64 | + |
| 65 | + |
57 | 66 | frame_examples_sub = dedent(
|
58 | 67 | """\
|
59 | 68 | >>> int_values = [1, 2, 3, 4, 5]
|
|
136 | 145 | 1 column_2 1000000 non-null object
|
137 | 146 | 2 column_3 1000000 non-null object
|
138 | 147 | dtypes: object(3)
|
139 |
| - memory usage: 165.9 MB""" |
| 148 | + memory usage: 165.9 MB |
| 149 | + |
| 150 | + >>> info_dict = df.info(return_dict=True) |
| 151 | + >>> print(info_dict) |
| 152 | + {'Column_summary': '...', 'Memory_usage': 24000128, 'Index_type': 'RangeIndex', 'Index_entries': 1000000}""" |
140 | 153 | )
|
141 | 154 |
|
142 | 155 |
|
|
153 | 166 | "type_sub": " and columns",
|
154 | 167 | "max_cols_sub": frame_max_cols_sub,
|
155 | 168 | "show_counts_sub": show_counts_sub,
|
| 169 | + "return_dict_sub": return_dict_sub, |
156 | 170 | "examples_sub": frame_examples_sub,
|
157 | 171 | "see_also_sub": frame_see_also_sub,
|
158 | 172 | "version_added_sub": "",
|
|
233 | 247 | "type_sub": "",
|
234 | 248 | "max_cols_sub": "",
|
235 | 249 | "show_counts_sub": show_counts_sub,
|
| 250 | + "return_dict_sub": return_dict_sub, |
236 | 251 | "examples_sub": series_examples_sub,
|
237 | 252 | "see_also_sub": series_see_also_sub,
|
238 | 253 | "version_added_sub": "\n.. versionadded:: 1.4.0\n",
|
|
273 | 288 | :ref:`Frequently Asked Questions <df-memory-usage>` for more
|
274 | 289 | details.
|
275 | 290 | {show_counts_sub}
|
276 |
| -
|
| 291 | + {return_dict_sub} |
| 292 | + |
277 | 293 | Returns
|
278 | 294 | -------
|
279 |
| - None |
280 |
| - This method prints a summary of a {klass} and returns None. |
| 295 | + dict or None |
| 296 | + If return_dict is True, returns a dictionary summarizing the {klass}. |
| 297 | + Otherwise, returns None. |
281 | 298 |
|
282 | 299 | See Also
|
283 | 300 | --------
|
@@ -435,7 +452,7 @@ def render(
|
435 | 452 | max_cols: int | None,
|
436 | 453 | verbose: bool | None,
|
437 | 454 | show_counts: bool | None,
|
438 |
| - ) -> None: |
| 455 | + ) -> None | dict: |
439 | 456 | pass
|
440 | 457 |
|
441 | 458 |
|
@@ -524,7 +541,7 @@ def render(
|
524 | 541 | verbose: bool | None,
|
525 | 542 | show_counts: bool | None,
|
526 | 543 | return_dict: bool | None,
|
527 |
| - ) -> None: |
| 544 | + ) -> None | dict: |
528 | 545 | if return_dict:
|
529 | 546 | return self.to_dict()
|
530 | 547 | else:
|
|
0 commit comments