File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ Exceptions and warnings
46
46
errors.MergeError
47
47
errors.NoBufferPresent
48
48
errors.NullFrequencyError
49
+ errors.NullKeyWarning
49
50
errors.NumbaUtilError
50
51
errors.NumExprClobberingError
51
52
errors.OptionError
Original file line number Diff line number Diff line change @@ -878,6 +878,29 @@ class CategoricalConversionWarning(Warning):
878
878
"""
879
879
880
880
881
+ class NullKeyWarning (Warning ):
882
+ """
883
+ Warning raised when grouping on null/NA keys with default `dropna` argument.
884
+
885
+ This warning helps ensure data integrity and alerts users to potential issues
886
+ during grouping/aggregating when the default value of `dropna` would lead to
887
+ null keys being dropped from the output.
888
+
889
+ For more information, see discussion of [PDEP-11](#53094)
890
+
891
+ See Also
892
+ --------
893
+ DataFrame.groupby : Group DataFrame using a mapper or by a Series of columns.
894
+ DataFrame.pivot_table : Create a spreadsheet-style pivot table as a DataFrame.
895
+
896
+ Examples
897
+ --------
898
+ >>> df = pd.DataFrame({"A": ["a", None], "B": [1, 2]})
899
+ >>> df.groupby(["A"]).sum() # doctest: +SKIP
900
+ ... # NullKeyWarning: ...
901
+ """
902
+
903
+
881
904
class LossySetitemError (Exception ):
882
905
"""
883
906
Raised when trying to do a __setitem__ on an np.ndarray that is not lossless.
@@ -927,6 +950,7 @@ class InvalidComparison(Exception):
927
950
"MergeError" ,
928
951
"NoBufferPresent" ,
929
952
"NullFrequencyError" ,
953
+ "NullKeyWarning" ,
930
954
"NumExprClobberingError" ,
931
955
"NumbaUtilError" ,
932
956
"OptionError" ,
You can’t perform that action at this time.
0 commit comments