hashmap

Convert two dictionary to influx writing measurement fields in python

Convert two dictionary to influx writing measurement fields in python Question: I have a dictionary like {‘BTC’: {‘030323’: 562.7, ‘170323’: 9.900000000000002, ‘250223’: 64.60000000000004, ‘290923’: 17.6, ‘100323’: 53.90000000000002, ‘310323’: 27.4, ‘260223’: 15.499999999999996, ‘300623’: 33.7, ‘280423’: 30.0, ‘291223’: 28.6, ‘260523’: 1.0999999999999999}, ‘ETH’: {‘030323’: 562.7, ‘170323’: 9.900000000000002, ‘250223’: 64.60000000000004, ‘290923’: 17.6, ‘100323’: 53.90000000000002, ‘310323’: 27.4, ‘260223’: 15.499999999999996, ‘300623’: …

Total answers: 1

how to remove key value pair in dictionary based on condition python

how to remove key value pair in dictionary based on condition python Question: I have a dictionary like { ‘timestamp’: 1677231711722, ‘instrument_name’: ‘BTC-30JUN23-8000-P’, ‘index_price’: 23845.81, ‘direction’: ‘buy’, ‘amount’: 27.0}, { ‘timestamp’: 1677231711722, ‘instrument_name’: ‘BTC-30JUN23-8000-P’, ‘index_price’: 23845.81, ‘direction’: ‘buy’, ‘amount’: 2.4}, { ‘timestamp’: 1677231702010, ‘instrument_name’: ‘BTC-25FEB23-27000-C’, ‘index_price’: 23844.34, ‘direction’: ‘buy’, ‘amount’: 0.1} I have timestamp as …

Total answers: 1

create hashmap from dictionaries python

create hashmap from dictionaries python Question: I have dictionaries like { {‘instrument_name’: ‘BTC-24FEB23-24000-C’, ‘index_price’: 23822.86, ‘direction’: ‘sell’, ‘amount’: 0.5}, { ‘instrument_name’: ‘BTC-30JUN23-40000-C’, ‘index_price’: 23813.52, ‘direction’: ‘sell’, ‘amount’: 0.1}, { ‘instrument_name’: ‘BTC-24FEB23-24000-C’, ‘index_price’: 23812.99, ‘direction’: ‘sell’, ‘amount’: 6.0}, { ‘instrument_name’: ‘BTC-26MAY23-18000-P’, ‘index_price’: 23817.83, ‘direction’: ‘buy’, ‘amount’: 0.3} } I want output like , group by dates …

Total answers: 3

subract two nested dictionaries python

subract two nested dictionaries python Question: i have two nested dict {‘BTC’: {‘DAE’: -10526, ‘Vega’: 186, ‘Theta’: -34, ‘Gamma’: 149674}, ‘ETH’: {‘DAE’: -1123, ‘Vega’: 57, ‘Theta’: -5, ‘Gamma’: 2257}} and {‘BTC’: {‘DAE’: -105126, ‘Vega’: 1186, ‘Theta’: -314, ‘Gamma’: 1419674}, ‘ETH’: {‘DAE’: -11213, ‘Vega’: 157, ‘Theta’: -15, ‘Gamma’: 22157}} Want to get subracted dict values. Getting …

Total answers: 1

need to re-write my code in less than O(n2) complexity

need to re-write my code in less than O(n2) complexity Question: I have an algorithm written which gives result. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you …

Total answers: 2

Why does `slice` have to be unhashable?

Why does `slice` have to be unhashable? Question: Why doesn’t python make slice hashable? In my simple mind you can simply xor its start, stop, and step and you will have a good hash. It will be very useful when we want unordered sets of slices. Asked By: Daniel Chin || Source Answers: slice objects …

Total answers: 2

unordered_map<int, vector<float>> equivalent in Python

unordered_map<int, vector<float>> equivalent in Python Question: I need a structure in Python which maps an integer index to a vector of floating point numbers. My data is like: [0] = {1.0, 1.0, 1.0, 1.0} [1] = {0.5, 1.0} If I were to write this in C++ I would use the following code for define / …

Total answers: 4

Python equivalent for HashMap

Python equivalent for HashMap Question: I’m new to python. I have a directory which has many subfolders and files. So in these files I have to replace some specified set of strings to new strings. In java I have done this using HashMap. I have stored the old strings as keys and new strings as …

Total answers: 1

Python dictionary keys. "In" complexity

Python dictionary keys. "In" complexity Question: Quick question to mainly satisfy my curiosity on the topic. I am writing some large python programs with an SQlite database backend and will be dealing with a large number of records in the future, so I need to optimize as much as I can. For a few functions, …

Total answers: 6