About 154,000 results
Open links in new tab
  1. python - How to split elements of a list? - Stack Overflow

    So i.split('\t', 1) calls the split() method of strings. Per the documentation, the first parameter of this method is the string to split by and the second is the maximum number of splits to perform. …

  2. python - Split list into smaller lists (split in half) - Stack Overflow

    Apr 15, 2009 · While the answers above are more or less correct, you may run into trouble if the size of your array isn't divisible by 2, as the result of a / 2, a being odd, is a float in python 3.0, …

  3. python - How do I split a list into equally-sized chunks ... - Stack ...

    Sep 29, 2016 · Python split list into n chunks. 8. Split list into separate but overlapping chunks. 1. How to Split or ...

  4. python - How can I partition (split up, divide) a list based on a ...

    I landed here looking for a list equivalent of str.split(), to split the list into an ordered collection of consecutive sub-lists. E.g. split([1,2,3,4,5,3,6], 3) -> ([1,2],[4,5],[6]), as opposed to dividing a …

  5. python - How do I split a string into a list of characters? - Stack ...

    The big plus is that it works the same in both Python 2 and Python 3. Also, starting from Python 3.5 (thanks to the awesome PEP 448 ) it's now possible to build a list from any iterable by …

  6. python - How to to split a list at a certain value - Stack Overflow

    May 29, 2015 · Here is a function that will split a list into an arbitrary number of sub-lists and return a list of them, much like a string split. def split_list(input_list,seperator): outer = [] inner = …

  7. python - Slicing a list into a list of sub-lists - Stack Overflow

    You could use numpy's array_split function e.g., np.array_split(np.array(data), 20) to split into 20 nearly equal size chunks. To make sure chunks are exactly equal in size use np.split . – Alex

  8. Split a list into parts based on a set of indexes in Python

    Aug 3, 2009 · What is the best way to split a list into parts based on an arbitrary number of indexes? E.g. given the code below indexes = [5, 12, 17] list = range(20) return something like …

  9. python - How do I split a string into a list of words ... - Stack …

    If you want to split a string into a list of words and if the string has punctuations, it's probably advisable to remove them. For example, str.split() the following string as s = "Hi, these are …

  10. python - How to split a list on an element delimiter - Stack Overflow

    I am primarily interested in readability for beginners (e.g. teaching), canonical / 'Pythonic' approaches, and secondarily in the most efficient approaches (e.g. timeit speed). Ideally …

Refresh