'Â always at beginning of string when stored to Dataframe / csv [duplicate]
Goal: prevent  from appearing in Dataframe .csv.
val = f"£{format(r.randint(200, 10000), ',')}"
val = '£' + format(r.randint(200, 10000), ',')
val = str(f"£{format(r.randint(200, 10000), ',')}")
val = str('£' + format(r.randint(200, 10000), ','))
Example Output:
£2,213
Solution 1:[1]
The character £ is Unicode code point U+00A3, which has a two-byte UTF-8 encoding of C2 A3. Your terminal, though, is using a different encoding (e.g. ISO-8859), which treats this as two separate characters, Â and £. You'll need to fix your terminal to use UTF-8 instead to display the text as intended.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | chepner |
