Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
mroeschke opened this issue May 18, 2021 · 2 comments · Fixed by #45294
Closed
3 tasks done
Labels
Bug Datetime Datetime data dtype Needs Discussion Requires discussion from core team before further action quantile quantile method
Milestone

Comments

@mroeschke
Copy link
Member

  • 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)
@mroeschke mroeschke added Bug Needs Triage Issue that has not been reviewed by a pandas team member quantile quantile method Datetime Datetime data dtype and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 18, 2021
@jmholzer
Copy link
Contributor

I've taken a look at the code for quantile and think I can implement a solution, can I work on this / open a PR?

@mroeschke
Copy link
Member Author

Sure go for it @jmholzer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Datetime Datetime data dtype Needs Discussion Requires discussion from core team before further action quantile quantile method
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants