Computer >> Máy Tính >  >> Lập trình >> Python

In độ lệch chuẩn của chuỗi Pandas

Trong chương trình này, chúng ta sẽ tìm độ lệch chuẩn của một chuỗi Pandas. Độ lệch chuẩn là một thống kê đo lường mức độ phân tán của tập dữ liệu so với giá trị trung bình của nó và được tính bằng căn bậc hai của phương sai.

Thuật toán

Step 1: Define a Pandas series
Step 2: Calculate the standard deviation of the series using the std() function in the pandas library.
Step 3: Print the standard deviation.

Mã mẫu

import pandas as pd

series = pd.Series([10,20,30,40,50])
print("Series: \n", series)

series_std = series.std()
print("Standard Deviation of the series: ",series.std())

Đầu ra

Series:
0    10
1    20
2    30
3    40
4    50
dtype: int64
Standard Deviation of the series:  15.811388300841896