Questions tagged [ordereddictionary]

A collection of key-value pairs also accessible by insertion-order.

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

Object of Type None is Not Subscriptable But Code Still Works

Here is my code: if table_exists: # Fetch from table query = f'select * from {table}' data = OrderedDict() data = mycm.fetch_single_row(cur, query) print(type(data)) ...
1 vote
1 answer
31 views

How to add a new element to a sequence with a EOL comment

I have a YAML file as # This is the group manages the permissions group: - state: present group: name: "Developers" description: "The development team" userNames: ...
0 votes
1 answer
38 views

How to do Arithmetic operations between two Ordered Dictionaries in Python ? Please help me

I am trying to do arithmetic operations between two Ordered dictionaries in Python. However I am facing the error : "TypeError: unsupported operand type(s) for -: 'collections.OrderedDict' and '...
0 votes
1 answer
77 views

Python 3.7+: Access elements of a dictionary by order

So I understand that, since Python 3.7, dicts are ordered, but the documentation doesn't seem to list methods of using said ordering. For example, how do I access say the first element of the dict by ...
0 votes
0 answers
15 views

OrderedDictionary inside the init consisting of list of dictionaries gives the error for the state of transitions module for the state maching

In a class ABCD inside the init method I have variable state consisting of OrderedDict containing list of dictionaries. Basically the state is of module 'transitions' which are imported from class '...
0 votes
1 answer
50 views

OrderByDescending for orderedDictionary in c#

I have declared a ordereddictionary . I am trying to sort it according to its values on descending order but found that "ordereddictionary does not contain a definition for OrderByDescending &...
-2 votes
1 answer
61 views

Python: Why does this dictionary change even if I don't access it?

I'm trying to implement a genetic algorithm and I'm running into a very weird issue. I have the following loop for running the genetic algorithm: while True: # Calc population fitness ...
  • 9
0 votes
0 answers
51 views

XCode getting stuck in build if using OrderedDictionary in swift

if use OrderedDictionary in swift xcode getting stuck in build. once will remove project running successfully. i have using xcode 13.2 and swift 5 enter image description here i need to maintain ...
0 votes
0 answers
17 views

How to delete all the keys in a dictionary maintaining the values [duplicate]

