Skip to content

Commit bd4f286

Browse files
committed
Changed position of empty string warning
1 parent 4d46206 commit bd4f286

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

pandas/_libs/tslibs/timestamps.pyx

+8-8
Original file line numberDiff line numberDiff line change
@@ -2635,14 +2635,6 @@ class Timestamp(_Timestamp):
26352635
elif not (999 >= nanosecond >= 0):
26362636
raise ValueError("nanosecond must be in 0..999")
26372637
2638-
if ts_input == "":
2639-
warnings.warn(
2640-
"Passing an empty string to Timestamp is deprecated and will raise "
2641-
"a ValueError in a future version.",
2642-
FutureWarning,
2643-
stacklevel = 2
2644-
)
2645-
26462638
ts = convert_to_tsobject(ts_input, tzobj, unit, 0, 0, nanosecond)
26472639
26482640
if ts.value == NPY_NAT:
@@ -2653,6 +2645,14 @@ class Timestamp(_Timestamp):
26532645
"Passed data is timezone-aware, incompatible with 'tz=None'."
26542646
)
26552647
2648+
if ts_input == "":
2649+
warnings.warn(
2650+
"Passing an empty string to Timestamp is deprecated and will raise "
2651+
"a ValueError in a future version.",
2652+
FutureWarning,
2653+
stacklevel = 2
2654+
)
2655+
26562656
return create_timestamp_from_ts(ts.value, ts.dts, ts.tzinfo, ts.fold, ts.creso)
26572657
26582658
def _round(self, freq, mode, ambiguous="raise", nonexistent="raise"):

pandas/tests/scalar/timestamp/test_constructors.py

-1
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,6 @@ def test_non_nano_value():
10781078
assert result == -52700112000
10791079

10801080

1081-
@pytest.mark.filterwarnings("ignore:Passing an empty string to Timestamp")
10821081
@pytest.mark.parametrize("na_value", [None, np.nan, np.datetime64("NaT"), NaT, NA])
10831082
def test_timestamp_constructor_na_value(na_value):
10841083
# GH45481

0 commit comments

Comments
 (0)