Category "python"

Creating Python zip for AWS Lambda using Bazel

I've a monorepo that contains a set of Python AWS lambdas and I'm using Bazel for building and packaging the lambdas. I'm now trying to use Bazel to create a zi

Apache Beam with Dataflow: flag 'ignore_unknown_columns' for WriteToBigQuery not working

I am building a streaming pipeline using Apache Beam (Python SDK version 2.37.0) and Google Dataflow to write some data I receive via Pubsub to BigQuery. I proc

plotly dash link to local html file

i want to link a local HTML file to a plotly dash table. from dash import Dash from dash_table import DataTable import pandas as pd df = pd.DataFrame( {

Caused by: java.net.SocketTimeoutException: Accept timed out

I am getting this error while running pyspark package in pycharm using python 3.9 using this below code. from pyspark.sql import SparkSession from pyspark.sql.t

Pytest logging ignores dependency warnings

I have a simple python script that leads to a pandas SettingsWithCopyWarning: import logging import pandas as pd def method(): logging.info("info") l

How to customize general error messages of numpy?

I am writing a Vector and Matrix classes that use numpy in the backend in order to abstract some common methods and calculations (specifically, physics calculat

Conversion between binary vector and 128 bit number

Is there a way to convert back and forth between a binary vector and a 128-bit number? I have the following binary vector: import numpy as np bits = np.array([

How to make SPOT market order on Bybit with ccxt?

I am using ccxt library to work with exchange. Struggling with making market order on Bybit. How it can be fixed? The error i've got is TypeError: Exchange.requ

Add a comma after two words in pandas

I have the following texts in a df column: La Palma La Palma Nueva La Palma, Nueva Concepcion El Estor El Estor Nuevo Nuevo Leon San Jose La Paz Colombia Mexico

Django context processors available globally to templates in ALL apps

I am new to Django/Python, and am trying to figure out the best way to have global constants in my project that are available to templates in ALL APPS in the pr

Is there a simple way to compare two class objects for all items that are not none?

I am looking to compare two instances of the same class, but only the items for which both are not None. for instance, I will have a Bolt class, and one instanc

Generate binary outcome dummy data based on probability of items and its feature

I want to generate a synthetic data from scratch which is a binary outcome sequence data (0/1). My data has following property- For the sake of an example, lets

How to correctly compute the gradient of a curve using numpy gradient?

I have a curve which is composed of 1200 values and i just want to compute its derivative so i use numpy gradient function. Here is the code i'm using: data = n

How do I continue a for loop when no data is present which causes an index error?

I am learning python and I'm guessing something very obvious is at fault here. I have a web scraping program that, I suspect, upon finding an empty data field t

Drag and drop without QLineEdit (or at least doesn't require user to highlight the text)

I want the user to be able to drag and drop a premade block of text, for the purpose of placing and reordering some items, but the only way I can see how to do

What is the reason, sometimes the parameters in class does not defined in __init__ but added as instance variables?

Why does these attributes (commented) does not included in the init ? class RRT(object): def __init__(self, start, stop, obstacle_list, rand_area): self.s

Custom mocking for testing with pytest

I have a code base (shown below), with a src directory containing the code, that I have developed, alongside with some supporting Third Party libs in tp directo

Simulating a request with Hmac signature

I am trying to send a request after reverse engineering a private API, but the headers have these two elements that are crucial for the success of sending this

Pandas to read a excel file from s3 and apply some operation and write the file in same location

i am using pandas to read an excel file from s3 and i will be doing some operation in one of the column and write the new version in same location. Basically ne

OpenAPI is missing schemas for some of the Pydantic models in FastAPI app

I am building a FastAPI application, which has a lot of Pydantic models. Even though the application is working just fine, as expected the OpenAPI (Swagger UI)