Category "python"

Why my Spark mapPartition function is being slowed?

My algorithm is simple: I am using Spark to distribute the processing of a process that runs a cross-validation in Python. I have 3 workers and all I do is assi

bson.errors.InvalidDocument: cannot encode object of object having list of Object

I have a class defined in below form class B(): xyz: int class C(): abc: int Class A(): bList: List[B] cList: List[C] iex : int MongoDb Save Operation

Solving "CUDA out of memory" when fine-tuning GPT-2 (HuggingFace)

I get the reoccuring CUDA out of memory error when using the HuggingFace Transformers library to fine-tune a GPT-2 model and can't seem to solve it, despite my

python selenium xpath loop skips random elements

I was trying to select all the 264 Recipients from the second form on this website and I used the code below: s = Service('./chromedriver.exe') driver = webdriv

Python - Scraping API and Transform Json Data to CSV

My experience: Just started with Python and no developer My Goal: Trying to scrape Sofascore API for getting Soccer Lineups to CSV. The json data need to be tra

Not able to install django-allauth in ubuntu 18.04.6 LTS

I'm trying to add social authentication in my project but when I try to install django-allauth it is giving me error I've tried this post but no luck it's givin

Combing concurrent.future.as_complete() with dictionary using zip()

I am a first time user of concurrent.futures and following the official guides. Problem: Inside the as_completed() block, how do I access the k, v which is insi

Cannibals and missionaries problem python -artificial intelligence algorithm

I'm trying to solve the cannibals and missionaries problem in python (with some additional criteria, but the main idea is the classic one). So, in the class Gra

python how to use string value for custom sort?

I have an datafremae like this time_posted 0 5 days ago 1 an hour ago 2 a day ago 3 6 hours ago 4 4 hours ago I tried this df.sort_values(by='time_p

How to read text from an image and save it to a text file

I used image_path= "image.jpg" reader = easyocr.Reader(['en'], gpu=False) result= reader.readtext(image_path) print(result) print("text printed") output: Using

Problem in changing directory with a path variable in google colab

I want to change directory in google colab. a = 'drive/MyDrive/COLAB/colab_common_utilities' Following works: # method 1: import os os.chdir('drive/MyDrive/COLA

Visual Studio Code freezes after short while "The window is not responding"

Problem: I can open VS code and start typing but after ~30s (sometimes minutes) the window freezes showing this message: I am using python on a jupyter noteboo

ModuleNotFoundError: No module named 'faker'

I am trying to install faker package and I got a message that is successfully installed But when trying the code from faker import Faker, I got a message Module

Matplotlib How to change length of line

Can you please help, how to change my code, so the red line will be longer and connect black point? data.plot(kind = "scatter", x = "Pocet.potvrdenych", y = "Po

how can i convert my sympy code to symengine in python

This code I wrote in Sympy is running slow. I want to write this with symengine. How can I translate? I had some difficulty with the Solve commands. Can you hel

Python FastAPI backend get request path operation function access data saved outside of the function

I am quite new to FastAPI, so I have a question if it is possible to access data within the path operation function, which(data) is stored/generated outside of

No module name 'sklearn.ensemble.forest'

I am using this code to detect face_spoofing import numpy as np import cv2 import joblib from face_detector import get_face_detector, find_faces def calc_hist(

How to switch from the old to the new version of TensorFlow?

I did not use TensorFlow for a while and now, when I was starting to use it again, I have the problem with the first basic line of my code: X = tf.placeholder(n

I want to repeat a function indefinitely [duplicate]

I am working through some exercises on python and my task is to create a program that can take a number, divide it by 2 if it is an even numbe

Recenter plot after set_xdata and set_ydata

I can use the set_xdata and set_ydata functions to update an existing matplotlib plot. But after updating I want to recenter the plot so that all the points fal