Return True if any value in the group is truthful, else False. Parameters ---------- skipna : bool, default True Flag to ignore nan values during truth testing. Returns ------- Series or DataFrame DataFrame or Series
(self, skipna: bool = True)
| 1966 | |
| 1967 | @final |
| 1968 | def any(self, skipna: bool = True) -> NDFrameT: |
| 1969 | """ |
| 1970 | Return True if any value in the group is truthful, else False. |
| 1971 | |
| 1972 | Parameters |
| 1973 | ---------- |
| 1974 | skipna : bool, default True |
| 1975 | Flag to ignore nan values during truth testing. |
| 1976 | |
| 1977 | Returns |
| 1978 | ------- |
| 1979 | Series or DataFrame |
| 1980 | DataFrame or Series of boolean values, where a value is True if any element |
| 1981 | is True within its respective group, False otherwise. |
| 1982 | |
| 1983 | See Also |
| 1984 | -------- |
| 1985 | Series.any : Apply function any to a Series. |
| 1986 | DataFrame.any : Apply function any to each row or column of a DataFrame. |
| 1987 | |
| 1988 | Examples |
| 1989 | -------- |
| 1990 | For SeriesGroupBy: |
| 1991 | |
| 1992 | >>> lst = ["a", "a", "b"] |
| 1993 | >>> ser = pd.Series([1, 2, 0], index=lst) |
| 1994 | >>> ser |
| 1995 | a 1 |
| 1996 | a 2 |
| 1997 | b 0 |
| 1998 | dtype: int64 |
| 1999 | >>> ser.groupby(level=0).any() |
| 2000 | a True |
| 2001 | b False |
| 2002 | dtype: bool |
| 2003 | |
| 2004 | For DataFrameGroupBy: |
| 2005 | |
| 2006 | >>> data = [[1, 0, 3], [1, 0, 6], [7, 1, 9]] |
| 2007 | >>> df = pd.DataFrame( |
| 2008 | ... data, columns=["a", "b", "c"], index=["ostrich", "penguin", "parrot"] |
| 2009 | ... ) |
| 2010 | >>> df |
| 2011 | a b c |
| 2012 | ostrich 1 0 3 |
| 2013 | penguin 1 0 6 |
| 2014 | parrot 7 1 9 |
| 2015 | >>> df.groupby(by=["a"]).any() |
| 2016 | b c |
| 2017 | a |
| 2018 | 1 False True |
| 2019 | 7 True True |
| 2020 | """ |
| 2021 | return self._cython_agg_general( |
| 2022 | "any", |
| 2023 | alt=lambda x: Series(x, copy=False).any(skipna=skipna), |
| 2024 | skipna=skipna, |
| 2025 | ) |
no test coverage detected