python – How do I split a list equally-sized chunks?

How do you split a list into evenly sized chunks? “Evenly sized chunks”, to me, implies that they are all the same length, or barring that option, at minimal variance in length. Eg 5 baskets for 21 items could have the following results: >>> import statistics >>> statistics.variance([5,5,5,5,1]) 3.2 >>> statistics.variance([5,4,4,4,4]) 0.19999999999999998 A practical reason … Read more

r – recursively split a dataframe with partykit::lmtree as a stump tree

I am trying to recursively split my data using a stump tree based on the lmtree function from the partykitlibrary. The idea is the following: [1] for each variable of interest run and lmtree with a depth of 2, store the regression model’s results and splitting rules. [2] for each subset of data created from … Read more

python – Split pdf from A4 into A6 quarters and don’t save empty quarters

Do not judge strictly, I’m a self-taught beginner))) Please help me figure out how to share I learned both with the help of PyPDF2 and with the help of PyMuPDF (fitz). But when splitting, it often happens that there is text in only one quarter, but it writes all 4 quarters to the new file, … Read more