列印 Pandas 數列的平均值


Pandas 庫中的 mean() 函式可用於查詢數列的平均值。

演算法

Step 1: Define a Pandas series.
Step 2: Use the mean() function to calculate the mean.
Step 3: Print the mean.

示例程式碼

import pandas as pd

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

series_mean = series.mean()
print("Mean of the Pandas series:\n", series_mean)

輸出

Pandas Series:
0    10
1    20
2    30
3    40
4    50
dtype: int64
Mean of the Pandas series:
30.0

更新於:16-Mar-2021

1K+ 次瀏覽

開啟您的 職業 生涯

完成課程即可獲得認證

開始
廣告