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

BUG: pd.DataFrame.replace(to_replace: list, method: str) raises TypeError: No matching signature found #37899

Closed
2 of 3 tasks
oguzhanogreden opened this issue Nov 16, 2020 · 3 comments
Labels
Bug Categorical Categorical Data Type replace replace method

Comments

@oguzhanogreden
Copy link
Contributor

  • I have checked that this issue has not already been reported: search query

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas: Tested with '1.2.0.dev0+1137.g50b34a4a8')


Code Sample, a copy-pastable example

import pandas as pd

df = pd.DataFrame({
    'x': pd.Categorical([1, 2, 3], [1, 2, 3])
})

df.replace([1, 2], method='bfill')

# > Traceback excerpt: 635 def backfill_inplace(algos_t[:] values, const uint8_t[:] mask, limit=None):
# > TypeError: No matching signature found

Problem description

This should work fine, within bounds of considerations like #18250.

Expected Output

Should be equivalent to pd.Categorical([3, 3, 3], [1,2,3]) (or pd.Categorical([3, 3, 3], [3]) depending on the what's done with unused categories elsewhere.)

Output of pd.show_versions()

INSTALLED VERSIONS

commit : 50b34a4
python : 3.8.3.final.0
python-bits : 64
OS : Darwin
OS-release : 19.4.0
Version : Darwin Kernel Version 19.4.0: Wed Mar 4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 1.2.0.dev0+1137.g50b34a4a8
numpy : 1.18.5
pytz : 2020.1
dateutil : 2.8.1
pip : 20.1.1
setuptools : 47.3.1.post20200616
Cython : 0.29.21
pytest : 5.4.3
hypothesis : 5.16.2
sphinx : 3.1.1
blosc : None
feather : None
xlsxwriter : 1.2.9
lxml.etree : 4.5.1
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.15.0
pandas_datareader: None
bs4 : 4.9.1
bottleneck : 1.3.2
fsspec : 0.7.4
fastparquet : 0.4.0
gcsfs : None
matplotlib : 3.2.1
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : 0.17.1
pyxlsb : None
s3fs : 0.4.2
scipy : 1.4.1
sqlalchemy : 1.3.17
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.15.1
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.48.0

Noticed while working on #32542

@oguzhanogreden oguzhanogreden added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 16, 2020
@oguzhanogreden
Copy link
Contributor Author

I know too little about Cython and the type system that's used. My guess is that this may be happening due a mismatch between the types defined in algos_t and CategoricalDtype.

@mroeschke mroeschke added replace replace method Categorical Categorical Data Type and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 14, 2021
@jbrockmendel
Copy link
Member

closed by #44270

@oguzhanogreden
Copy link
Contributor Author

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type replace replace method
Projects
None yet
Development

No branches or pull requests

3 participants