• 회원가입
  • 로그인
  • 구글아이디로 로그인

[module] Python - statistics.median() 메서드 ★ - 중앙값 (= 중간값 = 가운데값 = median메서드 = 메디안메서드)

2127  

목차

  1. statistics.median() 예제 - 중앙값 구하기
  2. statistics.median() 정의
  3. statistics.median() 구문

 

statistics.median() 예제 - 중앙값 구하기

 

import statistics

print(statistics.median([1, 2, 3, 4, 5])) # 3

print(statistics.median([-3, 5.5, -5.5, 15])) # 1.25

 

 

statistics.median() 정의

 

주어진 데이터의 중앙값 (= 중간값) 구하기.

 


 

※ 중앙값 계산 전, 먼저 데이터를 오름차순 정렬.

※ 중앙값 = (n+1 / 2)번째 값.

※ 데이터가 홀수 개: 중간값.

※ 데이터가 짝수 개: 두 중간값의 평균.

※ Python 3.4 이상.

 

 

statistics.median() 구문

 

statistics.median(data)

 


[매개변수]

 

data

필수. 최소 1개 이상 데이터 있는 숫자 시퀀스.
※ 시퀀스 예: List, Tuple, Set 등

※ data 없는 경우, StatisticsError 에러 반환.

 


[반환값]

 

float 자료형의 중앙값.

 



분류 제목
module Python - statistics.stdev() 메서드 -
module Python - statistics.pvariance() 메서드 -
module Python - statistics.variance() 메서드 -
module Python - math 모듈 메서드・상수 종류 (※ 수학 모듈)
module Python - math.acos() 메서드 -
module Python - math.acosh() 메서드 -
module Python - math.asin() 메서드 -
module Python - math.asinh() 메서드 -
module Python - math.atan() 메서드 -
module Python - math.atan2() 메서드 -
module Python - math.atanh() 메서드 -
module Python - math.ceil() 메서드 ★ - 천장 반올림 (= 상위 정수로 반올림. = ceil메서드…
module Python - math.comb() 메서드 -
module Python - math.copysign() 메서드 -
module Python - math.cos() 메서드 -
module Python - math.cosh() 메서드 -
module Python - math.degrees() 메서드 -
module Python - math.dist() 메서드 -
module Python - math.erf() 메서드 -
module Python - math.erfc() 메서드 -
3/7
목록
찾아주셔서 감사합니다. Since 2012