Round columns in pandas dataframe

0 votes

I have got the following pandas data frame

          Y         X id WP_NER
0 35.973496 -2.734554  1  WP_01 
1 35.592138 -2.903913  2  WP_02 
2 35.329853 -3.391070  3  WP_03 
3 35.392608 -3.928513  4  WP_04 
4 35.579265 -3.942995  5  WP_05 
5 35.519728 -3.408771  6  WP_06 
6 35.759485 -3.078903 7 WP_07 

I´d like to round Y and X columns using pandas. How do I do this?

Jul 4 in Python by ana1504.k
• 7,870 points
36 views

1 answer to this question.

0 votes

You can now, use round on dataframe

The code will be:

In [661]: df.round({'Y': 2, 'X': 2})
Out[661]:
       Y     X  id WP_NER
0  35.97 -2.73   1  WP_01
1  35.59 -2.90   2  WP_02
2  35.33 -3.39   3  WP_03
3  35.39 -3.93   4  WP_04
4  35.58 -3.94   5  WP_05
5  35.52 -3.41   6  WP_06
6  35.76 -3.08   7  WP_07
answered Jul 4 by SDeb
• 13,160 points

Related Questions In Python

0 votes
0 answers

how do sort the columns in a dataframe using the pandas?

can you give an example using dataframe? READ MORE

May 6 in Python by Waseem
• 4,480 points
21 views
0 votes
1 answer

How to convert multiple columns to string in pandas dataframe?

Hi, To convert multiple columns to string, include a list of ...READ MORE

answered Jul 18 in Python by Taj
• 1,040 points
72 views
+2 votes
2 answers

How can I replace values with 'none' in a dataframe using pandas

Actually in later versions of pandas this ...READ MORE

answered Aug 13, 2018 in Python by bug_seeker
• 15,350 points
5,753 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 232 views
0 votes
1 answer

df.mul vs df.rmul in Pandas

The documentation is not identical. As stated ...READ MORE

answered Jan 18 in Python by SDeb
• 13,160 points
126 views
0 votes
1 answer

Add one row to pandas DataFrame

You can try the following : >>> import ...READ MORE

answered Mar 1 in Python by SDeb
• 13,160 points
76 views