|
6 | 6 |
|
7 | 7 | import numpy as np
|
8 | 8 |
|
9 |
| -from pandas._libs import Timestamp |
10 | 9 | import pandas._libs.hashing as hashing
|
11 | 10 |
|
12 |
| -from pandas.core.dtypes.cast import infer_dtype_from_scalar |
13 | 11 | from pandas.core.dtypes.common import (
|
14 | 12 | is_categorical_dtype,
|
15 | 13 | is_extension_array_dtype,
|
|
21 | 19 | ABCMultiIndex,
|
22 | 20 | ABCSeries,
|
23 | 21 | )
|
24 |
| -from pandas.core.dtypes.missing import isna |
25 | 22 |
|
26 | 23 | # 16 byte long hashing key
|
27 | 24 | _default_hash_key = "0123456789123456"
|
@@ -299,37 +296,3 @@ def hash_array(
|
299 | 296 | vals *= np.uint64(0x94D049BB133111EB)
|
300 | 297 | vals ^= vals >> 31
|
301 | 298 | return vals
|
302 |
| - |
303 |
| - |
304 |
| -def _hash_scalar( |
305 |
| - val, encoding: str = "utf8", hash_key: str = _default_hash_key |
306 |
| -) -> np.ndarray: |
307 |
| - """ |
308 |
| - Hash scalar value. |
309 |
| -
|
310 |
| - Parameters |
311 |
| - ---------- |
312 |
| - val : scalar |
313 |
| - encoding : str, default "utf8" |
314 |
| - hash_key : str, default _default_hash_key |
315 |
| -
|
316 |
| - Returns |
317 |
| - ------- |
318 |
| - 1d uint64 numpy array of hash value, of length 1 |
319 |
| - """ |
320 |
| - if isna(val): |
321 |
| - # this is to be consistent with the _hash_categorical implementation |
322 |
| - return np.array([np.iinfo(np.uint64).max], dtype="u8") |
323 |
| - |
324 |
| - if getattr(val, "tzinfo", None) is not None: |
325 |
| - # for tz-aware datetimes, we need the underlying naive UTC value and |
326 |
| - # not the tz aware object or pd extension type (as |
327 |
| - # infer_dtype_from_scalar would do) |
328 |
| - if not isinstance(val, Timestamp): |
329 |
| - val = Timestamp(val) |
330 |
| - val = val.tz_convert(None) |
331 |
| - |
332 |
| - dtype, val = infer_dtype_from_scalar(val) |
333 |
| - vals = np.array([val], dtype=dtype) |
334 |
| - |
335 |
| - return hash_array(vals, hash_key=hash_key, encoding=encoding, categorize=False) |
0 commit comments