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.

learn more… | top users | synonyms (1)

5
votes
2answers
187 views

Extracting values from dictionaries where the keys match

I have two Dictionaries with around 65,000 KeyValuePairs each. I used foreach and if-else statements to compare them and get values, but it goes very slow. How could I optimize my code and gain more ...
2
votes
1answer
53 views

Clustering similar tweets in a corpus

I am attempting to write a statistical program using an LDA model I've trained/created using Gensim. I am very new to Python and am a student level programmer. This current program is working and ...
2
votes
2answers
99 views

Take a result set and organize it into a dictionary

I'm trying to take a result set and organize it into a dictionary then assign the dictionary values to variables that are publicly accessible from my controller. My issue is I have to check if there ...
1
vote
2answers
41 views

Permute and count between nested dictionaries

Goal: Permute inner values between two dictionaries with matching outer key, Save permuatations in counter, Move to next outer key, update counter with new permutations. Problem: Many lookups on ...
1
vote
2answers
47 views

Matching lines in a CSV file with items in a dictionary

I was wondering if there was a better way of writing this... I have a CSV file (about 6640 lines). After reading through the file, the values for the DFN_Network ...
1
vote
1answer
97 views

A basic pure Python hash map using a tree

I would like feedback on my first attempt to understand how hash tables work. I've read some on how hash tables use modulo operations to find the location of a key. Can you help me understand, ...
0
votes
1answer
38 views

Match two dictionary keys efficiently in Python

I have two dictionaries that I need the keys to match and if they match i will get the value of the first dictionary and then get the value of 2nd dictionary and build a new dictionary out of those. ...
2
votes
3answers
143 views

Search in a big dictionary Python

I have a big Python dictionary with more then 150,000 keys every key has list value. This dictionary contains infinitive words as key and all grammatical forms of these words as values: ...
0
votes
4answers
75 views

Adding to a dictionary and skipping duplicate keys

What is the cleanest way to use dictionaries and protect against an unhandled ArgumentException if the key already exists in the dictionary? I'd like to say that I ...
2
votes
2answers
130 views

Dictionary app using WIn32

I'm creating a dictionary app using Win32 API. I stored the word meaning in a file called dictionary.dic in the following format: Word Meaning A The first letter B The second ...
38
votes
2answers
123 views

Counting all the vowels in a passage of text

My son just started high school and in Math, he was asked to do some stats homework. The exercise was to count all the vowels in a passage of text, then answer some questions about frequency. Out of ...
2
votes
2answers
99 views

Functions to merge dictionaries with a comparison

I have several functions for merging some dictionaries but over time I created a more general function that would make all these others obsolete if it weren't slower. I have the specialized (and ...
2
votes
1answer
30 views

Optimize performance of flatten function in python

I have to flatten a large number (>300k) dicts to write them to a csv file. Example: ...
2
votes
2answers
86 views

Insert rows in the datagridview with a dictionary

I would like to improve the function below without calling twice InserisciRigaNote. Before I fill my dictionary. When I compare ...
1
vote
3answers
137 views

Recursively Save Python Dictionaries to HDF5 Files Using h5py

I have a bunch of custom classes for which I've implemented a method of saving files in HDF5 format using the h5py module. A bit of background: I've accomplished ...
3
votes
2answers
58 views

Most efficient dict filter on key tuple?

I have a dict wherein a value needs to be retrievable by any one of several keys. It seemed that making multiple dictionaries or multiple entries in a single ...
3
votes
2answers
94 views

Dynamic class instancing (with conditional parameters and methods) based on a dictionary

In a RPG game I'm developing, after building a base Weapon class, instead of having many subclasses of Weapon, I want the ...
1
vote
1answer
38 views

Writing a Counter object to a CSV-file in Python 3

In Python 3.4, a Counter object called cnt like this: ...
4
votes
2answers
88 views

Dictionary lookup of non-nullable struct into nullable destination

I've got an IDictionary<SomeT, DateTime> that does not always contain the desired key-value pair. For that reason, a target method expects a ...
4
votes
3answers
74 views

Efficient dictionary printing

Here's what my task is: Dependant on the "Logged In" user, they'll have different access rights and will see different menus. I have tried using the .get() ...
4
votes
3answers
84 views

Load recurring (but not strictly identical) sets of Key, Values into a DataFrame from text files

I am reading text files that contain data from observations. The format is not Fixed Width or Delimited, so I built a generator ...
2
votes
1answer
136 views

Custom Implementation of ObservableDictionary

I recently found myself in need of an IDictionary<TKey,TValue> implementation that was observable from a WPF UI. Since the .Net framework does not provide ...
7
votes
2answers
79 views

Copying a Dictionary and Replace its Values

I have a custom dictionary where the values are numpy arrays. I would like to have a convenience function that creates a copy of its content except that the values are changed. If no value is passed, ...
11
votes
1answer
71 views

iterating over the values of a list of ordered dictionaries

I am facing the following problem: I have a special data structure that is a dictionary whose keys are integers (dimensions). The values are also dictionaries whose keys are strings (geometric types) ...
6
votes
2answers
69 views

Unicode-capable symbol table (N-way search tree with hash buckets)

