I have an external file, and I have to convert the strings from the external file to a list of dictionary objects, containing keys and with respective values. The problem is I keep getting error on the code I already tried, such as “too many values to unpack”. I am really stuck in here. Here is th…
How to test a Faust agent that sends data to a sink?
I am trying to write unit tests using pytest for my Faust application. I have referred to the documentation here but it does not mention what to do when my Faust agent is sending data to a sink. Without a sink, my tests are working fine but when I use a sink, I get this error: I have tried various
sending order to open a position via MetaTrader5 python module and nothing happens
I followed Metatrader5 python documentation and this answer in stack overflow I try to open a sell position: Nothing happens and there is no reaction in applications terminal. I also check Trade and History section in Metatrader5 to find some related information but I find out nothing. how can I monitor the l…
Change contrast and sharpness of a Picture in Python
I’m new to coding, some my code isn’t the cleanest (as evidenced below). Is there a more efficent way to change both the sharpness and contrast with Pillow in python without having to save and open the file twice? My horrible code: Answer You can do it without saving to disk like this: Transforms …
How to add watermark in all pages of PDF files with python?
I’m try to adding watermark to every pages of my PDF file.My PDF files have 58 pages but my output file has get only last page in my PDF file. This’s my code: Please tell me how to add watermark all pages. Answer You’re rewriting your “merged” file for each page. Try something li…
the graphs of the two projectiles does not work properly when complementary angles(eg 30 and 60) are passes to xy_plot1 and xyplot2 function
Answer Be careful! Your theta argument for the xyplot() function is in degrees, but inside your function, the math.sin() function takes the argument for the angle in units of radians. The easiest fix is to provide your theta argument in units of radians instead of degrees. You also don’t need both funct…
OSError: [WinError 740] The requested operation requires elevation
I am having a simple code which has an image called “try.png” and I want to convert it from Image to Text using pytesseract but I am having some issues with the code. But it’s giving me an error. Any idea on how to over come this error Answer tesseract-ocr-setup-4.00.00dev.exe sounds like a …
Multiple Columns for HUE parameter in Seaborn violinplot
I am working with tips data set, and here is the head of data set. My code is I want a violinplot of day with total_bill in which hue is sex and smoker, but I can not find any option to set multiple values of hue. Is there any way? Answer You could use a seaborn.catplot in order to use
How to get the centroids in DBSCAN sklearn?
I am using DBSCAN for clustering. However, now I want to pick a point from each cluster that represents it, but I realized that DBSCAN does not have centroids as in kmeans. However, I observed that DBSCAN has something called core points. I am thinking if it is possible to use these core points or any other a…
Discord.py REWRITE – How to make a Guild Invite
I am trying to make my bot create an invite This gives an error ‘bot’ object has no Attribute ‘create_invite’ I am using the Discord.py Rewrite. Thanks in advance! Answer You’ll need to specify what you’re making the invite for, because the bot doesn’t currently have …