Skip to main content

All 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. ...
Samuel Traxler's user avatar
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 (...
Noah Broyles's user avatar
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 ...
Victor Adeyemo's user avatar
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 ...
gjdpm1's user avatar
  • 73
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 ...
Trevor Allen's user avatar
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 ...
Jordan's user avatar
  • 21
1 vote
1 answer
51 views

tablename alias in attribute name

I have dataframe like this: ...
elisa's user avatar
  • 185
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 ...
SDG's user avatar
  • 213
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 ...
fuzzysolutions's user avatar
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 ...
user3385538's user avatar
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 ...
Tutunak's user avatar
  • 13
2 votes
2 answers
6k views

The efficiency of looping over nested dictionaries in Python

How to make the following code more efficient? ...
fishiwhj's user avatar
  • 341