Skip to content

BUG: Series.plot.hist segfault for timedelta64  #43941

Open
@cdeil

Description

@cdeil

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the master branch of pandas.

Reproducible Example

import pandas as pd

t = pd.to_datetime(["2021-01-01", "2021-01-03", "2021-01-04"])
print(t)

dt = t.to_series().diff()
print(dt)

dt.plot.hist()

Issue Description

I get this crash from the dt.plot.hist() call:

% python crash.py
DatetimeIndex(['2021-01-01', '2021-01-03', '2021-01-04'], dtype='datetime64[ns]', freq=None)
2021-01-01      NaT
2021-01-03   2 days
2021-01-04   1 days
dtype: timedelta64[ns]
zsh: segmentation fault  python crash.py

Expected Behavior

No segfault. Give a plot or some informative exception.

Installed Versions

This is with Python 3.9 on MacOS installed via conda-forge.

% cat environment.yml
name: cement

channels:

  • conda-forge
  • nodefaults

dependencies:

  • python==3.9
  • jupyterlab==3.1
  • pandas==1.3
  • scikit-learn==1.0
  • missingno
  • matplotlib
  • seaborn==0.11
  • dtale==1.56
  • pandas-profiling
  • sweetviz==2.1
  • hcrystalball==0.1.10
  • pip
  • pip:
    • flaml

pd.show_versions()

INSTALLED VERSIONS

commit : f00ed8f
python : 3.9.0.final.0
python-bits : 64
OS : Darwin
OS-release : 20.6.0
Version : Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.UTF-8

pandas : 1.3.0
numpy : 1.21.2
pytz : 2021.1
dateutil : 2.8.2
pip : 21.2.4
setuptools : 58.0.4
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.28.0
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.4.3
numexpr : None
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.7.1
sqlalchemy : None
tables : None
tabulate : None
xarray : 0.19.0
xlrd : 2.0.1
xlwt : None
numba : 0.53.1

Metadata

Metadata

Labels

BugNeeds TriageIssue that has not been reviewed by a pandas team memberVisualizationplotting

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions