On checking I found my polars version :

pl.__version__

0.17.3

https://pola-rs.github.io/polars/py-polars/html/reference/dataframe/api/polars.DataFrame.groupby.html

I need to do:

df.groupby("a").agg(pl.col("b").sum())  # there is no underscore in groupby

#output

shape: (3, 2)
a   b
str i64
"a" 2
"c" 3
"b" 5

and the document says :

Deprecated since version 0.19.0: This method has been renamed to DataFrame.group_by().

This is the new document for polars version 0.19

https://pola-rs.github.io/polars/py-polars/html/reference/dataframe/api/polars.DataFrame.group_by.html#polars-dataframe-group-by

Answer from Talha Tayyab on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › pandas attributeerror: 'dataframe' object has no attribute 'group_by'
r/learnpython on Reddit: Pandas AttributeError: 'DataFrame' object has no attribute 'group_by'
February 28, 2018 -

Hello,

Has anyone ever come across this before?

I'm trying to group some data in a dataframe and getting this error. The steps I've taken are:

  1. in a for loop:

read in a csv from an api using pd.read_csv() replaced some values in a column using a for loop and .loc[] appended the resulting data frame to a list

2) concatenated the list of dataframes using pd.concat()

3) added a calculated column to the new DF by multiplying another column

4) added two empty columns

5) filtered the DF using .loc[] based on a value within a column

6) filtered the DF using .loc[] based on a value in a different column

7) tried to use this code:

new_DF = old_df.group_by(['col1', 'col_2', 'col_3', 'adgroup', 'col_4', 'col5', 'col6'], as_index=False)[['col7', 'col8', 
'col9']].sum()

The DF seems to behaving normally for example I can do dtypes and columns on it and add columns which are calculated from other columns. What is super frustrating is that I can do pd.to_csv() and then pd.read_csv() on the DF and then I'm able to do the grouping I want (however this isn't ideal which is why I'm posting).

Any advice would be appreciated.

Cheers

🌐
GitHub
github.com › pandas-dev › pandas › issues › 55041
BUG: groupby.agg fails when input has duplicate columns and dict input · Issue #55041 · pandas-dev/pandas
September 7, 2023 - df = DataFrame( [[1, 2, 3, 4], [1, 3, 4, 5], [2, 4, 5, 6]], columns=["a", "b", "c", "c"], ) gb = df.groupby("a") gb.agg({"c": "sum"}) raises AttributeError: 'DataFrame' object has no attribute 'name'. Did you mean: 'rename'? I would expect it to aggregate both of the columns named "c".
Author   rhshadrach
Discussions

