Closed
Description
Code Sample
# Your code here
import pandas as pd
import numpy as np
times = np.array([np.datetime64('2012-02-15T12:00:00.000000000')])
times.setflags(write=False)
[d for d in pd.to_datetime(times)]
Problem description
The above code raises a ValueError: buffer source array is read-only
during the iteration over the DatetimeIndex
.
Note: This code snippet is just for demonstration. Read-only arrays are generated e.g. from an xarray broadcast
.
This did not happen for pandas<=0.25.0
Expected Output
[Timestamp('2012-02-15 12:00:00')]
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit : None
python : 3.7.3.final.0
python-bits : 64
OS : Linux
OS-release : 4.19.0-5-amd64
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 0.25.0
numpy : 1.17.0
pytz : 2019.2
dateutil : 2.8.0
pip : 19.2.2
setuptools : 41.1.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 7.7.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None