dictionary Questions

4

Solved

I have been searching for a way to save the references of variables of various types into a dictionary, together with a corresponding key. Then i would like to modify the instance of the variable b...
Macarthur asked 20/6, 2014 at 13:57

9

Solved

Moving some code from Python to C++. BASEPAIRS = { "T": "A", "A": "T", "G": "C", "C": "G" } Thinking maps might be overkill? What would you use?
Launcher asked 1/3, 2013 at 5:56

14

Solved

I want to generate a dict with the letters of the alphabet as the keys, something like letter_count = {'a': 0, 'b': 0, 'c': 0} what would be a fast way of generating that dict, rather than me havi...
Embryologist asked 17/1, 2009 at 16:51

5

Solved

I've the same issue as asked by the OP in How to import or include data structures (e.g. a dict) into a Python file from a separate file. However for some reason i'm unable to get it working. My s...
Magic asked 17/6, 2015 at 14:0

4

Solved

Please help me understand why this "replace from dictionary" operation is slow in Python/Pandas: # Series has 200 rows and 1 column # Dictionary has 11269 key-value pairs series.replace(dictionary...
Gorged asked 1/2, 2017 at 17:7

5

Solved

I've got a large dictionary from which I have to look up for values a lot of times. My keys are integers but represent labels so do not need to be added, subtracted, etc... I ended up trying to ass...
Czarevna asked 6/12, 2011 at 16:53

9

Solved

Get the value from a nested dictionary with the help of key path, here is the dict: json = { "app": { "Garden": { "Flowers": { "Red flower": "Rose", "White Flower": "Jasmine", "Yellow Flower...
Sludge asked 24/6, 2015 at 17:49

6

Solved

Let's say I have a nested dictionary with depth N. How can I convert each inner nested dictionary into a simple namespace? example_input = {key0a: "test", key0b: {key1a: {key2a: {...keyNx...
Dairymaid asked 15/2, 2021 at 12:31

3

Solved

Let say I have a dictionary: from typing import Dict v = { 'height': 5, 'width': 14, 'depth': 3 } result = do_something(v) def do_something(value: Dict[???]): # do stuff How do I declare the d...
Satyriasis asked 1/10, 2018 at 14:55

11

Solved

Given a series of GPS coordinate pairs, I need to calculate the area of a polygon (n-gon). This is relatively small (not larger than 50,000 sqft). The geocodes are created by applying an affine tra...
Polo asked 18/5, 2010 at 21:27

7

Solved

I'm trying to use the new (ES6) Map objects in order to represent a map between properties and a value. I have objects in a form similar to: {key1:value1_1,key2:value2_1},..... {key1:value1_N,ke...
Ewall asked 17/2, 2014 at 20:13

3

Given, a serialized protobuf (protocol buffer) output in the string format. I want to convert it to a python dictionary. Suppose, this is the serialized protobuf, given as a python string: person {...
Moor asked 20/6, 2021 at 12:58

4

Solved

The error says: AttributeError: 'list' object has no attribute 'cost' I am trying to get a simple profit calculation to work using the following class to handle a dictionary of bicycles: class...
Maxilliped asked 29/3, 2015 at 22:2

8

Solved

I am making a group chatting app and I have images associated with the users, so whenever they say something, their image is displayed next to it. I wrote the server in python and the client will b...
Repel asked 21/6, 2015 at 16:39

8

Solved

This is my code: a = dict(aa='aaaa', bb='bbbbb', cc='ccccc', ...) print(a.pop(['cc', ...])) but this raises an error. What is the best simple way to pop many elements from a python dictionary?
Valero asked 17/3, 2011 at 1:36

4

Solved

I would like to get the keys from an unbound TypedDict subclass. What is the correct way to do so? Below I have a hacky method, and I'm wondering if there's a more standard way. Current Method I u...
Atmospherics asked 21/5, 2020 at 20:44

11

Solved

I currently have a need to temporarily swap out values in a JavaScript string, and therefore I will need to have a two-way map/hash thing. For example, let's say I want to change \* to __asterisk_...
Englishman asked 12/1, 2014 at 3:7

10

Solved

I've been doing a basic program to find the max, min, median, variance, mode etc. of a vector. Everything went fine until I got to the mode. The way I see it, I should be able to loop through the v...
Submarginal asked 21/2, 2012 at 1:33

3

Solved

I have created the following class. Package, website and comments are all strings and distroDict is a (string, list) dictionary. class TableEntry(object): def __init__(self, package, website, di...
Malvia asked 17/12, 2015 at 3:24

16

Solved

What is the equivalent of Python dictionaries but in Bash (should work across OS X and Linux).
Tombac asked 29/9, 2009 at 18:29

25

Solved

Are there any dictionary classes in the .NET base class library which allow duplicate keys to be used? The only solution I've found is to create, for example, a class like: Dictionary<string, L...
Aundreaaunson asked 28/9, 2008 at 16:33

37

Solved

I need to merge multiple dictionaries, here's what I have for instance: dict1 = {1:{"a":{"A"}}, 2:{"b":{"B"}}} dict2 = {2:{"c":{"C"}}, 3...
Galwegian asked 26/8, 2011 at 12:44

5

Solved

guys i want to swap the keys and values in dictionary my dictionary loook like this public static void Main(string[] args) { Dictionary<int,int> dic = new Dictionary<int,int>{{1,10}, ...
Accumulator asked 24/8, 2018 at 12:10

19

I have the following code: var user = (Dictionary<string, object>)serializer.DeserializeObject(responsecontent); The input in responsecontent is JSON, but it is not properly deserialized int...
Bamberg asked 8/7, 2011 at 5:3

4

Solved

Let's assume that I've two classes : CD and CDModel, and the mapping is defined as follows: Mapper.CreateMap<CDModel, CD>() .ForMember(c => c.Name, opt => opt.MapFrom(m => m.Title))...
Brogle asked 25/7, 2011 at 11:52

© 2022 - 2024 — McMap. All rights reserved.