...

/

The round() Function with a Pandas Series

The round() Function with a Pandas Series

Let's find out how the round operator works in pandas.

We'll cover the following...

Try it yourself

Try executing the code below to see the result.

Python 3.5
import pandas as pd
s = pd.Series([-2.5, -1.5, -0.5, 0.5, 1.5, 2.5])
print(s.round())

Explanation

Rounding is easy most of the time. For example, round(1.1) evaluates to 1 and round(1.8) ...