-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
AlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffBugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversions
Milestone
Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
The .index.dtype
is not stable for DataFrame.mode. It depends on whether the DataFrame is empty and possible the dtypes
In [60]: pd.DataFrame([], columns=['a', 'b']).mode().index.dtype
Out[60]: dtype('O')
Problem description
The index dtype should always be Int64, to match the non-empty case
Expected Output
In [61]: pd.DataFrame({"A": ['a']}).mode().index.dtype
Out[61]: dtype('int64')
Metadata
Metadata
Assignees
Labels
AlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffBugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversions