My code does not throw an error, it simply creates the files, but of which are empty. I tried it from the command line, and it works using the wildcard training_set_pssm/*.pssm path, but I must do it from the IDE because it is not printing the correct output anyway. The input file is a set of checkpoint files that look
Tag: loops
Compare all elements of a list
To illustrate my problem, imagine I have a list and I want to compare each element with the next one to check if they are the same value. The problem is that when I try to access the last element of the list and compare it with “the next one”, that one is out of range, so I would get
Looping through a filtered dataframe to see if a value is in a list column
Apologies for the vague title, I’m not entirely sure how to word it more correctly. I have a DataFrame like this: Which is created with this: And the logic behind it is that each line is a customer record: they can only ever save one product at a time (which is why savedProduct has one product code) but they can
How to get row number and specify tooltip from another columns in that row?
the problem is that i can’t iterate through whole dataframe and for each cellwidgetitem in specific row in column 1 specify tooltip from another columns in the same row. Above code works and does show whole dataframe in QTableWidget and below code works for extracting text from several columns and setToolTip for CellWidgetItem from row 1 and column 1. But
Do you know how to split a list of strings into different variables?
I am a beginner in python, and I have a question that perhaps is simple. I have a “file.txt”, where in principle there can be a number n of strings. This is loaded into the program with: Now, I load a dataframe from a csv, which has a column (with name “Identifier”) that contains a lot of names. The goal
For loops and conditionals in Python
I am new to Python and I was wondering if there was a way I could shorten/optimise the below loops: I tried this oneliner, but it doesn’t seem to work: Answer You can use itertools.product to handle the nested loops for you, and I think (although I’m not sure because I can’t see your data) you can skip all the
Iterate through an adjacency matrix with a list
So I have a n x n adjacency matrix, N x N NumPy array, where the i-th row and the j-th column is the distance between the i-th and j-th cities. I also have list, in a specific order in which I have to visit the cities and and add the distances together. The list items are pointing to row/column
loop through the list to get Maximum sum for a given range in python
I am a novice in python. I have a code where I loop through a list to capture maximum sum of numbers for given range k. It is working fine but I want it to make it shorter/optimal. ‘k’ may vary Ans: 1533 when k = 3 Ans: 1333 when k = 2 Answer You can start by adding up
How is print(‘r’) or print(‘ ‘) giving me the output?
We were asked to print the following output: I understand that it would require two loops so I tired this: With this I am getting the desired output, but as soon as I remove the last line of print(‘r’) the output becomes something like this: The desired output also comes out when I used print(‘ ‘) instead of print(‘r’), I
Accessing pandas cell value using df.itertuples() and column name gives AttributeError
I have the following dataframe from where I want to retrieve the cell values using index and column names. The left column indicates the index values whereas the column names are from 1 to 5. This is a dummy dataframe which looks small but going forward I will be using this code to access a dataframe with 100+ columns and