Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
13 views

List append dictionary - handling missing data

For reading a HTML-tree, I have a script that reads the element-tree. However, the problem I have is that with creating a list, the script uses for a missing value, the last known value. However, ...
user16760825's user avatar
0 votes
1 answer
51 views

Appending nested dictionary objects to a list based on the values of the nested dictionary object. PYTHON

I've come across an issue with some code I'm writing to display a list of objects that the user can select from. Each object has a given 'Size' attached to it, and each time an object is selected, ...
Moonlyte Demon's user avatar
0 votes
0 answers
33 views

How can I add together list items that I got from a dictionary?

So this is a simple program I am doing for a homework assignment that I am getting stuck on somewhere in the middle. Create a program in Python to display a menu on the kiosk at the coffee shop and ...
alyssa's user avatar
  • 1
0 votes
1 answer
47 views

When to use append() and when the += operator in Python?

This is my first question on Stack Overflow. I want to add a new dictionary at the end of an existing list with multiple dictionaries (see example below): travel_log = [ { "country": &...
Carlotta Ferri's user avatar
1 vote
0 answers
61 views

Add value in dictionary with inner dictionary [duplicate]

Could you please help with the following problem. I have a dictionary with the following structure: {'logtype16777217': {'Table_AmfSetID.csv': [], 'Table_QCI.csv': [], 'Table_body.csv': [], '...
TRP's user avatar
  • 53
0 votes
2 answers
36 views

Append integers to a dictionary whose starting values are empty lists

I have the dictionary my_dict = {'A': [], 'B': [], 'C': []} and am trying to create the following: my_dict = {'A': [0,3,6], 'B': [1,4,7], 'C': [2,5,8]}. This is what I have devised to do this: labels =...
Innocuous Rift's user avatar
-1 votes
2 answers
70 views

Why does my code create a sublist instead of a new element (Python)?

My code starts with a string that contains a sentence and the category that each word belongs to. Then I store this information in a 2-dimensional list: cadena ="El/DT perro/N come/V carne/N de/P ...
Luca P.'s user avatar
  • 13
1 vote
1 answer
40 views

Dict with df. How to fill empty data frames which are in values of dictionary?

I created dictionary with data frames. I want to fill each data frame - append new row to each. It is in for loop. When I have one data frame, and list of values it is works: row = [20, 'Gornik Zabrze'...
Corcky's user avatar
  • 25
0 votes
1 answer
50 views

Why are values inside list changing (Python) [duplicate]

I created a list called database and appended 'person' to it. When the values in person change from the for loop it keeps changing the values inside the array as well. The last value in 'reader_data' ...
user22529608's user avatar
-2 votes
2 answers
76 views

Best way to create multiple list from a dictionary

What is the best way to create multiple list from a dictionary? My dictionary looks like this: mydict = {'aaa': ['111', '222', '333'], 'bbb': ['444', '555']} I'm trying to make lists like this: aaa ['...
user22335241's user avatar
0 votes
1 answer
39 views

updating dictionaries in python from list of booleans

I have an empty dictionary I want to add to. My solution works but I want to keep adding for each iteration in a dataset. The outcome is only showing one key:value pair. Is there a way to do this? My ...
n3wb's user avatar
  • 7
0 votes
2 answers
703 views

Why do my previous dictionaries in a list change when I try to add a new one?

I have a code that does the following: Goes through a list of dictionaries, fills up a "temporary" dictionary with each one's data, and then appends the "temporary" dictionary to ...
TheParable's user avatar
0 votes
1 answer
18 views

How to append each single value from a dictionary list into its own column?

This is the dictionary I have and I wanted to put every single value from the list into its own column. my_dict = {1: ['Home', 'Stories'], 2: ['Sounds', 'Stories', 'Home', 'Home', 'Stories'], 3: ['...
Sophie Martusewicz's user avatar
2 votes
4 answers
520 views

How to append the list in a dictionary into its own column?

I have a dictionary with lists as values as you can see here: my_dict = {1: ['Home', 'Stories'], 2: ['Sounds', 'Stories', 'Home', 'Home', 'Stories'], 3: ['Journeys / Series', 'Journeys / Series', '...
Sophie Martusewicz's user avatar
-1 votes
1 answer
113 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 = [ {"...
Kaii's user avatar
  • 11
0 votes
1 answer
67 views

How do I append a nested dictionary to a CSV file with keys out of order?

I have a nested dictionary in the format: nested_dict = { 'dictA': {'key_1a': 'value_1a', 'key_2a': 'value2a',...}, 'dictB': {'key_2b': 'value_2b', 'key_1b': 'value_1b,...}, ...
rtd730's user avatar
  • 13
0 votes
2 answers
368 views

append() is overwriting the previous data he has written instead of just adding at the end

i'm wondering why the function append() is overwritting the elements given in a list that he has to write one after another. I'm really lost here. So here is the list of elements (I use fake identity ...
Matteo's user avatar
  • 23
0 votes
3 answers
46 views

Appending a list in a dictionary

I have list of a list of dictionaries on hurricane data called list_hurricane, which looks like **Simplified View** Hurricane A Hurricane B [[{key1:value1, key2:value2,...}],[{...
J8311's user avatar
  • 1
0 votes
1 answer
56 views

Appending a dataframe to dictionary of dataframe

I have a dictionary structured with all the results of a test_train_split run 50 times. However, from time to time I need to force an already removed subset into the testing dataframes. Currently I'm ...
a.s.1's user avatar
  • 39
-1 votes
1 answer
46 views

how to print a list in below format

The following code is converting two dictionaries into a list: payment_no=[] for i in df2: payment_list=[] for k in df3: if df2[i]['Payment_Number'] == df3[k]['Payment_Number']: ...
hazeeb hashim siddique's user avatar
0 votes
1 answer
26 views

Why below code works when 2 conditions "==" but give empty list same code has 2 conditions "!="?

d1 = [{"name": "a", "author": "b", "read": False}, {"name": "c", "author": "b", "read": False},...
Pavel's user avatar
  • 3
1 vote
1 answer
430 views

Python list.append dictionaries with same pattern in a loop. The Dictionary is updated per loop, while the list is update in a whole [duplicate]

There is a pattern in a text file and I use regex to extra them all in to tuples. "a host (e.g., '146.204.224.152') a user_name (e.g., 'feest6811' note: sometimes the user name is missing! In ...
LunaPapa's user avatar
0 votes
2 answers
33 views

Accepting inputs to append to list/dictionary depending on whether data is present on both sides of chosen value

I'm attempting to create a list (or dictionary, unsure which is more appropriate) which will have values I have input. It will only append inputted values if it follows the correct format, which is ...
veryconfused's user avatar
0 votes
1 answer
94 views

Append dictionary in json using Python

I am doing my first Python program and its Hangman game. I managed to make it work but as a part of the task I need to write "best results -hall of fame" table as json file. Each entry in ...
Rosohatica's user avatar
1 vote
1 answer
23 views

Create New Dictionary by taking Elements present in list and keep appending element inside the dictionary

I have list : b = ["apple", "banana", "cherry"] I need to add all elements present in list and create new dictionary by appending it in existing dictionary. My code: b = [...
Divyank's user avatar
  • 1,036
-1 votes
2 answers
5k views

TypeError: unhashable type: 'numpy.ndarray' when trying to append to a dictionary

I'm trying to append values to my dictionary, but I can't solve this error. This is my dictionary: groups = {'group1': array([450, 449.]), 'group2': array([490, 489.]), 'group3': array([568, 567.])} ...
Ludovica's user avatar
0 votes
1 answer
133 views

How to append a list of dictionary inside of a dictionary

I have an issue that I am scratching my head over. I have dictionary as follow: my_dict = {'key': ['string', [{'id': 'id_value', 'number' : 'number_value'}]]} and in the processing of this dictionary ...
J. Donič's user avatar
  • 163
0 votes
1 answer
59 views

Is it possible to append different values to different keys of a dictionary?

I have a dictionary: groups = {'group1': array([450, 449.]), 'group2': array([490, 489.]), 'group3': array([568, 567.])} I have to iterate over a txt file that I have loaded using numpy.loadtxt() ...
Ludovica's user avatar
0 votes
2 answers
33 views

Python: How to append individual dictionaries to Series data structure

My goal is to create an output that has a Series datatype and following output: I tried to achieve this by using the code below: series_structure = pd.Series() for i in table_dtypes[0]: if i == &...
PineNuts0's user avatar
  • 5,214
0 votes
2 answers
153 views

AWS Lambda: Append each dictionary to a new line of an Array - Python

I have an array of Dictionaries in python as shown below, I am iterating over a list and order_number etc is assigned as a variable for each one. I am doing this in AWS Lambda customer.append({'Name' :...
Jess_D_'s user avatar
  • 13
0 votes
4 answers
131 views

Creating a new list based on the conditions of the dictionary nested in the list

I am new to Python. I am trying to create a new list based on a specific condition, which is fruits['type'] === 'edit'. fruits = [{'type': 'edit', 'ns': 0, 'title': 'List', 'pageid': 39338740}, ...
Brie Tasi's user avatar
-3 votes
1 answer
55 views

How to change value in a dict?

I have so many dict data with different formats and I want to change the key place to None. I create this function to read all value, but I can change it def test(T, data): if T: T.pop(0) ...
marwen aydi's user avatar
-2 votes
2 answers
61 views

list.append() automatically updates dictionary values?

Does anyone know why my dictionary updated automatically even though I didn't use the dict.update() method? fruits = { "green" : ["kiwi"] } name = "avocado" list_tmp ...
askren's user avatar
  • 31
-2 votes
1 answer
45 views

Printing Dictionary after appending only shows latest dictionary entry instead of the full dictionary

I'm trying to create a blank dictionary that we add user inputs to (Character Name, Age, HP). Later on I will use those inputs to create new classes instances. Here's the result as well as a note ...
Mitsuki555's user avatar
0 votes
3 answers
81 views

How to append to second value of dictionary value after underscore in +1 manner

Imagine I have a dictionary as such: barcodedict={"12_20":[10,15,20], "12_21":[5, "5_1","5_2",6]} Then I have a number that corresponds to a date, lets say ...
Rivered's user avatar
  • 779
-1 votes
5 answers
74 views

How to combine a list with dictionaries and values outside to allow for loop

It's hard for me to explain in the title, but I have a list of 2 dictionaries data, and I want to insert things and stuff into them according to index via for loop or other iterators. this is what I ...
Mars2024's user avatar
  • 384
0 votes
1 answer
232 views

Extract & Append Inner Dictionary to Outer Dictionary

Overview For converting API responses to Pandas Dataframes I was looking for a solution that would extract Inner Dictionaries from the Outer(main) Dictionary and append the key value pairs from the ...
Callum's user avatar
  • 251
0 votes
4 answers
58 views

How do you append two dictionaries such that the result of the value is a list of lists

I have two dictionaries: dd = {1: [10, 15], 5: [10, 20, 27], 3: [7]} dd1 = {1: [1, 4], 5: [2, 5, 6], 3: [3]} I would like to have the appended dictionary dd look like this: dd = {1: [[10, 15],[1, 4]],...
rweber's user avatar
  • 142
2 votes
1 answer
64 views

Appending a different dataset to ONE list every iteration

In my current code I'm iterating through 4500 cell values of a column from an excel file. In each iteration, the cell value is added between two halves of an invalid URL to form a valid URL. I can ...
noviceprogramer's user avatar
-1 votes
1 answer
44 views

Find the first number is tuple in python

I have this code and this a,b and c values and after appeidnig in tuple i need to find the first number of 1 and last value from 7 ,how i can get this two first and last value from the tuple. a=1,5 b=...
Hasan's user avatar
  • 7
-1 votes
1 answer
1k views

How to add value in dictionary if key exists instead of replace it

The below will replace values in the dictionary rather than adding them. ie if there are two wallets with a USD balance I would like the dictionary to add them together rather than replace the first ...
JamilOxalys's user avatar
0 votes
1 answer
80 views

How to append dictionary values via recursion with user input in Python?

I have created a method called 'ads' inside of a larger Class. The method should take user input and append the value slot (0) of the dictionary with this data. The dictionary keys, however, are ...
Raheem Sabella's user avatar
0 votes
1 answer
182 views

Append dict at same time python

I want to append elements to an empty dictionary in python. For a current frame I am attributing two keys: 'ID' and 'Coordinates'. My problem is when I am appending the values, e.g df={} for i in ...
fribeiro98's user avatar
1 vote
1 answer
111 views

How do I 'append' a dictionary into an existing JSON dictionary using python?

Take a look at this example dictionary: This is in a JSON file: { "fridge": { "vegetables": { "Cucumber": 0, "Carrot": 2, ...
Hyperba's user avatar
  • 119
-1 votes
1 answer
37 views

Python: Add four lists to a dictionary that already has keys, all lists/dict have same length of values

I have 5 lists: periods = [] interface_sum = [] intraslab_sum = [] crustal_sum = [] total_sums = [] I want to make the periods list as the key, then have the rest of those lists appended onto the ...
brice0408's user avatar
0 votes
0 answers
57 views

Cumulatively add values to a dictionary Python

I have a list of 2 different dictionaries which I update in a function, however I want to run this in a for loop where for loop two I want to iteratively add to these 2 dictionaries that I already ...
MrKnudz's user avatar
  • 41
0 votes
3 answers
166 views

Append a dictionary array to another dictionary array in Swift

I have two quote dictionaries I'm trying to append after an in-app purchase. I have tried several different methods to append the dictionaries together but I'm still getting an error "No exact ...
Sharlene's user avatar
0 votes
1 answer
34 views

unable to add a string properly to the dictionary

I am having a fastapi to do predictions and returing the output as a response but i have implemented input checking where if the user gives unsupported input it returns a Invalid smile but the problem ...
user avatar
0 votes
2 answers
57 views

Conversion Program

I have a program where I need to prompt the user for an input of a word and a key. Next, the program should remove all the spaces, punctuation and all numbers from the word and convert all the letters ...
Hypnotix999's user avatar
0 votes
0 answers
21 views

unexpected behavior when using append method on python dictionary [duplicate]

I am trying to update the value for a particular key in a dictionary. However, for some reason, all the keys in the dictionary are updated with that value. I don't know what part of the code throws ...
daisynorthwest's user avatar

1
2 3 4 5
8