Skip to content
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

REF: handling of max_colwidth parameter #25977

Closed

Conversation

simonjayhawkins
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

this would be a precursor to fixes for #7059, #9784 and #6491.

getting the display.max_colwidth value is moved from _make_fixed_width to format_array to be consistent with the handling of the column_space, float_format and precision display options.

the PR also includes refactoring of the prior fix to to_html #24841

_format_col is moved from DataFrameFormatter to TableFormatter to make it available to HTMLFormatter and NotebookFormatter.

at the moment _make_fixed_width is called by format_array, but also by _to_str_columns and _get_formatted_index.

_to_str_columns is not an issue because the calls are preceded to calls to format_array

IMO _get_formatted_index needs to be refactored to call format_array directly and probably some additional tests as a precursor to this PR.

thoughts?

cc @TomAugspurger

@jreback jreback added the Output-Formatting __repr__ of pandas objects, to_string label Apr 3, 2019
@jreback
Copy link
Contributor

jreback commented May 12, 2019

can you merge master and update

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, can you add a whatsnew note

pandas/io/formats/format.py Show resolved Hide resolved
@@ -873,6 +875,11 @@ def format_array(values, formatter, float_format=None, na_rep='NaN',
When formatting an Index subclass
(e.g. IntervalIndex._format_native_types), we don't want the
leading space since it should be left-aligned.
max_colwidth: False, int or None, optional, default None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a versionadded tag

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a public function. have added anyway.

@jreback
Copy link
Contributor

jreback commented May 19, 2019

@simonjayhawkins can you rebase and update when possible

@jreback
Copy link
Contributor

jreback commented Jul 3, 2019

@simonjayhawkins whats the status of this?

@simonjayhawkins
Copy link
Member Author

@simonjayhawkins whats the status of this?

still need to do a precursor. checks were passing and i don't think they should have been. so holding as draft unless you'd rather it be closed for now.

@simonjayhawkins can you rebase and update when possible

comments addressed.

looks good, can you add a whatsnew note

this should be a pure refactor. no whatsnew needed?

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine. small comments.

@@ -420,6 +428,24 @@ def _get_formatter(self, i):
i = self.columns[i]
return self.formatters.get(i, None)

def _format_col(self, i: int):
"""
Calls `format_array` for column `i` of truncated DataFrame with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you say positional column i

* int: the maximum width of strings
* None: use display.max_colwidth setting

.. versionadded:: 1.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can just remove the versionadded (or make it 0.25.0)

@WillAyd
Copy link
Member

WillAyd commented Aug 28, 2019

@simonjayhawkins is this still active?

@simonjayhawkins
Copy link
Member Author

can close for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants