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].

Filter by
Sorted by
Tagged with
0 votes
2 answers
18 views

React doesn't render with map

I'am trying to render a list of property objects with react unfortunately it just doesn't render the content of the list . import Property from "../Property" import { Container } from "....
-1 votes
1 answer
18 views

sort a list that contains dictionaries with same key

I have four dictionaries that have same key and different value. I want to print them after sorted by the values, but I can not sort them. I want to sort dictionaries with the value of first key, if ...
  • 1
1 vote
0 answers
19 views

LibreOffice Calc , Some spreadsheet data is randomly ignored when converting to a dictionary using openpyxl

from openpyxl import load_workbook # MAKE DICTIONARY FROM SPREADSHEET workbook = load_workbook('Zonebreakers3col.xlsx') sheet = workbook.active for value in sheet.iter_rows(values_only = True): ...
  • 17
0 votes
2 answers
47 views

I'm having trouble replacing an empty element in a dictionary in python 3.7

I am trying to find a way to replace an empty object in python but it never worked out here is the code i tried import datetime import time A = {'name : '', ' 'age': 0, 'tasks done': '', 'number of ...
0 votes
2 answers
29 views

Map element from one list to all elements in a sub-list to form a list of tuples (coordinates)

I am trying to map each element[x] from list: rows to all elements of the sub-list[x] from another list: cols and the result should be a list of tuples. These 2 lists, rows and cols have the same ...
  • 29
0 votes
0 answers
37 views

Find and Update Dictionary Value Using Key List

This might be difficult to explain (which is part of the reason I haven't figured out how to google it properly) but I'll do my best. I'm using MQTT and I subscribe to a topic (say "generic_topic/...
  • 61
0 votes
0 answers
25 views

How can i write the arguments in this text adventure so it automatically takes the sub or main part of my story out of my dict?

I am trying to code a text adventure using python and im stuck. Right now i always get a KeyError besause of my story sub parts. I have a function, func_eval(), to build other preassigned functions ...
  • 1
1 vote
1 answer
30 views

Subclassing dict and implementing __getitem__ for nested class (python)

I am currently trying to implement a subclass (called 'Pointer_dict') for the python dictionary class dict. The purpose of this class is to save memory when creating copies of dictionaries and ...
  • 11
0 votes
2 answers
15 views

How to type new Map([['1', ()=>{}], [2, ()=>{}]]) ? I try to Map<string|number, () => void>, but it throw ts error No overload matches

const a: Map<string | number, () => void> = new Map([ [ 2, () => { console.log('a'); }, ], [ '2', () => { console.log('a'); }, ], ]); throw ...
-1 votes
4 answers
49 views

Why am I getting TypeError: '>=' not supported between instances of 'dict_values' and 'int'?

I am aware of this post, but unfortunately I'm not able to translate it into a solution for my own case (I am a beginner, 6 weeks into my first Python course). Objective I have a dictionary with {'str'...
  • 107
-1 votes
0 answers
27 views

Parsing a ios notification

I get firebase notification from CloudKit. I parse the dictionary and get to the value corresponding to key "aps" if let val = dict["aps"], let msgId = dict["gcm.message_id&...
  • 537
0 votes
1 answer
20 views

Json to Groovy list of objects

I want to transform this json: [ { "askey": { "ad": "000001", "bt": 1 }, "Id": { "mc": 30, "zs&...
-2 votes
1 answer
39 views

Robustness of a dictionary to prevent extra spaces

I'm using a dictionary and all the keys come from a text file. I have to iterate through a dictionary to set the values of another array. The array population function looks like this: ...
  • 1
0 votes
0 answers
46 views

Cant figure out why I keep getting "scheme map contract violation expected: procedure? error" [closed]

I have the following code: (define (eval-1 exp) ; display expressions added. -- dlb (display "Executing eval-1, exp = ") (displayln exp) (cond ((constant? exp) (displayln ...
  • 1
0 votes
1 answer
29 views

Extract value from embedded dictionaries inside pandas df

I have pandas dataframe: Name A B $overall {'all': 26929} {'all': 2036} QWE {'$overall': {'all': 6},'Mar 18, 2021': {'all': 3},'Mar 3, 2021': {'all': 3}} {'$overall': {'all': 3},'Mar 3, 2021': {'...
  • 21
-1 votes
1 answer
27 views

rename list in data frame according to dictionary in Python

it is necessary to create a column with the name according to their code. I have a dictionary, I'm trying to rename codes to titles. There are two conditions, because the code may not be in the ...
-1 votes
4 answers
57 views

Converting a string to a Dictionary of type Dictionary<string, List<string>>() using C# [duplicate]

I have a string "{yhxj7027DO=[3], lzpd7453EH=[2, 3]}". I would like to convert it to a Dictionary of type new Dictionary<string, List<string>>(). I tried the following string = &...
  • 2,567
1 vote
1 answer
35 views

How to import data form lists in a dictionary in Python?

I want to create a program that takes 3 different inputs and stores them in 3 separate lists and then be able to combine them in a dictionary and print on screen. So far I got this : size = input(&...
0 votes
0 answers
8 views

merge list of 1-row dictionaries into list of 2-row dictionaries

I have a list with dictionaries with 2 keys: 0 and 1, and I want to create a list of dictionaries that has 2 lines: {0: ... , 1: ...} I know this must be very simple but I cant figure out what to do I ...
1 vote
1 answer
43 views

VBA Dictionary duplicating entries when using CStr for keys

While trying to fix a broken code with arrays and dictionaries, I came upon something weird when filling the dictionary (I have since used a different workaround) but was wondering what's causing the &...
0 votes
1 answer
33 views

Ipywidgets interactive - take a dictionary as an argument

I have a function that looks like this that takes a dictionary as an argument. The dictionary looks like this: d = {'skill_1':3, 'skill_2':2, 'skill_5':5, 'skill_7':3} The function i have is a ...
  • 720
-1 votes
0 answers
16 views

Scraping data from interactive map by using Python [closed]

I am trying to scrape the 2019 zone alignment and 2019 beat alignment layer data from the map, eg: zone 1 - 108,109,110 etc https://atlantapd.maps.arcgis.com/apps/webappviewer/index.html?id=...
  • 1
-1 votes
1 answer
30 views

Python: Is there any way to sort keys in a dictionary with 2 values? [duplicate]

Python 3.11 I was coding a leaderboard and I haven't found a way, how to sort the users, my dictionary is this: users = { "level": { "Mark": 4, "Steve": 3,...
0 votes
1 answer
46 views

How to insert values into a nested python dictionary

I am trying to insert values into a nested python dictionary. The response I am getting is from a postgresql database where the table has four columns: coe, coe_type, count, coe_status Author 1, Open,...
0 votes
0 answers
22 views

Series to dict in Pandas - conflict with indexes [closed]

I wanted to convert a column of a table (=Series) to a dict to use it later in fillna(). However, the name of a column becomes one and only key. Is there a way to avoid it? dpr_dict = dead_per_region....
2 votes
2 answers
21 views

Write a program to read mbox-short.txt and figure out who has sent the greatest number of mail messages

File: http://www.py4e.com/code3/mbox-short.txt I had tried to filter the email addresses from this file but failed to filter the greatest number of mail messages. name = input("Enter file:") ...
  • 23
0 votes
1 answer
75 views

Pull value from dictionaries embedded in pandas df

I have pandas dataframe: Name A B $overall {'all': 26929} {'all': 2036} QWE {'$overall': {'all': 6},'Mar 18, 2021': {'all': 3},'Mar 3, 2021': {'all': 3}} {'$overall': {'all': 3},'Mar 3, 2021': {'...
  • 21
0 votes
2 answers
22 views

Iterate through nested lists & dictionaries to get grouping of one value by another

I am working to create a program which will generate today's news for each stock in my portfolio every time I run it. I have successfully downloaded the news for the portfolio's stocks, and to my ...
  • 11
0 votes
0 answers
14 views

How to add multiple colors and filters in Folium map

I have a dataset with 47 different local channels and the states in which they are broadcast. I'm trying to get a map put together where each channel would ideally be a different color (similar color ...
  • 11
0 votes
1 answer
37 views

Pandas df column has some value as dict

I have below pandas dataframe: A B {'all': 44} {'all': 16} NaN {'all': 175} How do I extract numeric value from each column and replace NaN as 0? I tried to use .values() on just first record: ...
  • 21
2 votes
2 answers
42 views

Javascript create dictionary from another dictionary

If I have a dict like below: const d = {"S1": [2, 3, 4], "S2": [5, 6, 7, 8]} I want to create another dictionary that can get the len or the 1st element as value with the same key,...
0 votes
1 answer
50 views

How to use elements in two columns from a DataFrame as a dictionary to be applied in another DataFrame

So, I have data from a wildlife rehabilitation center, and each animal received enters the database with it's common name and a unique ID number. I have to take all these common names and write the ...
-1 votes
2 answers
59 views

How do I access using Python Dict and List

Here I am giving two variables namely "a", "result". If "result" matches with any of the record in "a" in "city" then it should return entire record ...
0 votes
3 answers
54 views

replacing every letter with its position in the alphabet with map function is sorted by alphabet order and not by typed order

i just created a function to replace every letter with its position in the alphabet, but it is sorted in order of the alphabet. for example, if i type 'Alex' the positions should be (1, 12, 5, 24), ...
0 votes
2 answers
29 views

No output in finding all occurrences of a key in a nested python JSON

I have this sample JSON which is complex and has many levels of nesting as well items in in: { "resourceType": "Single", "type": "transaction", "...
  • 2,695
0 votes
0 answers
23 views

Assign values ​to key following multiple conditions and given options

hope your doing well. I've been working with an external API and I need to modify the response following certain conditions, but I cannot find a proper way to achieve what I supposed with the code. ...
  • 21
0 votes
0 answers
14 views

python support for recursive function within a loop

I'm a beginner on coding python and i ask your support. I'm writing a code to create a nested dictionary with father child relation. The program start with an API Rest call and in a loop need to ...
-1 votes
0 answers
27 views

dictionary in C with one-symbol keys [closed]

I recently started learning C and am trying to implement a dictionary to translate words into Morse code. The dictionary is implemented using hashed tables. I know that it is possible to implement ...
  • 1
-1 votes
2 answers
56 views

Transform a dictionary into a list of tuples with Python

I want to transform a dictionary into a list of tuples, but doing it 'row-wise': the first tuple should cointain the first values, the second tuple the second values, and so on. I have some working ...
-1 votes
1 answer
44 views

Update collection with data from Dictionary

I have method that returns Dictionary with value true/false Here is this method public Dictionary<IItemWithRules, bool> CheckAvailability(List<IItemWithRules> tiles) { //... } I want ...
  • 2,285
1 vote
1 answer
18 views

Is there a way to use an if statement inside a map procedure?

I am relatively new to Netlogo and I'm currently stuck on a problem. I want to update several values in a list called list1 depending on the values in two other lists called list2 and list3. Basically ...
0 votes
2 answers
49 views

Map grouped dictionary of multidimensional array to struct

I have a multidimensional array: tempCalculatorArray [[String]] - it always carries 2 Strings i.e. "AMT", "Simple scoring system". I want to display my array in a UITableView and ...
-1 votes
1 answer
19 views

How do I update the sorted dict as well as the original dict

Once i append another value into the dict it updates the roster. As expected. Yet, once i try and output the sorted roster it doesnt update? How can I fix this? I tried by: roster = [ {"...
  • 11
0 votes
2 answers
24 views

Creating a dictionary of class objects with multithreading

I am trying to create a dictionary of class objects. If I do it one at a time, it works. If I try and use multithreading I end up with an empty dictionary. This works for one item: import concurrent ...
0 votes
1 answer
49 views

How to use a dictionary to standardize terminology across lists

I have been trying to solve this issue for a while but I can't seem to think of a right solution. Basically, I am parsing few pdfs and depending on the source of the pdf, the terminology used is ...
  • 23
-1 votes
1 answer
42 views

Compare text in dataframe with words in dictionary

I constructed the dictionary (MYdict) which outputs: {'MATCH': ['actor', 'addicted', 'addiction', 'affected', 'alli', 'angel', 'ani', 'apartment', 'astrology', 'avoiding', 'beach', 'being', 'belong', '...
  • 27
0 votes
1 answer
26 views

Plotting a dictionary containing a dictionary using matplotlib

I'm attempting to create a stacked bar graph with matplotlib with the x axis being female and male in this case and the y axis showing the number of "Yes" for each gender. Then I'd stack the ...
0 votes
1 answer
16 views

YOLOV8 test MAP score

I can calculate the map score of the validation set using yolo version 8. but is there any way to calculate the MAP of the test score? The code for calculating the map of the validation set is given ...
  • 31
-2 votes
0 answers
15 views

Google Map Place API with PHP CURL

I used the Google Map Place API in PHP with CURL call , I got the data from CURL calling but I need to restrict my API key , when I restrict my API key with Website URL , it is not working. What I ...
0 votes
0 answers
8 views

Package mapbox_gl flutter raised exception

How can I solve the "java.lang.IncompatibleClassChangeError" exception when using Mapbox GL in a Flutter application on Android? I'm developing a Flutter application that uses the Mapbox GL ...

1
2 3 4 5
1694