@@ -897,69 +897,6 @@ def test_dayfirst(self):
897
897
898
898
899
899
class TestGuessDatetimeFormat (object ):
900
-
901
- def test_guess_datetime_format_with_parseable_formats (self ):
902
- tm ._skip_if_not_us_locale ()
903
- dt_string_to_format = (('20111230' , '%Y%m%d' ),
904
- ('2011-12-30' , '%Y-%m-%d' ),
905
- ('30-12-2011' , '%d-%m-%Y' ),
906
- ('2011-12-30 00:00:00' , '%Y-%m-%d %H:%M:%S' ),
907
- ('2011-12-30T00:00:00' , '%Y-%m-%dT%H:%M:%S' ),
908
- ('2011-12-30 00:00:00.000000' ,
909
- '%Y-%m-%d %H:%M:%S.%f' ), )
910
-
911
- for dt_string , dt_format in dt_string_to_format :
912
- assert tools ._guess_datetime_format (dt_string ) == dt_format
913
-
914
- def test_guess_datetime_format_with_dayfirst (self ):
915
- ambiguous_string = '01/01/2011'
916
- assert tools ._guess_datetime_format (
917
- ambiguous_string , dayfirst = True ) == '%d/%m/%Y'
918
- assert tools ._guess_datetime_format (
919
- ambiguous_string , dayfirst = False ) == '%m/%d/%Y'
920
-
921
- def test_guess_datetime_format_with_locale_specific_formats (self ):
922
- # The month names will vary depending on the locale, in which
923
- # case these wont be parsed properly (dateutil can't parse them)
924
- tm ._skip_if_has_locale ()
925
-
926
- dt_string_to_format = (('30/Dec/2011' , '%d/%b/%Y' ),
927
- ('30/December/2011' , '%d/%B/%Y' ),
928
- ('30/Dec/2011 00:00:00' , '%d/%b/%Y %H:%M:%S' ), )
929
-
930
- for dt_string , dt_format in dt_string_to_format :
931
- assert tools ._guess_datetime_format (dt_string ) == dt_format
932
-
933
- def test_guess_datetime_format_invalid_inputs (self ):
934
- # A datetime string must include a year, month and a day for it
935
- # to be guessable, in addition to being a string that looks like
936
- # a datetime
937
- invalid_dts = [
938
- '2013' ,
939
- '01/2013' ,
940
- '12:00:00' ,
941
- '1/1/1/1' ,
942
- 'this_is_not_a_datetime' ,
943
- '51a' ,
944
- 9 ,
945
- datetime (2011 , 1 , 1 ),
946
- ]
947
-
948
- for invalid_dt in invalid_dts :
949
- assert tools ._guess_datetime_format (invalid_dt ) is None
950
-
951
- def test_guess_datetime_format_nopadding (self ):
952
- # GH 11142
953
- dt_string_to_format = (('2011-1-1' , '%Y-%m-%d' ),
954
- ('30-1-2011' , '%d-%m-%Y' ),
955
- ('1/1/2011' , '%m/%d/%Y' ),
956
- ('2011-1-1 00:00:00' , '%Y-%m-%d %H:%M:%S' ),
957
- ('2011-1-1 0:0:0' , '%Y-%m-%d %H:%M:%S' ),
958
- ('2011-1-3T00:00:0' , '%Y-%m-%dT%H:%M:%S' ))
959
-
960
- for dt_string , dt_format in dt_string_to_format :
961
- assert tools ._guess_datetime_format (dt_string ) == dt_format
962
-
963
900
def test_guess_datetime_format_for_array (self ):
964
901
tm ._skip_if_not_us_locale ()
965
902
expected_format = '%Y-%m-%d %H:%M:%S.%f'
@@ -1074,21 +1011,6 @@ def test_day_not_in_month_ignore(self):
1074
1011
1075
1012
1076
1013
class TestDatetimeParsingWrappers (object ):
1077
- def test_does_not_convert_mixed_integer (self ):
1078
- bad_date_strings = ('-50000' , '999' , '123.1234' , 'm' , 'T' )
1079
-
1080
- for bad_date_string in bad_date_strings :
1081
- assert not parsing ._does_string_look_like_datetime (bad_date_string )
1082
-
1083
- good_date_strings = ('2012-01-01' ,
1084
- '01/01/2012' ,
1085
- 'Mon Sep 16, 2013' ,
1086
- '01012012' ,
1087
- '0101' ,
1088
- '1-1' , )
1089
-
1090
- for good_date_string in good_date_strings :
1091
- assert parsing ._does_string_look_like_datetime (good_date_string )
1092
1014
1093
1015
def test_parsers (self ):
1094
1016
@@ -1148,8 +1070,8 @@ def test_parsers(self):
1148
1070
}
1149
1071
1150
1072
for date_str , expected in compat .iteritems (cases ):
1151
- result1 , _ , _ = tools .parse_time_string (date_str ,
1152
- yearfirst = yearfirst )
1073
+ result1 , _ , _ = parsing .parse_time_string (date_str ,
1074
+ yearfirst = yearfirst )
1153
1075
result2 = to_datetime (date_str , yearfirst = yearfirst )
1154
1076
result3 = to_datetime ([date_str ], yearfirst = yearfirst )
1155
1077
# result5 is used below
@@ -1175,7 +1097,7 @@ def test_parsers(self):
1175
1097
assert result7 == expected
1176
1098
1177
1099
# NaT
1178
- result1 , _ , _ = tools .parse_time_string ('NaT' )
1100
+ result1 , _ , _ = parsing .parse_time_string ('NaT' )
1179
1101
result2 = to_datetime ('NaT' )
1180
1102
result3 = Timestamp ('NaT' )
1181
1103
result4 = DatetimeIndex (['NaT' ])[0 ]
@@ -1184,12 +1106,6 @@ def test_parsers(self):
1184
1106
assert result3 is tslib .NaT
1185
1107
assert result4 is tslib .NaT
1186
1108
1187
- def test_parsers_quarter_invalid (self ):
1188
-
1189
- cases = ['2Q 2005' , '2Q-200A' , '2Q-200' , '22Q2005' , '6Q-20' , '2Q200.' ]
1190
- for case in cases :
1191
- pytest .raises (ValueError , tools .parse_time_string , case )
1192
-
1193
1109
def test_parsers_dayfirst_yearfirst (self ):
1194
1110
# OK
1195
1111
# 2.5.1 10-11-12 [dayfirst=0, yearfirst=0] -> 2012-10-11 00:00:00
@@ -1264,9 +1180,9 @@ def test_parsers_dayfirst_yearfirst(self):
1264
1180
yearfirst = yearfirst )
1265
1181
assert dateutil_result == expected
1266
1182
1267
- result1 , _ , _ = tools .parse_time_string (date_str ,
1268
- dayfirst = dayfirst ,
1269
- yearfirst = yearfirst )
1183
+ result1 , _ , _ = parsing .parse_time_string (date_str ,
1184
+ dayfirst = dayfirst ,
1185
+ yearfirst = yearfirst )
1270
1186
1271
1187
# we don't support dayfirst/yearfirst here:
1272
1188
if not dayfirst and not yearfirst :
@@ -1289,7 +1205,7 @@ def test_parsers_timestring(self):
1289
1205
'9:05' : (parse ('9:05' ), datetime (1 , 1 , 1 , 9 , 5 ))}
1290
1206
1291
1207
for date_str , (exp_now , exp_def ) in compat .iteritems (cases ):
1292
- result1 , _ , _ = tools .parse_time_string (date_str )
1208
+ result1 , _ , _ = parsing .parse_time_string (date_str )
1293
1209
result2 = to_datetime (date_str )
1294
1210
result3 = to_datetime ([date_str ])
1295
1211
result4 = Timestamp (date_str )
@@ -1338,34 +1254,6 @@ def test_parsers_time(self):
1338
1254
assert isinstance (res , list )
1339
1255
assert res == expected_arr
1340
1256
1341
- def test_parsers_monthfreq (self ):
1342
- cases = {'201101' : datetime (2011 , 1 , 1 , 0 , 0 ),
1343
- '200005' : datetime (2000 , 5 , 1 , 0 , 0 )}
1344
-
1345
- for date_str , expected in compat .iteritems (cases ):
1346
- result1 , _ , _ = tools .parse_time_string (date_str , freq = 'M' )
1347
- assert result1 == expected
1348
-
1349
- def test_parsers_quarterly_with_freq (self ):
1350
- msg = ('Incorrect quarterly string is given, quarter '
1351
- 'must be between 1 and 4: 2013Q5' )
1352
- with tm .assert_raises_regex (parsing .DateParseError , msg ):
1353
- tools .parse_time_string ('2013Q5' )
1354
-
1355
- # GH 5418
1356
- msg = ('Unable to retrieve month information from given freq: '
1357
- 'INVLD-L-DEC-SAT' )
1358
- with tm .assert_raises_regex (parsing .DateParseError , msg ):
1359
- tools .parse_time_string ('2013Q1' , freq = 'INVLD-L-DEC-SAT' )
1360
-
1361
- cases = {('2013Q2' , None ): datetime (2013 , 4 , 1 ),
1362
- ('2013Q2' , 'A-APR' ): datetime (2012 , 8 , 1 ),
1363
- ('2013-Q2' , 'A-DEC' ): datetime (2013 , 4 , 1 )}
1364
-
1365
- for (date_str , freq ), exp in compat .iteritems (cases ):
1366
- result , _ , _ = tools .parse_time_string (date_str , freq = freq )
1367
- assert result == exp
1368
-
1369
1257
def test_parsers_timezone_minute_offsets_roundtrip (self ):
1370
1258
# GH11708
1371
1259
base = to_datetime ("2013-01-01 00:00:00" )
@@ -1423,14 +1311,6 @@ def test_parsers_iso8601(self):
1423
1311
1424
1312
1425
1313
class TestArrayToDatetime (object ):
1426
-
1427
- def test_try_parse_dates (self ):
1428
- arr = np .array (['5/1/2000' , '6/1/2000' , '7/1/2000' ], dtype = object )
1429
-
1430
- result = parsing .try_parse_dates (arr , dayfirst = True )
1431
- expected = [parse (d , dayfirst = True ) for d in arr ]
1432
- assert np .array_equal (result , expected )
1433
-
1434
1314
def test_parsing_valid_dates (self ):
1435
1315
arr = np .array (['01-01-2013' , '01-02-2013' ], dtype = object )
1436
1316
tm .assert_numpy_array_equal (
0 commit comments