BUG AttributeError: 'DataFrameGroupBy' object has no attribute '_obj_with_exclusions'
In [5]: df.groupby('a').mean() ... agg_labels) /home/nicolas/Git/pandas/pandas/core/groupby.py in __getattr__(self, attr) 557 558 raise AttributeError("%r object has no attribute %r" % --> 559 (type(self).__name__, attr)) 560 561 def __getitem__(self, key): AttributeError: 'DataFrameGroupBy' object has ... More on github.com
🌐 github.com
13
November 18, 2015
python - AttributeError: 'DataFrame' object has no attribute 'group_by' - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
Dataframe groupby()[column].agg fails with AttributeError
There was an error while loading. Please reload this page More on github.com
🌐 github.com
1
April 24, 2018
AttributeError: 'DataFrame' object has no attribute 'name'
AttributeError Traceback (most recent call last) in 8 smote_train, smote_target = oversampler.fi... More on github.com
🌐 github.com
18
December 18, 2019
🌐
GitHub
github.com › pandas-dev › pandas › issues › 11640
BUG AttributeError: 'DataFrameGroupBy' object has no attribute '_obj_with_exclusions' · Issue #11640 · pandas-dev/pandas
November 18, 2015 - In [5]: df.groupby('a').mean() ... agg_labels) /home/nicolas/Git/pandas/pandas/core/groupby.py in __getattr__(self, attr) 557 558 raise AttributeError("%r object has no attribute %r" % --> 559 (type(self).__name__, attr)) 560 561 def __getitem__(self, key): AttributeError: 'DataFrameGroupBy' object has ...
Author   nbonnotte
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 1.1 › reference › groupby.html
GroupBy — pandas 1.1.5 documentation
GroupBy objects are returned by groupby calls: pandas.DataFrame.groupby(), pandas.Series.groupby(), etc · Dict {group name -> group labels}
🌐
GitHub
github.com › dask › dask › issues › 3438
Dataframe groupby()[column].agg fails with AttributeError · Issue #3438 · dask/dask
April 24, 2018 - AttributeError Traceback (most recent call last) <ipython-input-1-b43466d1ae6a> in <module>() 6 -0.666]}) 7 ddf = dd.from_pandas(df, npartitions=1) ----> 8 ddf.groupby('A')['B'].agg('var') 9 10 ~/applications/anaconda3/lib/python3.6/site-packages/dask/dataframe/groupby.py in agg(self, arg, split_every, split_out) 1217 @derived_from(pd.core.groupby.SeriesGroupBy) 1218 def agg(self, arg, split_every=None, split_out=1): -> 1219 return self.aggregate(arg, split_every=split_every, split_out=split_out) ~/applications/anaconda3/lib/python3.6/site-packages/dask/dataframe/groupby.py in aggregate(self, arg, split_every, split_out) 1211 1212 if not isinstance(arg, (list, dict)): -> 1213 result = result[result.columns[0]] 1214 1215 return result AttributeError: 'Series' object has no attribute 'columns'
Author   joergdietrich
🌐
Databricks Community
community.databricks.com › t5 › data-engineering › issue-with-pyspark-groupby-groupeddata › td-p › 7255
Issue with Pyspark GroupBy GroupedData - Databricks Community - 7255
March 27, 2023 - ... The issue with your code is that the groupBy operation returns a GroupedData object, which does not have a get_group method. Instead, you can use the filter method to filter the bronze_df DataFrame for each entity name and write the resulting DataFrames to separate Silver tables.
Find elsewhere
🌐
GitHub
github.com › scikit-learn-contrib › imbalanced-learn › issues › 666
AttributeError: 'DataFrame' object has no attribute 'name' · Issue #666 · scikit-learn-contrib/imbalanced-learn
December 18, 2019 - AttributeError Traceback (most recent call last) <ipython-input-32-8d38637b6cc6> in <module> 6 7 oversampler=SMOTE(random_state=42) ----> 8 smote_train, smote_target = oversampler.fit_resample(X,y) 9 10 print("Before OverSampling, counts of label '0', '1':", smote_target['label'].value_counts()) ~\Anaconda3\lib\site-packages\imblearn\base.py in fit_resample(self, X, y) 73 """ 74 check_classification_targets(y) ---> 75 X, y, binarize_y = self._check_X_y(X, y) 76 77 self.sampling_strategy_ = check_sampling_strategy( ~\Anaconda3\lib\site-packages\imblearn\base.py in _check_X_y(self, X, y, accept_
Author   islrnd
🌐
Stack Overflow
stackoverflow.com › questions › 54409818 › attributeerror-dataframe-object-has-no-attribute-agg
python - AttributeError: 'DataFrame' object has no attribute 'agg' - Stack Overflow
.agg is not a function/method that is usable on a dataframe object. This would be something that you might use on a grouped dataframe, or GroupBy object.
🌐
Databricks Community
community.databricks.com › t5 › data-engineering › attributeerror-dataframe-object-has-no-attribute › td-p › 61132
AttributeError: 'DataFrame' object has no attribut... - Databricks Community - 61132
February 19, 2024 - Hello, I have some trouble deduplicating rows on the "id" column, with the method "dropDuplicatesWithinWatermark" in a pipeline. When I run this pipeline, I get the error message: "AttributeError: 'DataFrame' object has no attribute 'dropDuplicatesWithinWatermark'" Here is part of the code: @dl...
🌐
GitHub
github.com › pandas-dev › pandas › issues › 49907
BUG: SeriesGroupBy.apply sets name attribute if result is DataFrame · Issue #49907 · pandas-dev/pandas
November 25, 2022 - def f(piece): return DataFrame({"value": piece, "demeaned": piece - piece.mean()}) df = pd.DataFrame({'a': [1,2,3], 'b': [4, 5, 5]}) res = df.groupby('a')['b'].apply(f) print(res.name) This prints 'b'. But .name shouldn't be an attribute of DataFrame... AttributeError: 'DataFrame' object has no attribute 'name'
Author   MarcoGorelli
🌐
Data Science Dojo
discuss.datasciencedojo.com › python
How to get group from groupby by key? - Python - Data Science Dojo Discussions
February 24, 2023 - Hello, I am having trouble accessing a specific group from my pandas DataFrame using the groupby() method. I have grouped my DataFrame by the ‘A’ column, and now I am trying to access the group with the key ‘foo’. I have tried using the .get_group() method, but it returns the group ...
🌐
Kaggle
kaggle.com › questions-and-answers › 511815
Convert DataFrameGroupBy object to a DataFrame
Checking your browser before accessing www.kaggle.com · Click here if you are not automatically redirected after 5 seconds
🌐
Reddit
reddit.com › r/learnpython › 'dataframe' object has no attribute 'name' when trying to delete specific rows in a csv file
r/learnpython on Reddit: 'DataFrame' object has no attribute 'name' when trying to delete specific rows in a csv file
July 8, 2022 -

It claims that the error revolves around df = df[df.name != "gif"], even though rows with those characters are exactly what I'm trying to delete.

import pandas as pd


df = pd.read_csv("Output Configured 3 edit.csv")
df =  df[df.name != "gif"] 

# df.column_name != whole string from the cell
# now, all the rows with the column: Name and Value: "dog" will be deleted

df.to_csv(file, index=False)
🌐
GitHub
github.com › dask › dask › issues › 8624
AttributeError: 'DataFrame' object has no attribute 'name'; Various stack overflow / github suggested fixes not working · Issue #8624 · dask/dask
January 26, 2022 - Then in the main script where I had done all the upstream transformations to the dataframe which we are working on, instantiate this class and call its get_df_of_ids method: { from myimportutils.my_import_utils import SomeUtils tools = SomeUtils(homes_to_import_unnormalized_dd_df) df_of_locale_ids = tools.get_df_of_ids() # This line fails: } ... { File "[ ... redacted]/pandas/core/generic.py", line 5487, in __getattr__ return object.__getattribute__(self, name) AttributeError: 'DataFrame' object has no attribute 'name'.
Author   david-thrower
🌐
GitHub
github.com › pandas-dev › pandas › issues › 11562
'mode' not recognized by df.groupby().agg(), but pd.Series.mode works · Issue #11562 · pandas-dev/pandas
November 9, 2015 - df = pd.DataFrame({'A': [1, 2, ... Cannot access callable attribute 'mode' of 'DataFrameGroupBy' objects, try using the 'apply' method ·...
Author   patricksurry