BUG: empty dataframe indexing raises ValueError: buffer source array is read-only only when coming from db #57130
Closed
3 tasks done
Labels
Milestone
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
when reading an empty dataframe via
read_sql
(i.e. a query returning nothing) it is impossible to check for an index-conditions via.loc
. It works fine withpd.options.mode.copy_on_write = False
.Expected Behavior
both,
df_plain.loc[df_plain.index > 69]
anddf_sql.loc[df_sql.index > 69]
should behave the same since the dfs are equal (assert_frame_equal
).Installed Versions
INSTALLED VERSIONS
commit : 56b5979
python : 3.11.7.final.0
python-bits : 64
OS : Linux
OS-release : 6.5.0-15-generic
Version : #15~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 12 18:54:30 UTC 2
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : de_DE.UTF-8
LOCALE : de_DE.UTF-8
pandas : 0+untagged.2.g56b5979
numpy : 1.26.3
pytz : 2023.4
dateutil : 2.8.2
setuptools : 69.0.3
pip : 23.3.2
Cython : 3.0.5
pytest : 8.0.0
hypothesis : 6.97.1
sphinx : 7.2.6
blosc : None
feather : None
xlsxwriter : 3.1.9
lxml.etree : 5.1.0
html5lib : 1.1
pymysql : 1.4.6
psycopg2 : 2.9.9
jinja2 : 3.1.3
IPython : 8.20.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : 1.3.7
dataframe-api-compat : None
fastparquet : 2023.10.1
fsspec : 2023.12.2
gcsfs : 2023.12.2post1
matplotlib : 3.8.2
numba : 0.58.1
numexpr : 2.9.0
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : 15.0.0
pyreadstat : 1.2.6
python-calamine : None
pyxlsb : 1.0.10
s3fs : 2023.12.2
scipy : 1.12.0
sqlalchemy : 2.0.25
tables : 3.9.2
tabulate : 0.9.0
xarray : 2024.1.1
xlrd : 2.0.1
zstandard : 0.22.0
tzdata : 2023.4
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: