@@ -21,17 +21,22 @@ def test_frame_consistency(request, groupby_func):
21
21
if groupby_func in ("first" , "last" ):
22
22
msg = "first and last are entirely different between frame and groupby"
23
23
request .node .add_marker (pytest .mark .xfail (reason = msg ))
24
- if groupby_func in ("nth" , " cumcount" , "ngroup" ):
24
+ if groupby_func in ("cumcount" ,):
25
25
msg = "DataFrame has no such method"
26
26
request .node .add_marker (pytest .mark .xfail (reason = msg ))
27
- if groupby_func in ("size" ,):
28
- msg = "Method is a property"
29
- request .node .add_marker (pytest .mark .xfail (reason = msg ))
27
+
28
+ if groupby_func == "ngroup" :
29
+ assert not hasattr (DataFrame , groupby_func )
30
+ return
30
31
31
32
frame_method = getattr (DataFrame , groupby_func )
32
33
gb_method = getattr (DataFrameGroupBy , groupby_func )
33
34
result = set (inspect .signature (gb_method ).parameters )
34
- expected = set (inspect .signature (frame_method ).parameters )
35
+ if groupby_func == "size" :
36
+ # "size" is a method on GroupBy but property on DataFrame:
37
+ expected = {"self" }
38
+ else :
39
+ expected = set (inspect .signature (frame_method ).parameters )
35
40
36
41
# Exclude certain arguments from result and expected depending on the operation
37
42
# Some of these may be purposeful inconsistencies between the APIs
@@ -79,17 +84,22 @@ def test_series_consistency(request, groupby_func):
79
84
if groupby_func in ("first" , "last" ):
80
85
msg = "first and last are entirely different between Series and groupby"
81
86
request .node .add_marker (pytest .mark .xfail (reason = msg ))
82
- if groupby_func in ("nth" , " cumcount" , "ngroup " , "corrwith" ):
87
+ if groupby_func in ("cumcount" , "corrwith" ):
83
88
msg = "Series has no such method"
84
89
request .node .add_marker (pytest .mark .xfail (reason = msg ))
85
- if groupby_func in ("size" ,):
86
- msg = "Method is a property"
87
- request .node .add_marker (pytest .mark .xfail (reason = msg ))
90
+
91
+ if groupby_func == "ngroup" :
92
+ assert not hasattr (Series , groupby_func )
93
+ return
88
94
89
95
series_method = getattr (Series , groupby_func )
90
96
gb_method = getattr (SeriesGroupBy , groupby_func )
91
97
result = set (inspect .signature (gb_method ).parameters )
92
- expected = set (inspect .signature (series_method ).parameters )
98
+ if groupby_func == "size" :
99
+ # "size" is a method on GroupBy but property on Series
100
+ expected = {"self" }
101
+ else :
102
+ expected = set (inspect .signature (series_method ).parameters )
93
103
94
104
# Exclude certain arguments from result and expected depending on the operation
95
105
# Some of these may be purposeful inconsistencies between the APIs
0 commit comments