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
1
vote
2answers
96 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 ...
0
votes
1answer
61 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
48 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 ...
8
votes
3answers
635 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 ...
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 ...
2
votes
1answer
59 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 ...
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 ...
5
votes
2answers
129 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 ...
3
votes
1answer
65 views

identifying pairwise groups from dictionary

I have a dictionary that looks like this ...
5
votes
3answers
478 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 ...
-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 ...
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 ...
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. ...
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 ...
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
5answers
2k views

Bidirectional Dictionary

The management of bidirectional mappings is a reoccuring topic. I took the time to write an (hopefully) efficient implementation. ...
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 ...
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 ...
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
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): ...
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 ...
5
votes
0answers
190 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
849 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
31 views

tablename alias in attribute name

I have dataframe like this: ...
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? <...
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 ...
3
votes
0answers
295 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
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
344 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
3answers
704 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
84 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
49 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
66 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
239 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
2k 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
120 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
190 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 ...
0
votes
3answers
801 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
75 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
2k 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