File tree 1 file changed +23
-1
lines changed
1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 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
@@ -778,6 +778,28 @@ def test_mixed_freq_irreg_period(self):
778
778
irreg .plot ()
779
779
ps .plot ()
780
780
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
+
781
803
@slow
782
804
def test_to_weekly_resampling (self ):
783
805
idxh = date_range ('1/1/1999' , periods = 52 , freq = 'W' )
You can’t perform that action at this time.
0 commit comments