Questions tagged [frozenset]
66 questions
2
votes
1 answer
Should instances of a frozenset subclass be hashable in Python 3?
According to https://docs.python.org/2/library/stdtypes.html#frozenset, in Python 2:
The frozenset type is immutable and hashable -- its contents cannot be altered after is created; however, it can be used as a dictionary key or as an element of…
pzrq
- 1,167
- 1
- 14
- 16
2
votes
1 answer
python TypeError: frozenset expected at most 1 arguments, got 4
I'm getting this error when trying to make a frozen set:
class Transcriber:
DNA_BASES = frozenset('A','T','G','C')
...
And this is the Traceback:
~/python/project5$ python wp_proj5.py
Traceback (most recent call last):
File "wp_proj5.py",…
Tom
- 8,259
- 23
- 78
- 141
1
vote
1 answer
Extending FrozenSet from typing
I'm probably doing something dumb here. For those of you who want to copy and paste, make sure that you:
from typing import *
I'm using Python 3.7.4.
This:
class S(FrozenSet[str]):
def __init__(self, strs: Iterable[str], name: str):
…
Hrvoje Jurić
- 85
- 4
1
vote
1 answer
In python, frozenset's subclass's __init__ method throw TypeError of arguments number
The class's __init__ method has 3 arguments, but when I instantiate it with 3 arguments, it throw an error that it expected 1 arguments. I cannot undrestand.
class ArrObj(frozenset):
def __init__(self, elem_list, elem_count, self_count):
…
xupeng
- 57
- 4
1
vote
1 answer
Extract Frozenset items from Pandas Dataframe
I have the following dataframe:
And I would like to convert the columns "antecedents" and "consequents" to string, removing the "frozenset({ ... })" format and thus have, for all the rows:
"VENTOLIN S.INAL200D 100MCG", instead of frozenset({…
Alessandro Ceccarelli
- 1,153
- 1
- 12
- 25
1
vote
0 answers
How is equality determined for Python frozenset instances?
How is the code below possible?
>>> frozenset(('a_')) == frozenset(['a_'])
False
>>> frozenset(('a')) == frozenset(['a'])
True
My understanding is that so long as each each element of the iterable is hashable, a frozen set will be instantiated with…
Greg
- 133
- 1
- 8
1
vote
2 answers
Frozenset union of two columns
I have a dataset containing two columns with frozensets. Now I would like to merge/take the union of these frozensets. I can do this with a for loop, however my dataset contains > 27 million rows, so I am looking for a way to avoid the for loop.…
Tox
- 705
- 1
- 8
- 31
1
vote
1 answer
Using Python, what is the fastest way to compare two large dictionaries while returning keys (as frozensets) that match past a certain threshold?
Assume I have two very large dictionaries: bigDictA and bigDictB, so something like below.
bigDictA = {frozenset("a1","b2","c3"): [some floats in a list], ...}
bigDictB = {frozenset("a1","b2"): [some floats in a list], ...}
Now, the algorithm I…
D00dood
- 183
- 8
1
vote
2 answers
Sorting a list of python sets by value
The frozenset docs says:
The frozenset type is immutable and hashable — its contents cannot be altered after it is created; it can therefore be used as a dictionary key or as an element of another set.
However, the docs for for python sets…
Travis Black
- 655
- 4
- 14
1
vote
1 answer
Retrieving elements from Frozenset/Alternatives to Frozenset
I have frozenset output that looks like this:
The data below is just an example. Overall I want the data to be in this format:
For doubles:
Item Item Confidence
For Triples:
Item Item Item Confidence
Doubles:
[(frozenset({'GRO73461'}),…
Srikar Murali
- 115
- 2
- 13
1
vote
0 answers
Extracting elements from frozenset
I've been trying to develop an apriori algorithm using this data. I was able to get the associations and the confidence for both the pairs and the triples but am having trouble formatting the output and extracting the correct elements.
I ran the…
Srikar Murali
- 115
- 2
- 13
1
vote
1 answer
Python: frozensets comparison
consider the following script:
# multipleSmallFrozensets is a list of 7 frozensets of differenet number of string objects
multipleSmallFrozensets = [
frozenset({'YHR007C', 'YHR042W'}),
frozenset({'YPL274W'}),
frozenset({'YCL064C'}),
…
7kemZmani
- 618
- 1
- 8
- 19
1
vote
3 answers
Retrieving values if keys of the dictionary are in frozensets
I'm using frozensets to keep the keys of my dictionary to take an advantage of union, difference and intersection operations. But when I'm trying to retrieve values by keys from the dictionary through dict.get() it yields a None value.
newDict =…
Michael
- 137
- 9
0
votes
0 answers
TypeError: unhashable type: 'set' in dropdown plotly python
The following code works by itself but I have a "TypeError: unhashable type: 'set'" when it's in my plotly graph. Can you help me out with this ? I never worked with set or frozenset.
Thanks a lot !
code that works be itself :
updatemenus = []
for…
mfou
- 1
- 1
0
votes
1 answer
Fast API, accept an array in post request
I'm trying to learn how to use the Fast API library.
I'm trying to accept an array in the post using frozenset as the docs states, but it doesn't seem to work.
import logging
from fastapi import FastAPI, BackgroundTasks
from worker.celery_app…
user12177026