All Questions
12 questions
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 (...
2
votes
2
answers
204
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 ...
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 ...
2
votes
1
answer
165
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
51
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 ...
1
vote
1
answer
242
views
Search dictionary for matching values
I have a dictionary self.indexList = {} filled with 3-item-lists values = [lineId, nominalLineId, vertex] for each dictionary ...
4
votes
1
answer
305
views
Finding average word length in a given year
I have written a function which takes the year in question and words as a data which is a dictionary that maps words to the list of year/count. Now I am wondering how I can improve the code that I ...
1
vote
2
answers
860
views
Code to generate a dictionary from two lists
I created a script to perform a union on 2 lists: keys and words. I needed to create a dictionary from them. If there are more keys than words, missing words are replaced with "None". Any excess words ...
2
votes
2
answers
6k
views
The efficiency of looping over nested dictionaries in Python
How to make the following code more efficient?
...