As in my previous question, this module is coupled with its own testing framework. As a symbol-table for a Unicode-capable programming language interpreter, I decided to combine the 3 types of ...
3
votes
2answers
85 views

Compare dicts and record changes

My goal is to continually update an object and record any changes and the times they were made at. The input has to be JSON but the output/storage format doesn't. This function will check a JSON ...
1
vote
1answer
146 views

Test if a key exists anywhere in a nested object

I have complex objects containing nested objects. I need to check if a key exists anywhere in the nested object. I wrote this code as a makeshift solution. Is there any other way to search for the ...
1
vote
1answer
39 views

A Simple SortableDictionary for JavaScript

First, I must humbly admit that I've been a developer for many years but I've almost never had to work as a front-end, Web UI developer. I've been given an opportunity to work for an organization as ...
3
votes
2answers
92 views

Mapping a user input string to a corresponding block of code

My idea is I can define a block of code (inline) that corresponds to an input string then can call that block of code when given that input. I'm used to this sort ...
2
votes
1answer
159 views

Calculating sum of values in each child of dictionary for QTreeView

There is data stored in JSON file with the following structure: goods_data = {"year" : {"month" : {"day" : {"01" : {"name" : "some item", "price" : "10.01", "category" : "root | first | sub first ...
1
vote
1answer
108 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. ...
4
votes
2answers
637 views

Wrapping tuples to be used as keys in a Dictionary

I'm currently working on a project where I have to map some objects to several properties. Basically I need a Dictionary with Tuples as keys and instances of MyClass as values. As using tuples can ...
1
vote
1answer
27 views

Reading XML files and finding pairs between the files

I read three files and parse a few individual fields from each row of the XML. Using these fields, I find the dictionaries that contain the same keys (ItemK and either SensorK for sensors or PointK ...
3
votes
2answers
68 views

Practice with dictionaries

Post a cursory read of this I implemented a simple dictionary and an interface to assign, replace, look up, and redefine its terms to apply the concepts. It's simple, but I'd still like to know any ...
1
vote
1answer
63 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 ...
2
votes
2answers
76 views

Grouping over a list of dictionaries

I am consuming data from an API that reads from a SharePoint list. The API is basically this: ...
5
votes
2answers
356 views

Counting words from standard input in Swift

I know Swift isn't exactly meant to be used to write your classic stdin to stdout scripts, and that Python, Ruby, Perl, bash, awk, and friends are much better in this area, but I'd still like to see ...
1
vote
1answer
50 views

Map all symbols in module to dictionary

The div and add functions are located randomly in my package structure. I have a function with this signature: ...
0
votes
1answer
103 views

Data Structures C# Dictionary<int,user> and user has a property that is a list<numbers>

I am about to post a question to Stack Overflow about how to do a better job adding a number to the list inside the User class. But I feel if I refactored this I ...
2
votes
2answers
62 views

Iterate over large amount of words in Python

I wrote a program that should check a dictionary that contains about 50000 other dictionaries. In those dictionaries, one of the keys has a list of words as value. Now, I iterate over those words, ...
2
votes
3answers
66 views

Search dictionary by value

I have a dictionary which I use to lookup my binary and ASCII values (from A - P). It works, but my ascii2bin function just doesn't really feel right (and ...
11
votes
1answer
241 views

OOP paradigm implementation of a Dictionary data model

Here is the implementation of interface Dictionary using chained hash table class HashTableChained. Despite item 22* saying ...
5
votes
2answers
86 views

InfixDictionary: Data structure for Infix string lookup

I needed a data structure to quickly find all previously inserted values, that have the given string as key or substring (full text search). At first, I tried out some tree structures (infix ...
4
votes
4answers
799 views

DuplicateDictionary - A dictionary-like class which allows duplicates

Since I couldn't find any good answers I made my own class called DuplicateDictionary for personal usage. I would like some tips to improve it. ...
2
votes
1answer
45 views

CSV parsing program that creates distinct header rows with transaction rows underneath

My code reads in the data using DictReader, then creates a header row that contains my composite key (PEOPLE_ID, DON_DATE), and then adds various values that are ...
4
votes
2answers
145 views

Commission calculation

I am trying to improve the performance of the current solution for calculating commission in a betting platform. The following is the code currently used to solve the problem. The primary problem ...
2
votes
1answer
314 views

Unique dictionary values - print keys

I'm working on this code for exam in an MIT Python course. It's working but I'm trying to improve it. What could I do, and what should I avoid? ...
6
votes
4answers
498 views

Fast evaluation of Euclidean distance with sparse data

I am working on a KNN implementation for sparse datasets (that I apply to text analysis). My points are represented by a Dictionary<string, double>, each key ...
4
votes
3answers
1k views

Return IEnumerable<KeyValuePair> from a private method; use Dictionary or anon. type?

Is it okay to return IEnumerable<KeyValuePair<string, string>> from a private method instead of returning a read-only dictionary? This allows for ...
1
vote
1answer
75 views

Dictionary file manager

The dictionary class loads entries from a file and then can perform operations on them. The dictionary class then stores the entries back into the file. I would like to know the best way to check if ...