Professional Documents
Culture Documents
P ython is a great language for doing data analysis, primarily because of the fantastic
There are some impor tant math operations that can be per formed on a pandas series to
s=read_csv("stock.csv", squeeze=True)
Function Use
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Got It !
Policy ▲
https://www.geeksforgeeks.org/python-math-operations-for-data-analysis/ 1/9
2/15/22, 6:28 PM Python | Math operations for Data analysis - GeeksforGeeks
Function Use
Data Structures
s.std() Algorithms Interview Preparation
Returns standard deviation of all values Topic-wise Practice C++ Java Python
s.max()
s.idxmax()
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Got It !
Policy ▲
https://www.geeksforgeeks.org/python-math-operations-for-data-analysis/ 2/9
2/15/22, 6:28 PM Python | Math operations for Data analysis - GeeksforGeeks
Function Use
We use cookies to ensure you have the best browsing experience on our website. By using
our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Got It !
Policy ▲
https://www.geeksforgeeks.org/python-math-operations-for-data-analysis/ 3/9
2/15/22, 6:28 PM Python | Math operations for Data analysis - GeeksforGeeks
Function Use
Code #1:
P ython3
https://www.geeksforgeeks.org/python-math-operations-for-data-analysis/ 4/9
2/15/22, 6:28 PM Python | Math operations for Data analysis - GeeksforGeeks
#calculation average
print(s.sum()/s.count())
Start Your Coding Journey Now! Login Register
#using std function
print(s.std())
#using min function
print(s.min())
#using max function
print(s.max())
#using count function
print(s.median())
#using mode function
print(s.mode())
Output :
3012
1006942.0
334.3100929614874
334.3100929614874
173.18720477113115
49.95
782.22
283.315
0 291.21
Code #2:
P ython3
https://www.geeksforgeeks.org/python-math-operations-for-data-analysis/ 5/9
2/15/22, 6:28 PM Python | Math operations for Data analysis - GeeksforGeeks
print(s.describe())
#using count function
Start Your Coding Journey Now!
print(s.idxmax()) Login Register
#using idxmin function
print(s.idxmin())
#count of elements having value 3
print(s.value_counts().head(3))
Output :
dtype: float64
count 3012.000000
mean 334.310093
std 173.187205
min 49.950000
25% 218.045000
50% 283.315000
75% 443.000000
max 782.220000
3011
11
291.21 5
288.47 3
194.80 3
1. .sum(), .mean(), .mode(), .median() and other such mathematical operations are
not applicable on string or any other data type than numeric value.
2. .sum() on a string series would give an unexpected output and return a string by
https://www.geeksforgeeks.org/python-math-operations-for-data-analysis/ 6/9
2/15/22, 6:28 PM Python | Math operations for Data analysis - GeeksforGeeks
Like 2
Previous Next
https://www.geeksforgeeks.org/python-math-operations-for-data-analysis/ 7/9