-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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: Can only compare identically-labeled Series objects (string vs. object) #61099
Comments
Hi @wahsmail, pandas/pandas/core/indexes/base.py Lines 5453 to 5463 in 5d9cf43
Also confirmed that the comparison doesn't raise when |
take |
take |
Hi @rhshadrach 👋 I’m working on fixing [https://github.com//issues/61099] and ran into a failure in test_mixed_col_index_dtype. My fix updates Index.equals so that StringDtype and object dtypes are treated as equivalent when comparing column indexes. As a result, this test now fails because result.columns.dtype becomes "string" while expected.columns.dtype remains object. There are two options I’m considering: Update the test to explicitly cast expected.columns to "string" when using_infer_string=True, so it reflects the result. Thanks! |
@MayurKishorKumar - in that test I'm seeing that when pandas/pandas/tests/frame/test_arithmetic.py Lines 2193 to 2200 in 5736b96
So I don't see how |
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 a series (or dataframe) with otherwise identical indices are compared, but the indexes are technically dtype(object) and dtype(string), element-wise comparison fails. In the debugger, it looks like the ExtensionArray StringArray.equals is False when comparing to a python list of strings, causing Series._indexed_same to return False.
Expected Behavior
Ideally the string and object dtype would be comparable. This in-between state for Pandas dtypes has been quite awkward, with some libraries porting over to numpy-nullable / pyarrow dtype backends, but the Pandas library defaults not using them yet.
Installed Versions
Replace this line with the output of pd.show_versions()
The text was updated successfully, but these errors were encountered: