key

How do I fix this to avoid this key error?

How do I fix this to avoid this key error? Question: def romanToInt(self, s): """ :type s: str :rtype: int """ roman_table = {"I" : 1, "V" : 5, "X" : 10, "L" : 50, "C" : 100, "D" : 500, "M" : 1000} num = 0 last = "I" for numeral in s[::-1]: if …

Total answers: 1

How to create a new list in Python based on two factors?

How to create a new list in Python based on two factors? Question: I have a list of list in Python like this: vehicle_list = [[‘car’, ‘123464’, ‘4322445’], [‘car’, ‘64346’, ‘643267’], [‘bicycle’, ‘1357’, ‘78543’], [‘bicycle’, ‘75325’, ‘75425’], [‘car’, ‘8652’, ‘652466’], [‘taxi’, ‘653367’, ‘63226’], [‘taxi’, ‘96544’, ‘22267’], [‘taxi’, ‘86542222’, ‘54433’], [‘motorcycle’, ‘675422’, ‘56312’], [‘motorcycle’, ‘53225’, ‘88885’], …

Total answers: 3

Bypass top level keys in python nested dictionary to extract low level keys

Bypass top level keys in python nested dictionary to extract low level keys Question: I have a complex nested dictionary. I want to extract all "symbol" keys. I have tried functions extracting all values, .get, converting to a list, tuples, and I know I could break it down piece by piece, but I would like …

Total answers: 2

Fastest way to extract the same key values in a list of dictionary in Python

Fastest way to extract the same key values in a list of dictionary in Python Question: I have a list of dictionary like this: [{‘open’: ‘38532.5’, ‘high’: ‘38578’, ‘low’: ‘38517’, ‘close’: ‘38578’}, {‘open’: ‘38578’, ‘high’: ‘38588.5’, ‘low’: ‘38501’, ‘close’: ‘38573.5’}, {‘open’: ‘38573.5’, ‘high’: ‘38574’, ‘low’: ‘38552.5’, ‘close’: ‘38553’}] What is the fastest way to extract …

Total answers: 2

trying to create script that scan for secrets in python code

trying to create script that scan for secrets in python code Question: As part of our CI/CD we want to add some check to run code on python files and check if there are some secrets in code (like API, passwords etc.). I saw only programs that do this, and I want to create a …

Total answers: 1

sort_values() with 'key' to sort a column of tuples in a dataframe

sort_values() with 'key' to sort a column of tuples in a dataframe Question: I have the following dataframe: df = pd.DataFrame({‘Params’: {0: (400, 30), 1: (2000, 10), 2: (1200, 10), 3: (2000, 30), 4: (1600, None)}, ‘mean_test_score’: {0: -0.6197478578718253, 1: -0.6164605619489576, 2: -0.6229674626212879, 3: -0.7963084775995496, 4: -0.7854265341671137}}) I wish to sort it according to the …

Total answers: 1

How to change the order of keys in a Python 3.5 dictionary, using another list as a reference for keys?

How to change the order of keys in a Python 3.5 dictionary, using another list as a reference for keys? Question: I’m trying to change the order of ‘keys’ in a dictionary, with no success. This is my initial dictionary: Not_Ordered={ ‘item’:’book’, ‘pages’:200, ‘weight’:1.0, ‘price’:25, ‘city’:’London’ } Is there a chance for me to change …

Total answers: 4

Entering text to span Selenium/Python

Entering text to span Selenium/Python Question: I try to enter text to span in place of “SAMPLE TEXT”. I’m using Selenium/Python but I can’t do it using send_keys method. Do you have any other ideas how can I do that? I attached screenshots with HTML and screenshot from app I tried to use that code, …

Total answers: 1