|
4 | 4 | from pandas.compat import lrange, zip
|
5 | 5 |
|
6 | 6 | import numpy as np
|
7 |
| -from pandas import Index, Series, DataFrame |
| 7 | +from pandas import Index, Series, DataFrame, NaT |
8 | 8 |
|
9 | 9 | from pandas.tseries.index import date_range, bdate_range
|
10 | 10 | from pandas.tseries.offsets import DateOffset
|
@@ -813,6 +813,23 @@ def test_mixed_freq_shared_ax(self):
|
813 | 813 | # self.assertEqual(ax1.lines[0].get_xydata()[0, 0],
|
814 | 814 | # ax2.lines[0].get_xydata()[0, 0])
|
815 | 815 |
|
| 816 | + def test_nat_handling(self): |
| 817 | + |
| 818 | + import matplotlib.pyplot as plt |
| 819 | + |
| 820 | + fig = plt.gcf() |
| 821 | + plt.clf() |
| 822 | + ax = fig.add_subplot(111) |
| 823 | + |
| 824 | + dti = DatetimeIndex(['2015-01-01', NaT, '2015-01-03']) |
| 825 | + s = Series(range(len(dti)), dti) |
| 826 | + s.plot(ax=ax) |
| 827 | + xdata = ax.get_lines()[0].get_xdata() |
| 828 | + # plot x data is bounded by index values |
| 829 | + self.assertLessEqual(s.index.min(), Series(xdata).min()) |
| 830 | + self.assertLessEqual(Series(xdata).max(), s.index.max()) |
| 831 | + _check_plot_works(s.plot) |
| 832 | + |
816 | 833 | @slow
|
817 | 834 | def test_to_weekly_resampling(self):
|
818 | 835 | idxh = date_range('1/1/1999', periods=52, freq='W')
|
|
0 commit comments