All Questions
72 questions
0
votes
2
answers
124
views
For a custom Mapping class that returns self as iterator, list() returns empty. How do I fix it?
The following is a simplified version of what I am trying to do (the actual implementation has a number of nuances):
from __future__ import annotations
from collections.abc import MutableMapping
...
1
vote
1
answer
65
views
creating a function looping through multiple subsets and then grouping and summing those combinations of subsets
I am attempting to build a function that processes data and subsets across two combinations of dimensions, grouping on a status label and sums on price creating a single row dataframe with the ...
0
votes
1
answer
58
views
Looping through combinations of subsets of data for processing
I am processing sales data, sub-setting across a combination of two distinct dimensions.
The first is a category as indicated by each of these three indicators ['RA','DS','TP']. There are more ...
0
votes
2
answers
170
views
Iterate over multiple elements at once Python [duplicate]
If I have a list like l=[1,2,3,4,5,6]. If I do something like:
for i in l:
print(i)
It will print all element separately.
1
2
3
4
.
.
.
Is there a way to iterate simultaneously over multiple ...
2
votes
3
answers
77
views
If True: turn following values to True in list of booleans until nth position after True is reached
I have a list of booleans
l = [False, False, False, True, False, False, False]
that I want to turn into
l_new = [False, False, False, True, True, True, False]
That means, whenever there is a True in ...
0
votes
0
answers
31
views
How to iterate over a dataframe that's processed in another function? [duplicate]
I want to use the reactome2py package to analyse pathways by adapting the Reference code.
I want to iterate over the dataframe (e.g., df for data_linear_cna.txt).
Reference code:
https://colab....
0
votes
1
answer
212
views
Python is not running my codes in else statement
I am doing the first Hog project for CS61A, a UC Berkeley Intro CS course that publishes all its materials online, to self-study CS(Link:https://inst.eecs.berkeley.edu/\~cs61a/sp20/) For its first ...
3
votes
1
answer
167
views
Why is islice(permutations) 100 times faster if I keep a reference to the underlying iterator?
Iterating through islice(permutations(a), n) is somehow 100 times faster if I just keep an extra reference to the permutations iterator. Alternating between with and without the extra reference:
2.1 ...
-1
votes
2
answers
199
views
Iterate through the same list starting from different points in Python
I want to iterate through the same list from two different starting points.
I can do this way:
for LayerIndex in range(len( layers ) - 1):
thisLayer = layers[LayerIndex ]
nextLayer = ...
0
votes
0
answers
212
views
python: iteration continues until next comparison meets a condition
I have a project like the following:
my_project:
|__my_new_data
| |__new_data.csv
|
|__my_original_data
| |__original_data.csv
|__process.py
|
|__read.py
I have a function ...
1
vote
3
answers
52
views
Iteration Functionality
Below is the simple programme which I wrote in Python
Animal = ['tiger','lion','dog','cat']
xyz = iter(Animal)
print(next(xyz))
The output was
tiger
Now I read that iter() method points towards the ...
0
votes
2
answers
451
views
Simple for loop to guess variable name in python
I am new to python (coming from R) and trying to practice for loops, so I made up this challenge to have the computer guess the name string. Unfortunately I have stumped myself. Can anyone offer ...
1
vote
1
answer
59
views
For loop creates only one array instead of multiple
I have binary images containing different numbers of objects and I have to count the number of spots (the coordinates of these spots come from csv files) inside each object.
The code I have works when ...
0
votes
2
answers
558
views
How does iter() convert the list into the iterator object?
I know that an iter() function converts the list (or another collection) to iterator object. But I can't exactly understand what an iterator object is.
I read that it's unordered data, every element ...
0
votes
1
answer
935
views
Numpy iteration over all dimensions but the last one with unknown number of dimensions
Physical Background
I'm working on a function that calculates some metrics for each vertical profile in an up to four dimensional temperature field (time, longitude, latitude, pressure as height ...