Skip to content

Commit f31daa8

Browse files
remove defaultdict
1 parent 7332c1c commit f31daa8

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,6 @@ class Timedelta(_Timedelta):
14791479

14801480
def __new__(cls, object value=_no_input, unit=None, **kwargs):
14811481
cdef:
1482-
_Timedelta td_base
14831482
NPY_DATETIMEUNIT out_reso = NPY_FR_ns
14841483

14851484
# process kwargs iff no value passed
@@ -1496,17 +1495,17 @@ class Timedelta(_Timedelta):
14961495
)
14971496
# GH43764, convert any input to nanoseconds first, to ensure any potential
14981497
# nanosecond contributions from kwargs parsed as floats are included
1499-
kwargs = collections.defaultdict(int, {key: _to_py_int_float(val) for key, val in kwargs.items()})
1498+
# kwargs = collections.defaultdict(int, {key: _to_py_int_float(val) for key, val in kwargs.items()})
15001499
ns = sum(
15011500
(
1502-
kwargs["weeks"] * 7 * 24 * 3600 * 1_000_000_000,
1503-
kwargs["days"] * 24 * 3600 * 1_000_000_000,
1504-
kwargs["hours"] * 3600 * 1_000_000_000,
1505-
kwargs["minutes"] * 60 * 1_000_000_000,
1506-
kwargs["seconds"] * 1_000_000_000,
1507-
kwargs["milliseconds"] * 1_000_000,
1508-
kwargs["microseconds"] * 1_000,
1509-
kwargs["nanoseconds"],
1501+
_to_py_int_float(kwargs.get("weeks", 0)) * 7 * 24 * 3600 * 1_000_000_000,
1502+
_to_py_int_float(kwargs.get("days", 0)) * 24 * 3600 * 1_000_000_000,
1503+
_to_py_int_float(kwargs.get("hours", 0)) * 3600 * 1_000_000_000,
1504+
_to_py_int_float(kwargs.get("minutes", 0)) * 60 * 1_000_000_000,
1505+
_to_py_int_float(kwargs.get("seconds", 0)) * 1_000_000_000,
1506+
_to_py_int_float(kwargs.get("milliseconds", 0)) * 1_000_000,
1507+
_to_py_int_float(kwargs.get("microseconds", 0)) * 1_000,
1508+
_to_py_int_float(kwargs.get("nanoseconds", 0)),
15101509
)
15111510
)
15121511
return create_timedelta(ns, "ns", out_reso)

0 commit comments

Comments
 (0)