@@ -2657,16 +2657,16 @@ def test_listlike_binop_axis_1_bf_index(scalars_dfs):
2657
2657
assert_pandas_df_equal (bf_result , pd_result , check_dtype = False )
2658
2658
2659
2659
2660
- def test_binop_with_self_aggregate (session , scalars_dfs ):
2661
- scalars_df , scalars_pandas_df = scalars_dfs
2660
+ def test_binop_with_self_aggregate (scalars_dfs_maybe_ordered ):
2661
+ scalars_df , scalars_pandas_df = scalars_dfs_maybe_ordered
2662
2662
2663
2663
df_columns = ["int64_col" , "float64_col" , "int64_too" ]
2664
2664
2665
2665
# Ensure that this takes the optimized single-query path by counting executions
2666
- execution_count_before = session ._metrics .execution_count
2666
+ execution_count_before = scalars_df . _session ._metrics .execution_count
2667
2667
bf_df = scalars_df [df_columns ]
2668
2668
bf_result = (bf_df - bf_df .mean ()).to_pandas ()
2669
- execution_count_after = session ._metrics .execution_count
2669
+ execution_count_after = scalars_df . _session ._metrics .execution_count
2670
2670
2671
2671
pd_df = scalars_pandas_df [df_columns ]
2672
2672
pd_result = pd_df - pd_df .mean ()
@@ -2677,6 +2677,29 @@ def test_binop_with_self_aggregate(session, scalars_dfs):
2677
2677
assert_pandas_df_equal (bf_result , pd_result , check_dtype = False )
2678
2678
2679
2679
2680
+ def test_binop_with_self_aggregate_w_index_reset (scalars_dfs_maybe_ordered ):
2681
+ scalars_df , scalars_pandas_df = scalars_dfs_maybe_ordered
2682
+
2683
+ df_columns = ["int64_col" , "float64_col" , "int64_too" ]
2684
+
2685
+ # Ensure that this takes the optimized single-query path by counting executions
2686
+ execution_count_before = scalars_df ._session ._metrics .execution_count
2687
+ bf_df = scalars_df [df_columns ].reset_index (drop = True )
2688
+ bf_result = (bf_df - bf_df .mean ()).to_pandas ()
2689
+ execution_count_after = scalars_df ._session ._metrics .execution_count
2690
+
2691
+ pd_df = scalars_pandas_df [df_columns ].reset_index (drop = True )
2692
+ pd_result = pd_df - pd_df .mean ()
2693
+
2694
+ executions = execution_count_after - execution_count_before
2695
+
2696
+ assert executions == 1
2697
+ pd_result .index = pd_result .index .astype ("Int64" )
2698
+ assert_pandas_df_equal (
2699
+ bf_result , pd_result , check_dtype = False , check_index_type = False
2700
+ )
2701
+
2702
+
2680
2703
@pytest .mark .parametrize (
2681
2704
("left_labels" , "right_labels" ),
2682
2705
[
0 commit comments