change
temp['total'] = pd.DataFrame(project_data.groupby(col1)[col2].agg({'total':'count'})).reset_index()['total'] temp['Avg'] = pd.DataFrame(project_data.groupby(col1)[col2].agg({'Avg':'mean'})).reset_index()['Avg']
to
temp['total'] = pd.DataFrame(project_data.groupby(col1)[col2].agg(total='count')).reset_index()['total'] temp['Avg'] = pd.DataFrame(project_data.groupby(col1)[col2].agg(Avg='mean')).reset_index()['Avg']
reason: in new pandas version named aggregation is the recommended replacement for the deprecated “dict-of-dicts” approach to naming the output of column-specific aggregations (Deprecate groupby.agg() with a dictionary when renaming).
source: https://pandas.pydata.org/pandas-docs/stable/whatsnew/v0.25.0.html
Related Posts:
- Pandas group-by and sum
- Pandas group-by and sum
- how to sort pandas dataframe from one column
- Delete a column from a Pandas DataFrame
- Constructing pandas DataFrame from values in variables gives “ValueError: If using all scalar values, you must pass an index”
- How to iterate over rows in a DataFrame in Pandas
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- Writing a pandas DataFrame to CSV file
- Modifing data while using iterrows() does not work
- What does `ValueError: cannot reindex from a duplicate axis` mean?
- Pandas DataFrame Groupby two columns and get counts
- How to show all columns’ names on a large pandas dataframe?
- ValueError: Unknown label type: ‘continuous’
- How to groupby based on two columns in pandas?
- How to deal with SettingWithCopyWarning in Pandas
- ImportError: No module named pandas
- TypeError: ‘Series’ objects are mutable, thus they cannot be hashed problemwith column
- Create a Pandas Dataframe by appending one row at a time
- ValueError: Length of values does not match length of index | Pandas DataFrame.unique()
- Creating an empty Pandas DataFrame, then filling it?
- Python Pandas Counting the Occurrences of a Specific value
- Count unique values per groups with Pandas
- DataFrame constructor not properly called
- Convert pandas Series to DataFrame
- ImportError: Missing required dependencies [‘numpy’]
- How to iterate over rows in a DataFrame in Pandas
- Pandas “Can only compare identically-labeled DataFrame objects” error
- Pandas: ValueError: cannot convert float NaN to integer
- ValueError: Length of values does not match length of index | Pandas DataFrame.unique()
- ‘DataFrame’ object has no attribute ‘sort’
- pandas: merge (join) two data frames on multiple columns
- Why do I get: “Length of values does not match length of index” error?
- why should I make a copy of a data frame in pandas
- Pandas, merging two dataframes on multiple columns, and multiplying result
- How to customize a scatter matrix to see all titles?
- What is dtype(‘O’), in pandas?
- How to read a .xlsx file using the pandas Library in iPython?
- Plot pie chart and table of pandas dataframe
- What is dtype(‘O’), in pandas?
- Pandas ‘count(distinct)’ equivalent
- Python TypeError: cannot convert the series to
when trying to do math on dataframe - ValueError: ‘object too deep for desired array’
- What does axis in pandas mean?
- How to take column-slices of dataframe in pandas
- Combine two columns of text in pandas dataframe
- Group by index + column in pandas
- Pandas: change data type of Series to String
- Normalize data in pandas
- Convert a Pandas DataFrame to a dictionary
- Selecting with complex criteria from pandas.DataFrame
- Create a Pandas Dataframe by appending one row at a time
- module ‘pandas’ has no attribute ‘rolling_mean’
- Modify the legend of pandas bar plot
- Count unique values using pandas groupby
- Ignoring NaNs with str.containsv
- Count unique values per groups with Pandas [duplicate]
- Map to List error: Series object not callable
- Pandas DataFrame: replace all values in a column, based on condition
- How to convert string to datetime format in pandas python?
- No numeric types to aggregate – change in groupby() behaviour?
- Pandas – How to flatten a hierarchical index in columns
- Pandas OR statement ending in series contains
- ValueError: Expected object or value when reading json as pandas dataframe
- How to check if a column exists in Pandas
- How to get a value from a cell of a dataframe?
- Pandas split DataFrame by column value
- How to get row number in dataframe in Pandas?
- AttributeError: ‘Series’ object has no attribute ‘reshape’
- Pandas – Drop function error (label not contained in axis)
- datetime to string with series in pandas
- import pandas_datareader gives ImportError: cannot import name ‘is_list_like’
- Coalesce values from 2 columns into a single column in a pandas dataframe
- Unknown format code ‘f’ for object of type ‘str’- Folium
- How to add pandas data to an existing csv file?
- Find the unique values in a column and then sort them
- pandas groupby sort within groups
- Convert Pandas Column to DateTime
- if else function in pandas dataframe
- cannot convert the series to
- Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support
- Read data (.dat file) with Pandas
- How to convert index of a pandas dataframe into a column
- pandas replace multiple values one column
- Boolean Series key will be reindexed to match DataFrame index
- Converting Pandas dataframe into Spark dataframe error
- Must have equal len keys and value when setting with an iterable
- Difference between data type ‘datetime64[ns]’ and ‘
- Merging two DataFrames
- pandas: multiple conditions while indexing data frame – unexpected behavior
- How to print a specific row of a pandas DataFrame?
- Logical operators for Boolean indexing in Pandas
- How to update Pandas from Anaconda and is it possible to use eclipse with this last
- vectorize conditional assignment in pandas dataframe
- Error in Reading a csv file in pandas[CParserError: Error tokenizing data. C error: Buffer overflow caught – possible malformed input file.]
- Convert list of dictionaries to a pandas DataFrame
- Python Pandas : pivot table with aggfunc = count unique distinct
- Compare two columns using pandas
- AttributeError: ‘Series’ object has no attribute ‘split’ error in sending emails
- alueError: ordinal must be >= 1