Skip to main content

All Questions

Tagged with
1 vote
1 answer
53 views

Netlogo: efficient iteration using 'foreach'

I want to calculate and store two certain quantities associated with turtles' properties, namely count how many turtles meet a condition and the sum of these turtles' specific attribute. That specific ...
G. Papad.'s user avatar
0 votes
0 answers
22 views

Is there a reason that Python allows indexing the class list itself? [duplicate]

I have come across a "feature" of Python that allows one to index the list class (and all classes that implement __getitem__() AFAIK). It took me a non-trivial amount of time to uncover that ...
Epanemu's user avatar
  • 118
-1 votes
2 answers
75 views

Going back to an earlier index in list iteration

I have this loop over a list: MyList = ["test", "test2", "test3", "test4", "test5", "test6", "test7"] for item in MyList: ...
EliaOndacs's user avatar
-2 votes
2 answers
107 views

Python: best way to iterate through lists and store which has max value for each index

In Python (3.8), I have 15 lists of the same length. Each list contains floats. Here for the example, I will pretend I have 3 lists of length 5 to demonstrate my problem: List1 = [29.561801, 29.564141,...
Tritize's user avatar
  • 39
0 votes
2 answers
56 views

Python - Iterating through nested dictionaries to populate a list based on values - Encounter 'str' object has no attribute 'items'

I'm creating a code that should allow a user to select multiple objects from a list. Each user has an allotted amount of space, and each object has a specified size. I'm trying to populate the list ...
Moonlyte Demon's user avatar
0 votes
1 answer
40 views

Tkinter: Listbox not populating from function call, populates from list

I have a function that creates a list, and another that's supposed to populate a tkinter listbox with the items from that list. When a radio button is clicked the contents of the listbox should update....
Sabresong's user avatar
0 votes
0 answers
20 views

In python, iteration over specific condition with dataframe row not working

Help me in correcting the logic to attain the expected output. import pandas as pd # Sample DataFrame data = { 'phase': ['aaa', 'bbb', 'ccc', 'ddd', 'eee'], 'phase_input': ['NULL', 'io.flow,...
user12345's user avatar
  • 509
0 votes
0 answers
22 views

How can I use a for loop to strip parens from list elements and print them one at a time? [duplicate]

I have a list from an n_choose_k operation. The list is composed of number combinations that are each surrounded by parentheses. import itertools number = 9 k = 3 n = range(1,number) combos = list(...
cat_herder's user avatar
-1 votes
2 answers
56 views

How to remove elements from list while iterating [duplicate]

hey I have a issue where i want to remove some elements from a list, the problem is it change the index and them don't know how to remove the index that actually need next so it remove "salt"...
Sheep's user avatar
  • 1
0 votes
1 answer
54 views

Iterate over a list to update PySpark df column

Need to add a new column to PySpark DF based on conditions by iterating over a list. new_line_id = array('a', 'b', 'c') Input DF (LineID is not the PK in this DF): Line ID M null T null null P ...
borderline_coder's user avatar
0 votes
1 answer
57 views

Read nested list with other attributes in Java streams

I have a list of object for example Person in turn have couple of lists with few generic attributes like below List<Address> address1 = List.of("1","2","5","6&...
rev gan's user avatar
  • 87
1 vote
1 answer
53 views

R code to iterate over lists, combining them into a data frame with grouping variables?

I am tasked with collecting table names, grouping variables, variable names, and variable values from a large number of complex XML Esri Workspace files. At the most basic level, I am having trouble ...
anagler's user avatar
  • 13
-1 votes
1 answer
52 views

How to iterate over a list of dictionaries in Python

Edit: Apologies - after reading the comments I realized this is a dictionary of dictionaries(?) The answer that solved this is to change it to ...price_list["market"].values() in the for ...
Kai's user avatar
  • 31
0 votes
2 answers
187 views

Function for converting columns of a data frame into key value pairs

I have a dataframe (these are just sample columns for reference, the actual number of columns is quite large) id A B C D 123 24 98 74 32 456 65 90 61 96 I would like to convert it into a data ...
Anusha Pal's user avatar
1 vote
1 answer
46 views

How can I put the elements in the list next to the print out of the dictionary values?

DESIRED OUTPUT: Proportion of 1- letter words: 4.76% (1231 words) Proportion of 2- letter words: 16.14% (4177 words) Proportion of 3- letter words: 20.33% (5261 words) Proportion of 4- letter words: ...
Jordan Faulkner's user avatar

15 30 50 per page
1
2 3 4 5
67