Convert dictionary key to object name in Python

I've got a dictionary whose keys are country names, and its values are an object of the class Country, which has several attributes (population, area, etc.). For example: {"Chile":Country(17000000,124234,...)} However, when I try to reach a countr...
more »

2017-10-04 23:10 (0) Answers

From dic pandas with nested dictionaries

I have a dictionary like that: {12: {'Soccer': {'value': 31, 'year': 2013}}, 23: {'Volley': {'value': 24, 'year': 2012},'Yoga': {'value': 3, 'year': 2014}}, 39: {'Baseball': {'value': 2, 'year': 2014},'basket': {'value': 4, 'year': 2012}}} and i ...
more »

2017-10-03 16:10 (2) Answers

swift generic dictionary function

I am trying to create a generic function for dictionary(of any data type). I get this error though when I call the function: error: cannot convert value of type '[Int : String]' to expected argument type '[_ : _]' wprintgeneric(inp: w) ...
more »

2017-09-29 10:09 (1) Answers

python - check if nan float in dictionary

import numpy as np import pandas as pd import tia.bbg.datamgr as dm mgr = dm.BbgDataManager() bb_yearb4 = "2016-12-30" bb_today = "2017-09-22" indices = [list of indices] sids_index = mgr[indices] df_idx = sids_index.get_historical('PX_LAST', bb_ye...
more »

2017-09-22 18:09 (1) Answers

Zip list with list of a list in Haskell

I want to zip [Int] with [[String]], so that I get [[(Int, String)]]. An example: [1,2,3] and [[a,b,c],[d,e,f]] becomes [[(1,a),(2,b),(3,c)],[(1,d),(2,e),(3,f)]] How could I do this? I have tried a few thing with map, but without success. ...
more »

2017-09-20 16:09 (1) Answers

Listing valid words from phone mapping

I recently came back from an interview and they asked basically: Given a list of valid words and a mapping of numbers to letters - something like 1 -> ABC, 2->DEF - how would I write a function that returns a list of strings that are valid. I struggl...
more »

2017-09-15 22:09 (1) Answers

Sort a dictionary of values with custom sequence

So basically I have a list of dictionaries with the following values : [ {'First Name ':'Stephen', 'Last Name':'Queen','Age':61,'Marks':89}, {'First Name ':'Stephen', 'Last Name':'Queen','Age':89,'Marks':68}, {'First Name ':'Angelica', 'Last Nam...
more »

2017-09-11 13:09 (1) Answers

c# Dictionary with class as Key

i am studying electronic engineering, and I am a beginner in c#. I Have measured data and would like to store it in a 2 demensional way. I thought i could make a dictionary like this: Dictionary<Key, string>dic = new Dictionary<Key, string&...
more »

2017-09-03 15:09 (1) Answers

Replace column values using a dictionary

I have this dataframe where gender is expected to be male or female. from io import StringIO import pandas as pd audit_trail = StringIO(''' course_id AcademicYear_to months TotalFee Gender 260 2017 24 100 male 260 2018 12 140 male 274 2016 36 300 m...
more »

2017-08-31 07:08 (2) Answers

Java 8 map filter and sort

I want to migrate this example to Java 8: Map<String, String> data = new HashMap<String, String>() {{ put("name", "Middle"); put("prefix", "Front"); put("postfix", "Back"); }}; String title = ""; if (data.containsKey...
more »

2017-08-30 04:08 (2) Answers

how to use nested dictionary in python?

I am trying to write some code with the Hunter.io API to automate some of my b2b email scraping. It's been a long time since I've written any code and I could use some input. I have a CSV file of Urls, and I want to call a function on each URL that o...
more »

2017-08-30 00:08 (1) Answers

macOS extend Force Touch look up popup

I just want to add some functionality to “look up pop-up” (the pop-up when you force click) (check this: support.apple.com/kb/PH25145?locale=en_US). I looked for Apple documents and googled but couldn’t come across anything. These were mainly ...
more »

2017-08-29 13:08 (0) Answers

Numba, Jitclass w/ nopython mode and dictionaries

trying to figure out how to skip a class method while using jitclass. Have a pretty big recursive model (pretty much, a massive for-loop), which - given path-dependent calculations, cannot be vectorized with straight Numpy. The class runs through a...
more »

2017-08-28 19:08 (1) Answers