Questions tagged [list]

The list tag may refer to: a linked list (an ordered set of nodes, each referencing its successor), or a form of dynamic array. Not to be used for HTML lists, use [html-lists] instead.

-2
votes
2answers
23 views

I have to send the content of a list to a string

I have to send the content of a list to a single string. I've tried using a loop, but only could print the result: for item in output_list: for line in item['output'].split('\n'): print(...
0
votes
2answers
23 views

How do I get an indexed result list in an enumerated for loop

I'm trying to get ephemeris time (ET) for a list of dates (that I imported from excel). I can get the ET but each time it loops it replaces the previous calculated time. I instead need all the ET's in ...
-2
votes
0answers
8 views

Java export List<T> to HTML Table without any library

I have a Springboot Action which contains a bunch of Lists of Objects. Basically i want each export each List as a clean HTML Table without using any libs. Can anyone give me a go how to implement ...
-2
votes
1answer
44 views

How do i get an element from List<T> elements= new ArrayList<>();?

I want to get the elements from the list. I'm working right now on a project, next to the Class name is: <T extends Comparable<T>> written. And I do have a ArrayList List<T> list ...
0
votes
3answers
28 views

Remove duplicates from a list and remove respective elements from second list in python

I have two lists. One contains strings, that represent names and one contains integers that represent the persons. For every name there is a respective number and I can access each name because they ...
4
votes
2answers
30 views

Find occurences of list in a list of list in a dataframe column