I have a dictionary but I want to get only the values, not the keys. How can I do it? `{0: 'despacio', 1: 'mios', 2: 'ir', 3: 'poca', 4: '_', 5: 'consigue', 6: 'eres'} Desired output: {'...
  • 17
-1 votes
1 answer
35 views

sql or python solution for getting merging duplicate rows into one in an ordered table and reordering them

Can someone help me do this in SQL in a select statement? I have a table xyz as follow: ColumnID Column A Column B 1 1 A 1 2 B 1 3 C 1 4 D 2 1 A 2 2 B 2 3 C 2 4 C 3 1 A 3 2 A 3 3 B 3 4 B ...
0 votes
1 answer
70 views

Finding transactions total filtered by dates in range in CoreData

Thank you everyone in advance. I'm new to SwiftUI. I am trying to find transactions total for dates filtered with CoreData fetch sectioned by month showing month by name sales total as section header ...
  • 1
3 votes
2 answers
67 views

How to compare 2 Ordered Dictionaries and create a new Ordered one with differences? (Python 3.7)

I'm struggling on how to generate a "Differences" Ordered-Dictionary containing the Different and also New values appearing on a "Modified" Ordered-Dictionary after comparing with ...
0 votes
0 answers
14 views

iterate over on ordereddict while adding values

I have an OrderedDict that starts with one value. and I want to add values while iterating the OD. this should be something like this: od = OrderedDict(0:"") for key, value in od.items(): ...
-1 votes
2 answers
29 views

Is there any more pythonic way to checkfor keys in an ordered dictionary in Django

type of data <class 'collections.OrderedDict'> if("a" not in data or "b" not in data or "c" not in data or "d" not in data or "e" ...
  • 47
0 votes
1 answer
222 views

How to access key values of ordered dict in django serializer query

I work with Django-Rest api and have serializer that returns me the data like this my_ordered = [OrderedDict([('idx', '1231233'), ('rock', None), ('Email', 'albundy@abc.com')]), OrderedDict([('idx', '...
  • 4,457
0 votes
0 answers
68 views

How to create a pandas dataframe from OrderedDict from the scrapbook module?

I'm attempting to convert the ordered dictionary output (see below) into a pandas dataframe where each key of the ordered dictionary is the name of a column (i.e., a variable name), and where each ...
0 votes
0 answers
25 views

Turn OrderedDict of dataframes into individual data frames?

I have some code that worked in another program that is not currently working for me, and I am not sure why. Other than the datasets being different, the only difference is that I am currently working ...
0 votes
0 answers
27 views

Python nested dictionary not keeping elements in order

I've been trying to create an input library for Selenium using the nested dictionary data type, and while at first it was working perfectly I am now realizing I have gotten myself into a position ...
0 votes
4 answers
54 views

List of Dictionary from .txt file using python

I have a text file with text formatted similar to the Dictionary format of python. I want to convert this text to list of Dictionary using Python. Please help. I am pasting the same text below. If ...
-2 votes
1 answer
86 views

How to convert JSON data inside a pandas column into new columns....column name="level_options"

i have used this code where i supposed to get 6enter image description here lists but got empty lists for all Option1=[] Option2=[] Option3=[] Option4=[] Option5=[] Correct_option=[] try: > ...
0 votes
1 answer
169 views

python sort dictionary by value where each element is a list (by the first element in the list)

I have a dictionary: dct = {'a' : [1,2] , 'b' : [5,9] , 'c' : [3,8] , 'd' : [0,1]} I want to sort it by the first element in the value to get: dct = {'d': [0, 1], 'a': [1, 2], 'c': [3, 8], 'b': [5, 9]...
  • 1,384
1 vote
0 answers
27 views

OrderedDict - For Loop - Delete current iterated value?

I need to compare current iteration of an OrderedDict's value with the previous iteration and then remove that current iteration if it is smaller than the previous. But when I use int() to do so, it ...
1 vote
1 answer
32 views

Apply conditional to data being iterated over in list comprehension

I have the following OrderedDict (I'm sorry for the formatting, I can't figure out how to get it to look readable). I basically have an object representing a conversation that sometimes has messages ...
-3 votes
1 answer
179 views

TypeError: expected at most 1 arguments, got 2....... data = collections.OrderedDict('data', distributed_data[i])

I am getting the following error related to this function definition what is wrong? Convert_to_client_data() is a function in federated learning where I am trying to convert a dataset into the ...
0 votes
1 answer
3k views

Convert a dictionary to pandas dataframe

I have a dictionary in which values are odict_items: {1: odict_items([('a', 0.0952), ('b', 14.583351), ('c', 120000), ('d', 6000)]), 2: odict_items([('a', 0.098733336), ('b', 14.526156), ('c', 120000)...
  • 122
-1 votes
1 answer
51 views

How to convert OrderedDict to a list of values only, in Python?

I have an OrderedDict object and I want to make a list with just the values while keeping the same order they have in the dictionary. Is there an out of the box method to do this? My OrderedDict ...
  • 2,833
0 votes
0 answers
188 views

Is ConcurrentDictionary.TryAdd() result in an order following the calling order?

I have tested in a multithreaded scenario, seems the key-value pairs added by TryAdd() method is randomly ordered, even with adequate interval for the Adding action to complete. Sometime new item was ...
2 votes
2 answers
121 views

Should I use LinkedHashMap or TreeMap if I insert and access in order?

If i put and iterate in natural order, should I use LinkedHashMap or TreeMap? I will use a Map<int, MyObj>, and I will put them in natural order (1,2,3,...). I know about their big-O time ...
0 votes
0 answers
239 views

DictionaryEntry seems obsolete, but how is OrderedDictionary?

System.Collections.DictionaryEntry is avoided for new projects, as seen in the Docs: We don't recommend that you use the DictionaryEntry structure for new development. Instead, we recommend that you ...
0 votes
1 answer
135 views

Generate a pandas dataframe from collections.OrderedDict

I have to open this xml file from this website and make a dataframe. I tried to pas a xml to dict and then pass to dataframe from urllib.request import urlopen import xmltodict from collections import ...
1 vote
1 answer
28 views

ADD Dictionary to List. In Funtion: $user_list.add("user3", $user_name), I must type in "USER3". How to pass variable to this spot?

$user_list = @{ user1 = [ordered]@{ properties = ("666-555-2345", "1234 E Main St", "Dodge Charger"); misc_data = 34145} user2 = [ordered]@{ properties = (&...
  • 113
1 vote
1 answer
81 views

transform ordered dictionaries to list of dictionaries iteratively

EDIT: I realized I made a mistake in my data structure and updated it. I have an ordered dict with some values as list and some as list of lists: odict = OrderedDict([('A', [33]), ...
  • 291
0 votes
1 answer
80 views

Fill dataframe rows according to the arrangement of the headers

I need to create a dataframe where each value in each row is appended to the related headers. The rows are saved as OrderedDict items. This is complicated because some key : value dictionary pairs do ...
-1 votes
1 answer
35 views

How to parse Value in OrderedDict and then sort it?

I have a multidimensional OrderedDict and the value from the key "stampdate" is a string and i have to parse it in a datetime-format and then i want to sort it. ##############################...
0 votes
1 answer
65 views

Expand OrderedDict with list values to a list of dictionaries

I have an OrderedDict with a list of values: OrderedDict([('key1', ['value1', 'value2']), ('key2', [[{'name': ['A', 'B'], 'amount': ['1', '2']}], [{'name': ['...
  • 291
0 votes
1 answer
470 views

how to count the number of keys having duplicate values when the values are in a list

example_dict = {'v':['f','f','f','f','f','f','f','f'], 'c':['p','p','p','p','p','p','p','p','p'], 'a':['p','p','p','p','p','p','p','p'], 'w2' = ['f','f','f','f','f','f','f','f','f']} #the code i have ...
2 votes
1 answer
119 views

foreach ($key in $map.keys) not behaving as expected

I'm trying to iterate over each key of a hash map, and for each key, look it's value up in 3 different maps, assigning to a psCustomObject. For some reason, after just going through the foreach once, ...
  • 3,494
0 votes
0 answers
70 views

Ordered dictionary returned as [0] from Function

ordered dictionary I have some code that returns an ordered dictionary, and all looks good when I return it in the function, but on the receiving end, it is all showing up in [0] of the data structure....
  • 3,494
0 votes
1 answer
641 views

How can I initialize an OrderedDictionary from a regular Dictionary in Swift?

Apples swift-collections package provides an alternative to a Dictionary type which guarantees to keep (not bring) its key-value pairs in order (unlike the regular Dictionary type). But how can I ...
  • 19.8k
0 votes
1 answer
476 views

psobject property set is losing order - how to retain order?

I'm working with Export-Excel, and the psobject property set I am using is re-ordering itself, which makes my excel heading in the wrong order. This is my code: foreach ($errCode in $ErrCodes) ...
  • 3,494
1 vote
1 answer
264 views

Can't get data out of ordered dictionary

I'm trying to get data out of my ordered dictionary, and for some reason it's not printing the data in it. I can get to the first item in the data structure, but I'm having trouble iterating over all ...
  • 3,494
0 votes
1 answer
64 views

Python: how to select n number of elements of each type from OrderedDict?

I have a Django serializer returning an OrderedDict from the serializer.data. It can contain for example this type of data: [OrderedDict([('id', '1'), ('date', '2022-01-08'), ('type', 'A')]), ...
  • 278
4 votes
1 answer
453 views

OrderedDictionary key name at specified index

Given an ordered dictionary, I would like to get the key at index 0. I can of course do a loop, get the key of the first iteration and immediately break out of the loop. But I wonder if there is a way ...
  • 5,983
2 votes
1 answer
68 views

Iterate from one key to another in an OrderedDict

I have an OrderedDict in and I have two keys. I know that one key is stored before the other key and I would like to iterate all items between the first key to the second key. I don't want to iterate ...
  • 3,847
0 votes
1 answer
50 views

Python - Accessing values from a dictionary

Working on something for fun...completely new to programming. How do I access the values in the dictionary so I can either add the cost values or check if its a "Main" or "Side" ...
  • 1
0 votes
2 answers
39 views

parsing 3 lists into list of dictionaries in python

I'm parsing a csv line by line. There are 3 columns in a row that need to be each split into lists and then combined into dictionaries in a list. The data inside each column is separated by two ...
  • 804
2 votes
1 answer
119 views

How to print a dataframe which is read from a csv file into dictionary format?

I turned the data in a csv file into a dataframe by using Pandas then proceeded to print the dataframe into dictionary format by using Ordereddict. However, the index numbers for each row are missing ...
1 vote
1 answer
88 views

How to read ordered dictionary data in R

Assume that you have in a csv in column A the following Python "code" "[OrderedDict([('YTC', OrderedDict([('V', 'B1')])), ('TA', '80'), ('TL', [OrderedDict([('TC', OrderedDict([('V',...
  • 13
0 votes
1 answer
544 views

plotting stacked bar graph

i want to plot stacked bar graph using matplotlib and pandas.The below code plot the bargraph very nicely.However when i change a,b,c,d,e,f,g,h ..etc to January, February... it doesnot plot the same ...
  • 479
0 votes
1 answer
36 views

How to reorder a python OrderedDict using cascading list values

I've seen simpler examples of this but I'm trying to get a bit more complex and can't work it out. If I have an OrderedDict in which the key describes a person and the value is a list of their [age, ...
  • 3

1
2 3 4 5
12