How does the round function work with pandas series?

Pandas series

Pandas series is a one-dimensional array that can hold all types of Python objects. A pandas series is like a column in a table.

class pandas.Series(data=None, index=None, dtype=None, name=None, copy=False, fastpath=False)
Pandas series
#import pandas
import pandas as pd
# Intialize series without index series
s1 = pd.Series([-2.5, -1.5, 1.5, 2.5])
#print Series
print("Series 1:")
print(s1)
# Intialize series with index series
s2 = {'a': 1, 'b': 2, 'c': 3}
ser2 = pd.Series(data=s2, index=['a', 'b', 'c'])
#print Series
print("Series 2:")
print(ser2)

Rounding in pandas series

Rounding is a simple concept. In Round(1.x), if x is less than 5, then it will be 1.0 and if x is greater than 5, then it will be 2.0. However, the main concern is what we do if x is equal to 5. Should we round it up or down?

In such a case, pandas checks for a digit before the decimal point. If it is an odd number, then it rounds up the number and if it is an even number, it rounds down the number. This is called bankers’ rounding.

Working of the Round() function
# import Pandas
import pandas as pd
# Intialize series
s1 =pd.Series([10.5,41.5,52.5,63.5,54.5,55.5,96.5])
# print rounded series
print(s1.round())
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved