Skip to content

Fix Styler._translate failing on numeric columns #12126

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

Closed
wants to merge 1 commit into from

Conversation

HHammond
Copy link
Contributor

Addresses #12125.

The previous behaviour was to use a __getitem__ lookup which caused incorrect behaviour with numeric columns. The adjusted code uses iloc numerical indexing to resolve the issue.

@jreback
Copy link
Contributor

jreback commented Jan 24, 2016

tests!

and u can use .iloc[r, c]

@HHammond
Copy link
Contributor Author

I'm working on the tests right now, just trying to figure out the best way to do "doesn't raise error" without comparing it to the output dictionary.

Didn't know about the .iloc[r, c], I'll change it to use that instead.

@HHammond HHammond force-pushed the fix_styler_numeric_cols branch from daf703f to b7501b0 Compare January 24, 2016 06:17
df = pd.DataFrame({0: [1, 2, 3]})
df.style._translate()

self.assertTrue(True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this the best way to assert that the code successfully ran without error?

Copy link
Contributor

Choose a reason for hiding this comment

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

no just put a comment that this is a smoke test

if an exception is raised the test fails

@HHammond HHammond force-pushed the fix_styler_numeric_cols branch 2 times, most recently from 895a18b to b31619c Compare January 24, 2016 06:28
@HHammond HHammond force-pushed the fix_styler_numeric_cols branch from b31619c to eb0acac Compare January 24, 2016 06:29
@TomAugspurger
Copy link
Contributor

I've got a branch that changes the template and translate around a bit to be cleaner. I'll push that later today when I'm at a computer and see how it messes up yourPR here.

@HHammond
Copy link
Contributor Author

Let me know what happens and I'll rebase form your PR if this still exists.

@HHammond
Copy link
Contributor Author

It might be worth keeping the test case anyway.

@jreback jreback added Bug Output-Formatting __repr__ of pandas objects, to_string IO HTML read_html, to_html, Styler.apply, Styler.applymap labels Jan 24, 2016
@jreback jreback changed the title Fix Styler._translate failing on numeric columns Fix Styler._translate failing on numeric columns Jan 24, 2016
@TomAugspurger
Copy link
Contributor

@HHammond I have got that change included on this branch. I've cherry-picked your test, thanks. I should have that branch wrapped up sometime this week.

@HHammond
Copy link
Contributor Author

Sounds good. Is it time to close this PR?

@TomAugspurger
Copy link
Contributor

Sure, we'll leave the issue open though. Thanks.

TomAugspurger added a commit to TomAugspurger/pandas that referenced this pull request Feb 7, 2016
Closes pandas-dev#11692
Closes pandas-dev#12134
Closes pandas-dev#12125

This adds a `.format` method to Styler for formatting the display value
(the actual text) of each scalar value.

In the processes of cleaning up the template, I close pandas-dev#12134 (spurious 0)
and pandas-dev#12125 (KeyError from using iloc improperly)

cherry pick test from pandas-dev#12126

only allow str formatting for now

fix tests for new spec

formatter callable

update notebook
TomAugspurger added a commit to TomAugspurger/pandas that referenced this pull request Feb 12, 2016
Closes pandas-dev#11692
Closes pandas-dev#12134
Closes pandas-dev#12125

This adds a `.format` method to Styler for formatting the display value
(the actual text) of each scalar value.

In the processes of cleaning up the template, I close pandas-dev#12134 (spurious 0)
and pandas-dev#12125 (KeyError from using iloc improperly)

cherry pick test from pandas-dev#12126

only allow str formatting for now

fix tests for new spec

formatter callable

update notebook
HHammond pushed a commit to HHammond/pandas that referenced this pull request Feb 13, 2016
Closes pandas-dev#11692
Closes pandas-dev#12134
Closes pandas-dev#12125

This adds a `.format` method to Styler for formatting the display value
(the actual text) of each scalar value.

In the processes of cleaning up the template, I close pandas-dev#12134 (spurious 0)
and pandas-dev#12125 (KeyError from using iloc improperly)

cherry pick test from pandas-dev#12126

only allow str formatting for now

fix tests for new spec

formatter callable

update notebook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO HTML read_html, to_html, Styler.apply, Styler.applymap Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants