pythonで中央値を求める方法/statistics.median関数の使い方

IT

statistics.median関数では、リストやタプルから中央値を求めることができます。

スポンサーリンク

statistics.median関数

python statistics median1
median関数を使う前に、あらかじめstatistics組み込みモジュールをimportしておきます。
#python
import statistics
list = [1,1,2,4,8,10,100]
md = statistics.median(list)
print(md)
statistics.medianの引数にリストやタプルを指定することで、
python statistics median2
中央値を取得することができます。
Python操作方法、関数・メソッドリファレンス
使用用途別にまとめたPythonリファレンスページです。 初期準備、基本概念 ダウンロード、インストール、起動 ShellとEditor、保存、実行 保存したPythonの起動 コメント、docstring、行またぎ コメント、...

コメント

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny