October 21, 2024
Chicago 12, Melborne City, USA
python

Iterate data pandas between two tables

I’m trying to add a new column to my customers table (table). This new column is the sum of pending orders for a product (SKU). Pending orders are in another table (tableOV). I managed to do this, but it is taking a long time to calculate. I would like to know if there is a

Read More
python

How to stop auto generating text in ShortUUIDField field

I have a model where ShortUUIDField automatically generating ids I want to disable the auto generation class Mymodel(models.Model): pid=ShortUUIDField(length=10,max_length=100,prefix="prd",alphabet="abcdef") sample_id = ShortUUIDField(length=10, max_length=100, prefix="var", alphabet="abcdef", null=True, blank=True,default=lambda: None) I added default=lambda: None in sample_id field but it is still automatically generating the ids. I want the id default to be blank You need to sign

Read More
python

Mininet bandwidth not updating dynamically via HTTP request in Flask API

I am simulating a custom network topology using Mininet and controlling bandwidth dynamically through a Flask API. The setup involves a server, a router, and two clients. I’m using TCLink in Mininet for bandwidth control and using tc (traffic control) to limit bandwidth per client dynamically. The code works well initially, and the Flask API

Read More
python

Scanned document forgery detection

I am supposed to start working on a project involving detecting forgeries on pdfs representing document scans (payslips, receipts,…), these documents were forged before being scanned. To be honest, I am a bit lost regarding the approach I should use as I am a beginner on computer vision. I suppose I can’t really use methods

Read More
python

How to auto deploy AWS lambda functions to multiple aws accounts

I am working on AWS lambda functions using python and SAM deployment.Already i am deploying in one account with two environments. If i need to deploy it to multiple AWS accounts, then how to auto deploy all lambdas to those both accounts and how to manage table names and api in the lambda? I have

Read More
python

My div diplays for a second and then disappears

I have this html page that receives html elements got from javascript as shown in the code below. I aim to display the information in a div called ‘results’. It displays for a second, and then it disappears as if it’s being replaced suddenly. Why is this happening? How do I fix it? const form

Read More
python

pd.to_datetime fails with old dates

I have a csv file with very old dates, and pd.to_datetime fails. It works in polars. Is this an inherent limitation in pandas, a bug or something else? import pandas as pd dates = ["12/31/1672","12/31/1677","10/19/2024"] df = pd.DataFrame(dates, columns=['Date']) df['Date'] = pd.to_datetime(df['Date'], format="%m/%d/%Y", errors="coerce") df Date 0 NaT 1 1677-12-31 2 2024-10-19 in polars import

Read More
python

Does Plotly has troubles plotting images when the x-axis is in date format?

I have been trying to plot an image as a marker in a plotly graph and haven’t been able to achieve this successfully. If I plot the image using integers for x axis everything seems to work fine: fig = go.Figure() pyLogo = Image.open(sell_icon_path) # Add trace fig.add_trace( go.Scatter(x=[0, 0.5, 1, 2, 2.2], y=[1.23, 2.5,

Read More
python

Execute .py file from the wsl shell

I’m trying to execute a simple hello.py file from the shell (a wsl really), but apparently it doesn’t work. I used the following command to be sure to be in the directory containing the .py file: import os os.getcwd() The error is always the following: NameError: name’hello.py’ is not defined. Any suggestion? I tried many

Read More
python

Error in Parsing Json data from Nseindia Option chain

This program was working earlier but now stopped working. import requests import pandas as pd import logging from datetime import datetime logging.basicConfig(level=logging.DEBUG) baseurl = "https://www.nseindia.com/" headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, ' 'like Gecko) ' 'Chrome/80.0.3987.149 Safari/537.36', 'accept-language': 'en,gu;q=0.9,hi;q=0.8', 'accept-encoding': 'gzip, deflate, br'} session = requests.Session() request = session.get(baseurl, headers=headers,

Read More