Skip to main content
-2 votes
1 answer
58 views

How to get sum of tuples using built-in function? [closed]

In Python 3 built-in function sum(iterable, /, start=0) allows to get the total from iterable. start value is not allowed to be a string. Ok, so we can call sum for lists (concatenation) sum([[1,2,3],[...
leofun01's user avatar
  • 337
0 votes
1 answer
101 views

mutating a column with `str_locate` only works correctly in a one-row data frame

I'm facing the following problem: I want to calculate the start positions of certain characters in a string and store them as additional columns in a data frame. However, this only works if I have a ...
deschen's user avatar
  • 11.6k
0 votes
1 answer
117 views

Trouble cycling through values in a for loop and filling a list in R

I'm trying to estimate the population growth of a population with different growths rates, shown below r <-c(0.5, 1.0, 1.5, 2, 2.5, 2.6, 2.7, 2.8, 2.9) I'm trying to fill N_List with the ...
Jordan S Davis's user avatar
-6 votes
2 answers
98 views

Why does list iterator skip elements after in-place modification using slice assignment

I know that modifying a list while iterating over it is dangerous. For example, using my_list.remove() is a famous problem because it causes the iterator to skip the next element. However, I found a ...
Time Mahattano's user avatar
2 votes
2 answers
109 views

How to sort 1 list over 2 frames

Is it possible to sort 0:5 to frame 1, and sort 5:10 to frame 2 using one list? Now it is clicking both radiobuttons in frame 1 and 2. I would like that only one can be selected at the time. My code: ...
Royy's user avatar
  • 147
1 vote
1 answer
63 views

expected integer but got "none"

I have two lists, but I want them to work as one. So only one radiobutton can be activated at the time. I am trying to get them to print something without an error, but I keep getting an error because ...
Royy's user avatar
  • 147
9 votes
1 answer
402 views

List isn't expanding

These lists aren't expanding, only the last thing on the list is visible. My list works when I use it as pack. But I want to have 3 lists right next to each other with radiobuttons using grid. But I ...
Royy's user avatar
  • 147
2 votes
2 answers
118 views

Merge every element of 2 lists of lists

Suppose, we have 2 lists of lists: a = [[1,2], [3,4]] b = [[5,6], [7,8]] We want to merge every element of the first list with every element of the second list and get: c = [[1,2,5,6], [1,2,7,8], [3,...
user4035's user avatar
  • 24k
-1 votes
1 answer
129 views

How can I merge two lists in Python while removing duplicates but preserving the original order? [duplicate]

I have two lists in Python: list1 = [1, 2, 3, 4] list2 = [3, 4, 5, 6] I want to merge them into a single list such that: No duplicates remain The original order of elements is preserved For the ...
Binil S Mathew's user avatar
-5 votes
0 answers
44 views

Find first matching array index in Python, but using lambda helper function [duplicate]

I have a data structure like arr = [ (2014, 0.21, 0.27), (2015, 0.23, 0.27), (2016, 0.25, None), (2017, 0.25, None), (2018, 0.27, None), ] where I want to find the index of the ...
natevw's user avatar
  • 18.1k
0 votes
1 answer
56 views

RealmSwift: List not refreshing after changes on data

I've got a list in detail of a NavigationSplitView. The data is stored with RealmSwift. @EnvironmentObject var realmService: RealmService @ObservedRealmObject var selectedGroup: Group @...
user2836375's user avatar
-3 votes
3 answers
109 views

list.pop('name') results in error: "str object cannot be interpreted as an integer"

I used the .pop() function to remove the guests, here is my code: guests = ['Bill' , 'john' , 'jason' , 'fatima' , 'muhammed' , 'abdul'] print(guests) guests.pop('jason') guests.pop('bill') print(...
ACertain DeltaruneFan's user avatar
1 vote
1 answer
106 views

How to extract a value from a list without getting “length 0” errors? [duplicate]

I’m parsing some JSON data in R and got this structure: entry <- list("Ontario"="ON", "ON"="13.6") When I try: j <- entry["Ontario"] population ...
赵一夫's user avatar
0 votes
0 answers
56 views

How to properly use "limit" in AWS Amplify Gen2 list-function?

Please help me to understand how to properly and correctly use the list-function of AWS Amplify. After running into many issues of existing data not being found/retrieved, I found out that if no "...
oleracea's user avatar
2 votes
1 answer
89 views

Sort each row of a pandas column consisting of delimited strings

CONTEXT Let's say I have df, which consists of a column of delimited strings that I would like to sort. import pandas as pd df = pd.DataFrame({'sort_me':['foo; bar','foo; bar','bar; foo']}) df ...
bismo's user avatar
  • 1,645

15 30 50 per page
1
2 3 4 5
9540