Category "python"

Django automatic file-upload: [WinError 123] The filename, directory name, or volume label syntax is incorrect C:\\path\to\folder\C:

I'm pretty new to Django and I'm working on a project in which I have to automate PDF file uploads from a given folder to a model in Django and these files will

JSON: Trouble editing a JSON file in Python

What I want to do is remove the array containing "Nike" under the "Shoe" variable. Here is the Json file: { "Shoes/Colorways": [ { "

How to write a python computer program that will take any valid arithmetic expression as a string and will output a list(or array of string)? [duplicate]

How to write a python computer program that will take any valid arithmetic expression as a string and will output a list (or array of string)

pyspark recover for an even number the two values ​of a median

Is there a way i pyspark to recover for an even number the two values ​​of a median ? For exemple: I have this dataframe df1 = spark.createDataFrame

How to write if else inside an if...else statement in python?

i am new to python and in this code i want to check if bid_data[8] not equal to '' then the below code runs otherwise only bidno = bid_data[0].split(":")[-1] sh

What is the most precise delay/sleep function in python

I was making an auto-clicker which has a cps of about 1500, to tune the cps to about 100-1200 cps I need a delay of accuracy about 1ms. Through my experimentati

Python Ctypes - loading dll throws OSError: [WinError 193] %1 is not a valid Win32 application

I have tried to run an exemple of a python code that gets a function from a library using ctypes. The exemple can be found here. I followed the instruction and

Python ThreadPoolExecutor is faster than a loop for CPU-bound task. How come?

Recently I've been working on a project, and found behaviour that I don't understand. We have endpoint that fetches documents from mongodb and then applies tran

"pywhatskit" on python not sending message

Using the module pywhatkit you can send messages on WhatsApp, I used the script: import pywhatkit as w w.sendwhatmsg("xxxxxxxx", " this is a generated msg",9,2

How to convert .py to .exe and run as a background function on windows while retaining args?

I'm looking to run a python script that calls commands through subprocess depending on various arguments that are given to it. For ease of use it would be valua

openAI DALL-E ModuleNotFoundError

I installed DALL-E following the instructions on https://github.com/openai/DALL-E and got : ---> 10 from dall_e import map_pixels, unmap_pixels, loa

How to specify a proxy in transformers pipeline

I am using sentiment-analysis pipeline as described here. from transformers import pipeline classifier = pipeline('sentiment-analysis') It's failing with a con

Pandas cannot open an Excel (.xlsx) file

Please see my code below: import pandas df = pandas.read_excel('cat.xlsx') After running that, it gives me the following error: Traceback (most recent call las

Count occurrences within a specific range

I have a data frame that looks like this: Tag 0 skip_1 1 run 2 skip_1 3 run 4 skip_1 5

How do I convert numpy.datetime64('2022-04-20T00:00:00.000000000') to datetime.date(2022, 4, 04)

I have a column df['Date] which is a datetime64[ns] type and after doing the sheets= sorted(df['Date'].unique(), reverse =True) I get a numpy.datetime64('2022-

Missing argument is required | Discord.py

I tried to make an command which displays mentioned users avatar. This is the code: @client.command(aliases=['av']) async def avatar(ctx, *, member: discord.Mem

Scipy minimize returns a higher value than minimum

As a part of multi-start optimization, I am running differential evolution (DE), the output of which I feed as initial values to scipy minimization with SLSQP (

selenium twitter login without new device notification

Is there a way to log in to twitter with selenium/python without getting the notification "login from a new device" on Twitter? Current code is import urllib.re

Lists stored as values in a dictionary of variable length - how to access all the last list items?

What is the most efficient way to access all the last list items of lists stored in a dictionary? Please note that I am looking for a solution that works indepe

Syntax Error when deploying django on apache2

I am trying to host a django application on a server using apache2 and mod_wsgi. The project itself is located at the path /usr/share/django-projects/mysite The