Category "dictionary"

Adding directional indication to flow map in R

I'm just getting started on visualising data with R. I've been working on creating a flowmap based off lats and long data from origins and destination of vario

How do you find the first key in a dictionary?

I am trying to get my program to print out "banana" from the dictionary. What would be the simplest way to do this? This is my dictionary: prices = { "ba

How to convert a pymongo.cursor.Cursor into a dict?

I am using pymongo to query for all items in a region (actually it is to query for all venues in a region on a map). I used db.command(SON()) before to search i

How can I do a dictionary format with f-string in Python 3 .6?

How can I do this format with a Python 3.6 F-String? person = {'name': 'Jenne', 'age': 23} print('My name {0[name]} and my age {1[age]}'.format(person, person)

MemoryError: Unable to allocate 1.88 GiB for an array with shape (2549150, 99) and data type object

I have a problem. I want to normalize with pd.json_normalize(...) a list with inside dict but unfortunately I got a MemoryError. Is there an option to work arou

Python help on TKinter

i'm trying to make an brick destroyer game on python with TKinter for my school project, it's barely finished but i have a problem when it's about to break some

When should I use ConcurrentDictionary and Dictionary?

I'm always confused on which one of these to pick. As I see it I use Dictionary over List if I want two data types as a Key and Value so I can easily find a val

Using ES6 Map with React and/or Redux

I am looking at using the ES6 Map object to do my hashing for me, instead of creating a custom hashing function. However, it seems to me that it doesn't have mu

Safe method to get value of nested dictionary

I have a nested dictionary. Is there only one way to get values out safely? try: example_dict['key1']['key2'] except KeyError: pass Or maybe python h

Replace tags in text file using key-value pairs from JSON file

I am trying to write a shell script that can read a json string, decode it to an array and foreach through the array and use the key/value for replacing strings

How to extract values from key value map?

I have a column of type map, where the key and value changes. I am trying to extract the value and create a new column. Input: ----------------+ |symbols

How to update history dictionary attribute of a class instance and preserve order?

I am new to class programming. I am trying to save initial attributes (which are a dictionary) of my object in its history, and then update history with the cha

Are dictionaries ordered in Python 3.6+?

Dictionaries are insertion ordered as of Python 3.6. It is described as a CPython implementation detail rather than a language feature. The documentation states

Find the sum of values within the values of a nested Dictionary

This is a question based on nested dictionaries. We are given a nested dictionary wherein in the outer dictionary, the name of the match is mentioned and the

Object-like attribute access for nested dictionary

I'm utilising a package which returns a nested dictionary. It feels awkward to access this return object in my class methods with the dictionary syntax, when ev

Does golang have the plan for supporting set datastructure?

This feature can be implemented with 'map'. countrySet := map[string]bool{ "US": true, "JP": true, "KR": true, } But to ease the eyes of readers, 'set'

How do I use the new computeIfAbsent function?

I very much want to use Map.computeIfAbsent but it has been too long since lambdas in undergrad. Almost directly from the docs: it gives an example of the ol

Trouble with output for Fantasy Game Inventory

I'm a beginner working on the Automate the boring stuff with Python book. I'm stuck on this practice problem. The instructions are as follows: List to Dictiona

Create dictionary from an array of objects using property of object as key for the dictionary?

With Swift is it possible to create a dictionary of [String:[Object]] from an array of objects [Object] using a property of those objects as the String key for

Iterator for custom class in Python 3

I'm trying to port a custom class from Python 2 to Python 3. I can't find the right syntax to port the iterator for the class. Here is a MVCE of the real class