Category "python"

Python Knapsack problem - using the average value of the selected items as a constraint?

I'm still relatively new to python so I'm having trouble figuring out how to accomplish a certain feat. What I'm trying to do: I have an Excel file with two col

403 when requesting Image URL in Python - works locally but not on PythonAnywhere

I'm trying to write a twitter bot using Python that just tweets images on a schedule and selects a random one from an array of URLs. I'm hosting the images on i

How to modify byte strings?

Let's say I have the following ELF file in python: >>> data=open('file','rb').read() >>> data b'\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x0

GlobalAveragePooling1D equivalence with Lambda Layer

Is the GlobalAveragePooling1D Layer the same like calculating the mean with a custom Lambda Layer? The data is temporal, so x has shape (batch, time, features)

Sawtooth validator is not registering a custom transaction processor. Logs 'No Handler for that type' message

I am trying to build a custom transaction processor for sawtooth but I have run into a wall and since then have been stuck there. I created a sawtooth test netw

Create a Tensorflow Dataset from a Pandas data frame with numerous labels?

I am trying to load a pandas dataframe into a tensor Dataset. The columns are text[string] and labels[a list in string format] A row would look something like:

ARIMA model not working properly in new statsmodels ARIMA for python

Earlier I used to use from statsmodels.tsa.arima_model import ARIMA model = ARIMA(log_air_passengers, order=(2, 1, 0)) results_AR = model.fit(disp=-1) plt.p

How do I draw a pattern of shapes using the Tkinter Canvas?

Essentially, i have a polygon shape drawn out in my canvas, and want to duplicate it so that it fills up the entire canvas. I am quite new to programming in gen

Serverless Python Local Module Not Found

I am looking to import my local python module file into my handler file in my serverless project, but despite this local file being located in the parent direct

Python dataclasses inheritance and default values

Given the following hierarchy of python dataclasses: @dataclass class A: a: str aa: str @dataclass class B(A): b: str @dataclass class C(A):

Dividing values in columns based on their previous marker

I have the following dataframe: df = {'id': [1,2,3,4], '1': ['Green', 'Green', 'Green', 'Green'], '2': ['34','67', 'Blue', '77'], '3': ['Blue', '45', '9

Python Flask_restplus flash_restx dynamic marshalling response

Is it possible to dynamicaly modify the marshalled response model (ie : change fields list, add mask, ...) ? ex : from flask_restplus import Resource, fields m

Python transform and filter list with for / if

Is there a way to both transform and filter in a single list comprehension, i.e.: def transform(el): if some_condition(el): return None return

How can I keep track of the information of multiple objects where there are various events in Simpy?

I tried to build a simulation model as below, but I got error. Here's my scenario. I have two big areas of hospital. EU (EU1 and EU2) IU (IU1 and IU2) Each bi

Python Selenium Chrome - Message: unknown error: cannot parse internal JSON template: Line: 1, column: 1, Unexpected token

This code works on two PCs but throws an error on another one. webdriver_path: str = os.environ.get("WEBDRIVER_PATH") chrome_user_data_dir: str = os.environ.get

How to specify a BaseSettings Config's env_file based on a field from the same class?

I want to implement this logic from pydantic import BaseSettings class Settings(BaseSettings): ENVIRONMENT: str = 'local' SECRET_KEY: str = 'someke

getting Fatal error in launcher: Unable to create process using '"c:\python37\python.exe" "C:\Python37\Scripts\pyrcc5.exe"

So i'm a beginner at machine learning and i want to try out this project i found it youtube (link here) but the problem is when i get onto the step where i do p

Django 404 error-page not found, how can I solve this problem?

My project is named main, and when I runserver I get this error.Anybody have any clue how to fix this error. Page not found (404) Request Method: GET Request UR

Discord Python bot - Coroutine never awaited

I'm trying to make a Blind-test bot game in Python, which actually works pretty fine. I managed to get a whole spotify playlist in the queue with that play_next

Python Zybooks lab function definition input

I have a zybooks lab with the prompt: Write a function max_magnitude() with two integer input parameters that returns the largest magnitude value. Use the funct