Skip to content

KDE Plot does not drop missing values #14821

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
keshavramaswamy opened this issue Dec 8, 2016 · 0 comments
Closed

KDE Plot does not drop missing values #14821

keshavramaswamy opened this issue Dec 8, 2016 · 0 comments
Labels
Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Visualization plotting
Milestone

Comments

@keshavramaswamy
Copy link
Contributor

keshavramaswamy commented Dec 8, 2016

df = pd.Series([np.nan, 4.0,5.0,6.0,np.nan,1.0,4.0,4.0,2.0,np.nan,np.nan,6.0,2.0,np.nan,np.nan,np.nan,np.nan,np.nan,
3.0,2.0,1.0,10.0,np.nan,np.nan,np.nan,np.nan,1.0,np.nan,np.nan,3.0])
df.plot(kind='kde')
df.plot(kind='hist')

The KDE Plot of a series with missing values fails, producing an empty plot whereas the histogram is able to drop the missing values.

Expected Output

  • The KDE Plot is generated when the missing values are removed manually or by using dropna()
  • According to the Pandas doc on plotting with missing data, the default way NaNs are handled is by dropping them. But this does not happen - an empty plot is generated
  • I have created a PR to fix this: #14820
INSTALLED VERSIONS

commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-92-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.19.1
nose: 1.3.7
pip: 9.0.1
setuptools: 23.0.0
Cython: 0.24
numpy: 1.11.1
scipy: 0.17.1
statsmodels: 0.6.1
xarray: None
IPython: 4.2.0
sphinx: 1.4.1
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: 1.1.0
tables: 3.2.2
numexpr: 2.6.0
matplotlib: 1.5.1
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.2
lxml: 3.6.0
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: 2.40.0
pandas_datareader: None

@TomAugspurger TomAugspurger added Visualization plotting Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate labels Dec 8, 2016
TomAugspurger pushed a commit that referenced this issue Dec 15, 2016
BUG: Fixed KDE plot to ignore missing values

 closes #14821

* fixed kde plot to ignore the missing values
* added comment to elaborate the changes made
* added a release note in whatsnew/0.19.2
* added test to check for  missing values and cleaned up whatsnew doc
* added comment to refer the issue
* modified to fit lint checks
* replaced ._xorig with .get_xdata()
ischurov pushed a commit to ischurov/pandas that referenced this issue Dec 19, 2016
BUG: Fixed KDE plot to ignore missing values

 closes pandas-dev#14821

* fixed kde plot to ignore the missing values
* added comment to elaborate the changes made
* added a release note in whatsnew/0.19.2
* added test to check for  missing values and cleaned up whatsnew doc
* added comment to refer the issue
* modified to fit lint checks
* replaced ._xorig with .get_xdata()
@jorisvandenbossche jorisvandenbossche added this to the 0.19.2 milestone Dec 24, 2016
jorisvandenbossche pushed a commit to jorisvandenbossche/pandas that referenced this issue Dec 24, 2016
BUG: Fixed KDE plot to ignore missing values

 closes pandas-dev#14821

* fixed kde plot to ignore the missing values
* added comment to elaborate the changes made
* added a release note in whatsnew/0.19.2
* added test to check for  missing values and cleaned up whatsnew doc
* added comment to refer the issue
* modified to fit lint checks
* replaced ._xorig with .get_xdata()
(cherry picked from commit 033d345)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Visualization plotting
Projects
None yet
Development

No branches or pull requests

3 participants