@@ -2961,19 +2961,16 @@ def test_pivot_empty_dataframe_period_dtype(self, freq):
29612961 tm .assert_frame_equal (result , expected )
29622962
29632963 def test_pivot_table_large_dataset_no_duplicates (self ):
2964- # GH 63314: pivot_table with large datasets should not produce duplicate indices
2965- # This test ensures that the fix for Python 3.14 hashtable issues works correctly
2964+ # GH 63314: pivot_table with large datasets should not produce
2965+ # duplicate indices. This test ensures the Python 3.14 fix works.
29662966 n_indices = 10000
29672967 metrics = ["apple" , "banana" , "coconut" ]
29682968
2969- data = []
2970- for i in range (n_indices ):
2971- for metric in metrics :
2972- data .append ({
2973- "idx" : f"id_{ i } " ,
2974- "metric" : metric ,
2975- "value" : i * 10 + len (metric )
2976- })
2969+ data = [
2970+ {"idx" : f"id_{ i } " , "metric" : metric , "value" : i * 10 + len (metric )}
2971+ for i in range (n_indices )
2972+ for metric in metrics
2973+ ]
29772974
29782975 df = DataFrame (data )
29792976
@@ -2985,15 +2982,19 @@ def test_pivot_table_large_dataset_no_duplicates(self):
29852982 )
29862983
29872984 # Verify no duplicate indices in the result
2988- assert len (result .index ) == len (result .index .unique ()), \
2989- f"Expected { len (result .index .unique ())} unique indices, got { len (result .index )} "
2985+ n_unique = len (result .index .unique ())
2986+ assert len (result .index ) == n_unique , (
2987+ f"Expected { n_unique } unique indices, got { len (result .index )} "
2988+ )
29902989
29912990 # Verify we have the expected number of rows
2992- assert len (result ) == n_indices , \
2991+ assert len (result ) == n_indices , (
29932992 f"Expected { n_indices } rows, got { len (result )} "
2993+ )
29942994
29952995 # Verify all expected indices are present
29962996 expected_indices = {f"id_{ i } " for i in range (n_indices )}
29972997 actual_indices = set (result .index )
2998- assert expected_indices == actual_indices , \
2998+ assert expected_indices == actual_indices , (
29992999 "Result indices don't match expected indices"
3000+ )
0 commit comments