@@ -184,13 +184,13 @@ def test_take_fill(self):
184
184
arr = self .array_cls (data , freq = "D" )
185
185
186
186
result = arr .take ([- 1 , 1 ], allow_fill = True , fill_value = None )
187
- assert result [0 ] is pd . NaT
187
+ assert result [0 ] is NaT
188
188
189
189
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
191
191
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
194
194
195
195
def test_take_fill_str (self , arr1d ):
196
196
# Cast str fill_value matching other fill_value-taking methods
@@ -205,7 +205,7 @@ def test_take_fill_str(self, arr1d):
205
205
def test_concat_same_type (self , arr1d ):
206
206
arr = arr1d
207
207
idx = self .index_cls (arr )
208
- idx = idx .insert (0 , pd . NaT )
208
+ idx = idx .insert (0 , NaT )
209
209
arr = self .array_cls (idx )
210
210
211
211
result = arr ._concat_same_type ([arr [:- 1 ], arr [1 :], arr ])
@@ -221,7 +221,7 @@ def test_unbox_scalar(self):
221
221
expected = arr ._data .dtype .type
222
222
assert isinstance (result , expected )
223
223
224
- result = arr ._unbox_scalar (pd . NaT )
224
+ result = arr ._unbox_scalar (NaT )
225
225
assert isinstance (result , expected )
226
226
227
227
msg = f"'value' should be a { self .dtype .__name__ } ."
@@ -234,7 +234,7 @@ def test_check_compatible_with(self):
234
234
235
235
arr ._check_compatible_with (arr [0 ])
236
236
arr ._check_compatible_with (arr [:1 ])
237
- arr ._check_compatible_with (pd . NaT )
237
+ arr ._check_compatible_with (NaT )
238
238
239
239
def test_scalar_from_string (self ):
240
240
data = np .arange (10 , dtype = "i8" ) * 24 * 3600 * 10 ** 9
@@ -254,15 +254,15 @@ def test_reduce_invalid(self):
254
254
def test_fillna_method_doesnt_change_orig (self , method ):
255
255
data = np .arange (10 , dtype = "i8" ) * 24 * 3600 * 10 ** 9
256
256
arr = self .array_cls (data , freq = "D" )
257
- arr [4 ] = pd . NaT
257
+ arr [4 ] = NaT
258
258
259
259
fill_value = arr [3 ] if method == "pad" else arr [5 ]
260
260
261
261
result = arr .fillna (method = method )
262
262
assert result [4 ] == fill_value
263
263
264
264
# check that the original was not changed
265
- assert arr [4 ] is pd . NaT
265
+ assert arr [4 ] is NaT
266
266
267
267
def test_searchsorted (self ):
268
268
data = np .arange (10 , dtype = "i8" ) * 24 * 3600 * 10 ** 9
@@ -286,7 +286,7 @@ def test_searchsorted(self):
286
286
287
287
# GH#29884 match numpy convention on whether NaT goes
288
288
# at the end or the beginning
289
- result = arr .searchsorted (pd . NaT )
289
+ result = arr .searchsorted (NaT )
290
290
if np_version_under1p18 :
291
291
# Following numpy convention, NaT goes at the beginning
292
292
# (unlike NaN which goes at the end)
@@ -616,7 +616,7 @@ def test_median(self, arr1d):
616
616
617
617
618
618
class TestDatetimeArray (SharedTests ):
619
- index_cls = pd . DatetimeIndex
619
+ index_cls = DatetimeIndex
620
620
array_cls = DatetimeArray
621
621
dtype = Timestamp
622
622
@@ -749,7 +749,7 @@ def test_from_dti(self, arr1d):
749
749
750
750
# Check that Index.__new__ knows what to do with DatetimeArray
751
751
dti2 = pd .Index (arr )
752
- assert isinstance (dti2 , pd . DatetimeIndex )
752
+ assert isinstance (dti2 , DatetimeIndex )
753
753
assert list (dti2 ) == list (arr )
754
754
755
755
def test_astype_object (self , arr1d ):
@@ -800,7 +800,7 @@ def test_to_period_2d(self, arr1d):
800
800
expected = arr1d .to_period ("D" ).reshape (1 , - 1 )
801
801
tm .assert_period_array_equal (result , expected )
802
802
803
- @pytest .mark .parametrize ("propname" , pd . DatetimeIndex ._bool_ops )
803
+ @pytest .mark .parametrize ("propname" , DatetimeIndex ._bool_ops )
804
804
def test_bool_properties (self , arr1d , propname ):
805
805
# in this case _bool_ops is just `is_leap_year`
806
806
dti = self .index_cls (arr1d )
@@ -812,7 +812,7 @@ def test_bool_properties(self, arr1d, propname):
812
812
813
813
tm .assert_numpy_array_equal (result , expected )
814
814
815
- @pytest .mark .parametrize ("propname" , pd . DatetimeIndex ._field_ops )
815
+ @pytest .mark .parametrize ("propname" , DatetimeIndex ._field_ops )
816
816
def test_int_properties (self , arr1d , propname ):
817
817
if propname in ["week" , "weekofyear" ]:
818
818
# GH#33595 Deprecate week and weekofyear
@@ -849,7 +849,7 @@ def test_take_fill_valid(self, arr1d):
849
849
# Timestamp with mismatched tz-awareness
850
850
arr .take ([- 1 , 1 ], allow_fill = True , fill_value = now )
851
851
852
- value = pd . NaT .value
852
+ value = NaT .value
853
853
msg = f"value should be a '{ arr1d ._scalar_type .__name__ } ' or 'NaT'. Got"
854
854
with pytest .raises (TypeError , match = msg ):
855
855
# require NaT, not iNaT, as it could be confused with an integer
@@ -908,7 +908,7 @@ def test_strftime(self, arr1d):
908
908
909
909
def test_strftime_nat (self ):
910
910
# GH 29578
911
- arr = DatetimeArray (DatetimeIndex (["2019-01-01" , pd . NaT ]))
911
+ arr = DatetimeArray (DatetimeIndex (["2019-01-01" , NaT ]))
912
912
913
913
result = arr .strftime ("%Y-%m-%d" )
914
914
expected = np .array (["2019-01-01" , np .nan ], dtype = object )
@@ -1064,7 +1064,7 @@ def test_astype_object(self, arr1d):
1064
1064
def test_take_fill_valid (self , arr1d ):
1065
1065
arr = arr1d
1066
1066
1067
- value = pd . NaT .value
1067
+ value = NaT .value
1068
1068
msg = f"value should be a '{ arr1d ._scalar_type .__name__ } ' or 'NaT'. Got"
1069
1069
with pytest .raises (TypeError , match = msg ):
1070
1070
# require NaT, not iNaT, as it could be confused with an integer
@@ -1152,7 +1152,7 @@ def test_strftime(self, arr1d):
1152
1152
1153
1153
def test_strftime_nat (self ):
1154
1154
# 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]" ))
1156
1156
1157
1157
result = arr .strftime ("%Y-%m-%d" )
1158
1158
expected = np .array (["2019-01-01" , np .nan ], dtype = object )
@@ -1164,18 +1164,18 @@ def test_strftime_nat(self):
1164
1164
[
1165
1165
(
1166
1166
TimedeltaIndex (["1 Day" , "3 Hours" , "NaT" ])._data ,
1167
- (pd . NaT , np .timedelta64 ("NaT" , "ns" )),
1167
+ (NaT , np .timedelta64 ("NaT" , "ns" )),
1168
1168
),
1169
1169
(
1170
1170
pd .date_range ("2000-01-01" , periods = 3 , freq = "D" )._data ,
1171
- (pd . NaT , np .datetime64 ("NaT" , "ns" )),
1171
+ (NaT , np .datetime64 ("NaT" , "ns" )),
1172
1172
),
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 ,)),
1174
1174
],
1175
1175
ids = lambda x : type (x ).__name__ ,
1176
1176
)
1177
1177
def 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 ]])
1179
1179
1180
1180
for nat in casting_nats :
1181
1181
arr = array .copy ()
@@ -1188,15 +1188,15 @@ def test_casting_nat_setitem_array(array, casting_nats):
1188
1188
[
1189
1189
(
1190
1190
TimedeltaIndex (["1 Day" , "3 Hours" , "NaT" ])._data ,
1191
- (np .datetime64 ("NaT" , "ns" ), pd . NaT .value ),
1191
+ (np .datetime64 ("NaT" , "ns" ), NaT .value ),
1192
1192
),
1193
1193
(
1194
1194
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 ),
1196
1196
),
1197
1197
(
1198
1198
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 ),
1200
1200
),
1201
1201
],
1202
1202
ids = lambda x : type (x ).__name__ ,
@@ -1226,7 +1226,7 @@ def test_to_numpy_extra(array):
1226
1226
else :
1227
1227
isnan = np .isnan
1228
1228
1229
- array [0 ] = pd . NaT
1229
+ array [0 ] = NaT
1230
1230
original = array .copy ()
1231
1231
1232
1232
result = array .to_numpy ()
0 commit comments