How to use the humanize.intword function in humanize

To help you get started, we’ve selected a few humanize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github artyshko / smd / GUI / spotify.py View on Github external
def getUserArtistsPrev(self):

            user_top_artists = self.__client.current_user_followed_artists(
                limit=50
            )
            
            artists = []

            for artist in user_top_artists['artists']['items']:

                followers = humanize.intword(artist['followers']['total'])
                followers_comma = humanize.intcomma(artist['followers']['total'])

                if str(followers).isdigit():

                    followers = followers_comma

                try:

                    data = {
                        'spotify':artist['external_urls']['spotify'],
                        'uri':artist['uri'],
                        'id':artist['id'],
                        'name':artist['name'],
                        'image':artist['images'][0]['url'],
                        'popularity':artist['popularity'],
                        'followers':artist['followers']['total'],
github RDCH106 / pycoinmon / pycoinmon / common.py View on Github external
tabulated_data = []
    tabulated_data.append(copy.copy(fields))   # Headers in position 0

    pos = 0
    for header in tabulated_data[0]:   # Headers in position 0
        good_header = difflib.get_close_matches(header, fields_good_name.keys())[0]
        tabulated_data[0][pos] = fields_good_name[good_header]
        if good_header in ['price', 'market_cap']:
            tabulated_data[0][pos] = tabulated_data[0][pos].replace('USD', currency)
        pos += 1

    for item in data:
        tab_item = []
        for field in fields:
            if humanize and re.search('market_cap*', field):
                tab_item.append(intword(int(float(item[field]))))
            else:
                tab_item.append(item[field])
        tabulated_data.append(copy.copy(tab_item))

    return tabulated_data
github pybel / pybel / src / pybel / struct / summary / supersummary.py View on Github external
def edges(
    graph: BELGraph,
    *,
    examples: bool = True,
    minimum: Optional[int] = None,
    file: Optional[TextIO] = None,
) -> None:
    """Print a summary of the edges in the graph."""
    df = edge_table_df(graph, examples=examples, minimum=minimum)
    headers = list(df.columns)
    headers[0] += ' ({})'.format(intword(len(df.index)))
    print(tabulate(df.values, headers=headers), file=file)
github online-pol-ads / FacebookApiPolAdsCollector / ad_screener_backend / app.py View on Github external
def humanize_int(i):
    """Format numbers for easier readability. Numbers over 1 million are comma formatted, numbers
    over 1 million will be formatted like "1.2 million"

    Args:
        i: int to format.
    Returns:
        string of formatted number.
    """
    if i < 1000000:
        return humanize.intcomma(i)
    return humanize.intword(i)
github evepraisal / python-evepraisal / evepraisal.py View on Github external
def format_isk_human(value):
    if value is None:
        return ""
    try:
        return "%s ISK" % humanize.intword(value, format='%.2f')
    except:
        return str(value)
github gil9red / SimplePyScripts / humanize__examples / integer__humanization.py View on Github external
# SOURCE: https://github.com/jmoiron/humanize


# pip install humanize
import humanize


# Integer humanization:
print(humanize.intcomma(12345))      # '12,345'
print(humanize.intcomma(123456789))  # '123,456,789'
print()

print(humanize.intword(123455913))      # '123.5 million'
print(humanize.intword(12345591313))    # '12.3 billion'
print(humanize.intword(1339014900000))  # '1.3 trillion'
print()

print(humanize.apnumber(4))   # 'four'
print(humanize.apnumber(7))   # 'seven'
print(humanize.apnumber(41))  # '41'
github csvsoundsystem / federal-treasury-api / twitter / tweetbot.py View on Github external
def human_number(num):
    n = humanize.intword(int(math.ceil(num))).lower()
    if re.search(r"^(\d+)\.0 ([A-Za-z]+)$", n):
        m = re.search(r"^(\d+)\.0 ([A-Za-z]+)$", n)
        n = m.group(1) + " " + m.group(2)
    return n