Skip to content

Commit ec8249b

Browse files
committed
BUG: check that only Timestamp is passed
1 parent 87f9823 commit ec8249b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pandas/_libs/tslibs/timestamps.pyx

+6-2
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,8 @@ class Timestamp(_Timestamp):
379379
_date_attributes = [year, month, day, hour, minute, second,
380380
microsecond, nanosecond]
381381

382+
_non_ts_attributes = [freq, tz, unit, tzinfo] + _date_attributes
383+
382384
if tzinfo is not None:
383385
if not PyTZInfo_Check(tzinfo):
384386
# tzinfo must be a datetime.tzinfo object, GH#17690
@@ -391,8 +393,10 @@ class Timestamp(_Timestamp):
391393
# User passed tzinfo instead of tz; avoid silently ignoring
392394
tz, tzinfo = tzinfo, None
393395

394-
if isinstance(ts_input, Timestamp) and tz is None:
395-
# GH 30543 if pd.Timestamp already passed, return it
396+
# GH 30543 if pd.Timestamp already passed, return it
397+
# check that only ts_input is passed
398+
if (isinstance(ts_input, Timestamp) and not
399+
any(arg is not None for arg in _non_ts_attributes)):
396400
return ts_input
397401
elif isinstance(ts_input, str):
398402
# User passed a date string to parse.

0 commit comments

Comments
 (0)