I’m very new to python and programming in general (This is my first programming language, I started about a month ago). I have a CSV file with data ordered like this (CSV file data at the bottom). There are 31 columns of data. The first column (wavelength) must be read in as the independent variable (x)…
Tag: for-loop
Curve grades fx (list operation and loops) python
I’m trying to put together a fx that I has a user input a list of grades and # of points to curve by. The fx should then add the amount to “curve by” to each test score and then return the avg. In one fx I am able to ask for grades, amt to curve by, and make a
Saving a new list from a a larger list using a loop
I have a large list, which I am pulling out every nth value from the first value up to the mth value to create new lists and I am using a for loop. My question is, how do I create a new list variable each time through the for loop? By way of simple example, I have the list: Which
Search word in word documents and print out the file name that contains that word?
Hey so I am new to Python and I wanted to make a script that retrieves the file name from a list of docx documents in a large directory if a file contains a certain word inside the word document. Here is my code below so far My thought process is to convert all these docx documents to txt files
OpenAI Gym: Walk through all possible actions in an action space
I want to build a brute-force approach that tests all actions in a Gym action space before selecting the best one. Is there any simple, straight-forward way to get all possible actions? Specifically, my action space is I know I can sample a random action with action_space.sample() and also check if an action …
For loop for assigning colors to a plot python
I am working on a for loop to assign numbers to the classes and I am successful in that but I find it hard to simultaneously insert different colors based on the number of classes using the same for loop but I am getting the error :’list’ object cannot be interpreted as an integer Below is the cod…
Deleting the last character in print statement when using for loop
I have created a list of numbers that are being inserted in a string, in this case it is a json. I am trying to delete the last character of the string after the list goes through and prints the very last element. I need to remove the last character which is a comma “,” in my string, only after
Compare each element of a list in existing order with elements of a second list in order as long as items in lists are equal
Compare each element of a list in existing order with elements of a second list in existing order as long as items in lists are equal. Stop if they’re not equal and give me as result the index and name of the last match. I thought it’s straightforward with a while loop but it seems like this has t…
Listing each iteration of rolling a six-sided-die in Python
I’m working on an animated bar plot to show how the number frequencies of rolling a six-sided die converge the more you roll the die. I’d like to show the number frequencies after each iteration, and for that I have to get a list of the number frequencies for that iteration in another list. Here&#…
Trouble when adding values for NaN in DataFrame
I have this DataFrame: And I want to fill the NaN values with keyword taken from the description. To that end I created a list with the keywords I want: Finally, I want to loop over each row in the DataFrame. Split the contents from the “description” column in each row and, if that word is also in…