I have a dataframe, df, with one column. data = {'details': [['brand : honda', 'car : city', 'colour : black'],['brand : toyota', 'car : innova'], ['brand : honda', 'colour : red']...
0
votes
2answers
21 views

Serialize a list os questions and return as a JSON

I'm trying to serialize a list of objects, but I get an erro, How can I serialize this list of objects? Thanks ids = request.data.__getitem__("ids") questions_array = [] for id ...
1
vote
1answer
31 views

While-loop - IndexError: list assignment index out of range

I keep getting Index Errors when I try to use while loops in combination with lists. I wrote the code some time ago, came back to it, but just couldn't wrap my head around it enough to find my ...
-2
votes
0answers
3 views

code showing some segmentation error and why?

To find the middle element in a linked list it is working for odd number of nodes but nor working for even include using namespace std; struct node { int data; node* next; }; node *head; ...
0
votes
1answer
35 views

Convert 2D array to 3D numpy array

I have a created a numpy array, each element of the array contains an array of the same shape (9,5). What I want is a 3D array. I've tried using np.stack. data = list(map(lambda x: getKmers(x, 9), ...
1
vote
5answers
29 views

Output elements from a string array to a sentence

The code should output string elements from list B when printing something from list A. Say we have text = "" letters = ["a", "b", "c"] names = ["Abby", "Bob", "Carl"] How to iterate through the ...
0
votes
0answers
14 views

How can I import multiple fasta-files from multiple subfolders into a list of lists

I have several subfolders ("C1", "C2", "C3") and each of these subfolders contain four fasta-files. I would like to import this so that each subfolder is an element of a list and each element should ...
-3
votes
1answer
28 views

How to develop a function

I am completely new in python and I am learning it. I have written the following code but i couldnt make any functions of it. Can somebody help me please? import pandas as pd import numpy as np f = ...
0
votes
0answers
21 views

Match 2 people together from list randomly using one condition

I am creating an excel sheet to randomly match 2 employees together from a list. Only criteria is that the employees cannot be apart of the same department. I've created a formula that randomly ...
3
votes
2answers
55 views

How to write list of list in chunk file

I have list of list that looks like this: listThing = [['apple','mango','cherry'], ['dog','cat','bird'], ['rose','jasmine','sunflower'] ['hospital','house','...
0
votes
1answer
40 views

Same Code, Different output, Python Data frame for record comparison

Good morning, the goal of my code is to compare records in multiple dataframes. If the record ID is present in another dataframe, output the months that the record is present. As an example, if ID 1 ...
1
vote
1answer
38 views

How to match the rest of the list, no matter the length

I want to write a function which takes a list of Strings with pattern matching. For example I check for a keyword set like this: parseArgs :: [String] -> Either String Command parseArgs ["set", k, ...
2
votes
2answers
43 views

Does the list object as argument value of an array object occupy memory in Python?

An array.array object has a smaller memory footprint than a list object in Python. Is it still memory-efficient when you create the array.array like below? from array import array array('l', [1, 2, 3,...
2
votes
3answers
34 views

How to merge N multi-lists into one big multi-list?

I have n multi-lists. I want to merge them into one big multi-list. Example: listA = [[1,2],[3,4],[6,7]] listB = [[10,20],[30,40],[60,70]] output: listAB = [[1,2,10,20],[3,4,30,40],[6,7,...
0
votes
0answers
16 views

How to conserve data type list when writing CSV with pandas

When i write my dataframe to csv it doesn't conserve my types. I have a dataframe where some of my columns contains lists. type(df[28]) = list 28 [Associations, collectivités territoriales, pô.....
1
vote
1answer
40 views

How can I take a single column from a SQL query and add it to a list in Python

I have a SQL query that will search a database and return a single row containing at least 3 different columns as follows: SELECT `epg_num` AS `epgNum`, `service_key` AS `serviceKey`, `...
0
votes
0answers
26 views

How to append values to list from same column in different worksheets?

I'm trying to get a list of values that are in the same column of different worksheets using gspread and Python. gs = gspread.authorize(credentials) week=[0,1,2,3] wks = gs.open('Worksheet')....
0
votes
3answers
30 views

Extract names of dataframe in list of dataframes and add it to columnnames

I have a list of dataframes: set.seed(23) date_list = seq(1:30) testframe = data.frame(Date = date_list) testframe$ABC = rnorm(30) testframe$DEF = rnorm(30) testframe$GHI = seq(from = 10, to = ...
-1
votes
2answers
41 views

Add missing values in the list by comparing the other list and vice versa

I am trying to add the missing values to the list by comparing the other list. If the data is not present in list_1 which is there in list_2, in same index of list_2 we have to add "Missing" in list_1 ...
0
votes
2answers
28 views

Dict comprehension from dict to inverse dict

I have the following data: a = {1: {'data': 243}, 2: {'data': 253}, 4: {'data':243}} And I want to turn it around, so that the key is the values, and the data values is the keys. So first try: b = ...
0
votes
0answers
40 views

Removing an element from inside a list in python

I am a beginner in python. I am trying to convert RLE compressed data into an ASCII image. I have made an algorithm which converts one part of an RLE into ASCII (For example 02a = aa) to tackle the ...
0
votes
0answers
30 views

Is this error because of the different in Python version?

I want to compare two list and then erase the common word in the second list. It works perfectly when I test this code online (version 3.6.1), but when I try with my python (version 3.7.3), it doesn't ...
0
votes
2answers
29 views

How to read each line in a file backwards using Python [duplicate]

I'm trying to read a file (example below), line by line, backwards using Python. abcd 23ad gh1 n d gjds 23iu bsddfs ND31 NG Note: I'm not trying to read the file from the end to the beginning, but ...
-1
votes
3answers
34 views

Merge 2 Lists to Remove Duplicates from the First While Keeping the Corresponding Values of the Second

I have two lists like this: 1stItem version1.1 1stItem version1.2 1stItem version1.3 2ndItem version1.1 2ndItem version1.2 3rdItem version1.1 3rdItem version1.2 3rdItem version1.3 3rdItem version1.4 ...
0
votes
0answers
16 views

Generate and update a dataframe columns dynamically [duplicate]

Imagine that we are receiving lists of characters in a dynamic way and the objective is to dedicate a column in a dataframe to each list. So, we don't know how many lists we could have and their sizes ...
0
votes
0answers
48 views

Removing an item from list removes the same item from other list as well. Why? [duplicate]

I have below code : a=[1,2,3,4] b=a for item in a: b.remove(item) print(b) print(a) The output is : [2, 3, 4] [2, 3, 4] Can someone explains why this is happening and how to prevent ...
-2
votes
3answers
54 views

How can I access this list in another class?

I have created a list of items from a CSV file, but am not sure how to access this list in another class. I have created the instance of the list class in the new class, but have not been able to find ...
0
votes
0answers
28 views

How to sort List after conversion from Map

I have a Role DTo DTo contains Class Role DTO { String rName, List<Users> user } UsersDto { String userName } Thinking that one role can have many users. ...
1
vote
5answers
64 views

how to count repeated characters in a string in python

Write a python function which performs the run length encoding for a given String and returns the run length encoded String. I tried it using looping but couldn't get the expected output. def encode(...
0
votes
2answers
53 views

How to Target <li> Element and Transfer between Lists

I am a newbie here. I have two different lists in HTML: the first list contains several elements, the second list contains none. My goal is to transfer the elements of list 1 to list 2. I do want to ...
-6
votes
2answers
43 views

Creating Boolean list from comparing 2 lists

I have 2 lists I want to compare. List_A contains all the filenames I have, List B contains the filenames I want. List_C being the output is a boolean list with the same length as List_A. Showing ...
-1
votes
1answer
27 views

How to write a list to a file without brackets

I have an integer list named LineValue of the form [0, 1, 1, 2, 0, 0], and I need to write it to file. To prevent a read error with my code, the form in the file needs to be 0,1,1,2,0,0 Instead, ...
-2
votes
2answers
53 views

Match Java Map keyset values with String values of a Java list of objects

I have a Java list of objects which each one contains a String value (code). Also I have a Java Map. I want to check whether all the elements in the Map keys are included in the list of the String ...
-3
votes
0answers
39 views

I wanted to change a value in my List , But all Of them changed

I have a Matrix in python and I want to change one of the values. here is my code: nap = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] for i in range(int(input())): x,y = ...
0
votes
1answer
41 views

Is it possible to sort a list of objects in Java through a common field? [duplicate]

I have a list of objects on my software that i want to sort through a common field, example : List<Object> obj ID 1 Price 0.0 ID 1 Price 1.2 ID 1 Price 1.3 ID 2 Price 2.0 Can i sort the list ...
1
vote
2answers
26 views

Compare lists in different dictionaries and match similarities

I would like to compare lists belonging to different dictionaries and print if there are any similarities dictionary = { 'C1' : [10,20,30], 'C2' : [20,30,40]} dictionarya = { 'S1' : [10,21,31], 'S2' ...
2
votes
1answer
60 views

How to efficiently search a list in python

I have a dictionary with only 4 keys (mydictionary) and a list (mynodes) as follows. mydictionary = {0: {('B', 'E', 'G'), ('A', 'E', 'G'), ('A', 'E', 'F'), ('A', 'D', 'F'), ('C', 'D', 'F'), ('C', ...
0
votes
0answers
30 views

How to extract unused element from random list/array? [duplicate]

Python question: I have an array of randomized numbers from 0-9: [6 7 3 9 2 8 1 4 0 5] (although this can be any size). They correspond to files in a folder and I initially extract only 8 of them, so ...
1
vote
2answers
57 views

An efficient way to find elements of a list that contain substrings from another list

list1 = ["happy new year", "game over", "a happy story", "hold on"] list2 = ["happy", "new", "hold"] Assume I have two string lists, I want to use a new list to store the matched pairs of those two ...
-4
votes
0answers
19 views

Get unique list from lists [on hold]

suppose I have a list of mylist = [[a,b,c][a,b,c,d][a,b,c,d,e][a,b,d,c,e][a,b,c,e,f][a,b,c,f,g]] If I want to extract the list that have longest unique values and order, how should I do it? ...
0
votes
0answers
24 views

Why does the iterator stop working after I add one more element to the list? [duplicate]

I try to learn about List and came around this code: List<Integer> l = new ArrayList<Integer>(); l.add(42); l.add(4711); l.add(1111); Iterator<Integer> it = l.iterator()...
0
votes
1answer
36 views

Append tuples in order to a list

I'm new in python. Is it possible to add my tuples to an empty list, but in an ordered way? The if i not in myTransfer: part is also not ideal I know, but just to get a clearer output. I tried doing ...
0
votes
1answer
10 views

Attribute Error with List of Stock Tickers

I am a bit confused as to why I am getting attribute error. This error only occurs when when I put a list equal to stock_list. If I print the list then copy and paste I do not get the error/ I have ...
0
votes
0answers
38 views

I cant seem to call my functions inside another function

I have this list with input from the use and I want to use this data to call different functions inside another functions. The way Im doing it does not seem to work, what should I do? I checked my ...
2
votes
2answers
65 views

Not sure why I am getting a segmentation fault here

I know i can change the code to fix the error but I don't understand why I am getting a segmentation fault. All help is appreciated, thank you. typedef struct nodes{ int data; struct nodes *...