Questions tagged [dictionary]
A dictionary maps keys to values allowing efficient retrieval of values by keys. USE [map-function] TAG for mapping functions; and for geography, [maps].
79,607
questions
-1
votes
0
answers
4
views
Mapbox get layer data when route is close to a coordinate point
I am trying to get layer data when a route is close to the coordinate listed in the layer. So far I have created my own solution by mapping through all of the layers I am interested in and matching ...
0
votes
2
answers
17
views
How can I make dictionary key as column of dataframe?
!pip install -U LeXmo
from LeXmo import LeXmo
df['Dict'] = df['Content '].apply(lambda x: [LeXmo.LeXmo(x)])
Using this snippet , I am able to generate this
But my desired output is
I want to make ...
0
votes
1
answer
8
views
Parsing yaml file format in python
I have yaml file in this format. I have chunks of data start with "- Buffer: 0". Need to store that chunks in dictionary and process the data.
- {MinimumRequiredVersion: 1.2.1}
- baran
- ...
0
votes
1
answer
25
views
Python nested json
Can any one have solution for this, i want there should be api data in this manner ??
I wanted api data in for similar state comes in one hood rather than seprate, different state data can be ...
-1
votes
1
answer
7
views
How can I print duplicate items from an OrderedDict?
My OrderedDict contains 5 key value pairs which result in the word, Belle. Every letter it's own key with values starting from 1 through 5, from left to right, B = 1, e = 2, etc. Printing this ...
0
votes
0
answers
20
views
TemplateSyntaxError: 'for' statements should use the format 'for x in y' [duplicate]
I'm creating a listing page that emulates Stack Overflow's page limit feature; a user can choose to modify the number of questions listed whether it be 10, 15, or 25 on a page.
In the process of ...
2
votes
1
answer
32
views
Function::identity doesn't work in Collectors.toMap [duplicate]
I am trying to turn a List<String> into a Map<T, String>, with the value of the map being an element contained within the previous List<String>, and the key being some attribute of ...
0
votes
1
answer
14
views
"Value 0:00:00.416559 has unexpected type <class 'datetime.timedelta'>" when diff of two timestamps as value in jsonPayload gcloud logger.log_struct()
Code:
from datetime import datetime
start = datetime.now()
sleep(1)
diff = datetime.now() - start
When saving the diff variable as a value of a dictionary "my_dict" that will then be ...
-1
votes
1
answer
5
views
KML labels not appearing in Google Map API
I have created a kml with LabelStyle showing Label size and labelcolor.
If I open google maps and import the kml the labels appear, however if I use the api and link to the kml. the markers appear but ...
-2
votes
0
answers
27
views
Issue when attempting to merge dictionaries containing lists [closed]
github link
So I'm attempting to take two dictionaries and merge them into one another to form just one dictionary. From my understanding this can be done pretty simply using dict1.update(dict2) and ...
0
votes
0
answers
2
views
problem doing a mapscreen system in renpy
I'm making a mapping system for a visual novel, at first it worked. But I decided to add a day and night system using variables and now it no longer recognizes the mapping system indicating that there ...
0
votes
1
answer
23
views
Trying to get column data from an a list of dictionaries
I have the following data:
locations = [
{"id": 1,"Name": "Ottawa"},
{"id": 2,"Name": "Ahmedabad"},
{"id": 3,"...
-2
votes
0
answers
26
views
This good for a simple dictionary? [closed]
#I think this is working pretty well but I want some thoughts
#If I made some mistakes let me know!
#simple dictionary for file reading
list = []
file = open(file="file_name", mode="tr&...
-4
votes
0
answers
23
views
How to map data to same card component but different data to each card [closed]
I have a created card component <Card/>, I have styled the same card three times differently,
if I have an list of three names, for eg: const names= [{name1:"Harry",name2:"Tom&...
1
vote
4
answers
32
views
Python DFS nested dictionary
I've written a function which should be able to search a nested dictionary, using DFS, to find a specific value. The recursive element seems to be working fine, however, when the base case should ...
0
votes
0
answers
16
views
global counter in recursive function applied to pandas dataframe
Following inspiration from Apply function on each row of a dataframe and increment a counter at the same time to apply recursive function with a termination counter to update a dictionary in a pandas ...
0
votes
1
answer
18
views
returning dictionary to break recursive loop returns NoneType [duplicate]
I have a recursive function where the input dictionary is updated
def update_dict(d: dict) -> dict:
global counter
print(f"COUNTER:{counter}")
keys=['a','b']
values=[1, 2]
...
0
votes
1
answer
6
views
Why does CollectionMarshal.GetValueRefOrAddDefault returns a ref nullable TValue?
The other available helper that is:
ref TValue GetValueRefOrNullRef<TKey, TValue>(Dictionary<TKey, TValue> dictionary, TKey key) where TKey : notnull
Can return a null ref (Unsafe.NullRef&...
0
votes
1
answer
22
views
Groovy - access element of json
I have this json output:
{"UT":{
"test_results":[
[
{
"branches": "8",
"build": "normal"
},
{
...
-1
votes
0
answers
20
views
Convert dict to jsonify
I try to return a jsonfy but I am getting the following Error:
TypeError: Object of type Series is not JSON serializable.
Below you can see my code:
@app.route("/kmeans", methods=['GET'])
...
-1
votes
0
answers
28
views
transform irregular python dict to C++ unordered map
In recent days, to faster my code running time, Im going to use C++ to process some I/O operations of the python dictionary, but here I met a problem--How can I transform an irregular nested python ...
0
votes
1
answer
24
views
How to apply multiple functions to all sheets and then save as one excel workbook
So I imported all sheets from an excel file using pd.read_excel('df.xlsx',sheet_name=None)
I have a dict with key value pairs.
In all these sheets there is a table present. I want to make the first ...
2
votes
2
answers
35
views
Adding a Key-Value pair in a list in an empty dictionary if the keys are the same [duplicate]
How can I print a dictionary as a union of given dictionaries & appending the values if the keys are equal?
Input:
dict_1 = {
"x":[1,"hello"],
"y":[2,"...
0
votes
2
answers
43
views
How to extract dict values and set as int variable?
What I want to do is to extract the value of a dictionary to do calculations with it. My dictionary only has one value. But I'm not able to do calculations (+-*/) with dictionary values and I don't ...
1
vote
3
answers
53
views
How to pull a key from a dict (pandas series) to its own row?
Here is my example data with two fields where the last one [outbreak] is a pandas series.
Start:
Goal (Excel mock-up):
Reproduction Code:
import pandas as pd
import json
d = {'report_id': [100, 101]...
-1
votes
1
answer
27
views
Why does my slice do not change the values of the pointed dictionary in list but changes the values of all the dictionaries in my list?
I am trying to change only one out of three identical dictionary in my list using a for loop to slice out exactly the 2nd dictionary on my list. But somehow the values of all the 3 dictionaries in my ...
0
votes
2
answers
25
views
How to extract list of specific keys from the dictionary in Python?
I have a list of dictionaries that looks like that:
lst = [{'id': 'ID1', 'Name':'Name1', 'Surname':'Surname1'},
{'id': 'ID2', 'Name':'Name2', 'Surname':'Surname2'},
{'id': 'ID3', 'Name':'...
1
vote
2
answers
45
views
Rename incrementing JSON objects in python
I have a JSON file that looks like this:
"153689763780624385": {
"1": {
"author": "Mike",
"date": "05/06/2022, 12:00:57"
...
0
votes
0
answers
7
views
How can I edit coordinates on a map imported from a delimited text layer?
I have a .shp and a .csv with coordinates. I want to plot those coordinates on the map. However, some points are out of my desired range and I want to delete them. I know I can't edit the layer but ...
0
votes
0
answers
34
views
Map iterator that points directly to the key or value, not the pair<key, value>
In my program, I have a template class that can take as arguments any type of container, like std::vector, std::map, etc.
The goal is that my class can work with both vector iterators and map ...
1
vote
1
answer
21
views
From dataframe to a nested dictionary
I am experiencing some hard time trying in creating a nested dictionary from a dataframe in python and would really appreciate your help.This is what the data looks like.
tag
id
cat
0
PA14_00030
GO:...
1
vote
2
answers
34
views
Python dictionary extract data from two dictionaries and insert in new dictionary
I am a Python beginner and am struggling with working with dictionaries.
I have the dictionaries routesAndID and findOutPlane:
routesAndID = {('Sydney', 'Dubai'): 3, ('New York', 'Los Angeles'): 2, ('...
-4
votes
0
answers
26
views
Regex pattern for letter followed by a special character and number [closed]
Whats the regex needed to match these strings in python?
E~1
E*2
+3
0
votes
2
answers
35
views
Dictionaries in different lengths comparison in Python
I am trying to figure out how to compare two dictionaries having different number of keys. For instance, here are two dictionaries:
person = {'name': 'John', 'birthYear': 1995, 'month': 1}
time = {'...
1
vote
1
answer
48
views
dictionary value not printing when I press submit in tkinter program
I am trying to create the below tkinter program:
Select an option from each of the 4 optionmenus.
Click Submit
Value from a dictionary where I have set up the keys to match the combination of the ...
1
vote
1
answer
22
views
Create dictionary out of txt file. One alphabet letter per row. Key is letter and value should be iteration of the loop
i got a problem..
I have a txt file that looks like this:
a
b
c
d
One letter per row, there is not two values per row, so nothing to split..
This code works, if I add a second value in my ...
-1
votes
1
answer
29
views
How can I use the variable input into a python dictionary?
Good day everyone, May I ask something. I've been having trouble with this problem code. I really need to make my own word translator but the problem is when the translation_word doesn't have the key ...
0
votes
0
answers
38
views
Spread object into Map in TypeScript
Using TypeScript, is it possible to type the following Map more acurately?
export const animalsMap = new Map<AnimalIdsEnum, object>([
[
AnimalIdsEnum.sylvester,
{
...
-1
votes
1
answer
26
views
How can I manage to use split() into a dict? (python)
Good day everyone, May I ask something, How can I manage to use separate or split() into a dict.
code example
translation_word = {
"ONE": "Uno",
"TWO": "Dos&...
0
votes
2
answers
30
views
Javascript map to array, get and set
let myMap = new Map();
myMap.set(1, [1,2,3]);
myMap.set(1, myMap.get(1).push(4));
console.log(myMap);
In the above code, 1 is mapped to the array [1,2,3]. Then I want to add 4 to this array. ...
0
votes
1
answer
45
views
Adding elements to a map with user-defined key and set of objects C++
I have a std::map that is encapsulated in a class, and the map consists of the user defined keys and sets of objects.
I have a function void add_new_object_to_map(/*parameters that I need to accept*/) ...
0
votes
1
answer
32
views
Dictionary in a Dictionary, how to remove and aggregate all the data
I have the below dictionary and want to put all the fruit into a new dictionary ie the output would be
{"Apples":1, "Banana":1, "Pear":1, "Orange":2}.
I keep ...
1
vote
2
answers
37
views
How to map and update python dictionary with different key value pair?
I want to transform a Dictionary in Python, from Dictionary 1 Into Dictionary 2 as follows.
transaction = {
"trans_time": "14/07/2015 10:03:20",
"trans_type": "DEBIT&...
0
votes
2
answers
45
views
To retrieve data from list where it contains dictionary as its values (python)
I am newbie to python, trying to understand the concepts. I am trying to traverse a list, where inside list, I have kept dictionary data set which are initialized. I have defined function to traverse ...
0
votes
1
answer
32
views
Matching values within a dictionary and grouping elements to a new dictionary key
I have a dictionary which has the following form:
{ 1:['a','b'],
2:['c','d'],
3:['b','e'],
4:['g','c']
..........
}
I want to find out if any values from the values matches with values in ...
0
votes
0
answers
17
views
Creating Multiple Charts based on dictionary length using javascript
I am new to javascript and trying to plot multiple graphs of the length of the dictionary in javascript using Canvasjs and flask. I have a dictionary with a list of tuples passing from flask to my ...
1
vote
0
answers
12
views
Dictionary of top5 similar words using FastText
I am working in an NLP task using the following FastText
# FastText
ft_model = FastText(word_tokenized_corpus,
max_n=0,
vector_size=64,
...
-1
votes
1
answer
49
views
Adding a new key to a dictionary with multiple rows
Currently I am importing a file as a dictionary with a structure similar to the following:
Dict:
key1
key2a
key3a
value1
value2
value3
key3b
value1
value2
value3
key2b
key2c
...
-1
votes
0
answers
19
views
iterating through json in python
[{
"userId": 1,
"id": 1,
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit",
"body": "quia et ...
-4
votes
0
answers
17
views
Apply Pandas groupby to a dictionarry? [closed]
is it possible to apply Pandas groupby to a dictionary?
If not how else could I achieve that?
Example:
dict = {"gender" : ["male", "female"],
"age" : [...