gpt4 book ai didi

python - 印度逗号样式的 Pandas 数据框输出

转载 作者:行者123 更新时间:2023-12-02 09:25:08 24 4
gpt4 key购买 nike

我已遵循 https://codereview.stackexchange.com/questions/148853/convert-an-amount-to-indian-notation 中给出的提示

能够以印度逗号格式显示数字,其中使用以下命令将 123456789 显示为 1,23,34,56,789:

print("INR {}".format(currency_in_indian_format(123456789))).

但是,我无法扩展此功能以显示 pandas 数据框中的所有值。有什么方法可以通过修改命令来完成此操作:

pd.options.display.float_format = '{:,.3f}'.format 

最佳答案

如果是印度卢比,请使用:

from babel.numbers import format_currency
print(format_currency(123456789, 'INR', locale='en_IN').replace(u'\xa0', u' '))

输出:

₹ 12,34,56,789.00

注意 - 您的预期输出中数字 3 重复两次,因此与我的不匹配。

关于python - 印度逗号样式的 Pandas 数据框输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54498898/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com