@@ -1953,41 +1953,33 @@ def get_categorical_invalid_expected():
19531953 tm .assert_equal (result , expected )
19541954 return
19551955
1956- if columns == "C" :
1957- # i.e. SeriesGroupBy
1958- if op in ["prod" , "sum" , "skew" ]:
1959- # ops that require more than just ordered-ness
1960- if is_dt64 or is_cat or is_per :
1961- # GH#41291
1962- # datetime64 -> prod and sum are invalid
1963- if op == "skew" :
1964- msg = "does not support reduction 'skew'"
1965- elif is_dt64 :
1966- msg = "datetime64 type does not support"
1967- elif is_per :
1968- msg = "Period type does not support"
1969- else :
1970- msg = "category type does not support"
1971- with pytest .raises (TypeError , match = msg ):
1972- get_result ()
1956+ if op in ["prod" , "sum" , "skew" ]:
1957+ # ops that require more than just ordered-ness
1958+ if is_dt64 or is_cat or is_per :
1959+ # GH#41291
1960+ # datetime64 -> prod and sum are invalid
1961+ if op == "skew" :
1962+ msg = "does not support reduction 'skew'"
1963+ elif is_dt64 :
1964+ msg = "datetime64 type does not support"
1965+ elif is_per :
1966+ msg = "Period type does not support"
1967+ else :
1968+ msg = "category type does not support"
1969+ with pytest .raises (TypeError , match = msg ):
1970+ get_result ()
19731971
1972+ if not isinstance (columns , list ):
1973+ # i.e. SeriesGroupBy
19741974 return
1975- else :
1976- # ie. DataFrameGroupBy
1977- if op in ["prod" , "sum" ]:
1978- # ops that require more than just ordered-ness
1979- if is_dt64 or is_per or is_cat :
1975+ elif op == "skew" :
1976+ # TODO: test the numeric_only=True case
1977+ return
1978+ else :
1979+ # i.e. op in ["prod", "sum"]:
1980+ # i.e. DataFrameGroupBy
1981+ # ops that require more than just ordered-ness
19801982 # GH#41291
1981- # datetime64 -> prod and sum are invalid
1982- if is_dt64 :
1983- msg = "datetime64 type does not support"
1984- elif is_per :
1985- msg = "Period type does not support"
1986- else :
1987- msg = "category type does not support"
1988-
1989- with pytest .raises (TypeError , match = msg ):
1990- get_result ()
19911983 result = get_result (numeric_only = True )
19921984
19931985 # with numeric_only=True, these are dropped, and we get
@@ -1998,17 +1990,6 @@ def get_categorical_invalid_expected():
19981990 tm .assert_equal (result , expected )
19991991 return
20001992
2001- if op == "skew" and (is_cat or is_dt64 or is_per ):
2002- msg = "|" .join (
2003- [
2004- "Categorical is not ordered" ,
2005- "does not support reduction" ,
2006- ]
2007- )
2008- with pytest .raises (TypeError , match = msg ):
2009- get_result ()
2010- return
2011-
20121993 result = get_result ()
20131994 expected = df .set_index (keys )[columns ]
20141995 if override_dtype is not None :
0 commit comments