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
Closed

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

mir06 opened this issue Aug 21, 2019 · 5 comments · Fixed by #28074
Labels
Datetime Datetime data dtype Regression Functionality that used to work in a prior pandas version

Comments

@mir06
Copy link

mir06 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
Copy link
Contributor

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?

@TomAugspurger TomAugspurger added this to the Contributions Welcome milestone Aug 21, 2019
@TomAugspurger TomAugspurger added the Datetime Datetime data dtype label Aug 21, 2019
@jbrockmendel
Copy link
Member

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.

@jorisvandenbossche jorisvandenbossche added the Regression Functionality that used to work in a prior pandas version label Aug 21, 2019
@jorisvandenbossche jorisvandenbossche modified the milestones: Contributions Welcome, 0.25.1 Aug 21, 2019
@TomAugspurger
Copy link
Contributor

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

@TomAugspurger TomAugspurger modified the milestones: 0.25.1, Contributions Welcome Aug 21, 2019
@jorisvandenbossche
Copy link
Member

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
Copy link
Contributor

TomAugspurger commented Aug 21, 2019 via email

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

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

* whatsnew
galuhsahid pushed a commit to galuhsahid/pandas that referenced this issue Aug 25, 2019
galuhsahid added a commit to galuhsahid/pandas that referenced this issue Aug 25, 2019
* 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)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants