Questions tagged [dictionary]

A dictionary, in computer science, is a data structure that maps keys to values such that given a key its corresponding value can be efficiently retrieved.

Filter by
Sorted by
Tagged with
2
votes
1answer
28 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 ...
6
votes
1answer
73 views

Distinguish between different types of log items in a dictionary by their key

My logging adapter is using a dictionary for storing data that is passed from middleware to middleware. It is a one-liner: ...
3
votes
1answer
33 views

Validating partially filled objects

The following classes are a simplification of an auto-generated code of an ORM (targeting Microsoft's Dynamics CRM): ...
2
votes
2answers
32 views

Consolidating a dictionary from nested dictionary

Currently learning from "LPTHW - Zed Shaw" and "Automating the boring stuff". There is a nested dictionary of the type ...
5
votes
0answers
141 views

Recursive conversion from ExpandoObject to Dictionary<string, object> #2

Because my original question was lacking many details, I have been advised to ask a new question. I will repeat the important parts of the original question and add examples etc to hopefully make it ...
4
votes
4answers
549 views

Recursive conversion from ExpandoObject to Dictionary<string, object>

For my blazor library which is a modification of this awesome library I have to convert an ExpandoObject into a ...
1
vote
1answer
30 views

tablename alias in attribute name

I have dataframe like this: ...
1
vote
2answers
98 views

Get value from a dictionary contained in a dictionary

I have an API that returns a dictionary of dictionaries. I currently have this code to access the value of the dictionary, but it looks like a code smell. Is there a better way to structure this? <...
3
votes
2answers
218 views

Pull-up sequence accumulator counter

I wanted to create a function describing a sport game called "Leader". The idea is that you make as many push-ups as you can, increasing each repetition by 1 and as you reach your maximum, each next ...
3
votes
0answers
121 views

Alternative for VLOOKUP/Index-Match in VBA

I am sharing this function I wrote with the community to provide an alternative to slow VLOOKUP and/or Index-...
4
votes
1answer
49 views

LeetCode: Intersection of two arrays ii C#

https://leetcode.com/problems/intersection-of-two-arrays-ii/ Please review for performance, I am having a problem with using TryGetValue, if someone can explain how this can be used in here. Given ...
3
votes
1answer
54 views

Building nested dictionaries to dump it to .json later

I am looking for some way to improve my code. It works but it doesn't look good and I am almost sure that lot of Best Practices rules are violated. The ...
10
votes
2answers
151 views

Multi Key dictionary implementation

Description I had to create a dictionary structure where one value can be referenced by several keys. For example the keys a, b...
7
votes
3answers
511 views

Finding dictionary keys whose values are duplicates

I currently have a dictionary (Duplicate_combos) that has a unique identifying number for the key value and the value is a list with two elements, a company code ...
5
votes
2answers
146 views

Splitting an amount of money equally between a group of people

I'm building a clone banking app at the moment, and one of the things I'm trying to do is add Split Transaction (which can then be shared with a set of friends paying a given amount each). Initially, ...
8
votes
3answers
629 views

Python program to find the most frequent letter in a text

Given a text like "Hello World!" the program outputs the most frequent letter, in this case the "l". If there are two letters with the same frequency, it outputs the first in alphabetical order, for ...
0
votes
0answers
80 views

Dictionary search: compare many values in a dictionary using keys

What I have: Mainly, a graph consists of 10000 nodes and around 500000 edges. I would like to construct a dictionary where keys are the edges and the value for each edge is an array consists of 0, ...
0
votes
2answers
48 views

Words dictionary out of a text file

Please tell me what the weak spots of this code are (specially in terms of efficiency) and how I can improve it: ...
2
votes
2answers
59 views

Fastest way to find dataframe indexes of column elements that exist as lists

I asked this question here: https://stackoverflow.com/q/55640147/5202255 and was told to post on this forum. I would like to know whether my solution can be improved or if there is another approach to ...
3
votes
1answer
146 views

Reverse dictionary where values are lists

I'm working on the following problem: I've got a dictionary like this one: dic={0:[0,1,2],1:[3,4,5]} And I want to reverse it so it looks like this: ...
13
votes
2answers
846 views

Count the occurrence of each unique word in the file

I've been doing a task for an interview that I will have soon. The requirement is to code the following problem in C#. Write a program (and prove that it works) that: Given a text file, count the ...
2
votes
1answer
115 views

Sluggish Loop Transferring Dictionary Data to Spreadsheet

I've added a timer to my code and the bottleneck comes when I'm looping through 47 rows and inputting data from a dictionary that I previously loaded with values. Since i use these files for a lot of ...
0
votes
2answers
151 views

Counting sort in Swift

I have this sorting algorithm which takes an array of dictionary values: guard var imageUrlString = anyImage.value as? [String:AnyObject] else { return } I then ...
1
vote
3answers
308 views

Randomly pick key from dictionary weighted by the keys value

I was trying to write a function that would get a random card from a dictionary of cards in a players deck weighted by the number of cards of each type you have. I don't know if the solution I came up ...
-2
votes
1answer
74 views

Eliminate shorter substrings from larger one

I have a dictionary that stores a string and its frequency which looks like this ...
6
votes
4answers
1k views

Parsing a string of key-value pairs as a dictionary

I always use nested list and dictionary comprehension for unstructured data and this is a common way I use it. ...
0
votes
2answers
33 views
1
vote
2answers
45 views

Creating a dict with external and internal IP addresses provided a list of candidates

I created a function that finds internal and external IP addresses, returns them in dict with the keys external_ips and local_ips...
3
votes
1answer
31 views

Appending values in Pandas column

I have a dictionary: x = {'[a]':'(1234)', '[b]':'(2345)', '[c]':'(xyzad)'} and a dataframe ...
1
vote
1answer
46 views

Transforming a dict of lists into a list of dicts

I would like to transform a dict of one format into a dict of another format. The raw_input dict will have the shape: ...
3
votes
5answers
605 views

Finding Isogram Word

An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times. The ...
3
votes
3answers
217 views

Word frequencies from large body of scraped text

I have a file with word frequency logs from a very messy corpus of scraped Polish text that I am trying to clean to get accurate word frequencies. Since this is a big text file, I divided it into ...
1
vote
2answers
74 views

Pythonic way of checking for dict keys

When checking a python dict for a key, which is the better way here: (I can't figure how to use dict.get() to make this cleaner) ...
5
votes
2answers
4k views

Merge two list of dicts with same key

I have two lists of dictionaries. Both lists always have the same ids. I want to get the following result: ...
4
votes
2answers
3k views

C++ Implementation of a dictionary data structure

I am quite new to C++ and would like some feedback on my implementation of a dictionary data structure. The code is below. ...
0
votes
1answer
34 views

Swift append an array when it's been declared as Any

I'm learning Swift and I have a following problem: I create a dictionary containing some data, one of which is stored as an array. I want make an operation on this array to add some info. Currently I ...
3
votes
2answers
1k views

Word ladders program in Python

Background information: Given two different strings of equal length, the spacing between them is the number of other strings you would need to connect them on a word ladder. Alternately, this is 1 ...
7
votes
2answers
1k views

Generic Dictionary Equality Comparer

I created the below comparer to allow me to use a generic dictionary as a key to another generic dictionary. My GetHashCode implementation creates a hash based on ...
-2
votes
1answer
162 views

Method to populate a dictionary from properties

I have a class with some properties. In the class I have a method that is "collecting" all the properties in a specific instance of the class to a dictionary, with the properties name being the ...
4
votes
1answer
66 views

Preparing tabular data to be sent as json

I query a database and pass the data for processing as a DataTable. After all computations (grouping, filtering, formatting etc.) I need to send it to a Web-Service ...
3
votes
2answers
639 views

Search in a nested list of a dictionary

I have a dictionary structured as {a_1: [((b_11,c_11),d_11), ((b_12, c_12), d_12), ...], a_2: [...], ...}. I want to extract the maximum abs(c) among all the ...
1
vote
1answer
73 views

Search dictionary for matching values

I have a dictionary self.indexList = {} filled with 3-item-lists values = [lineId, nominalLineId, vertex] for each dictionary ...
3
votes
1answer
57 views

turn a dict that may contain a pandas dataframe to several dicts

I have a dict that may be 'infinitely' nested and contain several pandas DataFrame's (all the DataFrame's have the same amount of rows). I want to create a new dict for each row in the DataFrame's, ...
1
vote
0answers
313 views

Filling values for nested dictionaries

I have a text file where any name followed with sequence word is considered a dictionary. The task is to go through the keys and values of a particular dictionary, which is already identified, and see ...
0
votes
1answer
75 views

Dictionary to generate control names

I have found myself referencing controls on a form (think Windows forms but more proprietary) by hard-typing their names in over and over again. Often I'll have a number of similar controls which ...
0
votes
1answer
139 views

Hash Tables: Ice Cream Parlor solution in javascript [closed]

I tried solving the Hash Tables: Ice Cream Parlor question in javascript: ...
12
votes
3answers
3k views

Codewars: Reduce strings to one character

I am trying to solve a puzzle in a performant way. This is the puzzle. Simply explained: you have a String and you must reduce it to one character with the given rules. This is the solution to the ...
5
votes
1answer
1k views

Asynchronous dictionary in Python

So I am working on writing a discord bot with discord.py. I decided, rather than making a serie of if/elif, to map the messages to the functions in a dictionnary, like so: ...
4
votes
1answer
1k views

Hackerrank Day 8: Dictionaries and Maps solution in C++

This is a solution for the Day 8 hackerrank.com challenge. The basic idea of the challenge is to create a mapping of names to phone numbers based on the the given input, and later look up the phone ...
2
votes
2answers
4k views

Accessing a subset of keys from a nested dictionary in Python

I am trying to access data from Coinmarketcap API in Python and came up with the following code: ...