Hello I am trying to find the number of rows for all files within a folder. I am trying to do this for a folder that contains only “.txt” files and for a folder that contains .”csv” files. I know that the way to get the number of rows for a SINGLE “.txt” file is something like this: Whereas for
Tag: loops
How to create a function which Iterates over multiple lists
So I’m creating a series of column mappings, I can do this manually like so The function produces a mapping of a value and its column. Great, now I want to make this more general. Currently, if I needed to map 2 columns for example I run the following: Works as well but not ideal if I have a lot
Python – Iterating through 2 list with arithmetic function
I have 2 python list, stock_level to track the amount of inventory and required to indicate the amount of each item in stock_level needed to create each product. How do I iterate through the 2 lists to find out how many products can be made and the inventory left outstanding after making the products i.e. given the above value, only
Draw Co-ordinates using Turtle
I’m trying to draw a set of co-ordinates using Python Turtle, however ,I’m stuck and have no clue how to move on. I know that I have to set up a loop function but I’m not sure how to write it out, still new to programming. Answer Add this to the loop in print_map:
How to iterate over a list once only in a nested loop in Python
I intend to send message to many numbers, but this is my code and issue (code is made shorter and required lines are here): I know my way is incorrect, because this is the output but I’m not sure how to solve this. Googling this did not help me. Output: My desired output would be like: I want to send
Python psychic guessing game repeats 10 times
I want it so it will randomly generate a number between 1-10 and the user will input their guess. It will then output if it is right or wrong, after 10 rounds it will tell them how psychic they are. I have done most of it but I cannot get it to randomly generate 10 numbers instead it generates 1
How does this iterative loop fit the model? ( Machine Learning)
I’m confused as to what for m in range(1, len(X_train)): is doing in the line model.fit(X_train[:m], y_train[:m]) y_train_predict = model.predict(X_train[:m]) . So I think that m is going to loop over the size of the training data.and that for each loop m+=1 but I don’t understand the rest Answer The purpose of this function is to show the performance of
Streamlit auto populate multiselect widgets to filter dataframe
I have a streamlit app where a user can upload a csv file. I would like streamlit to detect the object/dimension columns and create a multiselect filter for each of them with the unique values inside each of the columns. For example if the user uploads a file with 3 object/dimension, 3 separate multi select filters will be created. I
Python : Amount input with While
Beginner here. I’m trying to build a loop where the chekout displays a total amount that has to be over 0$. For example, if I start with 450$ the code works. But if I start with say -12 it will ask me again (which is what I want), but then if I enter 450 as the third essay; the first
How to obtain a value from inside a loop
I will be implementing multiprocessing so that the loops are occurring at the same time, but how can I make it so at the end of each iteration, I can obtain the value of westernEurope.cases and easternEurope.cases so that I can add them together Answer IMHO there is no need for multiprocessing. With a generator, your problem can be solved