DOC: Series.diff with boolean dtype does not return a series of dtype float #57565
Labels
Docs
Dtype Conversions
Unexpected or buggy dtype conversions
Needs Discussion
Requires discussion from core team before further action
Transformations
e.g. cumsum, diff, rank
Pandas version checks
main
hereLocation of the documentation
https://pandas.pydata.org/docs/reference/api/pandas.Series.diff.html#pandas.Series.diff
https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.diff.html#pandas.DataFrame.diff
Documentation problem
The documentation for
pandas.Series.diff
andpandas.DataFrame.diff
states that no matter the dtype of the original series/column, the output will be of dtypefloat64
. This is not true for series/columns of dtypesbool
-- the output here is of dtypeobject
.For example:
Indeed, the underlying function algorithms.diff explicitly differentiates between boolean and integer dtypes.
Suggested fix for documentation
The
Notes
section should read something like this:The text was updated successfully, but these errors were encountered: