Category "python"

Error in airflow 2 even though my task's have actually completed? ERROR - Could not serialize the XCom value into JSON

Hi All so my dag actully runs fine, all the outputs are working but airflow's UI does not change to succes and fails due to the following issue. Reading online

What's the fastest way of finding a random index in a Python list, a large number of times?

What's the best (fastest) way of extracting a random value from a list, a large number (>1M) of times? I am currently in a situation where I have a graph rep

Web3py merkle tree support

I am trying to implement a merkle tree just like merkletreejs but python does not have any good libraries that support keccak256 and sorted keccak256 trees. Doe

How can I mute the browser/tab in selenium using the geckodriver

I'm trying to mute the browser/tab in selenium since headless mode doesnt mute sounds, I've searched but all I could find was chrome solutions and they didn't w

Standard Deviation coming NaN in Pyspark rolling window

I have a dataset with 4 sensor values, 'volt', 'pressure', 'rotate' and 'vibration'. For these sensor values I am calculating rolling mean and rolling standard

Elegant pandas way to stratified frequencies

I want to know if I can reach my desired result with a "better" way? This means with less steps (but readable code!) and some pandas in-build features. That is

Disable pagination inspector on drf_yasg

I'm using drf_yasg to create my swagger document but I have an issue with PaginationInspector. In one of my views I declare a paginator and in swagger, is shown

PyQt5 A QA about menubar visibility by mouseover

Im using PyQT5 and Python Version is 3.78. I got a request than when I mouse over the button and display menubar.I made that code and it works. import sys from

Weighted categorical cross entropy

please I'm trying to build an NLP classifier on top of BERT but I'm struggling with data imbalance. I'm looking for an implementation of weighted CategoricalCro

OpenCV: My camera opens but it won't return any frames

I am working with OpenCV to record some videos. I have this very simple test code that records a 20 seconds video: import cv2 import os import time base_dir =

Using StandardScaler for multiple columns

I want to use StandardScaler only on certain columns, however my code resulted in error. Here is my code: from sklearn.preprocessing import StandardScaler num_c

Tkinter: Cannot edit entry widget after 2nd selection

I've made a simple GUI for placing objects in RoboDK via a Python script using Tkinter. Essentailly, the user selects an object using the btnSelect button, whic

Plot histogram from two columns of csv using pandas

I have a csv file containing two columns. What I'd like to do is to plot a histogram based on these two columns. My code is as follows: data = pd.read_csv('data

Python selenium clicking a button

I am trying to write a python script to automatically download csv using the "Download CSV" button from the below link: https://chartink.com/screener/copy-super

upload & download files from OneDrive with Python, do I need an Azure account?

I have some files in my personal OneDrive account. I want to access some of these files with Python, make some updates & then upload back to OneDrive. I hav

Q: Errors when usinig gluonts of LSTNet: GluonTSDataError

I've been studying time series forecasting, and I'm trying to learn how to use gluon-ts&python. Here is the source code of gluon-ts: https://github.com/aws

How to automatically choose meaning num_features_to_select with best result in select_features from CatBoostClassifier?

I'm writting a class on Python, where I'm trying to automatically pick up a value of num_features_to_select in CatBoostClassifier().select_features(). Right no

How to bypass Cloudflare with Python on GET requests?

I want to bypass Cloudflare on a GET request I have tried using Cloudscraper which worked for me in the past but now seems decreped. I tried: import cloudscrape

Matplotlib colorbar labels to fit into boxes

I created a scatter plot using matplotlib but I am somehow unable to get the labels to center into the boxes within the colorbar.. This is the code I have so fa

How to calculate the Euclidean distance in a canny image

I have a black line and purple lines. I want to calculate the distance between each purple pixel points in the canny image and the closest black line in the mos