@@ -184,13 +184,13 @@ def test_take_fill(self):
184184 arr = self .array_cls (data , freq = "D" )
185185
186186 result = arr .take ([- 1 , 1 ], allow_fill = True , fill_value = None )
187- assert result [0 ] is pd . NaT
187+ assert result [0 ] is NaT
188188
189189 result = arr .take ([- 1 , 1 ], allow_fill = True , fill_value = np .nan )
190- assert result [0 ] is pd . NaT
190+ assert result [0 ] is NaT
191191
192- result = arr .take ([- 1 , 1 ], allow_fill = True , fill_value = pd . NaT )
193- assert result [0 ] is pd . NaT
192+ result = arr .take ([- 1 , 1 ], allow_fill = True , fill_value = NaT )
193+ assert result [0 ] is NaT
194194
195195 def test_take_fill_str (self , arr1d ):
196196 # Cast str fill_value matching other fill_value-taking methods
@@ -205,7 +205,7 @@ def test_take_fill_str(self, arr1d):
205205 def test_concat_same_type (self , arr1d ):
206206 arr = arr1d
207207 idx = self .index_cls (arr )
208- idx = idx .insert (0 , pd . NaT )
208+ idx = idx .insert (0 , NaT )
209209 arr = self .array_cls (idx )
210210
211211 result = arr ._concat_same_type ([arr [:- 1 ], arr [1 :], arr ])
@@ -221,7 +221,7 @@ def test_unbox_scalar(self):
221221 expected = arr ._data .dtype .type
222222 assert isinstance (result , expected )
223223
224- result = arr ._unbox_scalar (pd . NaT )
224+ result = arr ._unbox_scalar (NaT )
225225 assert isinstance (result , expected )
226226
227227 msg = f"'value' should be a { self .dtype .__name__ } ."
@@ -234,7 +234,7 @@ def test_check_compatible_with(self):
234234
235235 arr ._check_compatible_with (arr [0 ])
236236 arr ._check_compatible_with (arr [:1 ])
237- arr ._check_compatible_with (pd . NaT )
237+ arr ._check_compatible_with (NaT )
238238
239239 def test_scalar_from_string (self ):
240240 data = np .arange (10 , dtype = "i8" ) * 24 * 3600 * 10 ** 9
@@ -254,15 +254,15 @@ def test_reduce_invalid(self):
254254 def test_fillna_method_doesnt_change_orig (self , method ):
255255 data = np .arange (10 , dtype = "i8" ) * 24 * 3600 * 10 ** 9
256256 arr = self .array_cls (data , freq = "D" )
257- arr [4 ] = pd . NaT
257+ arr [4 ] = NaT
258258
259259 fill_value = arr [3 ] if method == "pad" else arr [5 ]
260260
261261 result = arr .fillna (method = method )
262262 assert result [4 ] == fill_value
263263
264264 # check that the original was not changed
265- assert arr [4 ] is pd . NaT
265+ assert arr [4 ] is NaT
266266
267267 def test_searchsorted (self ):
268268 data = np .arange (10 , dtype = "i8" ) * 24 * 3600 * 10 ** 9
@@ -286,7 +286,7 @@ def test_searchsorted(self):
286286
287287 # GH#29884 match numpy convention on whether NaT goes
288288 # at the end or the beginning
289- result = arr .searchsorted (pd . NaT )
289+ result = arr .searchsorted (NaT )
290290 if np_version_under1p18 :
291291 # Following numpy convention, NaT goes at the beginning
292292 # (unlike NaN which goes at the end)
@@ -616,7 +616,7 @@ def test_median(self, arr1d):
616616
617617
618618class TestDatetimeArray (SharedTests ):
619- index_cls = pd . DatetimeIndex
619+ index_cls = DatetimeIndex
620620 array_cls = DatetimeArray
621621 dtype = Timestamp
622622
@@ -749,7 +749,7 @@ def test_from_dti(self, arr1d):
749749
750750 # Check that Index.__new__ knows what to do with DatetimeArray
751751 dti2 = pd .Index (arr )
752- assert isinstance (dti2 , pd . DatetimeIndex )
752+ assert isinstance (dti2 , DatetimeIndex )
753753 assert list (dti2 ) == list (arr )
754754
755755 def test_astype_object (self , arr1d ):
@@ -800,7 +800,7 @@ def test_to_period_2d(self, arr1d):
800800 expected = arr1d .to_period ("D" ).reshape (1 , - 1 )
801801 tm .assert_period_array_equal (result , expected )
802802
803- @pytest .mark .parametrize ("propname" , pd . DatetimeIndex ._bool_ops )
803+ @pytest .mark .parametrize ("propname" , DatetimeIndex ._bool_ops )
804804 def test_bool_properties (self , arr1d , propname ):
805805 # in this case _bool_ops is just `is_leap_year`
806806 dti = self .index_cls (arr1d )
@@ -812,7 +812,7 @@ def test_bool_properties(self, arr1d, propname):
812812
813813 tm .assert_numpy_array_equal (result , expected )
814814
815- @pytest .mark .parametrize ("propname" , pd . DatetimeIndex ._field_ops )
815+ @pytest .mark .parametrize ("propname" , DatetimeIndex ._field_ops )
816816 def test_int_properties (self , arr1d , propname ):
817817 if propname in ["week" , "weekofyear" ]:
818818 # GH#33595 Deprecate week and weekofyear
@@ -849,7 +849,7 @@ def test_take_fill_valid(self, arr1d):
849849 # Timestamp with mismatched tz-awareness
850850 arr .take ([- 1 , 1 ], allow_fill = True , fill_value = now )
851851
852- value = pd . NaT .value
852+ value = NaT .value
853853 msg = f"value should be a '{ arr1d ._scalar_type .__name__ } ' or 'NaT'. Got"
854854 with pytest .raises (TypeError , match = msg ):
855855 # require NaT, not iNaT, as it could be confused with an integer
@@ -908,7 +908,7 @@ def test_strftime(self, arr1d):
908908
909909 def test_strftime_nat (self ):
910910 # GH 29578
911- arr = DatetimeArray (DatetimeIndex (["2019-01-01" , pd . NaT ]))
911+ arr = DatetimeArray (DatetimeIndex (["2019-01-01" , NaT ]))
912912
913913 result = arr .strftime ("%Y-%m-%d" )
914914 expected = np .array (["2019-01-01" , np .nan ], dtype = object )
@@ -1064,7 +1064,7 @@ def test_astype_object(self, arr1d):
10641064 def test_take_fill_valid (self , arr1d ):
10651065 arr = arr1d
10661066
1067- value = pd . NaT .value
1067+ value = NaT .value
10681068 msg = f"value should be a '{ arr1d ._scalar_type .__name__ } ' or 'NaT'. Got"
10691069 with pytest .raises (TypeError , match = msg ):
10701070 # require NaT, not iNaT, as it could be confused with an integer
@@ -1152,7 +1152,7 @@ def test_strftime(self, arr1d):
11521152
11531153 def test_strftime_nat (self ):
11541154 # GH 29578
1155- arr = PeriodArray (PeriodIndex (["2019-01-01" , pd . NaT ], dtype = "period[D]" ))
1155+ arr = PeriodArray (PeriodIndex (["2019-01-01" , NaT ], dtype = "period[D]" ))
11561156
11571157 result = arr .strftime ("%Y-%m-%d" )
11581158 expected = np .array (["2019-01-01" , np .nan ], dtype = object )
@@ -1164,18 +1164,18 @@ def test_strftime_nat(self):
11641164 [
11651165 (
11661166 TimedeltaIndex (["1 Day" , "3 Hours" , "NaT" ])._data ,
1167- (pd . NaT , np .timedelta64 ("NaT" , "ns" )),
1167+ (NaT , np .timedelta64 ("NaT" , "ns" )),
11681168 ),
11691169 (
11701170 pd .date_range ("2000-01-01" , periods = 3 , freq = "D" )._data ,
1171- (pd . NaT , np .datetime64 ("NaT" , "ns" )),
1171+ (NaT , np .datetime64 ("NaT" , "ns" )),
11721172 ),
1173- (pd .period_range ("2000-01-01" , periods = 3 , freq = "D" )._data , (pd . NaT ,)),
1173+ (pd .period_range ("2000-01-01" , periods = 3 , freq = "D" )._data , (NaT ,)),
11741174 ],
11751175 ids = lambda x : type (x ).__name__ ,
11761176)
11771177def test_casting_nat_setitem_array (array , casting_nats ):
1178- expected = type (array )._from_sequence ([pd . NaT , array [1 ], array [2 ]])
1178+ expected = type (array )._from_sequence ([NaT , array [1 ], array [2 ]])
11791179
11801180 for nat in casting_nats :
11811181 arr = array .copy ()
@@ -1188,15 +1188,15 @@ def test_casting_nat_setitem_array(array, casting_nats):
11881188 [
11891189 (
11901190 TimedeltaIndex (["1 Day" , "3 Hours" , "NaT" ])._data ,
1191- (np .datetime64 ("NaT" , "ns" ), pd . NaT .value ),
1191+ (np .datetime64 ("NaT" , "ns" ), NaT .value ),
11921192 ),
11931193 (
11941194 pd .date_range ("2000-01-01" , periods = 3 , freq = "D" )._data ,
1195- (np .timedelta64 ("NaT" , "ns" ), pd . NaT .value ),
1195+ (np .timedelta64 ("NaT" , "ns" ), NaT .value ),
11961196 ),
11971197 (
11981198 pd .period_range ("2000-01-01" , periods = 3 , freq = "D" )._data ,
1199- (np .datetime64 ("NaT" , "ns" ), np .timedelta64 ("NaT" , "ns" ), pd . NaT .value ),
1199+ (np .datetime64 ("NaT" , "ns" ), np .timedelta64 ("NaT" , "ns" ), NaT .value ),
12001200 ),
12011201 ],
12021202 ids = lambda x : type (x ).__name__ ,
@@ -1226,7 +1226,7 @@ def test_to_numpy_extra(array):
12261226 else :
12271227 isnan = np .isnan
12281228
1229- array [0 ] = pd . NaT
1229+ array [0 ] = NaT
12301230 original = array .copy ()
12311231
12321232 result = array .to_numpy ()
0 commit comments