Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Data Science by (17.6k points)

I've been working with data imported from a CSV. Pandas changed some columns to float, so now the numbers in these columns get displayed as floating points! However, I need them to be displayed as integers, or, without comma. Is there a way to convert them to integers or not display the comma?

1 Answer

0 votes
by (41.4k points)

To modify the float output do this:

df= pd.DataFrame(range(5), columns=['a'])

df.a = df.a.astype(float)

df

Out[33]:

          a

0 0.0000000

1 1.0000000

2 2.0000000

3 3.0000000

4 4.0000000

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

df

Out[35]:

   a

0  0

1  1

2  2

3  3

4  4

If you wish to learn more about Data Science, then check out this Data Science tutorial for more insight.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...