Skip to content

KDE Plot does not drop missing values #14821

Closed
@keshavramaswamy

Description

@keshavramaswamy
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Missing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateVisualizationplotting

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions