Category "python"

AttributeError: 'list' object has no attribute 'i_sd'Which function can be used to get values from a Callback Class

The callback is called when specific events occur in an environment (e.g. at the beginning/end of a reset and beginning/end of a step). I have written a stub of

How to save SHA256 object to a file?

(I'm doing all this in python 3.10.4 using pycryptodome) I'm trying to do this process: Get a hash of a file Save that hash somewhere Load that hash and perform

How can I use jinja2 in python sanic?

According to my search. There are two main views: Install and use the sanic_jinja2 Just use the jinja2 But above two methods didn't work to me(Maybe it's my fau

I am running my code on google colab. Am getting RuntimeError: CUDA error: device-side assert triggered.Error is showing for torch.manual_seed(seed)

import random total_steps = 1 seed = 42 random.seed(seed) np.random.seed(seed) torch.manual_seed(seed) Below is the error am getting RuntimeError Traceback (mo

Webscraping sale prices from a grocery store- Am I on the right track or is there a simpler way?

I am new to all of this, and this is my first real coding project so forgive me if the answer is obvious :) I am trying to extract sale items from [my grocery s

Need help finding the smallest number and ending the program with -1

This is what I got: H = int(input("Enter a number or enter -1 to end)")) smallest = H counter=0 while(True): number = int(input("Enter a number: ")) if

Templates do not show image. Django

Here is what i tried to do: in my settings.py: TEMPLATES = [ ... 'OPTIONS': { 'context_processors': [ ...

LabelEncoding a permutation of combination of columns

I'd like to create class labels for a permutation of two columns using sklearn's LabelEncoder(). How do I achieve the following behavior? import pandas as pd im

Python requests library - POST requests takes too long

I have a problem with the python requests library. I try to send a simple POST request to my Keycloak server, to introspect an access token. I tested in in Post

How to use recursion to sum up a list of numbers up until a certain index

I have to write a code that makes use of recursion to sum numbers in a list up until the index is equal to a pre-determined integer value. i.e. list = [1,4,8,

(Pandas, Python) Selecting indices of a parent DF based on shared column values with a child DF

(I recently asked this question on r/learnpython (here), but didn't get any feedback, so am re-posting it verbatim here. Hope that is okay!) Suppose I have a D

KSQL Rest INSERT not inserting

I have created a KSQL table with the following command: ksql> CREATE TABLE CUSTTABLE (id INT PRIMARY KEY, name VARCHAR, purchase VARCHAR) WITH (KAFKA_TOPIC =

Getting bytes written to SQL database for integer column, want integer to be written

I am writing data from a dash app to a SQL database setup by Django and then reading back the table in a callback. I have a column that the value should either

Python rank: give negative rank to negative numbers

I have a basic set of data like: ID Value A 0.1 B 0.2 C -0.1 D -0.01 E 0.15 If we use data.rank() we get the result: ID Value A 3 B 5 C 1 D 2 E 4 Bu

Field value not persisted after import

Model.py class Order(models.Model): customerID = models.CharField(max_length=300, blank=True, null=True) osm_bol = models.CharField(max_length=300, bla

Filter column list based on another column in Python

In Python, I have a dataset like this below, where column1 and column2 are objects and not strings: data = {'id': ['first_value', 'first_value', 'second_value'

Django template language how to fix

Hi I'm trying to build a simple django app but I can't get index.html file to recognise the variables created in views.py. Nothing I do seems to work. Does it h

Name 'model' is not defined

When I input this code print(cross_val_score(model, X, y, cv=3)) An error comes back that reads name 'model' is not defined: print(cross_val_score(model, X, y

Not all edges showing in AtlasView NetworkX

I have the following network graph. # Create the graph with unique edges to check the algorithm correctness G = nx.MultiGraph() G.add_edge('A','B',route='56BM',

Porting python PKCS1_v1_5 encryption code to java but java code not work

I have a backend,which receives codes and returns true or false. I send it codes using my python encryption,it returns true(the result varible): from Cryptodome