|  | 
| 71 | 71 | ) | 
| 72 | 72 | from pandas.util._exceptions import ( | 
| 73 | 73 |  find_stack_level, | 
| 74 |  | - rewrite_warning, | 
| 75 | 74 | ) | 
| 76 | 75 | from pandas.util._validators import ( | 
| 77 | 76 |  validate_ascending, | 
| @@ -11926,25 +11925,13 @@ def _get_data() -> DataFrame: | 
| 11926 | 11925 |  row_index = np.tile(np.arange(nrows), ncols) | 
| 11927 | 11926 |  col_index = np.repeat(np.arange(ncols), nrows) | 
| 11928 | 11927 |  ser = Series(arr, index=col_index, copy=False) | 
| 11929 |  | - # GroupBy will raise a warning with SeriesGroupBy as the object, | 
| 11930 |  | - # likely confusing users | 
| 11931 |  | - with rewrite_warning( | 
| 11932 |  | - target_message=( | 
| 11933 |  | - f"The behavior of SeriesGroupBy.{name} with all-NA values" | 
| 11934 |  | - ), | 
| 11935 |  | - target_category=FutureWarning, | 
| 11936 |  | - new_message=( | 
| 11937 |  | - f"The behavior of {type(self).__name__}.{name} with all-NA " | 
| 11938 |  | - "values, or any-NA and skipna=False, is deprecated. In " | 
| 11939 |  | - "a future version this will raise ValueError" | 
| 11940 |  | - ), | 
| 11941 |  | - ): | 
| 11942 |  | - result = ser.groupby(row_index).agg(name, **kwds) | 
|  | 11928 | + if name == "all": | 
|  | 11929 | + # Behavior here appears incorrect; preserving | 
|  | 11930 | + # for backwards compatibility for now. | 
|  | 11931 | + # See https://github.com/pandas-dev/pandas/issues/57171 | 
|  | 11932 | + skipna = True | 
|  | 11933 | + result = ser.groupby(row_index).agg(name, **kwds, skipna=skipna) | 
| 11943 | 11934 |  result.index = df.index | 
| 11944 |  | - if not skipna and name not in ("any", "all"): | 
| 11945 |  | - mask = df.isna().to_numpy(dtype=np.bool_).any(axis=1) | 
| 11946 |  | - other = -1 if name in ("idxmax", "idxmin") else lib.no_default | 
| 11947 |  | - result = result.mask(mask, other) | 
| 11948 | 11935 |  return result | 
| 11949 | 11936 | 
 | 
| 11950 | 11937 |  df = df.T | 
| @@ -13258,13 +13245,11 @@ def idxmin( | 
| 13258 | 13245 |  # indices will always be np.ndarray since axis is not N | 
| 13259 | 13246 | 
 | 
| 13260 | 13247 |  if (indices == -1).any(): | 
| 13261 |  | - warnings.warn( | 
| 13262 |  | - f"The behavior of {type(self).__name__}.idxmin with all-NA " | 
| 13263 |  | - "values, or any-NA and skipna=False, is deprecated. In a future " | 
| 13264 |  | - "version this will raise ValueError", | 
| 13265 |  | - FutureWarning, | 
| 13266 |  | - stacklevel=find_stack_level(), | 
| 13267 |  | - ) | 
|  | 13248 | + if skipna: | 
|  | 13249 | + msg = "Encountered all NA values" | 
|  | 13250 | + else: | 
|  | 13251 | + msg = "Encountered an NA values with skipna=False" | 
|  | 13252 | + raise ValueError(msg) | 
| 13268 | 13253 | 
 | 
| 13269 | 13254 |  index = data._get_axis(axis) | 
| 13270 | 13255 |  result = algorithms.take( | 
| @@ -13365,13 +13350,11 @@ def idxmax( | 
| 13365 | 13350 |  # indices will always be 1d array since axis is not None | 
| 13366 | 13351 | 
 | 
| 13367 | 13352 |  if (indices == -1).any(): | 
| 13368 |  | - warnings.warn( | 
| 13369 |  | - f"The behavior of {type(self).__name__}.idxmax with all-NA " | 
| 13370 |  | - "values, or any-NA and skipna=False, is deprecated. In a future " | 
| 13371 |  | - "version this will raise ValueError", | 
| 13372 |  | - FutureWarning, | 
| 13373 |  | - stacklevel=find_stack_level(), | 
| 13374 |  | - ) | 
|  | 13353 | + if skipna: | 
|  | 13354 | + msg = "Encountered all NA values" | 
|  | 13355 | + else: | 
|  | 13356 | + msg = "Encountered an NA values with skipna=False" | 
|  | 13357 | + raise ValueError(msg) | 
| 13375 | 13358 | 
 | 
| 13376 | 13359 |  index = data._get_axis(axis) | 
| 13377 | 13360 |  result = algorithms.take( | 
|  | 
0 commit comments