File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -1029,6 +1029,9 @@ def to_datetime(
10291029 if arg is None :
10301030 return NaT
10311031
1032+ if not (0.0 <= threshold <= 1.0 ):
1033+ raise ValueError (f"`threshold` must be between 0.0 and 1.0, got { threshold } " )
1034+
10321035 if origin != "unix" :
10331036 arg = _adjust_to_origin (arg , origin , unit )
10341037
Original file line number Diff line number Diff line change @@ -4155,3 +4155,22 @@ def test_example(self):
41554155 threshold = 0.5 ,
41564156 )
41574157 assert isna (result )
4158+
4159+ def test_bad_threshold (self ):
4160+ with pytest .raises (
4161+ ValueError , match = "`threshold` must be between 0.0 and 1.0, got -0.5"
4162+ ):
4163+ _ = to_datetime (
4164+ "2020-01-01 12:20:20" ,
4165+ format = "%Y-%m-%d %H:%M:%S" ,
4166+ threshold = - 0.5 ,
4167+ )
4168+
4169+ with pytest .raises (
4170+ ValueError , match = "`threshold` must be between 0.0 and 1.0, got 2.0"
4171+ ):
4172+ _ = to_datetime (
4173+ "2020-01-01 12:20:20" ,
4174+ format = "%Y-%m-%d %H:%M:%S" ,
4175+ threshold = 2.0 ,
4176+ )
You can’t perform that action at this time.
0 commit comments