Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: buffer source array is read-only on DatetimeIndex with one element #28055

Closed
mir06 opened this issue Aug 21, 2019 · 5 comments · Fixed by #28074

Comments

@mir06
Copy link

commented Aug 21, 2019

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
@TomAugspurger

This comment has been minimized.

Copy link
Contributor

commented Aug 21, 2019

May need a fix similar to https://github.com/pandas-dev/pandas/pull/27946/files, but in ints_to_pydatetime. Care to submit a PR?

@jbrockmendel

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

Looks like in pd._libs.tslib.ints_to_pydatetime the argument int64_t[:] arr needs to be changed to const int64_t[:] arr. PR welcome.

@TomAugspurger

This comment has been minimized.

Copy link
Contributor

commented Aug 21, 2019

FYI @jorisvandenbossche I'm probably doing the release todayish, so I'm going to move this off the 0.25.1 milestone.

@jorisvandenbossche

This comment has been minimized.

Copy link
Member

commented Aug 21, 2019

I prefer to keep those issue on a milestone. If you want to get the queue clear on 0.25.1, it can be 0.25.2 (but for me just a 0.25.x milestone could also do). If not for 0.25.1/2, then 1.0. By default, I think we should mark regressions for the next milestone, even if nobody is directly going to work on it.

@TomAugspurger

This comment has been minimized.

Copy link
Contributor

commented Aug 21, 2019

jbrockmendel added a commit to jbrockmendel/pandas that referenced this issue Aug 21, 2019
TomAugspurger added a commit that referenced this issue Aug 21, 2019
BUG: iter with readonly values, closes #28055 (#28074)
* BUG: iter with readonly values, closes #28055

* whatsnew
TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue Aug 21, 2019
TomAugspurger added a commit that referenced this issue Aug 22, 2019
BUG: iter with readonly values, closes #28055 (#28074)
* BUG: iter with readonly values, closes #28055

* whatsnew
galuhsahid added a commit to galuhsahid/pandas that referenced this issue Aug 25, 2019
BUG: iter with readonly values, closes pandas-dev#28055 (pandas-dev#2…
…8074)

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

* whatsnew
galuhsahid added a commit to galuhsahid/pandas that referenced this issue Aug 25, 2019
Merge branch 'master' into parquet-categorical
* master: (40 commits)
  DOC: Fix GL01 and GL02 errors in the docstrings (pandas-dev#27988)
  Remove Encoding of values in char** For Labels (pandas-dev#27618)
  TYPING: more type hints for io.formats.printing (pandas-dev#27765)
  TST: fix compression tests when run without virtualenv/condaenv (pandas-dev#28051)
  DOC: Start 0.25.2 (pandas-dev#28111)
  DOC: Fix docstrings lack of punctuation (pandas-dev#28031)
  DOC: Remove alias for numpy.random.randn from the docs (pandas-dev#28082)
  DOC: update GroupBy.head()/tail() documentation (pandas-dev#27844)
  BUG: timedelta merge asof with tolerance (pandas-dev#27650)
  BUG: Series.rename raises error on values accepted by Series construc… (pandas-dev#27814)
  Preserve index when setting new column on empty dataframe. (pandas-dev#26471)
  BUG: Fixed groupby quantile for listlike q (pandas-dev#27827)
  BUG: iter with readonly values, closes pandas-dev#28055 (pandas-dev#28074)
  TST: non-strict xfail for period test (pandas-dev#28072)
  DOC: Update whatsnew (pandas-dev#28073)
  CI: disable codecov (pandas-dev#28065)
  CI: Set SHA for codecov upload (pandas-dev#28067)
  BUG: Correct the previous bug fixing on xlim for plotting (pandas-dev#28059)
  CI: Add pip dependence explicitly (pandas-dev#28008)
  DOC: Change document code prun in a row (pandas-dev#28029)
  ...
gabriellm1 added a commit to gabriellm1/pandas that referenced this issue Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.