Category "list"

Python error TypeError: list indices must be integers or slices, not tuple

def convert(data): new_data = [] for id_users in range(1, nb_users + 1): id_movies = data[:,1][data[:,0] == id_users] id_ratings = data[:,2][data[:,0]

Remove element from a list based on condition in pandas dataframe

a= {'A' : [1, 2,3,4], 'B' : ['FOOTBALL','BASKETBALL','HANDBALL','VOLLEYBALL'], 'C' : [[5,10,15,40],[1,4],[20,10,40],[10,40]] } How can I remove the element 40

find max value in a list of sets for an element at index 1 of sets

I have a list like this: dummy_list = [(8, 'N'), (4, 'Y'), (1, 'N'), (1, 'Y'), (3, 'N'), (4, 'Y'), (3, 'N'), (2, 'Y'), (1, 'N'), (2, 'Y'), (1, 'N')]

temporary variable doesn't store the original value

I have this list of lists: lst = [[1],[2],[3],[4]] And I want to move the i+1 element to the [0] index, like this: [[2],[1],[3],[4]] / [[3],[1],[2],[4]] / [[

getting data from a list flutter

i want to get data from a list its working with the first 6 attributes but i wanted to add the "description", "assetsideid", "assetnum", "location" and "descri

python list ofwords.the program outputsthosewords&theirfrequencies.Ex:if the input is:hey hi Mark hi mark the output is: hey 1 hi 2 Mark 2 hi 2 mark 2

I thought I could use this code: wordInput = input() myList = wordInput.split(" ") for i in myList: print(i,myList.count(i)) but its output is: hey 1 Hi

how do you convert a list into a int in python in one/two lines?

If you want to convert a list into a int You could use x = "" the_list = [5,7,8,6] for integer in the_list: x+=str(integer) ans = int(x) #output 5786 is

automatically remove items of a list every few second in redis

I'm trying to see how many users used my bot in the last 5 minute. I've got an idea to every time a user used my bot I add his/hers id into a redis list with a

Add elements in a list at the n index of a other list

calibres_prix =['115-135', '1.87'], ['136-165', '1.97'], ['150-180', '1.97'], ['190-220', '1.97'], ['80-95', '1.42'], ['95-115', '1.52'], ['150-180', '1.82

How to convert DataTable to List<T> in C#

For convert DataTable to List you can used the AutoMapper Library and you can do it automatically

how to add values from a function to a list

This is a sample database from a function can someone help me to send the output of function to list as shown in the screenshot [this function "getDistrict_Na

Get seconds between next day with time

I am trying to get the Duration until the next time, depending on a Day of Week in Java. I want to be able to schedule a Java task for the next day in a list, a

how to add values from a function to a list

This is a sample database from a function can someone help me to send the output of function to list as shown in the screenshot [this function "getDistrict_Na

Python flatten rows of 2D list

Currently working on a program that requires the flattening of columns, rows, and diagonals of a 2D list. I have written the following code that flattens the co

get list of lists from dict of lists by grouping elements at same index in every key-value pair [duplicate]

I have a dictionary a = {'a':[1,2,3],'b':[4,5,6]} Now, I wish to convert it into a list of lists such that [[1,4],[2,5],[3,6]] i.e. the

I want to delete all the lists with length 1 at the beginning and end but not in the middle in python

Given a list of lists (i.e. a nested list), I want to delete all the inner lists with length 1 from the beginning and the end of the outer list. For example d

Combine lists of dictionaries with specific value matches

Given a_list and b_list in python, I want to merge them so that the result is c_list. In the example below, only want to merge elements that have a matching 'A'

How to print result in one line [duplicate]

I am trying to solve a problem with this code: equipoa = input("Digite las iniciales del equipo a: ") equipob = input("Digite las iniciales de

Get a Map<String, List<String>> from List<Pojo>

I have a Student class with the following structure: class Student { String name; int age; String grade; } I have a List of Students (l

How can I count dictionary items with specific values inside list in Python?

I want to print and count the users who are 'male' and are born on 1973, 1980. Is there a way to search '1973' and '1980' in 'birthday' values so I can count th