86,297 questions
-4
votes
2
answers
89
views
I want to append a new dictionary to an existing dictionary [duplicate]
By This I mean if the first dictionary is this:
Names = {
Dicta : {
"Name" : "John",
"DOB" : 12122025,
},
}
The second dictionary is this:
Dictb = {
&...
-2
votes
2
answers
123
views
How do I consolidate an object of arrays of timestamped values into single array of objects?
I think the easiest way to show this is the following...
I have this:
{log_1: [{x:'11/25/2025 7:00 AM', y: '3'},{x:'11/25/2025 7:15 AM', y: '43'},{x:'11/25/2025 7:30 AM', y: '49'}],
log_2: [{x:'11/25/...
-3
votes
1
answer
100
views
Can't directly update a dict deepcopy [closed]
I can update a deepcopy of a dictionary in two steps. But when I try to make it a single step it returns None.
from copy import deepcopy
d0 = {'a': 1}
d1 = deepcopy(d0)
d1.update([('b', 2)])
print(d0,...
Advice
0
votes
8
replies
175
views
Finding the max values for list values for each key in a dictionary without using max()
Let's say I have a dictionary such as:
dict = { "Mars": [4, 3, 4, 7, 10], "Jupiter": [6, 6, 7, 9, 11], "Saturn": [4, 5, 12, 22, 1]}
I would like to iterate through each ...
0
votes
1
answer
141
views
Trying to create a Map in C++
I am trying to create a map of stringstreams in C++
std::map<int, std::stringstream> myMap;
std::stringstream ss;
myMap.insert(std::pair<int, std::stringstream>(1, ss));
This fails to ...
1
vote
3
answers
154
views
How to get and update multiple values with multiple keys in a dictionary with vb.net [duplicate]
I have a populated dictionary Test with two keys in TestKeys and five values in TestValues all created via structure objects:
Structure TestKeys
Public Key1 As String
Public Key2 ...
-4
votes
0
answers
45
views
Why is my Python dictionary iteration skipping keys when i modify it inside the loop? [duplicate]
I am to update a python dictionary while iterating over it, but some keys are getting skipp
data = {
"a": 1,
"b": 2,
"c": 3,
"d": 4
}
for key ...
Advice
2
votes
6
replies
84
views
How to model a deep inheritance in F# and allow all items to be added to an inventory
Referring to the attached diagram for an example hierarchy of materials, how can I represent this in F#? Once represented I need to be able to add ANY/ALL of the materials in level 4 (L4) of the ...
4
votes
3
answers
215
views
How to sort a dictionary of word counts by value while preserving the original key order? [duplicate]
I am trying to count word frequencies in a text and then sort them in descending order of frequency. So if two words have the same frequency, they should remain in the same order they first appeared ...
-3
votes
1
answer
191
views
How to create a dictionary where the keys are the alphabet (A-Z), and values are a letter from a string in Python?
I have to create a dictionary, where the keys are letters of the alphabet, and the values are the indexed letters of a given string.
Example:
Given the string "BDFHJLCPRTXVZNYEIWGAKMUSQO" ...
2
votes
1
answer
217
views
Are the iterators of `map<key, value, greater<>>` and `map<key, value, less<>>` guaranteed to be the same type?
I have 2 maps
using BidBook = std::map<float, int, std::greater<>>; // price -> qty
using AskBook = std::map<float, int, std::less<>>;
I have a struct that contain iterator ...
1
vote
3
answers
90
views
How do I make a list in dictionary
This is my simple code for noting down dreams from Python crash course practices 10.7
In this practice I tried to make a list of dreams instead of simply adding a value to key
but don't how to make a ...
0
votes
1
answer
92
views
Using std::map to look up function handlers [duplicate]
I am trying to use std::map to map numerical IDs to function handlers: All function handlers take two integers and return an integer. Handler 100 would calculate the product.
When preparing the map, ...
Advice
0
votes
9
replies
142
views
Pythonic way to obtain dictionary keys with desired property
In python 3.12 I have a dictionary of which the keys are 2-tuples of integers and of which the values are integers (as in the function f:N × N → N for which f(n, m) = n + m). What I need is those keys ...
Advice
1
vote
1
replies
33
views
Is there a way to transfer MBTiles formatted maps faster?
I need to transfer a MBTiles map tiles from a disk to another, is there a faster way then just mv? It is huge and takes time.
1
vote
1
answer
168
views
How can I update values in a nested JSON file using Python? [closed]
I have a JSON file with nested objects, and I want to update specific values inside it using Python.
The structure can vary, but it usually looks something like this:
{
"user": {
"...
-1
votes
2
answers
61
views
Nested dictionary, for yaml style markup
I couldn't figure out the way to process nested leafs/branches/parents, not sure what the actual best terminology is.
I've got the reading of the data happening correctly, far as i can tell.
Its in ...
2
votes
2
answers
156
views
Convert from iferror vlookup to VBA's dictionary array
I need help with a repetitive task that I use vlookup for huge dataset, a bunch of tables of >1 million rows from multiple columns, multiple sheets of another workbook.
ID
TA
ISRC
Result
ID1
TA1
...
2
votes
1
answer
95
views
Typescript infer real entries from object literal dictionary
I have a dictionary object, very simple:
const mydict = {
key1: "value1",
key2: "value2"
}
how do I make a type that automatically converts an object like this into entries?
...
2
votes
2
answers
183
views
terra R package: problem with plet(col=…). It seems no longer admits leaflet::colorNumeric output (map becomes flat color)
I’m trying to draw a SpatRaster on a dynamic map using terra::plet() and a standard palette. The example code used to work in older terra versions (the raster showed a proper yellow/orange gradient), ...
1
vote
1
answer
162
views
Why doesn’t this f-string with double quotes raise a SyntaxError in Python 3.13.3?
I'm currently following this Python course course from Harvard.
At the point in the video, the instructor shows that the following code should raise a SyntaxError because of the conflicting double ...
1
vote
1
answer
202
views
Implementing LRU cache using std::map and std::list in C++. Can't get required output
I am trying to write C++ code to implement a cache. The cache uses Least Recently Used policy explained by the behaviour:
If the cache has a capacity to store 5 keys like 5 3 2 1 4 then if next key=1 ...
0
votes
1
answer
130
views
entrySet vs sequencedEntrySet
I want to know the difference between entrySet and sequencedEntrySet methods in LinkedHashMap in Java 21+.
I am not sure why we have sequencedEntrySet since LinkedHashMap guarantees the insertion ...
-1
votes
1
answer
91
views
Why does `Array(3).map(x => 42)` return an empty array instead of `[42, 42, 42]` in JavaScript? [duplicate]
I was brushing up on Array for an implementation and I stumbled on this discovery, I expected the following code to give me an array filled with the number 42:
Array(3).map(x => 42)
But instead, ...
0
votes
1
answer
121
views
How to rename a dictionary key and keep the order in python? [duplicate]
I have a json file to store the data for an app. This json file has this dict in it:
{
"Survival": {
"text": "Survival",
"directory": "...
0
votes
0
answers
57
views
.NET MAUI Maps Not Loading - Android
I have a .NET MAUI solution with multiple projects sharing a common library ( General). Maps were working fine previously, but now they're not loading properly in my offline project,
Problem Details
...
0
votes
2
answers
176
views
How do I access specific keys and values from CSV files?
I have a CSV file keeping track of people's score in a game. I read it with csv.DictReader().
How do I create a dictionary with the keys being the names and the value being the scores?
CSV file ...
-4
votes
1
answer
66
views
JSON DIctionary saved to S3 using S3FileSystem saved with "/ in data
I am working on a project and trying to convert a csv into JSON Dictionary and saving that JSON data file to S3 bucket via S3FileSystem. If I save this JSON DIctionary to local machine, formate is ...
-5
votes
1
answer
175
views
Convert JavaScript objects to Java objects [closed]
I want to create an object in Java, converting code from JavaScript, but I cannot find how to do so.
It's a really simple problem in JavaScript:
MINI_KEYS = ["1", "2", "3"...
0
votes
2
answers
128
views
How to sort a dictionary with list of datetime objects as value?
I have a dictionary with lists of datetime as value:
month_a = [8,9,10]
day_a = [13,12,15]
month_b = [8,9,10]
day_b = [13,11,13]
dt_a=[]
for m,d in zip(month_a, day_a):
dt_a.append(datetime....
1
vote
1
answer
146
views
Advice on how to handle KeyError occurring when using map Lambda and slicing for dictionary lookup
I'm creating a lookup table / dictionary from a static spreadsheet for upcoming labelling on input data, adding a new field for flavor:
lookup_table_data = pd.read_csv(r'C:\Location\format1.csv', sep='...
0
votes
1
answer
105
views
Recursive function to create and populate dynamic-depth nested dictionary [closed]
I am attempting to build and populate a data structure consisting of multiple, but variable count, nested dictionaries in C#. I am currently using a recursive function to do so.
The data stored in the ...
0
votes
0
answers
65
views
Trying to add new Type to Dotnet Runtime from github
Hi I'm trying to modify the .NET runtime from github.com/dotnet/runtime.
I downloaded the release from that github repository website.
Then, you extract the files to C:\rt. Then run .\build.cmd -s clr+...
14
votes
3
answers
1k
views
Efficient extraction of first/only key in a dictionary
Assumption is that we have a dictionary containing exactly one key/value pair. Objective is to extract the only key.
I can think of four ways to do this (there may be more).
import timeit
def func1(d):...
2
votes
1
answer
56
views
Execute member function from dictionary lookup
I've been doing a lot of HackerRank challenges lately and many of them are in the form of "read instructions from input() and perform the instruction on an object." For example, with a list ...
0
votes
2
answers
189
views
QML + OSM: Loading Offline Tiles from Local Drive
I am struggling to get Qt/QML to use downloaded tiles from local drive. The map is always generated with online tiles and not my local files.
I looked at many other posts but none of them worked for ...
0
votes
2
answers
188
views
Why does Collectors.toMap() throw NullPointerException when mapping to null values? [duplicate]
I'm trying to convert a List of Products to a Map<Long, String> using Java streams. My goal is to collect the DTOs into a map where the key is getId() and the value is getLogoPath(). The ...
0
votes
2
answers
80
views
Labeling a column's values by its criteria based on 2 different columns
Hoping that everyone is having a good one.
(This is a continuation of another question I asked which can be found here: Does Excel VBA's "Scripting.Dictionary" work in languages other ...
2
votes
2
answers
130
views
Does Excel VBA's "Scripting.Dictionary" work in languages other than English?
everyone. I appreciate the people that helped me a few days back. I can say that there has been a bit of progress, but it's pretty much not done yet.
I'm trying to compare the Primary Store (Column C) ...
-1
votes
1
answer
51
views
ggplot: second geom_sf layer covers over the first one even with fill=NA [duplicate]
So zip_geo is a tigris object that has a variable at the zip code level I'd like to plot. I do it this way:
wind_map <- ggplot()+
geom_sf(data=shift_geometry(zip_geo), aes(fill=wind_group), ...
0
votes
2
answers
156
views
A C# question about adding a value to a dictionary
I have
var foundItems = new Dictionary<string, List<string>>();
string[] targetColumns;
string value;
Adding a value to a key works fine with this code:
foundItems[targetColumns[i]].Add(...
1
vote
1
answer
105
views
Pydantic does not validate dict values when assigning an unexpected type to dict values
I have the question same with link
Pydantic does not validate the key/values of dict fields
from typing import Dict
from pydantic import BaseModel
class TableModel(BaseModel):
table: Dict[str, ...
4
votes
1
answer
203
views
Why is a ConcurrentDictionary faster than a Dictionary in benchmark?
I have a really simple benchmark to measure and compare performance of Dictionary<string, int> and ConcurrentDictionary<string, int>:
[MemoryDiagnoser]
public class ...
1
vote
0
answers
49
views
R tigris: Areas not in a ZCTA [duplicate]
I'm trying to create a map of the US at the zip code level to show the value of a particular variable. Used this code to create the source:
zcta_geo <- tigris::zctas(class = "sf", year=...
0
votes
2
answers
118
views
If I specify the capacity of a dictionary through the constructor, should I use a prime? [closed]
I am initializing a fairly large dictionary in C#.
I have benchmarked the speed of building the dictionary with the capacity and without. It is (as expected) significantly faster (and uses ...
4
votes
3
answers
132
views
Efficient way creating a dict of dict from a pandas dataframe
I have a pandas dataframe of the following structure:
d = {'I': ['A', 'B', 'C', 'D'], 'X': [ 1, 0, 3, 1], 'Y': [0, 1, 2, 1], 'Z': [1, 0, 0, 0], 'W': [3, 2, 0, 0]}
df = pd.DataFrame(data=d, columns=['I'...
0
votes
2
answers
80
views
conditional map fetch efficiently
I have a map which lays down prices of commodities in different currencies
val commpricemap: Map[String , Map[String, Double]] = ???
AN example of an entry for gold is as below:
("AU" -> ...
2
votes
1
answer
285
views
Dataframe behavior: Pandas 1.1.5 vs 2.3.0
I recently had to update the virtual environment for one of my libraries from Python 3.7 to 3.10, which also involved updating Pandas from 1.1.5 to 2.3.0.
In the previous virtual environment, this ...
0
votes
0
answers
45
views
SwiftUI Map Heading annotation is not showing
I am creating a swiftui map view with code below, I can see the blue dot for user location, but I can not see the user heading annotation (the blue fan out partially transparent image connected to the ...
2
votes
2
answers
86
views
Why is my code not appending into my dictionary a value under a key despite complying with the loop parameters? [closed]
I'm sorting grades by number ranges and adding them to my dictionary keys. For some reason my code is ignoring value 68 altogether.
My code:
import numpy as np
exam_results = np.array(
[
...