diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index cca6238d2e89ac..ba164a82c162e8 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -942,7 +942,7 @@ Removal of prior version deprecations/changes - Removal of the previously deprecated module ``pandas.core.datetools`` (:issue:`14105`, :issue:`14094`) - Strings passed into :meth:`DataFrame.groupby` that refer to both column and index levels will raise a ``ValueError`` (:issue:`14432`) - :meth:`Index.repeat` and :meth:`MultiIndex.repeat` have renamed the ``n`` argument to ``repeats`` (:issue:`14645`) -- The ``Series`` constructor and ``.astype`` method will now raise a ``ValueError`` if timestamp dtypes are passed in without a frequency (e.g. ``np.datetime64``) for the ``dtype`` parameter (:issue:`15987`) +- The ``Series`` constructor and ``.astype`` method will now raise a ``ValueError`` if timestamp dtypes are passed in without a unit (e.g. ``np.datetime64``) for the ``dtype`` parameter (:issue:`15987`) - Removal of the previously deprecated ``as_indexer`` keyword completely from ``str.match()`` (:issue:`22356`, :issue:`6581`) - The modules ``pandas.types``, ``pandas.computation``, and ``pandas.util.decorators`` have been removed (:issue:`16157`, :issue:`16250`) - Removed the ``pandas.formats.style`` shim for :class:`pandas.io.formats.style.Styler` (:issue:`16059`) diff --git a/doc/test.parquet b/doc/test.parquet new file mode 100644 index 00000000000000..cc2f7edbb6ee4b Binary files /dev/null and b/doc/test.parquet differ diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index f8b7fb7d88ee00..47e17c9868cd78 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -667,7 +667,7 @@ def astype_nansafe(arr, dtype, copy=True, skipna=False): Raises ------ ValueError - The dtype was a datetime /timedelta dtype, but it had no frequency. + The dtype was a datetime64/timedelta64 dtype, but it had no unit. """ # dispatch on extension dtype if needed @@ -749,7 +749,7 @@ def astype_nansafe(arr, dtype, copy=True, skipna=False): return astype_nansafe(to_timedelta(arr).values, dtype, copy=copy) if dtype.name in ("datetime64", "timedelta64"): - msg = ("The '{dtype}' dtype has no frequency. " + msg = ("The '{dtype}' dtype has no unit. " "Please pass in '{dtype}[ns]' instead.") raise ValueError(msg.format(dtype=dtype.name)) @@ -1021,7 +1021,7 @@ def maybe_cast_to_datetime(value, dtype, errors='raise'): if is_datetime64 or is_datetime64tz or is_timedelta64: # Force the dtype if needed. - msg = ("The '{dtype}' dtype has no frequency. " + msg = ("The '{dtype}' dtype has no unit. " "Please pass in '{dtype}[ns]' instead.") if is_datetime64 and not is_dtype_equal(dtype, _NS_DTYPE): diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index bdd99dd4850422..7595b1278a2916 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -1198,7 +1198,7 @@ def test_constructor_cast_object(self, index): ]) def test_constructor_generic_timestamp_no_frequency(self, dtype): # see gh-15524, gh-15987 - msg = "dtype has no frequency. Please pass in" + msg = "dtype has no unit. Please pass in" with tm.assert_raises_regex(ValueError, msg): Series([], dtype=dtype) diff --git a/pandas/tests/series/test_dtypes.py b/pandas/tests/series/test_dtypes.py index c62531241369d8..64184a6465ba3f 100644 --- a/pandas/tests/series/test_dtypes.py +++ b/pandas/tests/series/test_dtypes.py @@ -404,7 +404,7 @@ def test_astype_generic_timestamp_no_frequency(self, dtype): data = [1] s = Series(data) - msg = "dtype has no frequency. Please pass in" + msg = "dtype has no unit. Please pass in" with tm.assert_raises_regex(ValueError, msg): s.astype(dtype)