This should work for you:

df.groupby(['latitude', 'longitude']).aggregate(lambda x: ','.join(map(str, x)))
Answer from HenriChab on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › groupby.html
GroupBy — pandas 3.0.2 documentation - PyData |
pandas.api.typing.DataFrameGroupBy and pandas.api.typing.SeriesGroupBy instances are returned by groupby calls pandas.DataFrame.groupby() and pandas.Series.groupby() respectively · DataFrameGroupBy.__iter__()
Top answer
1 of 2
2

This should work for you:

df.groupby(['latitude', 'longitude']).aggregate(lambda x: ','.join(map(str, x)))
2 of 2
2

The object type pandas.core.groupby.generic.DataFrameGroupBy is a list of tuples, where the first element is the groupby element and the second the dataframe for that group.

See the example below:

Creating test dataframe

import pandas as pd

df = pd.DataFrame({"ColA": [1,1,1,2,2,3,3,3], "ColB": [5,5,6,7,7,8,8,9], "ColC": [1,2,3,4,5,6,7,8]})

The test dataframe

>>> df
   ColA  ColB  ColC
0     1     5     1
1     1     5     2
2     1     6     3
3     2     7     4
4     2     7     5
5     3     8     6
6     3     8     7
7     3     9     8

Grouping dataframe

>>> groups = df.groupby(["ColA", "ColB"])

>>> type(groups)
<class 'pandas.core.groupby.generic.DataFrameGroupBy'>

Showing results

>>> for group in groups:
...     g, value = group
...     print(f"Key = {g}")
...     print(value)
...     print(80*"-")
...
Key = (1, 5)
   ColA  ColB  ColC
0     1     5     1
1     1     5     2
--------------------------------------------------------------------------------
Key = (1, 6)
   ColA  ColB  ColC
2     1     6     3
--------------------------------------------------------------------------------
Key = (2, 7)
   ColA  ColB  ColC
3     2     7     4
4     2     7     5
--------------------------------------------------------------------------------
Key = (3, 8)
   ColA  ColB  ColC
5     3     8     6
6     3     8     7
--------------------------------------------------------------------------------

IMPORTANT

As commented by @HenriChab, using aggregate or, for example, sum will return a dataframe type not a group type

>>> new_df = df.groupby(["ColA", "ColB"]).sum()
>>> new_df
           ColC
ColA ColB
1    5        3
     6        3
2    7        9
3    8       13
     9        8

Finally you can reset the index.

>>> new_df.reset_index(inplace=True)

>>> new_df
   ColA  ColB  ColC
0     1     5     3
1     1     6     3
2     2     7     9
3     3     8    13
4     3     9     8
Discussions

