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

fix(python): Remove default red formatting for negative floats in write_excel #17646

Closed
wants to merge 1 commit into from

Conversation

mcrumiller
Copy link
Contributor

@mcrumiller mcrumiller commented Jul 15, 2024

Closes #17624 if it's accepted. @alexander-beedie.

Quick check as this isn't really worth testing:

from datetime import date

import polars as pl

# Create a Pandas dataframe with some sample data.
df = pl.DataFrame(
    {
        "Dates": [date(2023, 1, 1), date(2023, 1, 2), date(2023, 1, 3)],
        "Strings": ["Alice", "Bob", "Carol"],
        "Numbers": [0.12345, 100, -99.523],
    }
)

df.write_excel(workbook="polars_format_default.xlsx")

Result:
image

@github-actions github-actions bot added fix Bug fix python Related to Python Polars labels Jul 15, 2024
@mcrumiller mcrumiller changed the title fix(python): Remove default red formatting from float in write_excel fix(python): Remove default red formatting for negative floats in write_excel Jul 15, 2024
Copy link

codecov bot commented Jul 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.69%. Comparing base (8bad2fd) to head (2557cb2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17646      +/-   ##
==========================================
- Coverage   80.69%   80.69%   -0.01%     
==========================================
  Files        1485     1485              
  Lines      195485   195485              
  Branches     2782     2782              
==========================================
- Hits       157747   157745       -2     
- Misses      37226    37228       +2     
  Partials      512      512              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexander-beedie
Copy link
Collaborator

alexander-beedie commented Jul 17, 2024

I've just closed the linked Issue as "not planned" - we should have sensible/useful default formatting. It's a nice balance of minimal/clean, and actually helpful.

Red is the default colour for negative values in all of Excel's default styles (the ones that actually apply a colour), so this is consistent with expectations/experience 👍

It's also already simple to strip the default formatting in favour of "General" if that's what somebody really wants (for most users it isn't 🙃):

df.write_excel(column_formats={cs.all(): "General"})
df.write_excel(column_formats={cs.numeric(): "General"})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

write_excel treats all numeric data as 'Currency' format
2 participants