-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Fix assert frame equal na dtype false 61473 #62672
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
Changes from all commits
4094088
12759b4
890af41
7f84118
484c1b4
193a2a1
99513c9
ce0d1f1
1bcc168
6264cc1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -882,6 +882,9 @@ def assert_series_equal( | |
| Second Series to compare. | ||
| check_dtype : bool, default True | ||
| Whether to check the Series dtype is identical. | ||
| check_dtype : bool, if False | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check_dtype is already there 2 lines up
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also the default is still True |
||
| Whether to check the series is equal or not if dtype is | ||
| False. | ||
| check_index_type : bool or {'equiv'}, default 'equiv' | ||
| Whether to check the Index class, dtype and inferred_type | ||
| are identical. | ||
|
|
@@ -1025,6 +1028,21 @@ def assert_series_equal( | |
| pass | ||
| else: | ||
| assert_attr_equal("dtype", left, right, obj=f"Attributes of {obj}") | ||
|
|
||
| if not check_dtype and (left.dtype != right.dtype): | ||
| # checks only when check_dtype is False #GH #61473 | ||
| lv, rv = left._values, right._values | ||
| lv = np.asarray(lv, dtype=object) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is going to be really expensive. no other alternatives? |
||
| rv = np.asarray(rv, dtype=object) | ||
| assert_numpy_array_equal( | ||
| lv, | ||
| rv, | ||
| check_dtype=check_dtype, | ||
| obj=str(obj), | ||
| index_values=left.index, | ||
| ) | ||
| check_exact = False | ||
|
|
||
| if check_exact: | ||
| left_values = left._values | ||
| right_values = right._values | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,21 +160,13 @@ def test_query_empty_string(self): | |
| df.query("") | ||
|
|
||
| def test_query_duplicate_column_name(self, engine, parser): | ||
| df = DataFrame( | ||
| { | ||
| "A": range(3), | ||
| "B": range(3), | ||
| "C": range(3) | ||
| } | ||
| ).rename(columns={"B": "A"}) | ||
| df = DataFrame({"A": range(3), "B": range(3), "C": range(3)}).rename( | ||
| columns={"B": "A"} | ||
| ) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these changes look unrelated. please revert |
||
|
|
||
| res = df.query("C == 1", engine=engine, parser=parser) | ||
|
|
||
| expect = DataFrame( | ||
| [[1, 1, 1]], | ||
| columns=["A", "A", "C"], | ||
| index=[1] | ||
| ) | ||
| expect = DataFrame([[1, 1, 1]], columns=["A", "A", "C"], index=[1]) | ||
|
|
||
| tm.assert_frame_equal(res, expect) | ||
|
|
||
|
|
@@ -1140,9 +1132,7 @@ def test_query_with_nested_special_character(self, parser, engine): | |
| [">=", operator.ge], | ||
| ], | ||
| ) | ||
| def test_query_lex_compare_strings( | ||
| self, parser, engine, op, func | ||
| ): | ||
| def test_query_lex_compare_strings(self, parser, engine, op, func): | ||
| a = Series(np.random.default_rng(2).choice(list("abcde"), 20)) | ||
| b = Series(np.arange(a.size)) | ||
| df = DataFrame({"X": a, "Y": b}) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"in dtype and dtype is false" is odd phrasing
DFs -> ```:class:
DataFrames````fails -> failing