Category "python-3.x"

FastAPI: How to use POST data as variable to trigger another script?

I have written an API on FastAPI with filename api.py: from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class Username(BaseMode

Generate multiple new pandas dataframes using lists and for loops

I have the following dataframe: import pandas as pd import numpy as np from numpy import rec, nan df1=pd.DataFrame.from_records(rec.array([(202001L, 2020L, 'app

How to check if all lowercase 'g' in a string has another 'g' adjacent to it?

I need to write a program that returns True/False based on the following conditions: A lowercase 'g' in a string is "happy" if there is another 'g' adjacent to

How to use python to create and modify windows shortcuts

Based on most of the postings I have read, I need to import winshell in order to create a Windows shortcut using python. But I am running Anaconda python and wh

Web based code editor with auto completion

guys I'm building the web based code editor for my personal project.I want to make it work like VS code but facing some issues. I'm using ACE editor. This is wh

Python defaultdict returns None on get, despite being initialized with a default value

I am trying to code a variant of Dijkstra's shortest path algorithm. In doing that, I want to initialize the shortest path distances to math.inf, and have this

How to group overlapping ranges of substrings?

I have a list of dictionary in the following format: ldict = [ {'start_offset': 0, 'end_offset': 10, 'string_type': 'verb'}, {'start_offset': 5, 'end_offset': 1

Which key failed in Python KeyError?

If I catch a KeyError, how can I tell what lookup failed? def poijson2xml(location_node, POI_JSON): try: man_json = POI_JSON["FastestMan"] woman_json

attributeerror: 'AioClientCreator' object has no attribute '_register_lazy_block_unknown_fips_pseudo_regions'

Recently, I have started to occupy the AWS platform, but when trying to occupy Sagemaker, the following error and I don't know if it is because of Sagemaker or

Have broken DAG when try to import MySqlOperator

Trying to compile DAG from Link to AirFlow official documentation Got Airflow dashboard error: Broken DAG: [/ua/sv/airflow/dags/example_mysql.py] Traceback (mos

How to group by values in a column and find time difference using python?

I have a dataframe as shown below: Col A Time Col B Col C 123 2018-01-06 03:45:23 B 1 141 2018-01-08 12:45:55 C 0 123 2018-01-08 11:45:29 A 0 123 2018-01-08 01

how to attach the token to a graphql mutation request?

I create this function to update details of user, before this function I have to login and get the token that I have to use in the next call. I use this for ini

What is the equivalent of reading a jpg file using PIL image?

Using python 3.10. My issue is I read a jpg file as a binary file and I get a bytes array. I have the following code: from PIL import Image def get_image_bytes

How to scrape data from Twitter without its API using BeatifulSoup

I'm currently trying to scrape some data from Twitter, like username, screen name, the content of the tweet etc. But I've run into some problems: I've been tryi

How can I delete via python all the s3 "delete marker" placeholder filtered by "LastModified " (for ex. just from yesterday)?

I modified some scripts to delete all the "delete marker" placeholders from some bucket in s3 but I never found/developed something where I can delete the "dele

Error 409 occurred in telebot when using multiprocessing [exe file]

I want to start another process, it will start, if I write to telegram bot "start". But right after this occurring the ERROR: 2022-04-11 11:16:13,602 (__init__.

Python - Maintain Folder Structures while Zipping

I've got an extremely specific use-case, where I've got multiple folders in a single directory, each of which as subfolders and files, so on and so forth. I nee

convert RGB to black and white

The code snippet in Python should convert the rgb image to black and white, but only a black image output. I do not know where the problem is (input and output

Get word definition/s from google translator using Python

please, I am making my own dictionary and cant figure out how to pull translation definitions from google translate. My idea is that python will open my excel f

Python Dictionary of Fortigate Interfaces to Find Matching Interface to Specified IP

This data is sanitized. Can someone help me with a way to take this source ip, loop through the dictionary "name", "ipv4_addresses" keys for subkeys "ip" and "