Skip to content

Conversation

mzeitlin11
Copy link
Member

This is a regression caused by #38759

@mzeitlin11 mzeitlin11 added Output-Formatting __repr__ of pandas objects, to_string Regression Functionality that used to work in a prior pandas version labels Apr 9, 2021
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, ping on green.

- Fixed regression in :meth:`DataFrame.where` not returning a copy in the case of an all True condition (:issue:`39595`)
- Fixed regression in :meth:`DataFrame.replace` raising ``IndexError`` when ``regex`` was a multi-key dictionary (:issue:`39338`)
-
- Fixed regression in repr of floats in an ``object`` column not respecting ``float_format`` (:issue:`40024`)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this only for to_html? or more generally?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess also console repr (so mention these 2). doesn't affect, csv for example, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep it affects to_html and console repr.

In theory we might want this to affect to_csv, but this doesn't change behavior right now because formatting is handled based on column dtype, such that float_format doesn't get used for object dtype columns even if some values in that column are floats.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also affects to_latex, but not to_json

Copy link
Contributor

Choose a reason for hiding this comment

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

ok pls list those and add a test for to_latex if you can

Copy link
Member Author

Choose a reason for hiding this comment

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

Have updated whatsnew and added to_latex test

@jreback jreback added this to the 1.2.4 milestone Apr 9, 2021
Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @mzeitlin11 lgtm

df = DataFrame(data={"x": [1000.0, "test"]})
result = df.to_html(float_format=lambda x: f"{x:,.0f}")
expected = """<table border="1" class="dataframe">
<thead>
Copy link
Member

Choose a reason for hiding this comment

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

the expected html should be in a file, but I see #36690 slipped through #36690 (comment) so OK to leave as follow-up

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, thanks that's good to know. Will make a follow-up fixing that

- Fixed regression in :meth:`DataFrame.where` not returning a copy in the case of an all True condition (:issue:`39595`)
- Fixed regression in :meth:`DataFrame.replace` raising ``IndexError`` when ``regex`` was a multi-key dictionary (:issue:`39338`)
-
- Fixed regression in repr of floats in an ``object`` column not respecting ``float_format`` when printed in the console or outputted through :meth:`DataFrame.to_html` and :meth:`DataFrame.to_latex` (:issue:`40024`)
Copy link
Member

Choose a reason for hiding this comment

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

and also to_string?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, have added reference to that as well

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @mzeitlin11

@simonjayhawkins simonjayhawkins merged commit d999e82 into pandas-dev:master Apr 11, 2021
@simonjayhawkins
Copy link
Member

Thanks @mzeitlin11

@simonjayhawkins
Copy link
Member

@meeseeksdev backport 1.2.x

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 Regression Functionality that used to work in a prior pandas version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Calling to_html with float_format strips all trailing zeros if an integer string is returned from the formatter

3 participants