Python pandasを使ってみるその②

前回からの続きになりますが次は

 

https://images.pyq.jp/repo/prod/pandas_start_first/pandas_start_first_3.jpg

Heightの部分だけ取り出してみます。

 

import pandas as pd

df = pd.DataFrame([['佐藤', 170, 60], ['田中', 160, 50], ['鈴木', 165, 58]],
columns=['Name', 'Height', 'Weight', ])

heights = df['Height']

print(heights)

 

 

結果

0   170

1   160

2   165

 

☆ポイント☆

heights = df['Height'].max() 最大数

heights = df['Height'].min() 最小数

heights = df['Height'].mean() 平均

heights = df['Height'].sum() 合計

 

以上、ちゃあ少佐でした。