We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have checked that this issue has not already been reported.
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.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
import pandas as pd df = pd.DataFrame({"Y0": [1, 2], "Y1": [3, 4]}) df = df.replace({"replace_string": "test"})
This raises a TypeError with the following Traceback:
Traceback (most recent call last): File "/home/developer/.config/JetBrains/PyCharmCE2020.1/scratches/scratch_1.py", line 7, in <module> df = df.replace({"replace_string": "test"}) File "/home/developer/PycharmProjects/pandas/pandas/core/frame.py", line 4277, in replace return super().replace( File "/home/developer/PycharmProjects/pandas/pandas/core/generic.py", line 6598, in replace return self.replace( File "/home/developer/PycharmProjects/pandas/pandas/core/frame.py", line 4277, in replace return super().replace( File "/home/developer/PycharmProjects/pandas/pandas/core/generic.py", line 6641, in replace new_data = self._mgr.replace_list( File "/home/developer/PycharmProjects/pandas/pandas/core/internals/managers.py", line 616, in replace_list masks = [comp(s, regex) for s in src_list] File "/home/developer/PycharmProjects/pandas/pandas/core/internals/managers.py", line 616, in <listcomp> masks = [comp(s, regex) for s in src_list] File "/home/developer/PycharmProjects/pandas/pandas/core/internals/managers.py", line 614, in comp return _compare_or_regex_search(values, s, regex) File "/home/developer/PycharmProjects/pandas/pandas/core/internals/managers.py", line 1946, in _compare_or_regex_search _check_comparison_types(False, a, b) File "/home/developer/PycharmProjects/pandas/pandas/core/internals/managers.py", line 1925, in _check_comparison_types raise TypeError( TypeError: Cannot compare types 'ndarray(dtype=int64)' and 'str' Process finished with exit code 1
The original DataFrame.
If at least one column is from dtype object, the replace works, for example the following works:
import pandas as pd df = pd.DataFrame({"Y0": [1, "2"], "Y1": [3, 4]}) df = df.replace({"replace_string": "test"})
Unexpectedly the following Code works:
import pandas as pd df = pd.DataFrame({"Y0": [1, 2], "Y1": [3, 4]}) df = df.replace(to_replace="replace_string", value="test")
This is probably related to #16784
Tested on master.
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
I have checked that this issue has not already been reported.
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.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
This raises a TypeError with the following Traceback:
Expected Output
The original DataFrame.
If at least one column is from dtype object, the replace works, for example the following works:
Unexpectedly the following Code works:
This is probably related to #16784
Tested on master.
The text was updated successfully, but these errors were encountered: