Skip to content

REF: simplify info.py #36752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4a1a2e7
REF: polymorphism and builder pattern in info
ivanovmg Sep 30, 2020
a3ccb83
TST: adjust expected gap between # and Column
ivanovmg Sep 30, 2020
a5e1136
LINT: remove TYPE_CHECKING import
ivanovmg Sep 30, 2020
401d7d8
TST: add test for empty dataframe info
ivanovmg Oct 1, 2020
6de3eb7
FIX: handle empty dataframe case
ivanovmg Oct 1, 2020
82f9ddc
REF: extract abstract cls BaseInfo and builder
ivanovmg Oct 1, 2020
75d65fb
DOC: fix docstrings
ivanovmg Oct 1, 2020
25d6ac8
REF: de-duplicate line_numbers, columns, dtypes
ivanovmg Oct 1, 2020
7a861dc
CLN: make HEADERS one-liners
ivanovmg Oct 1, 2020
8640fb9
REF: make _initialize_memory_usage staticmethod
ivanovmg Oct 1, 2020
cd676b0
DOC/TYP: add docstrings and type annotations
ivanovmg Oct 1, 2020
5ce8a72
REF: create memory usage string in BaseInfo
ivanovmg Oct 1, 2020
e0a2035
TYP: annotate DataFrameInfo.to_buffer
ivanovmg Oct 2, 2020
3010d6c
REF: rename kwarg null_counts -> show_counts
ivanovmg Oct 2, 2020
238f091
CLN: reuse exceeds_info_cols in show_counts
ivanovmg Oct 2, 2020
ffeff49
REF: extract property exceeds_info_rows
ivanovmg Oct 2, 2020
f160074
DOC: add docstrings in InfoPrinter
ivanovmg Oct 2, 2020
c368a94
CLN: rename counts -> dtype_counts
ivanovmg Oct 2, 2020
43288e1
REF: extract property non_null_counts
ivanovmg Oct 2, 2020
6cb600a
REF: extract method _get_non_null_counts
ivanovmg Oct 2, 2020
01bedfb
REF: generate rows for performance improvement
ivanovmg Oct 2, 2020
5bd4ce1
REF: remove COL_SPACE class attribute
ivanovmg Oct 2, 2020
269c9d7
CLN: drop attribute strcols
ivanovmg Oct 2, 2020
e27021a
CLN: simplify iteration, without unpacking
ivanovmg Oct 2, 2020
d0c1581
CLN: rename _get_* gen functions to _gen_*
ivanovmg Oct 2, 2020
d9c8b7c
CLN: avoid unpacking in for loop
ivanovmg Oct 2, 2020
5bdb1b1
REF: replace setter with initializer function
ivanovmg Oct 2, 2020
05c8a02
REF: eliminate dep of TableBuilder on InfoPrinter
ivanovmg Oct 2, 2020
d8f27f2
CLN: use yield from in _gen_rows
ivanovmg Oct 2, 2020
36d9171
DOC: add docstrings to abstract properties
ivanovmg Oct 2, 2020
a0eb9ac
Merge branch 'master' into refactor/info-polymorphism
ivanovmg Oct 3, 2020
fb5c0e4
REF: remove method for verbose builder selection
ivanovmg Oct 7, 2020
a41b04d
REF: parametrize verbose table builders
ivanovmg Oct 7, 2020
1f0c410
REF: move static method to module level function
ivanovmg Oct 7, 2020
171d028
CLN: rename mem_usage -> memory_usage_bytes
ivanovmg Oct 7, 2020
c4c002e
DOC: add docstrings to iterator funcs
ivanovmg Oct 7, 2020
3e5ecda
Merge branch 'master' into refactor/info-polymorphism
ivanovmg Oct 7, 2020
92c7754
PERF: property gross_column_widths to attribute
ivanovmg Oct 7, 2020
5fe1cd7
TYP: attribute gross_column_widths
ivanovmg Oct 7, 2020
fbd7fda
Merge branch 'master' into refactor/info-polymorphism
ivanovmg Oct 17, 2020
70c6e22
Merge branch 'master' into refactor/info-polymorphism
ivanovmg Oct 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2604,7 +2604,7 @@ def to_html(
DataFrame.memory_usage: Memory usage of DataFrame columns."""
),
)
@doc(DataFrameInfo.info)
@doc(DataFrameInfo.to_buffer)
def info(
self,
verbose: Optional[bool] = None,
Expand All @@ -2613,9 +2613,16 @@ def info(
memory_usage: Optional[Union[bool, str]] = None,
null_counts: Optional[bool] = None,
) -> None:
return DataFrameInfo(
self, verbose, buf, max_cols, memory_usage, null_counts
).info()
info = DataFrameInfo(
data=self,
memory_usage=memory_usage,
)
info.to_buffer(
buf=buf,
max_cols=max_cols,
verbose=verbose,
show_counts=null_counts,
)

def memory_usage(self, index=True, deep=False) -> Series:
"""
Expand Down
Loading