Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
0 answers
31 views

How can I sort a dictionary with in the dictionary by the keys of the second dictionary in python? [duplicate]

I have a dictionary as follows: dict_1 ={'Spain':{'wins':1,'loses':0,'draws':2,'goal_difference':2, 'points':3},'Portugal':{'wins':3,'loses:1,'draws':1,'goal_difference':0,'points':4},'Morocco':{'wins'...
MohammadMahdi Saeedi's user avatar
0 votes
1 answer
53 views

Iteratively source a value from a dictionary

I have a data set where I know a limited number of values and based on other values in a data set I can figure out what the subsequent values are. I could do this with a huge if function, but I know ...
James Oliver's user avatar
0 votes
0 answers
35 views

How to convert json string into json object of list if you are working with list of dictionary in c# lambda function using newtonso

I am working on a lambda api, and i need to get response in object of list. here is my model: public class Response { public List<Dictionary<string, string>> FailedTenant { get; set; } ...
RANU TANWAR's user avatar
0 votes
0 answers
22 views

lambda function in key argument in sorted() method in python? [duplicate]

I found this code from online and tries to find what is the logic.But i didn't get it. from collections import Counter arr = [4,3,1,1,3,3,2] k = 3 c = Counter(arr) print(c) s = sorted(arr,key = lambda ...
abilaashrajesh's user avatar
0 votes
1 answer
28 views

Create dataframe columns from a dictionary using lambda expression

I would like to create a pyspark dataframe dynamically using lambda form a give dictionary. Below is my dictionary. cols = [ {'Technical Label':'UserID', 'Column Mapping':'UID','Technical Column':'No'}...
Alex Raj Kaliamoorthy's user avatar
0 votes
0 answers
33 views

Python: when lambda is used to iterate, notation does not make sense [duplicate]

Here is some code from Python Cookbook. portfolio = [ {'name': 'IBM', 'shares': 100, 'price': 91.1}, {'name': 'AAPL', 'shares': 50, 'price': 543.22}, {'name': 'FB', 'shares': 200, ...
Kamran Butt's user avatar
0 votes
2 answers
83 views

Using counter in map, lambda in Python

I need to create this list ["1", "12", "123", "1234", "12345", ..., "123456789"] without using loops. How can I do it by using map, lambda ...
New2905's user avatar
  • 23
0 votes
0 answers
63 views

Using reduce and lambda function to find average grade in a dictionary list

In a dictionary list containing student information like name, age, grade. Use lambda and reduce function to find average grade of all students? I am not able to use the lambda and reduce function to ...
Akshay Sahni 's user avatar
0 votes
0 answers
11 views

Using lambda function to sort dictionary list

A dictionary contains name and age of a person. Use lambda function to filter out dictionaries for age less than 30 and then print the names of person in sorted list with name capitalized and prefixed ...
Akshay Sahni 's user avatar
0 votes
1 answer
16 views

How to sort a dictionary inside a dictionary by values?

I am trying to sort this dictionary that contains divisions of hockey teams. Each team is an element of the dictionary and each team's value is a dictionary that has a number of points (PTS) and a VRP ...
Popcycle999's user avatar
0 votes
0 answers
76 views

How to add an x before each element in a list of strings so I can use it then in a lambda expression

I have the code I show below, where I make a dictionary after grouping by some columns. My goal is to transfer the mean I've calculated in the groupby dataframe to an other dataframe. For that I've ...
Cristina Dominguez Fernandez's user avatar
0 votes
1 answer
146 views

How to convert a List<String> to Map<String, Long> using Lambda, where the key is the String and the value is a count of the number of vowels?

Given: List<String> myStrings = Arrays.asList("broom", "monsoon"); Return: Map<String, Long> stringToNumberOfVowels = Map.of("broom", 2, "monsoon", ...
Raoul Duke's user avatar
-2 votes
1 answer
37 views

error in dictionary , could not find why i cannot add c [closed]

from collections import defaultdict # Defining the dict and passing # lambda as default_factory argument d = defaultdict(lambda c: "Not Present") d["a"] = 1 d["b"] =...
LAKSHMAN GOPI's user avatar
0 votes
1 answer
75 views

defaultdict with a lambda that uses the key as a parameter [duplicate]

I was trying to create a defaultdict where the key was used as a parameter to create a classed object, but I get a TypeError when I try. I've put a minimum example below from collections import ...
Chris Rudd's user avatar
0 votes
1 answer
22 views

Get the key of the value satisfied the conditions in the dictionary

I have a dictionary as follows : k = {'e': 8, 'f': 2, 'g': 3} I want to give the condition: the value is smaller than the 5: (For example: value < 5) at the result: the key of the max value under ...
SH Chung's user avatar

15 30 50 per page
1
2 3 4 5
35