How to set the thousands place separator in pandas read_csv?

Matheus Rocha

I'm reading a csv file like this:

import pandas as pd

arq_pedido = pd.read_csv('Pedido.csv',delimiter=";", encoding = "ISO-8859-1")

I have a ID column (this column is supposed to be an INT column, but in Brazil (Portuguese), thousand's numbers is represented like this: 1.000 instead of 1000. So, my ID column is dfloat64 at the moment.

I have one ID who is 1.908 (1908), and this number shows 1.9080000000000001. How can I transform dfloat64 to int? Or, how can I replace dots (.) for comma (,), to turned that numbers in thousands ones?

James Elderfield

There is a thousands parameter for this. Try,

arq_pedido = pd.read_csv('Pedido.csv', delimiter=";", encoding = "ISO-8859-1", thousands=".")

You may also wish to set decimal="," to handle decimal numbers correcltly.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I parse numbers with thousands separator in pandas read_csv?

How to set thousands separator in Java?

How to set thousands separator in R?

How to show thousands separator for pandas value counts?

How to set a custom separator in pandas to_csv()?

Python pandas read_csv with custom separator

pandas read_csv ignores separator

Customizing the separator in pandas read_csv

How to set a variable when using Pandas' read_csv

How to make separator in pandas read_csv more flexible wrt whitespace, for irregular separators?

How to make separator in pandas read_csv more flexible wrt whitespace, for irregular separators?

Set thousands separator for C printf

Set global thousands separator for echarts

How to insert a comma as a thousands separator in a pandas dataframe column?

Read csv with numeric columns containing thousands separator

pandas read_csv ignore separator in last column

How to read pandas CSV file with comma separator and comma thousand separator

How to force dot on thousands separator?

How to the ISU thousands separator (space) ?

Pandas ignores set encoding in read_csv?

Does pandas support read `set` paramater using read_csv

How to change thousands separator to apostrophe in format string

how to change thousands separator for blank in R plotly?

How to determine Thousands Separator using Format in VBA

read_csv reads \, as a separator

Read in numbers from csv file with point as thousands separator

Pandas read csv with regex separator

pandas read_csv set `dtype` by column index (not name)

pandas read_csv column dtype is set to decimal but converts to string