Skip to content

DataFrame.quantile and DataFrame.describe Not Handling NaN #13744

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

Closed
chris-sheehan opened this issue Jul 21, 2016 · 1 comment
Closed

DataFrame.quantile and DataFrame.describe Not Handling NaN #13744

chris-sheehan opened this issue Jul 21, 2016 · 1 comment
Labels
Bug Duplicate Report Duplicate issue or pull request

Comments

@chris-sheehan
Copy link

chris-sheehan commented Jul 21, 2016

Code

>>> import numpy as np
>>> import pandas as pd
>>> df = DataFrame([1, 2, 3, np.nan], columns = ['x'])
>>> print df.x.quantile(0.5)

...outputs NaN, where would expect it to handle NaN values and return 2.0

Versions

pandas: 0.18.1
numpy: 1.11.0

In NumPy 1.10.1, the behavior of numpy.median and numpy.percentile are changed to not handle NaN...

Median warns and returns nan when invalid values are encountered... Similar to mean, median and percentile now emits a Runtime warning and returns NaN in slices where a NaN is present. To compute the median or percentile while ignoring invalid values use the new nanmedian or nanpercentile functions.

Since pandas.DataFrame uses numpy.percentile for .describe and .quantile, neither handle NaN values when paired with numpy >= 1.10.0.

@jorisvandenbossche jorisvandenbossche added Duplicate Report Duplicate issue or pull request Bug labels Jul 21, 2016
@jorisvandenbossche jorisvandenbossche added this to the No action milestone Jul 21, 2016
@jorisvandenbossche
Copy link
Member

@chris-sheehan Thanks for reporting! This has been fixed in the meantime in the development version. See #13098

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Duplicate Report Duplicate issue or pull request
Projects
None yet
Development

No branches or pull requests

2 participants