Skip to content Skip to sidebar Skip to footer
Showing posts with the label Group By

How To Do A Groupby On An Empty Set Of Columns In Pandas?

I am hitting on a corner case in pandas. I am trying to use the agg fn but without doing a groupby.… Read more How To Do A Groupby On An Empty Set Of Columns In Pandas?

Pandas Enumerate Groups In Descending Order

I've the following column: column 0 10 1 10 2 8 3 8 4 6 5 … Read more Pandas Enumerate Groups In Descending Order

Grouping On Identical Column Names In Pandas

time A1 A1 A2 A2 A2 A3 A3 2017-01 a1 a2 b1 b2 c ..... … Read more Grouping On Identical Column Names In Pandas

Groupby To Return Nth Group - Not Row

I'm attempting to group by two factors in a long (>2M) rows. Background to the data The seco… Read more Groupby To Return Nth Group - Not Row

Pandas - Select Values From A Groupby Object

I have a pandas groupby object, c: >>> c.index.names FrozenList([u'Thing1', u'… Read more Pandas - Select Values From A Groupby Object

Pandas Groupby And Sort Max Values

I am trying to groupby two Columns in a pandas df and return the max value. I'm then hoping to … Read more Pandas Groupby And Sort Max Values

Custom Groupby Based On Column Values

Given this dataframe: C index  0   9 1   0 2   1 3   5 4   0 5 … Read more Custom Groupby Based On Column Values

Python Pandas Unique Value Ignoring Nan

I want to use unique in groupby aggregation, but I don't want nan in the unique result. An exam… Read more Python Pandas Unique Value Ignoring Nan

Pandas Show Group Sum On All Rows

Given the following dataframe: col_a | col_b_tosum b | 5 b | 5 b | … Read more Pandas Show Group Sum On All Rows

Want To Find Year On Year Calculation Using Groupby And Apply For Various Years

I have a dataframe as follows: MARKET PRODUCT TIMEPERIOD DATE VALUES 0 USA MARKET A… Read more Want To Find Year On Year Calculation Using Groupby And Apply For Various Years

Filter Dataframe After Groupby And Nunique In Pandas

i tried df.groupby('item')['variable'].nunique() and it returns a unique count of e… Read more Filter Dataframe After Groupby And Nunique In Pandas

Python Pandas: Assign Last Value Of Dataframe Group To All Entries Of That Group

In Python Pandas, I have a DataFrame. I group this DataFrame by a column and want to assign the las… Read more Python Pandas: Assign Last Value Of Dataframe Group To All Entries Of That Group

Calculating Average Time Difference Among Items Grouped By A Specific Column

I have the following dataframe: userid | time 1 22.01.2001 13:00 1 22.01.2001 13… Read more Calculating Average Time Difference Among Items Grouped By A Specific Column

Pandas, Create Columns After Groupby

Regarding the Pandas DataFrame 'test_df': id_customer id_order product_name 3 … Read more Pandas, Create Columns After Groupby

How To Plot A Stacked Bar Chart Using Pandas Python

I have 3 dataframes for yearly data (one for 2014, 2015 and 2016), each having 3 columns named, … Read more How To Plot A Stacked Bar Chart Using Pandas Python

Pandas: Compute The Mean Of A Column Grouped By Another Column

Say I have a dataframe like this: gender height weight C 2000-01-01 male … Read more Pandas: Compute The Mean Of A Column Grouped By Another Column

Python Pandas Multiply Dataframe By Weights That Vary With Category In Vectorized Fashion

My problem is very similar to the one outlined here Except for that my main data frame has a catego… Read more Python Pandas Multiply Dataframe By Weights That Vary With Category In Vectorized Fashion

Python - Group By And Sum A List Of Tuples

Given the following list: [ ('A', '', Decimal('4.0000000000'), 1330, da… Read more Python - Group By And Sum A List Of Tuples

Pandas Group By Window Range (follow Up Question With Category)

Follow up question: I have the following data table: I want to extract groups within a certain wind… Read more Pandas Group By Window Range (follow Up Question With Category)

Pandas - Split Dataframe Into Multiple Dataframes Based On Dates?

I have a dataframe with multiple columns along with a date column. The date format is 12/31/15 and … Read more Pandas - Split Dataframe Into Multiple Dataframes Based On Dates?