diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2024-07-21 05:53:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-21 05:53:26 (GMT) |
commit | ebc18abbf34ff248764bda1a02db7f1c783b71e3 (patch) | |
tree | f0f84eefe17a3cc50e31b68616193c561bbdf7d4 /Doc | |
parent | c4c7097e64b0c9cb0081de8872b90594865c892b (diff) | |
download | cpython-ebc18abbf34ff248764bda1a02db7f1c783b71e3.zip cpython-ebc18abbf34ff248764bda1a02db7f1c783b71e3.tar.gz cpython-ebc18abbf34ff248764bda1a02db7f1c783b71e3.tar.bz2 |
gh-121977: Add tips for handling unhashable data (#122075)
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/statistics.rst | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Doc/library/statistics.rst b/Doc/library/statistics.rst index f7051ae..614f5b9 100644 --- a/Doc/library/statistics.rst +++ b/Doc/library/statistics.rst @@ -485,6 +485,12 @@ However, for reading convenience, most of the examples show sorted sequences. >>> mode(["red", "blue", "blue", "red", "green", "red", "red"]) 'red' + Only hashable inputs are supported. To handle type :class:`set`, + consider casting to :class:`frozenset`. To handle type :class:`list`, + consider casting to :class:`tuple`. For mixed or nested inputs, consider + using this slower quadratic algorithm that only depends on equality tests: + ``max(data, key=data.count)``. + .. versionchanged:: 3.8 Now handles multimodal datasets by returning the first mode encountered. Formerly, it raised :exc:`StatisticsError` when more than one mode was |