grouping

Ranking using multiple columns within groups allowing for tied ranks in Pandas

Ranking using multiple columns within groups allowing for tied ranks in Pandas Question: Intro and problem How can I rank observations within groups where the ranking is based on more than just one column and where the ranking allows for tied ranks? I know how to calculate aggregated group-level statistics using the groupby() method and …

Total answers: 1

Group a list of strings by similar values

Group a list of strings by similar values Question: I want to group a list of strings by similarity. In my case (here simplified cause this list can be huge) it’s a list of path to zip files like this: ["path/002_AC_HELICOPTEROS-MARINOS_20230329_210358_145T3_21049_00748_DMAU.zip", "path/002_AC_NOLAS_20230326_234440_145T2_20160_06473_VMS_UMS.zip", "path/002_AC_HELICOPTEROS-MARINOS_20230329_211105_145T3_21049_00748_FDCR.zip", "path/002_AC_HELICOPTEROS-MARINOS_20230329_205916_145T3_21049_00747_VMS_UMS.zip", "path/002_AC_NOLAS_20230326_235504_145T2_20160_06473_FDCR.zip"] I would like to group the strings in that list …

Total answers: 2

Grouping dataframe by similar non matching values

Grouping dataframe by similar non matching values Question: If I have a pandas dataframe with the following columns: id, num, amount. I want to group the dataframe such that all rows in each group have the same id and amount and where each row’s value of num has a value that is not more than …

Total answers: 2

How to group drivable areas in YOLOP

How to group drivable areas in YOLOP Question: On YOLOP, I can detect the lanes and drivable areas without problem. The data comes out of a torch model and being stored as a 2D numpy array such as like that: [[0 0 0 … 0 0 0] [0 0 0 … 0 0 0] [0 …

Total answers: 1

Grouping but the lists can contain duplicate elements

Grouping but the lists can contain duplicate elements Question: I have an ordered list L= [330.56, 330.6,330.65,330.7, …..] and I want to group it by a certain tolerance -+, but I can have duplicates, so I need to iterate over every element ( see if there are other elements within element-tol and element +tol) and …

Total answers: 1

grouping a dictionary inside a list in python

grouping a dictionary inside a list in python Question: I’ve just been studying python and I’m having trouble doing some exercises. I have a list containing, I think, a dictionary: dictionary_title=[ {‘Color’: ‘Green’, ‘ids’: 878}, {‘Color’: ‘Pink’, ‘ids’: 16}, {‘Color’: ‘Orange’, ‘ids’: 28}, {‘Color’: ‘Yellow’, ‘ids’: 9648}, {‘Color’: ‘Red’, ‘ids’: 878}, {‘Color’: ‘Brown’, ‘ids’: 12}, …

Total answers: 2

Fill grouping variable pandas dataframe

Fill grouping variable pandas dataframe Question: I have a pandas dataframe with an id column called doc_ID and a boolean column that reports if a certain value is below a threshold, like so: df = pd.DataFrame({‘doc_ID’: [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, …

Total answers: 1

Assign group number for each row, based on columns value ranges

Assign group number for each row, based on columns value ranges Question: I have some data, that needs to be clusterised into groups. That should be done by a few predifined conditions. Suppose we have the following table: d = {‘ID’: [100, 101, 102, 103, 104, 105], ‘col_1’: [12, 3, 7, 13, 19, 25], ‘col_2’: …

Total answers: 2