Skip to content

Commit

Permalink
feat: Add locale support, #47
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Jul 5, 2023
1 parent 32979a7 commit 431d719
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ocdskingfishercolab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import requests
import seaborn as sns
import sql
from babel.numbers import format_decimal
from gspread_dataframe import set_with_dataframe
from IPython import get_ipython
from IPython.display import HTML
Expand Down Expand Up @@ -597,11 +598,13 @@ def set_light_mode():
sns.set_theme()


def format_thousands(axis):
def format_thousands(axis, locale='en_US'):
"""
Use a comma as the thousands separator on the given axis.
Set the thousands separator on the given axis for the given locale, e.g. ``en_US``.
"""
axis.set_major_formatter(matplotlib.ticker.StrMethodFormatter('{x:,.0f}'))
axis.set_major_formatter(
matplotlib.ticker.FuncFormatter(lambda x, p: format_decimal(x, format="#", locale=locale))
)


class OCDSKingfisherColabError(Exception):
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ classifiers =
[options]
packages = find:
install_requires =
babel
flattentool
google-auth
gspread
Expand Down

0 comments on commit 431d719

Please sign in to comment.