Skip to content Skip to sidebar Skip to footer
Showing posts with the label Set

Hashable Data Structure With No Order And Allowed Duplicates

I have list of tuples/lists (-1, 0, 1) (-1, 1, 0) (-1, 2, -1) (-1, -1, 2) (0, 1, -1) I need them to… Read more Hashable Data Structure With No Order And Allowed Duplicates

Set Object Is Not Json Serializable

When I try to run the following code: import json d = {'testing': {1, 2, 3}} json_string =… Read more Set Object Is Not Json Serializable

Separating Nltk.freqdist Words Into Two Lists?

I have a series of texts that are instances of a custom WebText class. Each text is an object that … Read more Separating Nltk.freqdist Words Into Two Lists?

Disjoint-set Forests In Python Alternate Implementation

I'm implementing a disjoint set system in Python, but I've hit a wall. I'm using a tree… Read more Disjoint-set Forests In Python Alternate Implementation

Check If String Begins With One Of Several Substrings In Python

I couldn't figure out how to perform line.startswith('substring') for a set of substrin… Read more Check If String Begins With One Of Several Substrings In Python

Python Union Of Sets Raises Typeerror

Consider a sequence of sets: >>> [{n, 2*n} for n in range(5)] [{0}, {1, 2}, {2, 4}, {3, 6}… Read more Python Union Of Sets Raises Typeerror

Find A Second Largest Number In A Python List

I was trying to find the second largest number in a list and thought of converting list into set, a… Read more Find A Second Largest Number In A Python List

Lambda Versus List Comprehension Performance

I recently posted a question using a lambda function and in a reply someone had mentioned lambda is… Read more Lambda Versus List Comprehension Performance

Python Orderedset With .index() Method

Does anyone know about a fast OrderedSet implementation for python that: remembers insertion order… Read more Python Orderedset With .index() Method

What Is Pythononic Way Of Slicing A Set?

I have some list of data, for example some_data = [1, 2, 4, 1, 6, 23, 3, 56, 6, 2, 3, 5, 6, 32, 2, … Read more What Is Pythononic Way Of Slicing A Set?

Keep All Elements In One List From Another

I have two large lists train and keep, with the latter containing unique elements, for e.g. train =… Read more Keep All Elements In One List From Another

Attributeerror: 'nonetype' Object Has No Attribute 'add'

I got the following error AttributeError: 'NoneType' object has no attribute 'add'… Read more Attributeerror: 'nonetype' Object Has No Attribute 'add'

Rearranging A Dictionary Based On A Function-condition Over Its Items

(In relation to this question I posed a few days ago) I have a dictionary whose keys are strings, a… Read more Rearranging A Dictionary Based On A Function-condition Over Its Items

Adding The Number 1 To A Set Has No Effect

I cannot add the integer number 1 to an existing set. In an interactive shell, this is what I am do… Read more Adding The Number 1 To A Set Has No Effect

Get Common Values Out Of A List In Python

I have below list: a=[{'list1': ['35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52… Read more Get Common Values Out Of A List In Python

Intersection Of Tuples In A List - Python

I have a list of tuples like this : all_tuples=[(92, 242),(355, 403),(355, 436),(355, 489),(403, 4… Read more Intersection Of Tuples In A List - Python

Generating A Set From Given Sets Such It's Intersection With All The Sets Is Different From {}

i have been trying to figure out an effective algorithm that returns a set such as it's interse… Read more Generating A Set From Given Sets Such It's Intersection With All The Sets Is Different From {}

Find Sets That Contain At Least One Element From Other Sets

Suppose we are given n sets and want to construct all minimal sets that have at least one element i… Read more Find Sets That Contain At Least One Element From Other Sets

Constructing A Python Set From A Numpy Matrix

I'm trying to execute the following >> from numpy import * >> x = array([[3,2,3],[4… Read more Constructing A Python Set From A Numpy Matrix

Why Doesn't Python's Filter(predicate, Set) Return A Set?

Why was Python's filter designed such that if you run filter(my_predicate, some_set), I get bac… Read more Why Doesn't Python's Filter(predicate, Set) Return A Set?