|
6 | 6 |
|
7 | 7 | from collections import abc, defaultdict |
8 | 8 | import contextlib |
9 | | -from datetime import datetime, timedelta |
10 | 9 | from functools import partial |
11 | 10 | import inspect |
12 | 11 | from typing import Any, Collection, Iterable, Iterator, List, Union, cast |
13 | 12 | import warnings |
14 | 13 |
|
15 | 14 | import numpy as np |
16 | 15 |
|
17 | | -from pandas._libs import lib, tslibs |
| 16 | +from pandas._libs import lib |
18 | 17 | from pandas._typing import AnyArrayLike, Scalar, T |
19 | 18 | from pandas.compat.numpy import np_version_under1p18 |
20 | 19 |
|
21 | | -from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike |
| 20 | +from pandas.core.dtypes.cast import ( |
| 21 | + construct_1d_object_array_from_listlike, |
| 22 | + maybe_box_datetimelike, |
| 23 | +) |
22 | 24 | from pandas.core.dtypes.common import ( |
23 | 25 | is_array_like, |
24 | 26 | is_bool_dtype, |
@@ -78,21 +80,6 @@ def consensus_name_attr(objs): |
78 | 80 | return name |
79 | 81 |
|
80 | 82 |
|
81 | | -def maybe_box_datetimelike(value, dtype=None): |
82 | | - # turn a datetime like into a Timestamp/timedelta as needed |
83 | | - if dtype == object: |
84 | | - # If we dont have datetime64/timedelta64 dtype, we dont want to |
85 | | - # box datetimelike scalars |
86 | | - return value |
87 | | - |
88 | | - if isinstance(value, (np.datetime64, datetime)): |
89 | | - value = tslibs.Timestamp(value) |
90 | | - elif isinstance(value, (np.timedelta64, timedelta)): |
91 | | - value = tslibs.Timedelta(value) |
92 | | - |
93 | | - return value |
94 | | - |
95 | | - |
96 | 83 | def is_bool_indexer(key: Any) -> bool: |
97 | 84 | """ |
98 | 85 | Check whether `key` is a valid boolean indexer. |
|
0 commit comments