Skip to content

Commit

Permalink
BUG: iter with readonly values, closes pandas-dev#28055 (pandas-dev#2…
Browse files Browse the repository at this point in the history
…8074)

* BUG: iter with readonly values, closes pandas-dev#28055

* whatsnew
  • Loading branch information
jbrockmendel authored and gabriellm1 committed Aug 27, 2019
1 parent 629428d commit 78aebfe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.25.1.rst
Expand Up @@ -29,6 +29,7 @@ Datetimelike

- Bug in :func:`to_datetime` where passing a timezone-naive :class:`DatetimeArray` or :class:`DatetimeIndex` and ``utc=True`` would incorrectly return a timezone-naive result (:issue:`27733`)
- Bug in :meth:`Period.to_timestamp` where a :class:`Period` outside the :class:`Timestamp` implementation bounds (roughly 1677-09-21 to 2262-04-11) would return an incorrect :class:`Timestamp` instead of raising ``OutOfBoundsDatetime`` (:issue:`19643`)
- Bug in iterating over :class:`DatetimeIndex` when the underlying data is read-only (:issue:`28055`)

Timezones
^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/tslib.pyx
Expand Up @@ -71,7 +71,7 @@ cdef inline object create_time_from_ts(

@cython.wraparound(False)
@cython.boundscheck(False)
def ints_to_pydatetime(int64_t[:] arr, object tz=None, object freq=None,
def ints_to_pydatetime(const int64_t[:] arr, object tz=None, object freq=None,
str box="datetime"):
"""
Convert an i8 repr to an ndarray of datetimes, date, time or Timestamp
Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/indexes/datetimes/test_misc.py
Expand Up @@ -377,3 +377,11 @@ def test_nanosecond_field(self):
dti = DatetimeIndex(np.arange(10))

tm.assert_index_equal(dti.nanosecond, pd.Index(np.arange(10, dtype=np.int64)))


def test_iter_readonly():
# GH#28055 ints_to_pydatetime with readonly array
arr = np.array([np.datetime64("2012-02-15T12:00:00.000000000")])
arr.setflags(write=False)
dti = pd.to_datetime(arr)
list(dti)

0 comments on commit 78aebfe

Please sign in to comment.