Using a list object to store indices - loops

I have a dataset of FIFA 23 Player Analysis. I would like to remove some players whose contracts have expired by 2022. How do I store the indices of these players in a list?

Related

Python nodes- How to create this?

I have imported an array into Python. How do I:
Create a list of unique nodes in 2D array of edges, order it by node ID
Have number of edges and the number of unique nodes in the graph
Print the nodes in group 1 and group 2 separately?
enter image description here
What can I do? I have no idea and can't find useful info

manipulate array of json with moment range

I'm creating a planning app for my users.
I have multiple array of json :
users array
planning array with all slots working in a week
fonctions array of users (what they are doing in my companie)
absences array where my users are off (holidays or other)
With these array, I'm building another with absences of users based on slots working planning.
My code is functionnal but not optimised, it's work with small data, but when I push lot of data, this become slowwwwww.
Can you help me to optimise the code, and got the latest array ?
thank you very much
Here is my sand : https://codesandbox.io/s/snowy-glitter-i76i3h?file=/src/App.js

Rank elements based on their frequency in logarithmic time complexity

Cheers, I am trying to find an algorithm/data structure I can use to rank elements by their frequency.
For example, let's say I am given 5 names and I want to rank them based on their frequency. I am given the names consecutively, and every insertion and query I perform MUST be in O(log(n)) time, where n is the number of given names.
For example let's say I am given:
"foo"
"bar"
"bar"
"pop"
"foo"
"bar"
Then, by ranking the 1st should be "bar" (3 times), 2nd => "foo" and 3rd "pop". Keep in mind that when two or more elements have the same frequency (and the same ranking), which ever I return is correct.
I have tried using a Map (Hash), to keep the frequency in which the strings are given, for example if given "foo" I can return 3 (NOT the rank however), or even thought of using a Set (using an AVL tree) in order to arrange them by their frequency, but again I can't turn that into a Ranking data structure in logarithmic time. Any ideas ?
Return rating by name.
You can do insert and query in constant time O(1). For this, you need to employ two structures hash-map and something that I call doubly-linked-list.
Hash-map contains pairs - a name and pointer to a list item/bucket with this name statistics.
Doubly-linked-list bucket stores two numbers: an integer for the number of names pointing to the lower buckets (Rating) and a number of repetitions for the names in it (RepCount).
Initialization:
Create the first bucket, put all names into the hash-map and initialize pointers with the address of the first bucket. Create another bucket with RepCount = INFINITY and Rating = #names.
OPERATIONS:
Insert name. Find the address of the corresponding bucket Target, check if the bucket OneMore with OneMore.RepCount == Target.RepCount + 1 true exists. If it exists then --OneMore.Rating, if not then create one with RepCount = Target.RepCount + 1 and Rating = NextToTarget.Rating - 1. Observe that NextToTarget always exists due to initialization. Repoint hash-map entry to OneMore.
Query rating. Extract appropriate pointer from the hash-map and read Target.Rating.
Return name by rating (and rating by names)
You need two hash-maps and doubly-linked-list. In hash-map names store name => name-in-list*, in hash-map ratings store rating and a pointer to the first and the last name with this rating in the list rating => (first, last). In the list store pairs (name, rating) in the order described below.
Initialization:
Insert all names into the list. Insert a single entry into the hash-map (0, (list.head, list.tail)).
OPERATIONS:
Inset name. Recover name list node using names. Using ratings find out there node.rating finishes and move node next to it increasing its rating by one. Compare new rating with the next node's rating and see if you need to update an existing rating or create a new one in ratings. Remove ratings entry in case the old rating is empty now or update it if node was first or last.
Query name. Use ratings[..].first or return null if not exists.
Query rating. Return names[..].rating.

Generating list that matches criteria from larger list

Trying to write a function in Excel that will pull data from the larger list on the left and display a smaller list that matches criteria given. For example, I want to itemize each salespersons vehicles individually as a list under their names on the right. Is there an easy way to do this? I was thinking about generating an array based off of the sales reps name in E:E, then using =offset() to pull the vehicle model and display it under the reps name. But I can't think of a way to do this. Any pointers would be great.

MongoDB: Determine index of item in array

Is there a way to determine the index of a retrieved item in an array in MongoDB?
I have an array of object ids inside some document.
{
ids: [id1, id2, id3, ...]
}
I search the array for id3, and if it's found, I also want the position of the object added to the result. In this case, it's so I can insert more objects immediately after it in the array.
If I can't do this, how would I go about creating an ordered list of objects for which I can retrieve and easily modify the position of elements in the ordered list (since an insert operation on the list will result in modifying the position of all elements after the insert)?
answer:
Obtaining the positional index is NOT supported in mongodb. I will open a new question then about redesigning my application to deal with this limitation. Thanks everyone!
The way I see it, you have two choices:
Retrieve the whole array, mutate it however you wish in your language of choice, and update the array in the db with your new array.
Come up with a data structure that supports whatever it is you are ultimately trying to do.

Resources