Linked Questions

481 votes
17 answers
494k views

If I have a Python dictionary, how do I get the key to the entry which contains the minimum value? I was thinking about something to do with the min() function... Given the input: {320:1, 321:0, ...
163 votes
19 answers
181k views

I receive a dictionary as input, and would like to to return a dictionary whose keys will be the input's values and whose value will be the corresponding input keys. Values are unique. For example, ...
Roee Adler's user avatar
  • 34.1k
137 votes
10 answers
247k views

I want to use a WSDL SOAP based web service in Python. I have looked at the Dive Into Python code but the SOAPpy module does not work under Python 2.5. I have tried using suds which works partly, but ...
davidmytton's user avatar
  • 39.4k
24 votes
7 answers
13k views

Is there a way that I can define __init__ so keywords defined in **kwargs are assigned to the class? For example, if I were to initialize a ValidationRule class with ValidationRule(other='email'), ...
mpen's user avatar
  • 285k
5 votes
2 answers
6k views

I'm trying to port a custom class from Python 2 to Python 3. I can't find the right syntax to port the iterator for the class. Here is a MVCE of the real class and my attempts to solve this so far: ...
bkoodaa's user avatar
  • 5,453
4 votes
5 answers
10k views

I am trying to write a function which is equal to isnumber[column] function in excel dataset: feature1 feature2 feature3 123 1.07 1 231 2.08 3 122 ab 4 111 ...
Sai Sumanth's user avatar
4 votes
1 answer
2k views

I am trying to enumerate through a dictionary like this but it does not work. What's the simplest way to iterate through a dictionary in python while enumerating each entry? for i, k, v in enumerate(...
user2399453's user avatar
  • 3,172
0 votes
5 answers
164 views

I have something like this: class C: def get_data(): returns a list d = {several instances of C} Now, how do I iterate over all elements of all lists? I failed miserably: [e for e in [v.get_data()...
Michael's user avatar
  • 7,879
0 votes
1 answer
2k views

Recently I have been working on an object recognizer. Some of the code written below is copied. When I ran the code I got this weird error:AttributeError: 'numpy.ndarray' object has no attribute '...
user avatar
0 votes
3 answers
469 views

Given a large dataset of one million records, I am looking for ways to do a group by. I am new to python, but i know in SQL there's a groupby function and i am guessing it might be applicable. What ...
user2837332's user avatar
-1 votes
2 answers
178 views

I have two dictionaries: Let's say MaleDict = {'Jason':[(2014, 394),(2013, 350)...], 'Stephanie':[(2014, 3), (2013, 21),..]....} FemaleDict = {'Jason':[(2014, 56),(2013, 23)...], 'Stephanie':[(2014,...
Jason Halpman's user avatar
-7 votes
3 answers
77 views

Given a dictionary { 'a': [1, 2, 3], 'b': [4, 5, 6] } how do I get the output [ ['a', 1, 2, 3], ['b', 4, 5, 6] ]
Boris Lai's user avatar
-2 votes
1 answer
61 views

If I want to use translate on more than one unicode character like: 'banana'.translate({ord('ba'):u'cd'}) How can I do this? ord works on only one character. So what can make this happen? Note: The ...
CS13's user avatar
  • 1
-3 votes
2 answers
49 views

For example, I have this: alphabetValues = {"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7... Is it possible if instead of having: print(alphabetValues["c"]) To having something that would get "e" if I ...
hermitspike's user avatar