locale

How to make that f"…" string formatting uses comma instead of dot as decimal separator?

How to make that f"…" string formatting uses comma instead of dot as decimal separator? Question: I tried: import locale print(locale.locale_alias) locale.setlocale(locale.LC_ALL, ”) locale.setlocale(locale.LC_NUMERIC, "french") print(f"{3.14:.2f}") but the output is 3.14 whereas I would like 3,14. How to do this with f"…" string formatting? Note: I don’t want to use .replace(".", ",") Note: I’m looking …

Total answers: 3

icu: Sort strings based on 2 different locales

icu: Sort strings based on 2 different locales Question: As you probably know, the order of alphabet in some (maybe most) languages is different than their order in Unicode. That’s why we may want to use icu.Collator to sort, like this Python example: from icu import Collator, Locale collator = Collator.createInstance(Locale("fa_IR.UTF-8")) mylist.sort(key=collator.getSortKey) This works perfectly …

Total answers: 4

Django Locale not working after deploying to server [ FIXED ]

Django Locale not working after deploying to server [ FIXED ] Question: when i test it locally the translations do worked, but when I deploy it on a server it doesn’t work. Some of the words do get translated but it’s not from my locale, it’s django’s default translation. In settings.py: MIDDLEWARE = [ ‘django.middleware.security.SecurityMiddleware’, …

Total answers: 2

Sorting pandas dataframe with German Umlaute

Sorting pandas dataframe with German Umlaute Question: I have a dataframe which I want to sort via sort_values on one column. Problem is there are German umlaute as first letter of the words. Like Österreich, Zürich. Which will sort to Zürich, Österreich. It should be sorting Österreich, Zürich. Ö should be between N and O. …

Total answers: 3

Why are Google Colab shell commands not working?

Why are Google Colab shell commands not working? Question: Steps to reproduce: Open new Colab notebook on GPU !ls #works !pip install -q turicreate import turicreate as tc !ls #doesn’t work I get the following error: ————————————————————————— NotImplementedError Traceback (most recent call last) <ipython-input-22-16fdbe588ee8> in <module>() —-> 1 get_ipython().system(‘ls’) 2 # !nvcc –version 2 frames …

Total answers: 2

What is the difference between C.UTF-8 and en_US.UTF-8 locales?

What is the difference between C.UTF-8 and en_US.UTF-8 locales? Question: I’m migrating a Python application from an Ubuntu server with a en_US.UTF-8 locale to a new Debian server which comes with C.UTF-8 already set by default. I’m trying to understand if there could be any impact from this change. Asked By: Marcelo || Source Answers: …

Total answers: 4

display pandas dataframe with european formatting

display pandas dataframe with european formatting Question: I found answers on the question on how to load csv files with european formatting into pandas dataframes and display them in the US format (2,345.21). However how can I display floats saved in the US format in the european format (2.345,21) in pandas. I tried to just …

Total answers: 2

How can I list all available windows locales in python console?

How can I list all available windows locales in python console? Question: On linux we can use locale -a to see the list of locales available. $ locale -a C C.UTF-8 en_US.utf8 POSIX Is it possible to do the same from python console on windows? This can be handy when you try to do locale.setlocale(locale.LC_ALL, …

Total answers: 5

How do I strftime a date object in a different locale?

How do I strftime a date object in a different locale? Question: I have a date object in python and I need to generate a time stamp in the C locale for a legacy system, using the %a (weekday) and %b (month) codes. However I do not wish to change the application’s locale, since other …

Total answers: 3

IPython Notebook locale error

IPython Notebook locale error Question: After installing the latest Mac OSX 64-bit Anaconda Python distribution, I keep getting a ValueError when trying to start the IPython Notebook. Starting ipython works fine: 3-millerc-~:ipython Python 2.7.3 |Anaconda 1.4.0 (x86_64)| (default, Feb 25 2013, 18:45:56) Type “copyright”, “credits” or “license” for more information. IPython 0.13.1 — An enhanced …

Total answers: 4