Skip to content
Advertisement

Tag: algorithm

How can I figure out the average consecutive duration of “True” values in pandas df, per group?

With the following data, I think I want a column (DESIRED_DURATION_COL) to work out the duration (according to start_datetime) of consecutive Truths: project_id start_datetime diag_local_code DESIRED_DURATION_COL 1 2017-01-18 False 0 1 2019-04-14 True 0 1 2019-04-17 True 3 1 2019-04-19 False 0 1 2019-04-23 True 0 1 2019-04-25 True 2 1 2019-04-30 True 7 1 2019-05-21 False 0 This is

Algorithm for ordering data so that neighbor elements are as identical as possible

I have a (potentially large) list data of 3-tuples of small non-negative integers, like I want to order the tuples within data so that neighboring tuples (data[i] and data[i+1]) are “as similar as possible”. Define the dissimilarity of two 3-tuples as the number of elements which are unequal between them. E.g. (0, 1, 2) vs. (0, 1, 2): Dissimilarity 0.

Trouble sorting list of lists in Python with Insertion Sort

I am currently making a Python program which takes in the name of a grocery item, the aisle it’s on, its location along the aisle, and the price. It holds the data in a list of lists, with each inner list containing 4 elements. The program attempts to create the optimal route through the aisles, with traversal on odd aisles

How can I implement Circular SSTF in this code?

In my Operating Systems class, we have to present one algorithm as our final project. A mock model for any of the OS algorithms. I choose an algorithm which is an improved/variation of regular SSTF algorithm. It is called Circular SSTF. I have already implemented SSTF in python. But I can’t figure out a way to implement Circular SSTF. Any

Is it possible to do a depth first search iteratively without copying visited nodes?

Background I am searching a 2D grid for a word. We can search left/right and up/down. For example, in this grid, searching for “abef” starting at (0,0) will return True Example (grid1): Where I’m at The recursive version gives expected results (see dfs_rec() below). The iterative version also gives expected results (see dfs_iter() below). However, in this version I am

Advertisement