I have the following three lists: I was wondering how I can take these 3 lists and iterate through them to get lists so the first plot would be plotting dog as title with y value as the first list in 2d list 2 and the x value would the first list in 2d list 3. This would iterate for
Tag: python
Python .replace() function doesn’t seem to do anything
I’m trying to modify a table I scraped of Yahoo Finance containing dividends over the last 5 years. An example row of this table is: “1.50 Dividend”. As I want to do calculations with this table I needed only the number in the form of a float. So I used the .replace(“Dividend, “&…
Pandas merge stop at first match like vlookup instead of duplicating
I have two tables, PO data and commodity code data. Some genius decided that some material group codes should be the same as they are differentiated at a lower level by GL accounts. Because of that, I can’t merge on material groups, as I’ll get duplicate rows. Assume the following: As you can see,…
How can a create a percentage matrix based on a dataframe
I have a dataframe that looks like that : Place A Place B Type Number New York Paris A 34 Oslo London B 42 Oslo London A 24 i need to have the percentage number of each type according to the routes. I don’t know witch command to use to get a dataframe that looks like this xxx Paris Oslo
Trouble sorting list of lists in Python with Insertion Sort
I am currently making a Python program which takes in the name of a grocery item, the aisle it’s on, its location along the aisle, and the price. It holds the data in a list of lists, with each inner list containing 4 elements. The program attempts to create the optimal route through the aisles, with tr…
Keras Confusion Matrix does not look right
I am running a Keras model on the Breast Cancer dataset. I got around 96% accuracy with it, but the confusion matrix is completely off. Here are the graphs: And here is my confusion matrix: The matrix is saying that I have no true negatives and they’re actually false negatives, when I believe that it…
Check if any nested list within a 2d list both contains one value and does not contain another
I’m making a card game in python where the cards are stored in a 2D list, where the first layer of the list is each card and the second layer is the values a card has. I’m trying to make an if statement that checks if any card a player has in their hand (that is, any nested list within
Python AttributeError When Attribute is Set
I am creating a snake clone using pygame and I am running into a strange problem. I have a class called snake_tile that inherits from the pygame rectangle class with one additional attribute, the direction the tile is moving: I pass in a tuple as the direction when initializing the snake_tile object: Which wi…
How to convert Excel file to json using pandas?
I would like to parse Excel file which has a couple of sheets and save a data in JSON file. I don’t want to parse first and second sheet, and also the last one. I want to parse those in between and that number of sheets is not always equal and names of those sheets are not always the same.
$elemMatch to fetch specific values inside array
I have a collection named ‘attendance’ that has an array: I have been trying to query the values of the specific element in my array using $and and $elemMatch in: But it still prints the other section rather than one. I want to output to be: And I tried using the dot notation like: Still no luck. …