@@ -74,7 +74,7 @@ def max_value(group):
74
74
tm .assert_series_equal (result , expected )
75
75
76
76
77
- def test_pass_args_kwargs (ts , tsframe ):
77
+ def test_pass_args_kwargs (ts ):
78
78
def f (x , q = None , axis = 0 ):
79
79
return np .percentile (x , q , axis = axis )
80
80
@@ -100,31 +100,34 @@ def f(x, q=None, axis=0):
100
100
tm .assert_series_equal (apply_result , agg_expected )
101
101
tm .assert_series_equal (trans_result , trans_expected )
102
102
103
- # DataFrame
104
- for as_index in [True , False ]:
105
- df_grouped = tsframe .groupby (lambda x : x .month , as_index = as_index )
106
- warn = None if as_index else FutureWarning
107
- msg = "A grouping .* was excluded from the result"
108
- with tm .assert_produces_warning (warn , match = msg ):
109
- agg_result = df_grouped .agg (np .percentile , 80 , axis = 0 )
110
- with tm .assert_produces_warning (warn , match = msg ):
111
- apply_result = df_grouped .apply (DataFrame .quantile , 0.8 )
112
- with tm .assert_produces_warning (warn , match = msg ):
113
- expected = df_grouped .quantile (0.8 )
114
- tm .assert_frame_equal (apply_result , expected , check_names = False )
115
- tm .assert_frame_equal (agg_result , expected )
116
-
117
- apply_result = df_grouped .apply (DataFrame .quantile , [0.4 , 0.8 ])
118
- with tm .assert_produces_warning (warn , match = msg ):
119
- expected_seq = df_grouped .quantile ([0.4 , 0.8 ])
120
- tm .assert_frame_equal (apply_result , expected_seq , check_names = False )
121
-
122
- with tm .assert_produces_warning (warn , match = msg ):
123
- agg_result = df_grouped .agg (f , q = 80 )
124
- with tm .assert_produces_warning (warn , match = msg ):
125
- apply_result = df_grouped .apply (DataFrame .quantile , q = 0.8 )
126
- tm .assert_frame_equal (agg_result , expected )
127
- tm .assert_frame_equal (apply_result , expected , check_names = False )
103
+
104
+ def test_pass_args_kwargs_dataframe (tsframe , as_index ):
105
+ def f (x , q = None , axis = 0 ):
106
+ return np .percentile (x , q , axis = axis )
107
+
108
+ df_grouped = tsframe .groupby (lambda x : x .month , as_index = as_index )
109
+ warn = None if as_index else FutureWarning
110
+ msg = "A grouping .* was excluded from the result"
111
+ with tm .assert_produces_warning (warn , match = msg ):
112
+ agg_result = df_grouped .agg (np .percentile , 80 , axis = 0 )
113
+ with tm .assert_produces_warning (warn , match = msg ):
114
+ apply_result = df_grouped .apply (DataFrame .quantile , 0.8 )
115
+ with tm .assert_produces_warning (warn , match = msg ):
116
+ expected = df_grouped .quantile (0.8 )
117
+ tm .assert_frame_equal (apply_result , expected , check_names = False )
118
+ tm .assert_frame_equal (agg_result , expected )
119
+
120
+ apply_result = df_grouped .apply (DataFrame .quantile , [0.4 , 0.8 ])
121
+ with tm .assert_produces_warning (warn , match = msg ):
122
+ expected_seq = df_grouped .quantile ([0.4 , 0.8 ])
123
+ tm .assert_frame_equal (apply_result , expected_seq , check_names = False )
124
+
125
+ with tm .assert_produces_warning (warn , match = msg ):
126
+ agg_result = df_grouped .agg (f , q = 80 )
127
+ with tm .assert_produces_warning (warn , match = msg ):
128
+ apply_result = df_grouped .apply (DataFrame .quantile , q = 0.8 )
129
+ tm .assert_frame_equal (agg_result , expected )
130
+ tm .assert_frame_equal (apply_result , expected , check_names = False )
128
131
129
132
130
133
def test_len ():
0 commit comments