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
0
votes
1answer
60 views

To convert all the class properties to IDictionary<string, dynamic>

I have the requirement to return the result of my ViewModel as a Dictionary of KeyValue pairs. My view model comprises of multiple classes and can have null values in properties. I need to return only ...
2
votes
1answer
47 views

Add items to Dictionary from another dictionary on cell value change

I have created a very simple Class Module and a Dictionary to store original values when the workbook is opened as part of this project ive been working on. When the workbook opens I call a test to ...
12
votes
3answers
7k views

Creating zip but for dictionaries

I found myself needed zip but for dictionaries, and wanted to know if there is any way I can make this shorter and more concise, and/or faster. Also I cannot figure out what the type hinting might be ...
4
votes
3answers
59 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 ...
1
vote
2answers
88 views

Check if dictionary keys are declared, if not leave them as true

I've tried with: dictionary.TryGetValue("MoreDetails", out bool MoreDetails); but if the key is not present it defaults to false, and I need it to default to ...
8
votes
3answers
632 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: ...
5
votes
1answer
74 views

Normalizing mixed format nested dictionary with delimiter separated keys

I recently worked with some pickle files which had a really strange format where the keys are sometimes delimiter separated with colons and placed in the same depth but also mixed with ordinary key ...
12
votes
4answers
1k views

Extraction of value from a dict-tree, given a path of arbitrary length

Problem: We read a complex json-file which grants us a tree in terms of a python "dict of dicts". We're then requested to retrieve a specific path from the tree, represented by a list of elements. The ...
4
votes
1answer
79 views

Automating a set a of weekly reports, including graphs and delivery of reports

I have been writing code to automate some weekly reports. I had help over on Stack Overflow. I have code that works for the most part, however there are a few things that I just can't seem to fix. In ...
4
votes
2answers
239 views

Wrapper class for adding elements to HashSet

I have many object of class Test. I want to be sure that among them, there are no two objects o1 and ...
3
votes
1answer
65 views
2
votes
1answer
58 views

Dictionary function for R

I'm new to R and have created a dictionary function. A user will input a phrase into a text field and the server will read it and see if there's a match in a back-end data table and if so, output the ...
4
votes
1answer
342 views

Phonetic Alphabet Trainer

This is a little program I put together to help people learn the phonetic alphabet. Feel free to query the code. ...
5
votes
2answers
128 views

Fantasy Game Inventory - Automate the Boring Stuff with Python

Below is my code for the Fantasy Game Inventory problem from Chapter 5 of Automate the Boring Stuff with Python. Is there anything I can do to make it cleaner or more efficient? The code starts out ...
5
votes
3answers
477 views

Comparison of values in dictionary

I have the following dictionary: ...
3
votes
1answer
91 views

How do I efficiently create a dataframe from a list of dictionaries?

I used this API to download some data. The code is supposed to create a dataframe table using specific fields of an object, and it seems to work, but running slow. I think it would run faster if I ...
4
votes
2answers
87 views

Mini-git class performance issue

I want to build Git class where i can store integers. FilesSet is where I store current state of integers. Commits' key is ...
-1
votes
1answer
44 views

Dictionary comprehension with nested for loop and conditional if [closed]

Let's suppose I have two lists: list_b = ['cat.2','dog.6','bear.10','zebra.13'] list_a = ['cat','dog','bear','zebra'] I would like to create a dictionary with ...
3
votes
1answer
78 views

LeetCode: Time Based Key-Value Store C#

https://leetcode.com/problems/time-based-key-value-store/ Create a timebased key-value store class TimeMap, that supports two operations. ...
7
votes
1answer
1k views

Python DefaultDict implementation in JavaScript

I found Python's defaultdict and OrderedDict incredibly useful, hence I attempted an implementation in JavaScript. As JavaScript ...
4
votes
1answer
64 views

Immutable Keyed Set

Description An immutable keyed set is a readonly collection of elements without duplicates or null values having each of the elements linked to exactly one key. Example This simple example ...
8
votes
5answers
2k views

Bidirectional Dictionary

The management of bidirectional mappings is a reoccuring topic. I took the time to write an (hopefully) efficient implementation. ...
1
vote
2answers
71 views

Python, Iterate through a list sending batches of 100 records at a time to an API, then appending results to another list

I have a list of 9000 dictionaries and I am sending them to an API in batches of 100 (limit of the API). The API returns the list of 100 dictionaries just expanded with more key/value pairs. So both ...
4
votes
3answers
134 views

Bidirectional Map in C#

Inspired by this question and its answers, I've made my own version. ...
8
votes
1answer
129 views

Convert to dictionary

Earlier I did post with full code about Prepare and export data to MS Word file. The user t3chb0t recommended me to separate some part of full code to this post. Context The task of code for review ...
4
votes
2answers
87 views

Reverse Dictionary: Group from child array elements and get its minimum key

Objective I have following array and would like to group by each child and get its smallest Id:- ...
6
votes
3answers
426 views

LeetCode: Group Anagrams C#

LeetCode: Group Anagrams C# Given an array of strings, group anagrams together. ...
2
votes
1answer
43 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 ...
7
votes
1answer
16k views

Updating a .csv file

I have a CSV file, call it csv_file. It has the following content: Username, Password name1, pass1 name2, pass2 ... I also have a dictionary, call it ...
7
votes
2answers
9k views

List all possible permutations from a python dictionary of lists

The following code takes a dictionary of lists (indexed by keyword) and converts it into a list of list of dictionaries that contains all possible permutations of those lists. However, my solution ...
6
votes
1answer
78 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
0answers
294 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-...
3
votes
1answer
36 views

Validating partially filled objects

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

Get value from dictionary given a list of nested keys

I would like to get a deeply-nested value, for example {"a":{"b":{"c":"myValue"}} by providing the keys to traverse. I tried chaining together .get() but that didn'...
5
votes
1answer
260 views

Python function to generate Spanish conjugations

I tried to make a Python function to generate present tense Spanish conjugations. ...
4
votes
2answers
242 views

Genericizing PropertyValues

This should be the last iteration for this code. Does this approach make sense or am I heading down the wrong path? The only thing I can see to make this better is to genericize the ...
5
votes
0answers
189 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 ...
1
vote
1answer
31 views
4
votes
4answers
847 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
2answers
121 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? <...
8
votes
3answers
702 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 ...
3
votes
2answers
223 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 ...
4
votes
1answer
68 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
56 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
338 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
523 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
153 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
4answers
26k views

Dictionary GetValueOrDefault

I'm pretty sure there's no better way to do this but I thought a consensus on here might be nice. Let me know what you think. ...
24
votes
4answers
38k views

Type-safe Dictionary for various types

Assume the following situation: you have an object that can store any object based on a key (basically, IDictionary<string, object>). You want to store ...
2
votes
1answer
3k views