@@ -6748,6 +6748,7 @@ def groupby(
6748
6748
* ,
6749
6749
squeeze : Literal [False ] = False ,
6750
6750
restore_coord_dims : bool = False ,
6751
+ eagerly_compute_group : bool = True ,
6751
6752
** groupers : Grouper ,
6752
6753
) -> DataArrayGroupBy :
6753
6754
"""Returns a DataArrayGroupBy object for performing grouped operations.
@@ -6763,6 +6764,11 @@ def groupby(
6763
6764
restore_coord_dims : bool, default: False
6764
6765
If True, also restore the dimension order of multi-dimensional
6765
6766
coordinates.
6767
+ eagerly_compute_group: bool
6768
+ Whether to eagerly compute ``group`` when it is a chunked array.
6769
+ This option is to maintain backwards compatibility. Set to False
6770
+ to opt-in to future behaviour, where ``group`` is not automatically loaded
6771
+ into memory.
6766
6772
**groupers : Mapping of str to Grouper or Resampler
6767
6773
Mapping of variable name to group by to :py:class:`Grouper` or :py:class:`Resampler` object.
6768
6774
One of ``group`` or ``groupers`` must be provided.
@@ -6877,7 +6883,9 @@ def groupby(
6877
6883
)
6878
6884
6879
6885
_validate_groupby_squeeze (squeeze )
6880
- rgroupers = _parse_group_and_groupers (self , group , groupers )
6886
+ rgroupers = _parse_group_and_groupers (
6887
+ self , group , groupers , eagerly_compute_group = eagerly_compute_group
6888
+ )
6881
6889
return DataArrayGroupBy (self , rgroupers , restore_coord_dims = restore_coord_dims )
6882
6890
6883
6891
@_deprecate_positional_args ("v2024.07.0" )
@@ -6892,6 +6900,7 @@ def groupby_bins(
6892
6900
squeeze : Literal [False ] = False ,
6893
6901
restore_coord_dims : bool = False ,
6894
6902
duplicates : Literal ["raise" , "drop" ] = "raise" ,
6903
+ eagerly_compute_group : bool = True ,
6895
6904
) -> DataArrayGroupBy :
6896
6905
"""Returns a DataArrayGroupBy object for performing grouped operations.
6897
6906
@@ -6928,6 +6937,11 @@ def groupby_bins(
6928
6937
coordinates.
6929
6938
duplicates : {"raise", "drop"}, default: "raise"
6930
6939
If bin edges are not unique, raise ValueError or drop non-uniques.
6940
+ eagerly_compute_group: bool
6941
+ Whether to eagerly compute ``group`` when it is a chunked array.
6942
+ This option is to maintain backwards compatibility. Set to False
6943
+ to opt-in to future behaviour, where ``group`` is not automatically loaded
6944
+ into memory.
6931
6945
6932
6946
Returns
6933
6947
-------
@@ -6965,7 +6979,9 @@ def groupby_bins(
6965
6979
precision = precision ,
6966
6980
include_lowest = include_lowest ,
6967
6981
)
6968
- rgrouper = ResolvedGrouper (grouper , group , self )
6982
+ rgrouper = ResolvedGrouper (
6983
+ grouper , group , self , eagerly_compute_group = eagerly_compute_group
6984
+ )
6969
6985
6970
6986
return DataArrayGroupBy (
6971
6987
self ,
0 commit comments