All Questions
56 questions
3
votes
1
answer
63
views
Optimizing code for this function that filters a JSON file
I made a function that turns all child from a JSON file to parents (or brothers?). It adds the parent name to the key, so there are no duplicates.
It works ok, but I would like to ask if there are ...
4
votes
2
answers
408
views
Prioritise injured cats for treatment (dictionary/map search optimization Python and C++)
I am once again attempting another CP problem, and I have ONCE AGAIN run into an optimization issue because of the time limit of one second: https://open.kattis.com/problems/doctorkattis
It is common ...
3
votes
1
answer
2k
views
Better way of comparing two lists of dictionaries and display unique changes
Can I get a review of my code which compares 2 dictionaries and display unique changes.
...
10
votes
2
answers
8k
views
Efficient renaming of dict keys from another dict's values - Python
I have a dictionary in Python (uglyDict) that has some really un-cool key names. I would like to rename them based on values from another dictionary (...
3
votes
2
answers
582
views
Handle missing children nodes when parsing XML into a dictionary
I work on a code-base that uses xml to set up problems and specify model parameters. I've created a script that I run in tandem with our code. This script will ...
2
votes
2
answers
206
views
Finding unique keys
I made the following snippet. It finds unique keys based on their values. For all keys \$s\$ that are contained in another key \$D\$ with the same value, key \$s\$ is discarded and key \$D\$ is ...
7
votes
1
answer
1k
views
Merging two dictionaries together whilst adding keys but multiplying values
I have two dictionaries and a merged dictionary:
dict1 = {-3: 0.3, -2: 0.1, 1: 0.8}
dict2 = {0: 0.3, 1: 0.5, -1: 0.7}
dict_merged = {}
I have code that basically ...
1
vote
1
answer
70
views
Iterating lists and updating dictionary for corresponding match logic improvement
I have two lists:
Users - [<UserObject1>, <UserObject2>, ...]
Contributions - [...
9
votes
2
answers
4k
views
Better way to iterate through a dictionary and comparing its keys with itself
I have a dictionary with author names as keys and values of None. I want to use fuzzywuzzy ...
-1
votes
1
answer
64
views
Comparing dictionary values from list [closed]
I'm writing some Python code that will handle huge datasets.
On a small scale, this snippet works fine, but as the datasets become bigger it grinds my script to a halt (I know it is this part as I ...
1
vote
2
answers
201
views
Bi Directional Dictionary
I wrote a class that extends the dict class to provide indexing like functionality, so I can find which key(s) map to a given value in the dict. It's pretty bare ...
9
votes
3
answers
1k
views
Creating an affinity-matrix between protein and RNA sequences
I wrote an algorithm that analyzes protein-RNA interactions and I found that the following function is the bottleneck that causes performance issues:
...
2
votes
1
answer
167
views
Comparing web-scraped data from several sports betting APIs
I have written a python script that requests information from several Sports Betting API's, processes and standardises the results into a dictionary, Matches items between dictionaries and then ...
1
vote
1
answer
52
views
tablename alias in attribute name
I have dataframe like this:
...
11
votes
3
answers
2k
views
Find the common ancestor between two nodes of a tree
Here is my code in Python for to find a common ancestor between two nodes in a particular tree. This is a question from Cracking the Coding Interview that I decided to implement on my own. No one has ...