Skip to content

Commit 318bdfc

Browse files
committed
BUG: iter with readonly values, closes pandas-dev#28055
1 parent 8b3246f commit 318bdfc

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pandas/_libs/tslib.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ cdef inline object create_time_from_ts(
7171

7272
@cython.wraparound(False)
7373
@cython.boundscheck(False)
74-
def ints_to_pydatetime(int64_t[:] arr, object tz=None, object freq=None,
74+
def ints_to_pydatetime(const int64_t[:] arr, object tz=None, object freq=None,
7575
str box="datetime"):
7676
"""
7777
Convert an i8 repr to an ndarray of datetimes, date, time or Timestamp

pandas/tests/indexes/datetimes/test_misc.py

+8
Original file line numberDiff line numberDiff line change
@@ -377,3 +377,11 @@ def test_nanosecond_field(self):
377377
dti = DatetimeIndex(np.arange(10))
378378

379379
tm.assert_index_equal(dti.nanosecond, pd.Index(np.arange(10, dtype=np.int64)))
380+
381+
382+
def test_iter_readonly():
383+
# GH#28055 ints_to_pydatetime with readonly array
384+
arr = np.array([np.datetime64("2012-02-15T12:00:00.000000000")])
385+
arr.setflags(write=False)
386+
dti = pd.to_datetime(arr)
387+
list(dti)

0 commit comments

Comments
 (0)