|
23 | 23 | ensure_clean_store,
|
24 | 24 | )
|
25 | 25 |
|
| 26 | +from pandas.io.pytables import _set_tz |
| 27 | + |
26 | 28 |
|
27 | 29 | def _compare_with_tz(a, b):
|
28 | 30 | tm.assert_frame_equal(a, b)
|
@@ -345,3 +347,22 @@ def test_read_with_where_tz_aware_index(tmp_path, setup_path):
|
345 | 347 | store.append(key, expected, format="table", append=True)
|
346 | 348 | result = pd.read_hdf(path, key, where="DATE > 20151130")
|
347 | 349 | tm.assert_frame_equal(result, expected)
|
| 350 | + |
| 351 | + |
| 352 | +def test_set_tz_datetime64_unit(tmp_path, setup_path): |
| 353 | + # GH 59004 |
| 354 | + # https://numpy.org/doc/stable/reference/generated/numpy.datetime_data.html |
| 355 | + tz = None |
| 356 | + example_dtype = ["datetime64[s]", "datetime64[25s]", "datetime64[ns]"] |
| 357 | + example_values = [ |
| 358 | + np.array([978307200, 1012608000], dtype=np.int64), |
| 359 | + np.array([978307200, 1012608000], dtype=np.int64), |
| 360 | + np.array([978307200000000000, 1012608000000000000], dtype=np.int64), |
| 361 | + ] |
| 362 | + for dtype, values in zip(example_dtype, example_values): |
| 363 | + tm.assert_datetime_array_equal( |
| 364 | + _set_tz(values, tz, dtype), |
| 365 | + pd.arrays.DatetimeArray._from_sequence( |
| 366 | + DatetimeIndex(["2001-01-01", "2002-02-02"], dtype=dtype) |
| 367 | + ), |
| 368 | + ) |
0 commit comments