Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I have a list of tuples and I want to convert them to dictionary but the key should be tuple…
Tag: dictionary
How to convert list of dictionaries into a dictionary of dictionaries by using inner key:value pair
So, instead of trying to explain things first, I will just show you what I have and what I want (this is easier): What I have: What I want to get from what I have: Explanation: So, I want to create a dictionary by using the “label” keys as the main keys in that new dictionary. I also need to
How to generate a dictionary of lists containing all possible additive and subtractive combinations of a few lists
Say for instance I have a dictionary with string names as keys, and lists as values: I want to generate a new dictionary with keys corresponding to lists that are all the additive or subtractive combinations of the sublists. So this should be the result if we print each sublist in the new dictionary. I don…
Counting the number of triplets forming GP series in python
The problem statement is: You are given an array and you need to find number of triplets of indices(i,j,k) such that the elements at those indices are in geometric progression for a given common ratio, r and i<j<k. For example, arr=[1,4,16,64]. If r=4, we have [1,4,16] and [4,16,64] at indices (0,1,2) a…
Group dates into list based on value
I have a json object that I’m trying to group item together in. this code returns values grouped by date as the key and then a list of teams and dates like this However, I need it to return and key value pair like this where all the dates for a specific team are in a list as the value
Fastest method: for value in DictA, find value in DictB and retrieve other DictB value?
For each item in dictA, I want to search for it in dictB, if dictB has it then I want to pull some other values from dictB and add it to dictA. An example that is working is here, however it is rather slow as I have 50,000+ items to search through and it will perform this similar function on
Sort lists of dictionaries within dictionary
EDIT: I’m editing the whole post as it wasn’t as clear as I thougt. I have this dictionary (list of dictionaries within a dictionary) and I need to sort it by the values of “Position” and “Team”, meaning that I need to get all the values from those two keys and print them a…
how to access a dictionary from another function in the current function
I am trying to refer to the dictionary in function_one. I have tried to return the dictionary variables, and use the dictionary names as parameters and arguments. However, I am getting an error message saying that the dictionaries I am trying to access in function_two is not defined. Here is my simplified cod…
how to get only specific values from dictionary using key in python
I have this kind of 50 dictionary means that I have over 50 kind of dictionary for different values. like symbol and other key value. I want to get only symbol and open values in a list. What I have tried: Here data is the dictionary as mentioned above. please help. here is an example of several dictionaries.…
How to drop dictionaries with NaN values from list
This seems like a fairly simple thing but I haven’t been able to find an answer for it here (yet). I have a list of dictionaries, and some of the dictionaries in the list have NaN values. I just need to drop any dictionary from the list if it has a NaN value in it. I’ve tried it a few