aggregation

How to Split overlapping date ranges into multiple date ranges in Pandas?

How to Split overlapping date ranges into multiple date ranges in Pandas? Question: I have following pandas Data Frame. I want to find overlapped date range and aggregate common company in the same date range. My desired output would be following: how can I achieve this in pandas? I tried implementing few approaches but was …

Total answers: 1

How can I aggregate rows together according to a selected column using a pandas DataFrame

How can I aggregate rows together according to a selected column using a pandas DataFrame Question: this is my first question in Stack Overflow. I will water down the problem that I have at the moment. I am trying to clean a dataset for a User-based collaborative filtering recommendendation system. Here’s an oversimplication of the …

Total answers: 1

Defining an aggregation function with groupby in pandas

Defining an aggregation function with groupby in pandas Question: I would like to collapse my dataset using groupby and agg, however after collapsing, I want the new column to show a string value only for the grouped rows. For example, the initial data is: df = pd.DataFrame([["a",1],["a",2],["b",2]], columns=[‘category’,’value’]) category value 0 a 1 1 a …

Total answers: 2

Python – How can I aggregate a pandas dataframe base on conditions on different rows?

Python – How can I aggregate a pandas dataframe base on conditions on different rows? Question: I have a pandas data frame with information about road segments. PRIRTECODE PRIM_BMP PRIM_EMP SEGMENT_LENGTH ELEMENT_ID RAMP CURVE_YEAR SEGMENT_TYPE 0001A 0 0.147 0.147 4850943 0 2019 Line 0001A 0.147 0.183 0.036 4850943 0 2019 Line 0001A 0.183 0.24 0.057 …

Total answers: 2

Creating variable for $sum in aggregation

MongoDB Aggregation – Creating variable for $sum Question: Sample input: { "students":[ { "name" : "John", "semesters":[ { "semester": "fall", "grades": [ {"EXAM_1" : 25}, {"EXAM_2" : 45}, {"EXAM_3" : 22} ] }, { "semester": "winter", "grades": [ {"EXAM_1" : 85}, {"EXAM_2" : 32}, {"EXAM_3" : 17} ] } ] },{ "name" : "Abraham", "semesters":[ …

Total answers: 1

python runtime 3x deviation for 32 vs 34 char IDs

python runtime 3x deviation for 32 vs 34 char IDs Question: I am running an aggregation script, which heavily relies on aggregating / grouping on an identifier column. Each identifier in this column is 32 character long as a result of a hashing function. so my ID column which will be used in pandas groupby …

Total answers: 1