Skip to content

Commit f23101f

Browse files
committed
Add info to docs
1 parent bddb335 commit f23101f

File tree

4 files changed

+3
-19
lines changed

4 files changed

+3
-19
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Other enhancements
5656
- :meth:`DataFrame.cummin`, :meth:`DataFrame.cummax`, :meth:`DataFrame.cumprod` and :meth:`DataFrame.cumsum` methods now have a ``numeric_only`` parameter (:issue:`53072`)
5757
- :meth:`DataFrame.ewm` now allows ``adjust=False`` when ``times`` is provided (:issue:`54328`)
5858
- :meth:`DataFrame.fillna` and :meth:`Series.fillna` can now accept ``value=None``; for non-object dtype the corresponding NA value will be used (:issue:`57723`)
59+
- :meth:`DataFrame.groupby` now accepts no fields for ``groupby`` by in :meth:`DataFrame.groupby` (:issue:`61160`)
5960
- :meth:`DataFrame.pivot_table` and :func:`pivot_table` now allow the passing of keyword arguments to ``aggfunc`` through ``**kwargs`` (:issue:`57884`)
6061
- :meth:`DataFrame.to_json` now encodes ``Decimal`` as strings instead of floats (:issue:`60698`)
6162
- :meth:`Series.cummin` and :meth:`Series.cummax` now supports :class:`CategoricalDtype` (:issue:`52335`)

pandas/core/frame.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9155,7 +9155,6 @@ def groupby(
91559155

91569156
if level is None and (by is None or by == []):
91579157
by = Series(0, index=self.index)
9158-
# raise TypeError("You have to supply one of 'by' and 'level'")
91599158

91609159
return DataFrameGroupBy(
91619160
obj=self,

pandas/core/series.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,7 +1975,6 @@ def groupby(
19751975

19761976
if level is None and (by is None or by == []):
19771977
by = Series(0, index=self.index)
1978-
# raise TypeError("You have to supply one of 'by' and 'level'")
19791978
if not as_index:
19801979
raise TypeError("as_index=False only valid with DataFrame")
19811980

pandas/tests/groupby/test_grouping.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ def test_groupby_level_with_nas(self, sort):
696696
tm.assert_series_equal(result, expected)
697697

698698
def test_groupby_without_by(self):
699-
# Test DataFrame.groupby() without any fields (global aggregation)
699+
# GH 61160
700700
df = DataFrame({"A": [1, 2, 3, 4], "B": [10, 20, 30, 40]})
701701

702702
# Test basic aggregation with no fields
@@ -715,41 +715,26 @@ def test_groupby_without_by(self):
715715
expected = Series([10]) # Sum of the values
716716
tm.assert_series_equal(result, expected)
717717

718-
# Test with conditional logic - should work with None/empty list too
718+
# Test with conditional logic - should work with None/empty list
719719
groupby_fields = None
720720
result = df.groupby(groupby_fields).sum()
721721
expected = df.sum().to_frame().T
722722
tm.assert_frame_equal(result, expected)
723723

724-
# Test with empty list
725724
result = df.groupby([]).sum()
726725
tm.assert_frame_equal(result, expected)
727726

728727
def test_groupby_args(self, multiindex_dataframe_random_data):
729728
# PR8618 and issue 8015
730729
frame = multiindex_dataframe_random_data
731730

732-
# No longer expecting errors when groupby() is called with no arguments
733-
# This is now valid behavior that puts all rows in a single group
734731
result = frame.groupby().sum()
735732
expected = frame.sum().to_frame().T
736733
tm.assert_frame_equal(result, expected)
737734

738735
result = frame.groupby(by=None, level=None).sum()
739736
tm.assert_frame_equal(result, expected)
740737

741-
# def test_groupby_args(self, multiindex_dataframe_random_data):
742-
# # PR8618 and issue 8015
743-
# frame = multiindex_dataframe_random_data
744-
745-
# msg = "You have to supply one of 'by' and 'level'"
746-
# with pytest.raises(TypeError, match=msg):
747-
# frame.groupby()
748-
749-
# msg = "You have to supply one of 'by' and 'level'"
750-
# with pytest.raises(TypeError, match=msg):
751-
# frame.groupby(by=None, level=None)
752-
753738
@pytest.mark.parametrize(
754739
"sort,labels",
755740
[

0 commit comments

Comments
 (0)