From 4796ccb35406014293128ccab67244df135448a7 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Sun, 28 Oct 2018 12:25:11 -0700 Subject: [PATCH] CLN: Follow-up comments to gh-23392 * Use 'unit' instead of 'frequency' * Minor spacing issues in docs --- doc/source/whatsnew/v0.24.0.txt | 2 +- doc/test.parquet | Bin 0 -> 889 bytes pandas/core/dtypes/cast.py | 6 +++--- pandas/tests/series/test_constructors.py | 2 +- pandas/tests/series/test_dtypes.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 doc/test.parquet diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 89acd1a14a412..f4d2e776c137d 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 0000000000000000000000000000000000000000..cc2f7edbb6ee4bac87229d5f4650be1741753bf1 GIT binary patch literal 889 zcmb_b%}T>S7~CXFh&L(hvVj~z&{8pmwzS$xFWx+OC|*UvrrByBNux=MrSt`S3Xh(| z=kVmS_ylhLur~E%mxYg=nVoOGgdJa8cMwE6I=JEmHUQWk37}YFSrI@Dgw2dcGLki- zR18rnEzY!idPYD&ki_P@pdqOCA&^xfP$XiAUj+OrG%qp0${!xBEzaC=GoX|;;|mrA z)B{!wQ7UaM;Fq)(&{+%kEb)XNB9FMurL_g+F_5T^`hdvstc-LnCk8Y@85h(11~EIFA(kzU@?I~Kp8 Qni>FngCqV##{AKJ1E64#ng9R* literal 0 HcmV?d00001 diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index f8b7fb7d88ee0..47e17c9868cd7 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 bdd99dd485042..7595b1278a291 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 c62531241369d..64184a6465ba3 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)