Category "python"

How to retrieve all values of a specific attribute from sub-elements that contain this attribute?

I have the following XML file: <main> <node> <party iot="00">Big</party> <children type="me" value="3" iot="A"> &

Generate colored image in Python using ndarray

I am using the following code to generate a colored filter on an image in Python. However, it gives me a full green/blue/red image. I want to decrease the inten

How can I handle multiple lines at once while reading from a file?

The standard Python approach to working with files using the open() function to create a 'file object' f allows you to either load the entire file into memory a

How to read excel file with multiple sheets from python? I got error saying 'pandas' has no attribute 'excel'

At first, I wrote: import numpy as np import pandas as pd import glob all_data = pd.DataFrame() for f in glob.glob("*.xlsx"): df = pd.read_excel(f) all_

Is it more profitable to read files too large line by line or read all files in one step with pandas Dataframe, maybe?

I have run my script in an instance of 18Gb of ram, 4 CPU, and 20 Gb of a disk in both use cases My use case is (read line by line): Read line by line and proce

Can I use a python argument in a postgres variable for a query call?

I want to create a python function that takes a start date and end date as arguments. I want the dates passed to the function to be the start date and end date

LAB: Output values in a list below a user defined amount

Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the las

ModuleNotFoundErrer: PySide2 installation problems

I want to run a project which invovles PySide2 using Visual Studios. I have installed it using pip install PySide2 and the installation worked. But if I want t

Perceptron and classification task

There is data and a classification task: from sklearn.model_selection import GridSearchCV from sklearn.preprocessing import label_binarize from skle

How to write text on top of rectangle instead of below?

I'm trying to create a rectangle with text on top, but the text shows below the rectangle. How can I make the text go to the front layer? My code so far: from t

What happens if I using 'env.process()' whenever I need it?

I'd like to have a bed cleaner only when necessary. The error does not occur as shown in the code below, but the result is not accurate. Increasing or decreasin

remove outliers from df based on one column

My df has a price column that looks like 0 2125.000000 1 14469.483703 2 14101.832820 3 20287.619019 4 14469.483703

How to solve the problem with installing google colab?

Tried to solve a simple problem from google.colab import files import numpy as np file = files.upload() !ls my_array = np.loadtxt('train_vector.csv', delimi

PDF file sent from flask to client is empty when downloaded

I have a flask server that sends a pdf file with the send_file function. When I test this route on postman I can view and download the pdf. However when I try t

snowsql - tls_process_server_certificate

New to snowsql. Installed snowsql and ran the command snowsql -a <account_name> -u <user_name> and that failed with below error: 2022-04-28 18:50:5

Calculating a difference for groups within dataframe

I have a dataframe structured like the example, df, below. This contains 2 variables, time and state. Since these are repeated observations for identity, I want

How to run these Coral AI models inference in a computer rather than on the TPU?

I have the Coral AI usb TPU and I have succesfully run the Getting Started example, deploying the already compiled / trained example model (image classification

Add a column based on a condition that iterates over a list

So I have the following dataframe: Person_x Person_y Apple_x Banana_x Orange_x Apple_y Banana_y Orange_y Tomas Sidd

Error when trying to print string with multiple lines

I'm trying to make a tic tac toe game in Python but whenever I try to print the board, I get a weird error. Here is my code: import os from colorama import Fore

Dask looping over library function call

Goal I would like to parallelize a loop with dask that uses a library function inside the loop. This function, mhw.detect(), calculates some statistics on a sli