Skip to content

BUG: Empty DataFrame(..., dtype='datetime64[ns]').quantile(..., axis=1) returns float64 dtype #41544

Closed
@mroeschke

Description

@mroeschke
  • 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.


This ideally should still return datetime64[ns] dtype

In [1]: df = DataFrame(columns=["a", "b"], dtype="datetime64[ns]")

In [2]: df
Out[2]:
Empty DataFrame
Columns: [a, b]
Index: []

In [3]: df.quantile(0.5, axis=1, numeric_only=False)
Out[3]: Series([], Name: 0.5, dtype: float64)

In [4]: df.quantile(0.5, axis=1, numeric_only=False).dtype
Out[4]: dtype('float64')

In [5]: df
Out[5]:
Empty DataFrame
Columns: [a, b]
Index: []

In [6]: df.T
Out[6]:
Empty DataFrame
Columns: []
Index: [a, b]

# Probably the reason why we might get float64 dtype afterwards
In [7]: df.T.dtypes
Out[7]: Series([], dtype: object)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDatetimeDatetime data dtypeNeeds DiscussionRequires discussion from core team before further actionquantilequantile method

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions