Python statistics.mode() 메서드
예시
주어진 데이터의 모드(중심 경향)를 계산합니다.
# Import statistics Library
import statistics
# Calculate
the mode
print(statistics.mode([1, 3,
3, 3, 5, 7, 7 9, 11]))
print(statistics.mode([1, 1, 3, -5, 7, -9, 11]))
print(statistics.mode(['red',
'green', 'blue', 'red']))
정의 및 사용
이 statistics.mode()
방법은 주어진 숫자 또는 명목 데이터 세트의 모드(중심 경향)를 계산합니다.
통사론
statistics.mode(data)
매개변수 값
Parameter | Description |
---|---|
data | Required. The data values to be used (can be any sequence, list or iterator) |
참고: 데이터 가 비어 있으면 StatisticsError를 반환합니다.
기술적 세부 사항
반환 값: | float 주어진 데이터의 모드를 나타내는 A 또는 명목 값 |
---|---|
파이썬 버전: | 3.4 |
변경 로그: | 3.8: 이제 다중 모드 데이터 세트를 처리합니다(처음 발생한 모드를 반환함). |