I have the following df: Now I want to output column A values as file names. My output now is: 0.xml, 1.xml, 2.xml. However I would like my output files to be the following: 1.xml, 1.xml, 4.xml. Can you help me? Answer Use the ‘A’ value from the row, so:
Tag: for-loop
Binding a dataframe to a variable in a for-loop converts it into a tuple?
Sorry if this is basic but I am new to python. I was experimenting with creating plots in pandas through a for loop when I got AttributeError: ‘tuple’ object has no attribute ‘plot’. Looking at my code, I found out that assigning a dataframe to a variable converts it into a tuple. See below: Output: This doesn’t happen if I
How do I put a space between every data got from the FOR LOOP
I am a new learner in python and was trying to get some data from 2 webpages using Beautiful Soup and FOR LOOP to loop over it and print that. From the above code you can see that I am able to get output from both the webpages in a sequence but I want to insert a space or some
How to loop through elements from a python pandas dataframe to a new nested dictionary?
I am currently using pandas library to read data from a CSV file. The data includes a “data” column which consists of 1’s and 0’s, and a “published_at” column which has unique time and date stamps (I have converted it to become the index of the dataframe). Click here to see picture of the Dataframe from CSV (I deleted the
How can I get a row in Sqlite3 table with Tkinter Listbox widget?
I have Python program connected to Sqlite3 database with Tkinter on the frontend. My database table (subjectlist) consists of four columns: [id (unique interger), subject (text), serial (unique interger), is_active (boolean interger)]. Here is my program: Currently at runtime when I click item on listbox (which basically shows all subject column values that have is_active=1 on the same row) and
How can I get the value of a row in a column in SQLite 3 table with Tkinter Listbox widget?
I have Python program connected to SQLite 3 database with Tkinter on the frontend. My database table (subjectlist) consists of three columns: [id (unique interger), subject (text), serial (unique integer)]. Here is my program: Currently at runtime when I click item on listbox (witch basically shows all subject column values) and then press Tkinter button I get the subject I
Efficient way for checking number 3^x * 5^y
I want to check if number, based on lower and upper bound, has prime divisors only 3 and 5 and number should be multiplication of power of 3 and power of 5. My current solution is this. I want to optimize it, since checking powers with for loops isn’t good way in my opinion. Thanks in advance. Based on comments
How do I make a list of imported classes in Python?
Is there a way to avoid having to call foo(x)for each imported object? Some context: a, b, c are webpage classes and foo is a route() function that creates a route for each webpage. Update: There will be a growing list of imported classes in the main module as the application grows. I mentioned a, b, and c simply as
Why can’t I initialize instances using for loop – Python, class
error: name ‘w1’ is not defined I tried to use for loop to initialize all the workers( w1, w2, w3) so i can access them afterwards. But when I try to access them they say the instance is not defined, is it possible that you cant initialize using for loop. Thanks in advance, beginner here. Answer I think the best
I can’t do anything with python dict? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question Im really stuck with a little problem that I have. Currency_price.json is a file which contains a dictionary like this: