w3resource

Pandas Data Series: Create the mean and standard deviation of the data of a given Series

Pandas: Data Series Exercise-15 with Solution

Write a Pandas program to create the mean and standard deviation of the data of a given Series.

Sample Solution :

Python Code :

import pandas as pd
s = pd.Series(data = [1,2,3,4,5,6,7,8,9,5,3])
print("Original Data Series:")
print(s)
print("Mean of the said Data Series:")
print(s.mean())
print("Standard deviation of the said Data Series:")
print(s.std())

Sample Output:

Original Data Series:
0     1
1     2
2     3
3     4
4     5
5     6
6     7
7     8
8     9
9     5
10    3
dtype: int64
Mean of the said Data Series:
4.818181818181818
Standard deviation of the said Data Series:
2.522624895547565                 

Python Code Editor:


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Pandas program to change the order of index of a given series.
Next: Write a Pandas program to get the items of a given series not present in another given series.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz



Python: Tips of the Day

Returns a list with n elements removed from the beginning

Example:

def tips_take(itr, n = 1):
  return itr[:n]
print(tips_take([1, 2, 3], 5))
print(tips_take([1, 2, 3], 0))

Output:

[1, 2, 3]
[]