Skip to content

Commit d1c8776

Browse files
committed
TST: add test for fix of pandas-dev#12405
1 parent 5a3ec26 commit d1c8776

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

pandas/tests/plotting/test_datetimelike.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pandas.compat import lrange, zip
55

66
import numpy as np
7-
from pandas import Index, Series, DataFrame
7+
from pandas import Index, Series, DataFrame, NaT
88

99
from pandas.tseries.index import date_range, bdate_range
1010
from pandas.tseries.offsets import DateOffset
@@ -778,6 +778,28 @@ def test_mixed_freq_irreg_period(self):
778778
irreg.plot()
779779
ps.plot()
780780

781+
def test_nat_handling(self):
782+
783+
import matplotlib.pyplot as plt
784+
785+
def inject_nat_into_index_col(df):
786+
df.loc[len(df)//2, 'index'] = NaT
787+
return df
788+
789+
fig = plt.gcf()
790+
plt.clf()
791+
ax = plt.gca()
792+
793+
s = (tm.makeTimeSeries()
794+
.reset_index()
795+
.pipe(inject_nat_into_index_col)
796+
.set_index('index', drop=True))
797+
s.plot(ax=ax)
798+
xdata = ax.get_lines()[0].get_xdata()
799+
# plot x data is bounded by index values
800+
self.assertLessEqual(s.index.min(), Series(xdata).min())
801+
self.assertLessEqual(Series(xdata).max(), s.index.max())
802+
781803
@slow
782804
def test_to_weekly_resampling(self):
783805
idxh = date_range('1/1/1999', periods=52, freq='W')

0 commit comments

Comments
 (0)