-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Error while debugging #46890
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
Comments
Is there a reason you need to read from a file you just overwrote? Why not just use the df that's already in memory since it should be identical? Asking because code is built around real-use cases. |
The code was just for recreation purpose.
It happens when I read any parquet file
El lun., 2 may. 2022 23:44, RyuuOujiXS ***@***.***> escribió:
… Is there a reason you need to read from a file you just overwrote? Why not
just use the df that's already in memory since it should be identical?
Asking because code is built around real-use cases.
—
Reply to this email directly, view it on GitHub
<#46890 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOD3ZKTFPM7WKZCP3PKQCFLVIBECJANCNFSM5USH2F6A>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I have the same issue: appending a column to the index works fine while running, but fails when in debug mode. I'm using Spyder I've created some dummy code that shows the problem: import pandas as pd
df = pd.DataFrame({"a": [1, 2, 3], "b": [100, 200, 300], "c": ["a", "b", "c"]})
df.set_index("a", inplace=True)
df.set_index("b", append=True, inplace=True)
print(df)
print(df.index) Running this without debugging returns ✔️ : c
a b
1 100 a
2 200 b
3 300 c
MultiIndex([(1, 100),
(2, 200),
(3, 300)],
names=['a', 'b']) Running this with debugging in Spyder returns ❌ : Traceback (most recent call last):
File "C:\Users\username\Miniconda3\envs\some-env\lib\site-packages\spyder_kernels\customize\spyderpdb.py", line 776, in run
super(SpyderPdb, self).run(cmd, globals, locals)
File "C:\Users\username\Miniconda3\envs\some-env\lib\bdb.py", line 597, in run
exec(cmd, globals, locals)
File "c:\users\username\path\temp.py", line 6, in <module>
df.set_index("b", append=True, inplace=True)
File "C:\Users\username\Miniconda3\envs\some-env\lib\site-packages\pandas\util\_decorators.py", line 311, in wrapper
return func(*args, **kwargs)
File "C:\Users\username\Miniconda3\envs\some-env\lib\site-packages\pandas\core\frame.py", line 5560, in set_index
index._cleanup()
File "C:\Users\username\Miniconda3\envs\some-env\lib\site-packages\pandas\core\indexes\base.py", line 843, in _cleanup
self._engine.clear_mapping()
File "pandas\_libs\properties.pyx", line 37, in pandas._libs.properties.CachedProperty.__get__
File "C:\Users\username\Miniconda3\envs\some-env\lib\site-packages\pandas\core\indexes\multi.py", line 1097, in _engine
return MultiIndexUIntEngine(self.levels, self.codes, offsets)
File "pandas\_libs\index.pyx", line 635, in pandas._libs.index.BaseMultiIndexCodesEngine.__init__
File "C:\Users\username\Miniconda3\envs\some-env\lib\site-packages\pandas\core\indexes\multi.py", line 136, in _codes_to_ints
codes <<= self.offsets
AttributeError: 'MultiIndex' object has no attribute 'offsets' I thought I would work around it with: # df.set_index("b", append=True, inplace=True)
df = df.reset_index().set_index(["a", "b"]) But the same issue persists. |
yeah, it seems to be some issue with debugging in spyder last version. |
have you reported to |
As it only appears to happen with |
yep, seems like a problem with pandas, spyder and python 3.10 |
3.8 |
can you try with python 3.10? |
The Spyder issue was closed as:
The Spyder issue has an environment specification that reproduces this issue. Is there anything else I can provide to help resolve this issue? |
Same problem here with read_feather from pandas |
Thanks - yup, can reproduce with Python3.10! To reproduce:
import pandas as pd
df = pd.DataFrame({"a": [1, 2, 3], "b": [100, 200, 300], "c": ["a", "b", "c"]})
df.set_index("a", inplace=True)
import ipdb; ipdb.set_trace()
df.set_index("b", append=True, inplace=True)
we get
Note: this only happens with |
So I cannot debug on spyder if working with pandas on an environment ? this is a major problem considering I'm working on a big project and I have to control some functions independently |
yep, that's the problem |
Well, that's a bit of a broad statement... As stated in this comment:
So, if you simply specify |
This looks related to #41935. Is this still an issue in 1.4.3? |
I have recreated the environment linked to earlier, updated So it seems this issue is resolved, thanks! Fold out for the full
|
Thanks for checking @ba-tno, closing then! |
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
IMPORTANT: This only happens when debugging on line: pd.read_parquet('test.parquet')
I am using spyder on anaconda.
I can provide dependencies if necessary.
File "C:\Users\edudv\miniconda3\envs\test_pd\lib\site-packages\spyder_kernels\customize\spyderpdb.py", line 776, in run
super(SpyderPdb, self).run(cmd, globals, locals)
File "C:\Users\edudv\miniconda3\envs\test_pd\lib\bdb.py", line 597, in run
exec(cmd, globals, locals)
File "c:\users\edudv\downloads\test.py", line 16, in
df = pd.read_parquet('test.parquet')
File "C:\Users\edudv\miniconda3\envs\test_pd\lib\site-packages\pandas\io\parquet.py", line 493, in read_parquet
return impl.read(
File "C:\Users\edudv\miniconda3\envs\test_pd\lib\site-packages\pandas\io\parquet.py", line 240, in read
result = self.api.parquet.read_table(
File "pyarrow\array.pxi", line 767, in pyarrow.lib._PandasConvertible.to_pandas
File "pyarrow\table.pxi", line 1996, in pyarrow.lib.Table._to_pandas
File "C:\Users\edudv\miniconda3\envs\test_pd\lib\site-packages\pyarrow\pandas_compat.py", line 788, in table_to_blockmanager
columns = _deserialize_column_index(table, all_columns, column_indexes)
File "C:\Users\edudv\miniconda3\envs\test_pd\lib\site-packages\pyarrow\pandas_compat.py", line 903, in _deserialize_column_index
columns = _flatten_single_level_multiindex(columns)
File "C:\Users\edudv\miniconda3\envs\test_pd\lib\site-packages\pyarrow\pandas_compat.py", line 1150, in _flatten_single_level_multiindex
if not index.is_unique:
File "pandas_libs\properties.pyx", line 37, in pandas._libs.properties.CachedProperty.get
File "C:\Users\edudv\miniconda3\envs\test_pd\lib\site-packages\pandas\core\indexes\base.py", line 2237, in is_unique
return self._engine.is_unique
File "pandas_libs\properties.pyx", line 37, in pandas._libs.properties.CachedProperty.get
File "C:\Users\edudv\miniconda3\envs\test_pd\lib\site-packages\pandas\core\indexes\multi.py", line 1097, in _engine
return MultiIndexUIntEngine(self.levels, self.codes, offsets)
File "pandas_libs\index.pyx", line 635, in pandas._libs.index.BaseMultiIndexCodesEngine.init
File "C:\Users\edudv\miniconda3\envs\test_pd\lib\site-packages\pandas\core\indexes\multi.py", line 136, in _codes_to_ints
codes <<= self.offsets
AttributeError: 'MultiIndex' object has no attribute 'offsets'
Expected Behavior
Read parquet file
Installed Versions
INSTALLED VERSIONS
commit : 4bfe3d0
python : 3.10.4.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19044
machine : AMD64
processor : Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : en
LOCALE : es_ES.cp1252
pandas : 1.4.2
numpy : 1.22.3
pytz : 2022.1
dateutil : 2.8.2
pip : 22.0.4
setuptools : 62.1.0
Cython : None
pytest : None
hypothesis : None
sphinx : 4.5.0
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.1
IPython : 7.32.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli :
fastparquet : None
fsspec : None
gcsfs : None
markupsafe : 2.1.1
matplotlib : 3.5.1
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 7.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.8.0
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
C:\Users\edudv\miniconda3\envs\test_pd\lib\site-packages_distutils_hack_init_.py:30: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
The text was updated successfully, but these errors were encountered: