How to get SubMap from HTreeMap in MapDb - mapdb

How to get SubMap from HTreeMap in MapDb ? We have SubMap function in BTreeMap.
I need to remove different duplicates 10 key data.
key5, value 5 and so on.

HTreeMap is not sorted, so there is no option to get submap.

Related

Matching Pairs Problem in excel using basic functions

May I know how to check whether the Current Pairs match with the Ideal Pairs by using excel functions?
For example: The Current Pair of 1&8 does not match with the Ideal Pair of 1&14 and 1&29
I would also like to count the total number of matching pairs at the end. I have tried out different methods by using countifs() or match(), but in vain.
Appreciate your answer!
You can try below formula to count all matching pairs.
=SUM(--(IFERROR(XMATCH(B2:B7&C2:C7,F2:F7&G2:G7,0),0)>0))

When I combine two pandas columns with zip into a dict it reduces my samples

I have two colums in pandas: df.lat and df.lon.
Both have a length of 3897 and 556 NaN values.
My goal is to combine both columns and make a dict out of them.
I use the code:
dict(zip(df.lat,df.lon))
This creates a dict, but with one element less than my original columns.
I used len()to confirm this. I can not figure out why the dict has one element
less than my columns, when both columns have the same length.
Another problem is that the dict has only raw values, but not the keys "lat" respectively "lon".
Maybe someone here has an idea?
You may have a different length if there are repeated values in df.lat as you can't have duplicate keys in the dictionary and so these values would be dropped.
A more flexible approach may be to use the df.to_dict() native method in pandas. In this example the orientation you want is probably 'records'. Full code:
df[['lat', 'lon']].to_dict('records')

Get split value from two zip list

i have this two lists and i need to zip them and then i need to get one of the values
for x in heapq.nlargest(5, zip(list1,list2)):
print("->: ",x)
This prints ->: (9.99, 'SFO-RE.0025')
I need to get the 9.99 in order to run it thru another function evval('9.99')
I was hopping that someone could help me get this value
heapq.nlargest returns a list, so use x[0] to get the first item in x.
https://docs.python.org/3/library/heapq.html
https://realpython.com/lessons/indexing-and-slicing/

Find Max of Each Value in table

I have a table of ID values with multiple entries for different dates, How would i go about finding the max date for each ID? Preferably having the answer in a dynamic array as my table of values changes depending on which data the using is parsing
cheers
You mentioned you wanted it in a dynamic array, so I suggest using UNIQUE and MAXIFS inside a LET and combining the results with the use of SEQUENCE.
Something like:
=LET(x, UNIQUE(A:A),
mycols, SEQUENCE(1,2),
IF(mycols=1, x,
MAXIFS(B:B, A:A, x)))
For example:
EDIT (a much nicer solution provided by #JvdV): =CHOOSE({1,2},UNIQUE(A:A),MAXIFS(B:B,A:A,UNIQUE(A:A)))

Sort a dictionary according to the lists size and then alphabetically by their key in Python?

So I have a tiny problem. I got help here a while ago about sorting a dictionary with keys that have a list to each key according to the value of things in the list. The keys with lists with the least amount of values on the left and to the right the keys with lists with the most amount of values. That worked great. Now I know how to sort dictionary keys alphabetically but I cant get it to work combined with the above..
I'm trying to sort the dictionary below according to first how many values the key list contains... and then alphabetically if the key list contains the same amount of values as a previous key list.
so before I would have this:
Dict = {"anna":[1,2,3],"billy":[1,2],"cilla":[1,2,3,4],"cecillia":[1,2,3,4],"dan":[1]}
And after if everything goes well I would like to have...
Dict = {"dan":[1],"billy":[1,2],"anna":[1,2,3],"cecillia":[1,2,3,4],"cilla":[1,2,3,4]}
As you see in the above, cecillia comes before cilla since they both have 4 values in their lists... and dan comes in first since he has the least amount of values in his list. I hope this makes sense. What I have right now to get the below result is:
ascending = sorted(Dict, key =lambda x: len(Dict[x]))
this gives me for example:
{"dan":[1],"billy":[1,2],"anna":[1,2,3],"cilla":[1,2,3,4],"cecillia":[1,2,3,4]}
So it works but only for the values in the list.. now when I go
ascending.sort()
it sorts the dictionary alphabetically but then the order of values from least to greatest is gone. Anyone know how to to combine the two things? I would greatly appreciate it.
You cannot keep dictionaries sorted so you must convert it to a list of tuples:
D = [ (x, Dict[x]) for x in Dict]
ascending = sorted(D, key = lambda x: x[1])
ascending.sort()
See http://wiki.python.org/moin/HowTo/Sorting . BTW the feature you are relying on is in fact because the sorting algorithm is stable (which apparently was not the case when I was programming in Python).

Resources