Category "python"

Calling function from for loop - issue with parameters: NameError: name 'row' is not defined

I am calculating commute distances (home to offices) for all employees. This works for a single office with this piece of code: #Calculate distances from home t

Extract heading and content from an HTML page using a visual approach in Python

I'm looking for a way to extract the heading and content from raw HTML. There are a couple of Python packages out there which does this (Newspaper3k, python-rea

How to replace jupyter-notebook magic with python script

I have been using some jupyter notebook magics such as %matplotlib inline. How to load them using python script instead of % signs. Using jupyter %load_ext sql

Evaluating strings without eval()

In Python, can I evaluate a string (eg. “math.sin(3)+max(5,3)”) without using the dreaded eval(), and preferably with Decimal precision? Note: it is

Nested bar plots with three y axis using seaborn package

Using the python seaborn package I was trying to plot the nested bar graphs with three different y-axes as shown in the below figure: And the code that I have

group time stamps based on intervals

I have a dataset that looks like this: main_id time_stamp aaa 2019-05-29 08:16:05+05

asyncio.run() cannot be called from an event loop

I'm trying to call a function in async function and the problem is asyncio.run() don't work in a loop event Here is the RuntimeError: asyncio.run() cannot be c

Function not executing in telethon

If I start the client at the beginning of the script api_id = 123254534 api_hash = '124324235543' client = TelegramClient('parslon', api_id, api_hash) client.st

Check if number should be C++ float or C++ double using python

I am working on a simple C++ code generator created by excel parsing and I will need to distinguish between number type. I can deduce integer size (e.g. uint_32

Django CreateView object.id in get_succes_url pk(id) is NONE and then after redirecting to another URL it prints out created entry ID

I have a problem that I just can't figure out. After creating a work order I want to redirect to the detail page of that work order. Here is my models.py class

Can't access DataFrame elements after reading from CSV

I'm creating a matrix and converting it into DataFrame after creation. Since I'm working with lots of data and it takes a while for creation I wanted to store t

how to solve this errorss?egg_info?

Collecting playsound Using cached playsound-1.3.0.tar.gz (7.7 kB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error × p

my kivy app is all right on my computer, but don't show its content on my phone

My kivy project can run correctly on my computer, but if I use package logging to log, the project will not start application main loop on my phone. The followi

How to store data into a model associated with the current user?

In my frontend i'm logging into another app's api in the browser, I'm then redirected back to my app, that hits a View in my backend which gets a code from the

How to resolve the following error in discord.py: "TypeError BotBase.__init__() missing one keyword-only argument: 'intents'"

I am using the following code to run my discord bot: bot=commands.Bot(command_prefix="!") However, when trying to run it in vscode, I get the following error:

OpenCV warpAffine error during image augmentation using Albumentations

I have been trying to do image augmentation using a library called Albumentations. But I got some error from OpenCV while transforming the images. I ran the cod

Pygame installing but not running

I've uninstalled and reinstalled pygame multiple times using pip3 install pygame and it installs fine, but when I try to import it, it gives me a ModuleNotFound

how can I loop through search function - python

I am trying to make search program but I stuck in some loop part. There are several steps for function works. First, I will get a word(input) from users. Then,

Why win32com doesnt show me all emails

I want to parse emails in python through the Outlook application. Running this code I get only a few of my emails. import win32com.client outlook = win32com.cli

Why doesn't python3's print statement flush output when end keyword is specified?

from sys import argv, stdout as cout from time import sleep as sl print("Rewinding.......",end = '') # If end is given output isn't flushed. But why? cout.flush