IMHO, mixing custom types in this context is usually not required, as long as at least int-to-anything-else typecast is possible. Currently it's done only when there is at least one non-int and when the result can't be represented as int, that is:
>>> statistics.mean([1, 2, 3, 6]) 3 >>> statistics.mean([1, 2, 3, 6.]) 3.0 >>> statistics.mean([1, 2, 3, Decimal("6.00")]) Decimal('3') If the first example becomes 3.0, I'm not sure if this would be an issue given that division of ints (like 4 / 2) returns a float. But I would be surprised if any example above raised a TypeError. And I would assume the last should work without typecasting anything to float. On the other hand, one issue I commonly have with Pandas is its "always typecast to float" behavior (e.g. when adding a row with an empty cell for the numeric column, it forces it to be NaN and typecast the rest to float unless you explicitly set the column dtype to be "object" or a similar alternative; the rolling/windowing Pandas tools are "hardcoded" to typecast Decimal and other numeric types to float, making it more difficult to avoid floats, etc.). On Thu, 12 May 2022 at 11:51, Jonathan Fine <jfine2...@gmail.com> wrote: > Hi Steve > > Today's XKCD is on 'Selection Bias' and it is set in a statistics > conference: https://xkcd.com/2618/ > > According to its PEP the statistics module provides "common statistics > functions such as mean, median, variance and standard deviation". > > You ask "if you are a user of statistics, how important to you is the > ability to **mix** numeric types, in the same data set". > > Asking your question here introduces a selection bias. To compensate for > this, I suggest you also ask a similar question elsewhere, such as > comp.lang.python and at some forum for Python in education. > > Do look at https://xkcd.com/2618/, it makes the point quite nicely. > -- > Jonathan > > > > > > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/5QN2E5F3L4S2SEEWOFJCMOGZ6CFDVQSJ/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Danilo J. S. Bellini
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/XZTZ65O4RIFKEADIZNZ7CP4D4TF23IKL/ Code of Conduct: http://python.org/psf/codeofconduct/