-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
Description
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
This bug happens with my real life data, however I am sorry but I am unable to reproduce this bug with mock data that model my real life data. The following code works fine :
import pandas as pd
print(pd.__version__)
df = pd.DataFrame([[1, 1, 129, 'WP_158394508.1', '+', 132906, 134099, 397, '-', 'Tyrosine integrase', 'Tyrosine integrase', 'Tyrosine integrase', 'WP_011835230', 357.0, 326.0, 25.46, 5.270e-15, 69.3, 72.29, 88.8, 'Integrase', 'ICE', 'Tn5252', 'pRS01', '-', '-', '-', '-', '-', 'validated', 'no', 'Tyrosine integrase', 'Tyrosine integrase', 'Phage_integrase', 172.0, 4.600e-40, 3.300e-40, 123.3, 0.6, 123.8, 0.6, 98.84, 43.58, 'yes']], index=[0], columns=['hit_blast', 'hit_HMM', 'CDS_num', 'CDS', 'CDS_strand', 'CDS_start', 'CDS_end', 'CDS_length', 'Is_pseudo', 'CDS_Protein_type', 'CDS_Protein_type_blast', 'Blast_description', 'Query_blast', 'Query_blast_length', 'Ali_length', 'Ali_Identity_perc', 'E-value_blast', 'Bitscore_blast', 'CDS_coverage_blast', 'Query_blast_coverage', 'Query_blast_Protein_type', 'Associated_element_type', 'ICE_superfamily', 'ICE_family', 'IME_family', 'Relaxase_family_domain', 'Relaxase_family_MOB', 'Coupling_type', 'False_positives', 'SP_blast_validation', 'Use_annotation', 'Profile_Protein_type', 'Profile_description', 'Profile_name', 'Profile_length', 'i-Evalue_hmm', 'E-value_hmm', 'Score_hmm', 'Bias_hmm', 'Global_score', 'Global_bias', 'HMM_coverage', 'CDS_coverage_hmm', 'Possible_SP'])
idx = 0
df.at[idx, "False_positives"] = "-"
Issue Description
Upgrading to pandas version 1.4.0 or 1.4.1 causes a call to the method .at[idx, "XXX"]
to generate an InvalidIndexError :
Traceback (most recent call last):
File "XXX.py", line XXX, in XXX
data.at[idx, "False_positives"] = "-"
File "lib/python3.9/site-packages/pandas/core/indexing.py", line 2274, in setitem
return super().setitem(key, value)
File "/python3.9/site-packages/pandas/core/indexing.py", line 2229, in setitem
self.obj._set_value(*key, value=value, takeable=self._takeable)
File "/python3.9/site-packages/pandas/core/frame.py", line 3869, in _set_value
loc = self.index.get_loc(index)
File "/python3.9/site-packages/pandas/core/indexes/range.py", line 388, in get_loc
self._check_indexing_error(key)
File "/python3.9/site-packages/pandas/core/indexes/base.py", line 5637, in _check_indexing_error
raise InvalidIndexError(key)
pandas.errors.InvalidIndexError: Int64Index([0], dtype='int64')
This error does not occur with pandas version 1.3.5. Can you help figure this out ?
Expected Behavior
No exception should be raised.
Installed Versions
import pandas as pd
pd.show_versions()
INSTALLED VERSIONS
commit : 06d2301
python : 3.9.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.13.0-27-generic
Version : #29~20.04.1-Ubuntu SMP Fri Jan 14 00:32:30 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.4.1
numpy : 1.22.2
pytz : 2021.3
dateutil : 2.8.2
pip : 22.0.3
setuptools : 59.8.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 : None
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : 0.8.9
xarray : None
xlrd : None
xlwt : None
zstandard : None