Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

test: skip dtype check for pivot in print_code pandas test (#9475)

Myles Scolnickd5da2692ebea
diff --git a/tests/_plugins/ui/_impl/dataframes/test_print_code.py b/tests/_plugins/ui/_impl/dataframes/test_print_code.py
index 0e1bf75808..57a297b0cb 100644
--- a/tests/_plugins/ui/_impl/dataframes/test_print_code.py
+++ b/tests/_plugins/ui/_impl/dataframes/test_print_code.py
@@ -517,7 +517,12 @@ def test_print_code_result_matches_actual_transform_pandas(
key=lambda col: col.astype(str),
).reset_index(drop=True)
- pd.testing.assert_frame_equal(code_result, real_result)
+ # Pivot can produce dtype differences between native pandas
+ # (object) and narwhals (StringDtype) for string-valued columns.
+ check_dtype = transform.type != TransformType.PIVOT
+ pd.testing.assert_frame_equal(
+ code_result, real_result, check_dtype=check_dtype
+ )
@given(