Category "python"

How do I update the ssl certificate when running websocket connection? (Alpaca API websocket)

When I'm running below code, nothing happens even though the code should print "opened" , then "received a message" and print the message from the websocket, wh

Consuming API Workspace for Developers

I'm trying to consume Google's Workspace APIs, but I'm having extreme difficulty with the documentation to create my first code, following the first steps I did

About adding a snippet for python in vs code

How to write a snippet for 'main' function in vs code? It's not allowing to put double "" in between the body. Here is what I have written: "Print to console":

How to create sitemap with dynamic sub sitemap structure in django?

I'm trying create a dynamic generate sitemap in django and i hit the wall. Action I'm trying to code: in url.py i have url: re_path(r'sitemap-jobs.xml$'...) the

Scipy linprog constraints not satisfied

I’ve defined a linear programming model using scipy linprog however the equality constraints when I calculate them manually do not satisfy the constraint.

RuntimeError: The expanded size of the tensor (1300000) must match the existing size (80) at non-singleton dimension 0

I have following errors in my RBM code and here is the in raw. ipykernel_18388/119274704.py in v_to_h(self, v) 23 24 p_h = F.sigmoid( ---

Use diffie hellman key exchange algorithm to encrypt and decrypt files in python

I want to implement an algorithm which will encrypt and decrypt files using diffie hellman algorithm but I am unable to find any solution for the same. Here is

O(log n) algorithm in theory runs much slower in practice

The algorithm is for calculating 2^n recursively. I have used the Master theorem to determine that the time complexity is indeed O(log n) which seems to correct

Problem creating dll and loading then in Python ctypes

I want to learn to create DLLs in c++ and use them in python to increase the speed of calculations. To begin with, I tried to create a simple C++ dll and load

Multiple optional command parameters with discord.py

I was looking at asking for multiple optional parameters with discord.py, although I'm not sure how to do it. This is my example, although I'm pretty sure it's

vim select function in python

I am new to vim and recently I learned that it is possible to select a function in c with vip, and I was wondering if there is a way to do it with functions in

Need pandas groupby.count() or groupby.size.unstack() to output a dataframe I can use

So I need to count the number of occurrences of a value per year, per animal. I've managed to do it but it's outputting a single column kind of dataframe rather

what is the encoding method for message like this b'\xf1p&r\

I am testing sslkeylog python package to exact TLS master secret as below. I was successfully get the master_key, however the outoupt is hard to understand. Wha

PyQT how to change layouts size

I am trying to make a GUI that is very similar to Spotify using PyQT I've already designed the main window and I am struggling with applying the design to QT Cr

How can I efficiently bin 3D point cloud data based on point coordinates and desired bin grid size

I have a large point cloud in open3D and I want to basically make a 3D grid and bin the points based on which cube they are in. Other have called it "binning in

How to append parenthesis to the string text in python?

I have one string like "Article created on March 03 2021 for the some user" I want to convert that string to "Article created on (March 03 2021 for the some use

Entire Pandas Column Read in as NAN from read_csv()

I'm having trouble reading in my CSV file with Pandas. It's reading in a stock dataset which contains the Date and OHLCV columns, but for some reason, it's read

How to unmelt a completely melted table

I have this dataframe df which I have melted and then using pd.pivot_table I am able to get the table structure back at least looking at the rows it seems so -

Add variable to URL in Locust test

I'm been trying to figure out how to add a variable captured from a prior 'task' on Locust and add a variable to a new tasks GET request URL. The variable below

How can I make a def function with my "if" statements?

We were asked to make a function named temperature conversions that accepts an integer argument called temperature, a secondary string parameter called input un