Category "python"

How can run multiple celery tasks in parallel (by using group)?

I am new to Celery. I want to run demo_task in parallel, but it runs tasks sequentially instead of in parallel. Please let me know if I did something wrong. imp

How to combine winter months that span 2 years?

I have a dataframe p90results that contains daily counts of temperature exceedances from 12/01/1952-12/31/2021. I want to create a plot that sums the daily exc

How to concatenate two columns ignoring NaN?

I have a dataframe: id1 id2 a NaN b c d e I want to create new columns ids as a concatenation of id1 and id2: df.ids = df.id1 + "-" + df.id2

How to import utils from keras_unet

I'm trying to add utils from keras_unet in google colab, but I have a problem. import tensorflow as tfs from keras_unet import utils keras-unet init: TF versio

Using python to calculate 3d points in a plane from a 2D image, having some known locations on the 2D image (homography?)

I'm needing to solve a problem where I have a plane in known 3D space (a court), and I know the coordinates of its corners (and other line intersections). I the

How two processor will share same function

I have this function here that is factoring a number n. Right now I am using two processors to run the same function and as soon as one of the processors get a

How to form tuple column from two columns in Pandas

I've got a Pandas DataFrame and I want to combine the 'lat' and 'long' columns to form a tuple. <class 'pandas.core.frame.DataFrame'> Int64Index: 205482

How to get the dimensions of a word2vec vector?

I have run a word2vec model on my data list_of_sentence: from gensim.models import Word2Vec w2v_model=Word2Vec(list_of_sentence,min_count=5, workers=4) print(

Flaskr tutorial ModuleNotFoundError No module named Flaskr

I am going through the flask tutorial up to the Test Coverage section. And after finishing writing all the test files listed in the tutorial documentation I get

data accumulation with pandas

I'd like to accumulate like this. timestamp id strength 1383260400000 1 strength accumulated by square id1 or id2 == 1 1383260400000 2 strength accumulated by

Wikipedia scrapping problem, how I can get content all tags inside one

I got a problem while trying to scrap wikipedia page. I want to get definition of title, but inside the tag I'm interested in there are many other tags, and I d

How to solve this Python error when inserting list in database?

I'm trying to insert into database a list (that I extracted from a file) with 3 columns: log_time log_type message I used this code: #database connection try:

How to get everything after last slash in a URL?

How can I extract whatever follows the last slash in a URL in Python? For example, these URLs should return the following: URL: http://www.test.com/TEST1 retur

<RandomizedSearchCV> Pass the estimator obtained after fitting to scoring function as a parameter

Suppose I want to do a RandomizedSearchCV with custom both estimator and scorer : RandomizedSearchCV(cxCustomLogReg(), search_space, n_iter=5

How to write a method to check independence which returns a dictionary of length 3

I having some difficulty to try to understand the question and I am not very sure how to get a method to returns a dictionary of length 3. This is the sample ta

TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.I tried answers but did not work

enter image description here test_loss = test_loss / len(test_loader) # average over number of mini-batch acc = 100. * correct / len(test_loader.dat

The circle animation is not displayed with the following code in anaconda spyder. Why?

The circle animation is not displayed with the following code in anaconda spyder. Why? The code is given below. from matplotlib import pyplot as plt from matplo

Export data as xlsx or xls file in python

I am trying to achieve to export data as xlsx or xls format in python. This has to be achieved without any library such as pandas openpyxl etc. Most of the arti

Scrape Job description Indeed Selenium [closed]

A similar subject exists but I couldn't find the exact answer, so please could you help me? I copied from the internet the following code to s

why server shut down?

So I created a server but when I run it, it keeps shutting down. why it happens? import socket my_server = socket.socket() my_server.bind(("0.0.0.0", 8820)) my