Category "python"

How to include JSON and File data together in FastAPI endpoint?

I would like to POST JSON and File data together, as shown in the code below: fastapi.py @router.post('/rate') def users(user_review:schemas.Rate, image123: Upl

401: Unauthorized when trying to fetch Discord OAuth2 access token || Python 3.10

So I came to the idea one day to make a bot dashboard (it currently includes a rickroll and a pointless button). I watched some tutorials talking about how to g

What are dictionary view objects?

In python 2.7, we got the dictionary view methods available. Now, I know the pro and cons of the following: dict.items() (and values, keys): returns a list, s

can I define data filters with intake catalogs?

I would like to use intake to not only link to published datasets, but filter them in the catalog itself. Filtering is trivial to in python once you open the da

New color terminal prograss bar in pip

I find the new version pip(package installer for Python) has a colorful progress bar to show the downloading progress. How can I do that? Like this:

Problems matching values from nested dictionary

In TestRail, I have created several testruns. When I execute: test_runs = client.send_get('get_runs/1') pprint(test_runs) The following results are returned:

I can't run pipenv install django

Whenever I enter pipenv install django in the cmd an error appears: " 'pipenv' is not recognized as an internal or external command, operable program or batch f

How can I edit this code so that it prints the result a certain way?

I'm trying to get this code: line = input("String: ") letters = "" words = line.split() for word in words: letters = letters + word[0] print(" ".join(letter

Python, Convert Arbitrary List of Floats to Decimals with Most Precision without Rounding Errors

I'm writing code that has to take a bunch of floats in Python and convert them to decimals without any rounding errors but with as much precision as possible. I

Bloom, Cuckoo filters are too big for numbers

I'm trying to use bloom/cuckoo filter to check if i already stored a tuple of 2 numbers f.e. (7,25), (47,1576), ... etc In [12]: from cuckoo.filter import Scala

Dash use html.button for export csv with filter

i'm quite new in dash. I try to create a simple dash with a filter, and an export button. My data are simple: I have two Bank, with two app (one Android, one Ap

How to join all columns in dataframe? [duplicate]

I would like one column to have all the other columns in the data frame combined. here is what the dataframe looks like 0 1 2 0 123 321

I want to asyncronous blink a led during wifi connection micropython board

I have two co-routines. I start led blinking and wifi connection, but after wifi connection is complete i want to stop led blinking function. Led blinking funct

How to install Google Cloud DLP on Mac M1?

I am trying to download Google Cloud DLP on my Mac M1 running macOS Monterey. I am using Python 3.10.4 and pip 22.0.4. I first tried using pip install google-cl

How do I preserve search result in Django pagination

I am new to Django and I have develop form with Country and State field from the Profile Model. If I search for country and a particular state, I want a list of

For loop doesnt execute for all instances - OS Module Python

The code below reads the first 4 letters of a filename, and if a folder with those 4 letters exists then it shifts that file to that folder. Otherwise, it creat

How to filter the elements from nested lists composed of strings

I am trying to access elements from the nested lists. For example, file = [["Name","Age","Medal","Location"],["Jack","31","Gold","China"],["Jim","29","Silver","

How to print data if only matching string found in list?

key_word = ["apple","Apple","Boy","boy"] title1 = "Where the boy" title2 = "The Boy playing cricket" title3 = "hello world" title4 = "I want to buy apple vine

How to color a grayscale image based on a mask?

I have two images: A grayscale image, and a binary mask with the same dimensions. How do I color the image on the mask, while the rest of the image remains gray

Configurable mapping file python

My company is consuming an API that will give us large JSON objects. The API response info may be in dif fields based on query parameters (it's a 3rd party aggr