Category "python"

Given a matrix, return a list (or generator) of all it's pairwise-neighbors

Let's say i have this matrix: (doesn't have to be squared) a b c d e f g h i I want to return a list, or a generator, of all it's pairwise-neighbors. Meaning:

Is there a way to get win32 file handle from pipe's C file descriptor (python)?

Searched for about 1 hour and still unable to find any relevant search results. I want to wait on multiple pipes in a single thread, but unable to convert the f

How to fill in the blanks for one (or more) columns by calculating based on multiple conditions?

I collect and process hundreds of jumbled tables every day, and some of the data requires attention. (Sorry for my English and typography skills) The item with

How to create a new index level with columns name in Pandas?

I would like to add a new level to the index of a dataframe, based on columns name. How can i do that ? df home city A -0.166809 0.213299 B -0.

groupedby_obj How to select and use data given under a key

Code: grouped_object = cov.groupby(["Continent"]) for key, item in grouped_obj: print('key is: ' + str(key)) Output: key is: Africa key is: Asia key is: Eu

Log into a website using Requests module in Python

I am new in Python and web scraping, but I keep learning. I have managed to get some exciting results using BeautifulSoup and Requests libraries and my next goa

Python type hinting: custom data type

Let say, I want to have a custom type that I call Size. Fundamentally, this type is nothing more than an int. However, I would like to have the following behavi

Django - Show all ForeignKeys belonging to the given ID as a select multiple field

I have this model: class OrderProduct(models.Model): order = models.ForeignKey(to=Order, on_delete=models.CASCADE) product = models.ForeignKey(to=Produc

How to convert RGB percentage to RGB values?

Given the RGB percentages of a color, e.g. "wild watermelon", (99%, 42%, 52%), the right RGB values are (252, 108, 133). But when I tried rgb_percent = ('99%',

Azure durable function - Python SDK - trigger Activity Function from Client Function

I am preparing automation solution in Azure. I decided to use Azure Durable Functions. As per Durable Functions design I have created: Client Function (triggere

Saving data in the table

How I can save this: a=1b=2c=3d=4 into the table like this (I do not need header): 1 2 3 4 Thanks.

How to solve Luhn algoritm

there is a lot of information about how to write Luhn algortim. I'm trying it too and I think that I'am very close to succes but I have some mistake in my code

python3 join lists that have same value in list of lists

I have similar question to one that has been asked several years ago, the link is down here. the thing is that all answers are in python 2 and does work for me.

Discount on a price

So this is my code so far but at the end there i am trying to add a discount option. I am not sure how to add it to multiple products. Please let me know how i

How do I get rid of black bar in python window?

I'm working on a Object Detection project for the game Cuphead using OpenCV and Python. Now I'm trying to capture objects in real time but when the detection wi

right way to deploy a django-rq worker

maybe it's a silly question, but I didn't found much while googling around. So I'm on the way to transform my development environment to a deploy environment. I

Localstack and python and docker-compose strange behaviour

I have created a docker-compose file for localstack and I'm using only services like s3 and SQS. It works fine and I could create a dummy SQS, S3 from localsta

how to remove and replace an element in a list using python

def functionA(): countries = ["Nigeria", "Uganda", "America", "Chad"] print(countries) name1 = input("choose a country you don't like:") for i in range(3):

Cartopy: coastlines not lining up with imshow projection

I'm trying to produce a figure in Python that will line up the map coastlines from Cartopy with a RGB projection using satellite data (POLDER) that is fixed to

Can't find the error in my django project

I am creating a booking website for hotels using Django, I used the booking api to get the hotels with its images and location highlights... I sent to the djang