Python Pandas <pandas.core.groupby.DataFrameGroupBy object at ...> - Stack Overflow
I am trying to group and count the same info in a row: #Functions def postal_saude (): global df, lista_solic #List of solicitantes in Postal Saude list_sol = [lista_solic["name1"], More on stackoverflow.com
🌐 stackoverflow.com
Return type from `pandas.core.groupby.generic.DataFrameGroupBy.resample`
Describe the bug The type hint for pandas.core.groupby.generic.DataFrameGroupBy.resample says it returns a pandas.core.groupby.grouper.Grouper; however in at least some situations this function can return a pandas.core.resample.DatetimeIndexResamplerGroupby, which is not a Grouper. More on github.com
🌐 github.com
1
December 10, 2023
python - Convert DataFrameGroupBy object to DataFrame pandas - Stack Overflow
I just want a normal Dataframe back but I have a pandas.core.groupby.DataFrameGroupBy object. More on stackoverflow.com
🌐 stackoverflow.com
How does pandas .groupby() works?
Have you read the docs ? There is also a very extensive page in the user guide . More on reddit.com
🌐 r/learnpython
11
2
November 6, 2021
🌐
Built In
builtin.com › data-science › pandas-groupby
Pandas Groupby: 5 Methods to Know in Python | Built In
df_group = df.groupby("Product_Category") type(df_group) # Output pandas.core.groupby.generic.DataFrameGroupBy
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.core.groupby.DataFrameGroupBy.describe.html
pandas.core.groupby.DataFrameGroupBy.describe — pandas 2.3.3 documentation
A list-like of dtypes : Excludes the provided data types from the result. To exclude numeric types submit numpy.number. To exclude object columns submit the data type numpy.object. Strings can also be used in the style of select_dtypes (e.g. df.describe(exclude=['O'])). To exclude pandas categorical columns, use 'category'
🌐
Real Python
realpython.com › pandas-groupby
pandas GroupBy: Your Guide to Grouping Data in Python – Real Python
January 19, 2025 - >>> by_state = df.groupby("state") >>> print(by_state) <pandas.core.groupby.generic.DataFrameGroupBy object at 0x107293278>
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › python-pandas-dataframe-groupby
Pandas dataframe.groupby() Method - GeeksforGeeks
The code is providing total sales for each product category, demonstrating the core idea of grouping data and applying an aggregation function. The groupby() function in Pandas involves three main steps: Splitting, Applying, and Combining.
Published   July 11, 2025
🌐
GitHub
github.com › pandas-dev › pandas › blob › main › pandas › core › groupby › groupby.py
pandas/pandas/core/groupby/groupby.py at main · pandas-dev/pandas
The SeriesGroupBy and DataFrameGroupBy sub-class · (defined in pandas.core.groupby.generic) expose these user-facing objects to provide specific functionality. """ · from __future__ import annotations · · from collections.abc import ( Callable, Hashable, Iterable, Iterator, Mapping, Sequence, ) import datetime ·
Author   pandas-dev
Find elsewhere
🌐
GitHub
github.com › pandas-dev › pandas › blob › main › pandas › core › groupby › generic.py
pandas/pandas/core/groupby/generic.py at main · pandas-dev/pandas
>>> ser = df.groupby("animal")["breed"].unique() >>> ser · animal · cat [Persian] dog [Chihuahua, Beagle] Name: breed, dtype: object · """ result = self._op_via_apply("unique") return result · · · @set_module("pandas.api.typing") class DataFrameGroupBy(GroupBy[DataFrame]): _agg_examples_doc = dedent( """ Examples ·
Author   pandas-dev
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.core.groupby.DataFrameGroupBy.get_group.html
pandas.core.groupby.DataFrameGroupBy.get_group — pandas 2.3.3 documentation
>>> data = [[1, 2, 3], [1, 5, 6], [7, 8, 9]] >>> df = pd.DataFrame(data, columns=["a", "b", "c"], ... index=["owl", "toucan", "eagle"]) >>> df a b c owl 1 2 3 toucan 1 5 6 eagle 7 8 9 >>> df.groupby(by=["a"]).get_group((1,)) a b c owl 1 2 3 toucan 1 5 6
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.core.groupby.DataFrameGroupBy.groups.html
pandas.core.groupby.DataFrameGroupBy.groups — pandas 2.3.3 documentation
property DataFrameGroupBy.groups[source]# Dict {group name -> group labels}. Examples · For SeriesGroupBy: >>> lst = ['a', 'a', 'b'] >>> ser = pd.Series([1, 2, 3], index=lst) >>> ser a 1 a 2 b 3 dtype: int64 >>> ser.groupby(level=0).groups {'a': ['a', 'a'], 'b': ['b']} For DataFrameGroupBy: >>> data = [[1, 2, 3], [1, 5, 6], [7, 8, 9]] >>> df = pd.DataFrame(data, columns=["a", "b", "c"]) >>> df a b c 0 1 2 3 1 1 5 6 2 7 8 9 >>> df.groupby(by=["a"]).groups {1: [0, 1], 7: [2]} For Resampler: >>> ser = pd.Series([1, 2, 3, 4], index=pd.DatetimeIndex( ...
🌐
TutorialsPoint
tutorialspoint.com › python_pandas › python_pandas_groupby.htm
Python Pandas - GroupBy
Grouped Data: <pandas.core.groupby.generic.DataFrameGroupBy object at 0x7f1a11545060> You can group data based on multiple columns by applying a list of column values to the groupby() method. Here is an example where the data is grouped by multiple columns.
🌐
Dataquest
dataquest.io › blog › grouping-data-a-step-by-step-tutorial-to-groupby-in-pandas
Grouping Data: A Step-by-Step Tutorial to Using GroupBy in Pandas (2022) – Dataquest
March 6, 2023 - <pandas.core.groupby.generic.DataFrameGroupBy object at 0x0000026083789DF0> It is important to note that creating a GroupBy object only checks if we have passed a correct mapping; it doesn't really perform any of the operations of the split-apply-combine chain until we explicitly use some method on this object or extract some of its attributes.
🌐
GitHub
github.com › pandas-dev › pandas-stubs › issues › 825
Return type from `pandas.core.groupby.generic.DataFrameGroupBy.resample` · Issue #825 · pandas-dev/pandas-stubs
December 10, 2023 - Describe the bug The type hint for pandas.core.groupby.generic.DataFrameGroupBy.resample says it returns a pandas.core.groupby.grouper.Grouper; however in at least some situations this function can return a pandas.core.resample.DatetimeIndexResamplerGroupby, which is not a Grouper.
Author   vectro
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.groupby.html
pandas.DataFrame.groupby — pandas 3.0.2 documentation
The implementation of groupby is hash-based, meaning in particular that objects that compare as equal will be considered to be in the same group. An exception to this is that pandas has special handling of NA values: any NA values will be collapsed to a single group, regardless of how they compare.
🌐
GitHub
github.com › pandas-dev › pandas › issues › 27442
Give pandas.core.groupby.generic.DataFrameGroupBy __str__/_repr_pretty_/__repr__ methods · Issue #27442 · pandas-dev/pandas
July 17, 2019 - >>> df = pd.DataFrame({'a': [1, 1, 3], 'b': [9, 8, 7]}) >>> df.groupby('a') <pandas.core.groupby.generic.DataFrameGroupBy object at 0x7fd3d5a7b470>