Skip to content

Commit

Permalink
CLN: Follow-up comments to gh-23392 (#23401)
Browse files Browse the repository at this point in the history
* Use 'unit' instead of 'frequency'
* Minor spacing issues in docs

Follow-up to gh-23392
  • Loading branch information
gfyoung authored Oct 28, 2018
1 parent 360e727 commit 96d321c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.24.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
Binary file added doc/test.parquet
Binary file not shown.
6 changes: 3 additions & 3 deletions pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 96d321c

Please sign in to comment.