So I’m creating a discord bot that is constantly scraping a webpage, checking if the item is in stock. When the item becomes in stock, send a message in the chat. Since the scraping is in a constant loop, I figured I would put that in a thread, one for each page that needs to be scraped. The problem is
Elegant Way to Deal with Marshmallow Altering a SQLAlchemy Object
I have found myself in a situation that does not seem to have an elegant solution. Consider the following (pseudo-ish) REST API code I have A PUT endpoint that will create a new resource, then return the dump of that resource. An ORM object that has a filePath property. This must be stored as a relative path.…
Python statsmodels – ValueError: how to create variable in range 0 to 1?
Code: The problem I have is with the “You will need to create a new variable from baths, and it should make it such that those observations of 1 bath correspond to a value of 0, and those with more than 1 bath correspond to a 1.” instruction. I really do not know how to do that. I know that
Get Path of File Relative Path of File that Imported Module in Python
I have this code in my_program.py: And this is my_module.py: A file not found error arises when my_module.py is not in the same directory as my_program.py. This problem was solved using this code (my_module.py). The issue arises when my_program.py is imported by a file in a different directory. How can I fix …
Control the facecolor of histograms
In the following histogram, I would like to set two different colors for the bars of the histogram. There is a precedent question (this link), but the solution sets the bars’ colors in a range, e.g., bars 0 to 3 of one color. This is a different problem since I would like to differentiate two zones in t…
How to delete duplicates pandas
I need to check if there are some duplicates value in one column of a dataframe using Pandas and, if there is any duplicate, delete the entire row. I need to check just the first column. Example: What i need is: I can delete the ‘object’ duplicates with the following code, but I can’t delete…
pandas change dataset value of a specific row using loc
I’m new to programming, I’m working on a python project using pandas I wanted to change values of each row of a dataset using .loc, but it seems like it won’t work, the idea is to make a row take EOL value if the row is equal to 0, the code doesn’t bring an error, but my dataset is unc…
How to remove duplicates from a dataframe based on the column with string values
I am trying to remove duplicates based on the column item_id from a dataframe df. df : In this df the item_id is as follows: I am using the following function to remove the duplicates. I am unable to remove the duplicates although there rows 0 and 1 have similar item_id. I have some other cases where this fun…
How to improve rectangles from image using opencv?
I’ve an input image like below : ] I did some processing and got lines from my input image as below Lined Image : I want to have output with cell detected like this: Output Image I tried to found cells Bounding box using findContours and connectedComponentsWithStats method but they’re not giving m…
How to check if a string contains item(s) from a list and then add the existing values to a variable in python?
I have imported a .csv file as a flat list which contains keywords that should be added to same variable if they exist in description variable (string). I already have come up with a method to check what items from the list exist in the description string, but the problem is that it can’t check for keyw…