Category "list"

Why do I need Comparable for PriorityQueue?

I'm learning about Queue Collection and I don't understand why do I need to implement Comparable interface if I use PriorityQueue? I have used Comparable and Co

How can I get branch of a networkx graph as a list from pandas dataframe in Python?

I have a pandas dataframe df which looks as follows: From To 0 Node1 Node2 1 Node1 Node3 2 Node2 Node4 3 Node2 Node5 4 Node3 Node6 5 No

plotting data from a list in python

I need to plot the velocities of some objects(cars). Each velocity are being calculated through a routine and written in a file, roughly through this ( I have

how to remove duplicated elements from a list without using set()?

Let a = np.array([1, 1, 1,1,1,1]) b = np.array([2,2,2]) be two numpy arrays. Then let c = [a]+[b]+[b] clearly, c has duplicated elements b. Now I wish to

python tkinter append list

I am an amateur python programer with 2 months of experience. I am trying to write a GUI to-do list through tkinter. The actual placement of the buttons are n

How do i make a recursive function in python which does the following? magic list

I've got an assignment in which I need to code a recursive function (with no loops) in python that returns: [[]] if n is 1 [[],[[]]] if n is 2 [[],[[]],[[],[[]]

Finding the index wise maximum values of two lists

Lets say I have 2 lists: L1 = [2,4,1,6] L2 = [1,5,2,3] The output should be a new list that contains the biggest numbers found in L1 or L2 based on their pos

How do I multiply each element in a list by a number?

I have a list: my_list = [1, 2, 3, 4, 5] How can I multiply each element in my_list by 5? The output should be: [5, 10, 15, 20, 25]

Find the list of Google Container Registry public images

Where can I find the list of GCR public images? In case of docker images, we can list it in hub.docker.com. But I couldn't find anything like that for GCR.

myFile.write(item+"\n") TypeError: unsupported operand type(s) for +: 'int' and 'str'

Getting error: myFile.write(item+"\n") TypeError: unsupported operand type(s) for +: 'int' and 'str' and not sure why. Where shall I add the int? This i

Counting number of co-occurrences of words for a specified vocabulary and within a specified radius?

I have a vocabulary V = ["anarchism", "originated", "term", "abuse"], and list of words test = ['anarchism', 'originated', 'as', 'a', 'term', 'of', 'abuse', 'fi

How to convert list of list into a dataframe with differential list structure

I applied machine learning algorithm with caret package (caretlist) to predict death in a cohort of patients according to multiple variables (e.g. age, gender,

Is there any way to improve performance (e.g. vectorize) this look-up and recoding problem implemented by a for loop?

I need to make recodings to data sets of the following form. # List elements of varying length set.seed(12345) n = 1e3 m = sample(2:5, n, T) V = list() for(i

Combinations of 2 lists [duplicate]

Input: [1, 2, 3] [a, b] Expected Output: [(1,a),(1,b),(2,a),(2,b),(3,a),(3,b)] This works, but is there a better way without an if statemen

append values in for loop R as in python

I am trying to reproduce the following functions created in Python in R. # Python def square_area(side): return side * side results = [] for i in range(1

Converting a list to a linked list

I'm trying to figure out to convert a list to a linked list. I already have a class for the link but I'm trying to figure out how to convert a list to linked l

Test if all elements of a python list are False

How to return False if all elements are in a list are False? The given list is: data = [False, False, False]

How do i use comprehensions to output dictionary data after editing it and how to validate user input asking user to repeat

eList = [] while True: eDict = { "ID": "", "NAME": "", "EMAIL": "", "ADDRESS": "", "SALARY": ""} try:

How to append to a list in Terraform?

I have some code in the general form: variable "foo" { type = "list" default = [ 1,2,3 ] } resource "bar_type" "bar" { bar_field = "${var.foo}" } I wa

Nested for loop stop if null value using Scrapy

I use a nested for loop to get data of Weekdays. If one of the days is 'null' the loop stops at that day and doesn't get the rest of the days. I believe that I