About 444,000 results
Open links in new tab
  1. How can I filter items from a list in Python? - Stack Overflow

    Aug 22, 2009 · 4 What about using filter function In this example we are trying to only keep the even numbers in list_1.

  2. python - List comprehension vs. lambda + filter - Stack Overflow

    The first is the function call overhead: as soon as you use a Python function (whether created by def or lambda) it is likely that filter will be slower than the list comprehension.

  3. Filtering a list of strings based on contents - Stack Overflow

    Jan 28, 2010 · This simple filtering can be achieved in many ways with Python. The best approach is to use "list comprehensions" as follows:

  4. python - How to return a subset of a list that matches a condition ...

    How to return a subset of a list that matches a condition [duplicate] Asked 9 years, 10 months ago Modified 2 years, 6 months ago Viewed 101k times

  5. filtering elements from list of lists in Python? - Stack Overflow

    Apr 16, 2010 · I want to filter elements from a list of lists, and iterate over the elements of each element using a lambda. For example, given the list: a = [[1,2,3],[4,5,6]] suppose that I want to …

  6. Get unique values from a list in python - Stack Overflow

    Oct 15, 2012 · 1538 First declare your list properly, separated by commas. You can get the unique values by converting the list to a set.

  7. Filter list of object with condition in Python - Stack Overflow

    Aug 5, 2021 · Filter list of object with condition in Python Asked 4 years, 3 months ago Modified 3 years, 2 months ago Viewed 24k times

  8. python - remove None value from a list without removing the 0 …

    Apr 19, 2013 · [0, 23, 234, 89, 0, 35, 9] Because I'm calculating percentile of the data and the 0 make a lot of difference. How to remove the None value from a list without removing 0 value?

  9. python - Filtering a list based on a list of booleans - Stack Overflow

    I have a list of values which I need to filter given the values in a list of booleans: list_a = [1, 2, 4, 6] filter = [True, False, True, False] I generate a new filtered list with the following l...

  10. Python: filtering lists by indices - Stack Overflow

    Jan 20, 2016 · In Python I have a list of elements aList and a list of indices myIndices. Is there any way I can retrieve all at once those items in aList having as indices the values in myIndices? …