About 26,100 results
Open links in new tab
  1. Pythonic split list into n random chunks of roughly equal size

    As part of my implementation of cross-validation, I find myself needing to split a list into chunks of roughly equal size. import random def chunk(xs, n): ys = list(xs) random.shuffle(ys)...

  2. python - Splitting a list by indexes - Code Review Stack Exchange

    I am trying to build an efficient function for splitting a list of any size by any given number of indices. This method works and it took me a few hours to get it right (I hate how easy it is to get

  3. python - split list elements into multiple categories - Code Review ...

    Jan 17, 2025 · I have a list of groups, which I would like to categorize based on a few criteria, and the elements can satisfy multiple criteria, and thus end up in multiple groups. I created this …

  4. python - Split a list into a dictionary - Code Review Stack Exchange

    Feb 19, 2015 · I am trying to split my list into a dictionary and I wrote a function for it. It takes in a list and gets the list length. If the length of the list is 253 , it creates a dictionary with 26 keys - …

  5. python - Split dictionary of lists into two dicts based on binary ...

    Apr 20, 2018 · I have a very large dictionary that contains key-value pairs where the key is a string and the value a list. All lists have the same lengths. I want to split up the dataset …

  6. python - Split list of integers at certain value efficiently - Code ...

    Nov 3, 2017 · import itertools def largest_rect(a): maxRect = 0 # This will store the result if len(a) == 0: return 0 mina = min(a) # The area of a rectangle extending # all the way across the the …

  7. python - Split netmask or ip address - Code Review Stack Exchange

    Nov 17, 2023 · I've written a python function to split a netmask or an ip address. The code is about to become part of a custom router api. def split_ip_or_netmask(ip_address: str) -> list: …

  8. python - Split a number into equal parts given the number of …

    Mar 6, 2019 · In Python, there is a cultural difference in how tuple and list are used. In our case, we know that each piece will contain 2 pieces of information: the begining and the end. It …

  9. python - Split a list using another list whose items are the split ...

    Stack Exchange Network. Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their …

  10. python - Lazy split and semi-lazy split - Code Review Stack Exchange

    Feb 22, 2018 · Sometimes I need to be able to split data into chunks, and so something like str.split would be helpful. This comes with two downsides: Input has to be strings You …

Refresh