Data dodania Pytanie
2017-04-20 10:04 C# - Adding objects that implement interfaces to a dictionary »
I have a dictionary: private Dictionary<Type, IExample> examples; I have two classes that implement the interface: public class Example1 : I...
(5) odpowiedzi
2017-04-16 01:04 if/else statements vs dictionary »
If I were to write a statement using dictionary instead of an else statement, how would that be? For example, say I have def determineRank(years): ...
(3) odpowiedzi
2017-04-15 02:04 Scala immutable Map vs List of tuples »
What's the difference between an immutable Map and a List of tuples in Scala? When should I use each of them? Which one is preferable if both are poss...
(2) odpowiedzi
2017-04-14 14:04 Given a text count occurrences of all two consecutive words »
Input: Once upon a time a time this upon a Output: dictionary { 'Once upon': 1, 'upon a': 2, 'a time': 2, 'time a': 1, ...
(3) odpowiedzi
2017-04-10 00:04 Performance is slow when replacing a string in a pandas dataframe using a dict »
The following code works but needs to run faster. The dict has ~25K keys and the dataframe is ~3M rows. Is there a way to produce the same results but...
(3) odpowiedzi
2017-04-09 12:04 How to convert nested dictionary to dataframe? »
I've got a nested dictionary. It's some Nasdaq kind of data. Like this: {'CLSN': Date Open High Low Close Volume Adj Close ...
(2) odpowiedzi
2017-04-09 02:04 Comparing values of two dicts in Python »
I have 2 dictionaries: budgets = {'Engineering': 4500.0, 'Marketing': 5000.0, 'Operations': 3000.0, 'Sales': 2000.0} spending = {'Engineering': ...
(4) odpowiedzi
2017-04-08 00:04 Python: Dictionaries and how they are stored and accessed with iteritems() »
I wanted to clarify some points about dictionaries in Python, which may help some other Python enthusiasts in the future. Let's start with a simple d...
(2) odpowiedzi
2017-04-05 11:04 Nested list to dict »
I try create dict by nested list: groups = [['Group1', 'A', 'B'], ['Group2', 'C', 'D']] L = [{y:x[0] for y in x if y != x[0]} for x in groups] d = {...
(4) odpowiedzi
2017-04-02 10:04 print python dictionary in ruby hash format »
I have a simple python dict and it prints in below format, {'stats1': {'var': {'avail': 'yes'}, 'target': {'avail': 'no'}}} But am looking way to p...
(2) odpowiedzi
2017-03-29 17:03 Python - How to efficiently iterate through the subsets of a dictionary? »
I have a dictionary with 500 DateFrames in it. Each data frame has columns 'date' , 'num_patients'. I apply the model to all the data frames in the di...
(1) odpowiedzi
2017-03-28 15:03 Facing error as invalid literal for int () with base 10: in swift 2 »
As per screenshot while am submitting the feedback facing this issue. Any help is appreciated. I have to enter comments like smile or sad after tha...
(1) odpowiedzi
2017-03-28 08:03 How to create an Array or Dictionary whose values can only be String, Int and Boolean? »
I have a requirement where I need to create an array whose values can only be either String, Int or boolean. Swift compiler should complain if I tried...
(2) odpowiedzi
2017-03-26 21:03 Understand Function capturing through map and reduce »
I 'am beginner in Elixir language , so In the blow example iex> Enum.reduce([1, 2, 3], 0, &+/2) 6 iex> Enum.map([1, 2, 3], &(&a...
(3) odpowiedzi
2017-03-23 22:03 Dictionary w nested dicts to list in specified order »
Sorry for the post if it seems redundant. I've looked through a bunch of other posts and I can't seem to find what i'm looking for - perhaps bc I'm a ...
(1) odpowiedzi
2017-03-22 03:03 python dictionary iteritems() and keys() synchronized behavior »
Does iteritems() and keys() always return the keys (and values in the case of iteritems) of the python dictionary in the same order? ...
(1) odpowiedzi
2017-03-09 11:03 Sum values of similar keys inside two nested dictionary in python »
I have nested dictionary like this: data = { "2010":{ 'A':2, 'B':3, 'C':5, 'D':-18, }, ...
(4) odpowiedzi
2017-03-04 07:03 Data structure: Top K ordered dictionary keys by value »
I have a very large dictionary with entries of the form {(Tuple) : [int, int]}. For example, dict = {(1.0, 2.1):[2,3], (2.0, 3.1):[1,4],...} that cann...
(3) odpowiedzi
2017-03-03 18:03 Should I use a C# Dictionary if I only need fast lookup of keys, and values are irrelevant? »
I am in need of a data type that is able to insert entries and then be able to quickly determine if an entry has already been inserted. A Dictionary s...
(1) odpowiedzi
2017-03-02 15:03 Converting list to dict python »
Given a list: source = [{'A':123},{'B':234},{'C':345}] I need a dict from this list in the format: newDict = {'A':123,'B':234,'C':345} What is ...
(3) odpowiedzi
2017-03-02 11:03 Convert List of Object to Map with duplicate key »
I have a class that looks like this: case class Person(id : String, name : String, refId : String) {} And I have a list of Person. I want to have ...
(1) odpowiedzi
2017-03-01 21:03 Find unique (key: value) pair given N dictionnaries in python »
I would like to find an easy and/or fast way to find all common couple (pair: value) given N dictionnaries in python. (3.X would be best) PROBLEM Gi...
(3) odpowiedzi
2017-02-23 15:02 Why is the __dict__ of instances so small in Python 3? »
In Python, dictionaries created for the instances of a class are tiny compared to the dictionaries created containing the same attributes of that clas...
(1) odpowiedzi
2017-02-23 13:02 Haskell, print modified list values with map »
I have written the following code, which should take a list of values and print only the values > average, modifying them as val - avg. For example...
(1) odpowiedzi
2017-02-21 14:02 C# can't bind my model to razor TextBoxFor »
In my .cshtml file I have the following @model MyProject.MyViewModel.Range @for (int i = 0; i < Model.Range.Count; i++) { &l...
(2) odpowiedzi
2017-02-20 21:02 How to use map to lowercase strings in a dictionary? »
I'm experimenting around with the use of map, filter, and reduce in Python 3.6 at the moment. What I'm trying to do is, given a list of dictionaries, ...
(4) odpowiedzi
2017-02-16 21:02 Python - something faster than 2 nested for loops »
def fancymatching(fname1, fname2): #This function will do much smarter and fancy kinds of compares if (fname1 == fname2): return 1 els...
(2) odpowiedzi
2017-02-14 23:02 How to convert this text file into a dictionary? »
I have a file f that looks something like: #labelA there is something here #label_Bbb here aswell ... It can have a number of labels and any number...
(7) odpowiedzi
2017-02-14 09:02 What's the correct way to create a dictionary typealias? »
If I want to define a typealias for a Dictionary, which accept String as the key, and String for the value, but I also want it to can accept nil, whic...
(2) odpowiedzi
2017-02-13 11:02 Order of operations in a dictionary comprehension »
I came across the following interesting construct: assuming you have a list of lists as follows: my_list = [['captain1', 'foo1', 'bar1', 'foobar1'],...
(4) odpowiedzi
2017-02-07 17:02 Python: Map a function over recursive iterables »
I have an arbitrarily nested iterable like so: numbers = (1, 2, (3, (4, 5)), 7) and I'd like to map a function over it without changing the structu...
(2) odpowiedzi
2017-02-07 12:02 Order a dictionary based on specific values »
Before writing a function, I would like to be sure there is no pre-built (optimized) solution (like sorted()) that can: From a dictionary like this o...
(2) odpowiedzi
2017-02-01 19:02 Processing dictionary keys in arbitrary order »
I want to transform dictionary into a string. What would be beginner-level question is complicated by few rules that I have to adhere to: There is a...
(4) odpowiedzi
2017-02-01 15:02 Create array with key from dict with sorted by dict values »
I have an dictionary that I want to iterate trough in a tableview. One way of doing this is to create an array with all the keys and just fetch the ke...
(4) odpowiedzi
2017-01-27 11:01 Corresponding Dictionary Keys and Values Outputs »
As a dictionary is not ordered the output is also not ordered: >>> d = dict(b = 1, a = 2, z = 3) >>> d.keys() ['a', 'z', 'b'] >&...
(1) odpowiedzi