Category "python"

Finding the best linear section of data

I have some scientific data and wish to find the best region to fit a straight line in. Theoretically, the data should have a constant gradient but other influe

OpenCV - Correcting Image for Mis Alignment

I discovered the other day that my camera lens or perhaps tilted sensor is causing an object centered in front of the camera to appear off center in the capture

pytorch_lightning.utilities.exceptions.MisconfigurationException when training in pytorch lightning

I am training a sample model with dummy data then i got this error. I have gave everything properly but still i am getting this error: No `configure_optimizers(

Discord.py bot doesn't respond to commands but does on mentions

I have a problem with my discord.py bot. Here's a part of the code: import os, discord from discord.ext import commands from flask import Flask from threading i

How to add a comma after every three digits? [duplicate]

Add a character in between a string How can I add a comma after every three characters in a string? For example, i have a string number = "200

Python | Give list [1,2,3,4] -> return 1*2+2*3+3*4

So as i said in the title, i want to multipy each two neigbors in the list and sum them all - with a single code line. I'm looking for the most elegant and effi

How do you populate package variables when testing a class's method in Pytest?

I'm writing a test suite for a class that needs variables from a util package I have defined: # util/__init__.py codes = None def load_codes(): """Populat

Hello everyone. I would like to solve an optimal control problem by minimizing an integral but I get solution not found. here is the code [closed]

I would like to solve an optimal control problem by minimizing an integral, but I get solution not found. Here is the code. J(u)=\int{0}^{500}

Trying to load data for ml project in jupyter notebook but having issues with dtype

I'm trying to load images into my jupyter notebook but I'm getting this error TypeError Traceback (most recent call last) TypeE

Load new values from another Python script

I have a device which I am controlling in a for loop. I would like to check every iteration if a .txt file has changed. If it has I want to read values and send

How to make fixed ticks for graph using matplotlib [duplicate]

I am trying to make a graph with fixed ticks, regardless to the points values. For example, I want the ticks to be 0-6, and the points values

os.path.isdir() returns false

I'm trying to check if a folder exists by path = r"This PC\Bassel's Note\Internal storage\Audiobooks" print(os.path.isdir(path)) It always returns false even t

Listing files and folder in Sharepoint with Office365-REST-Python-Client responds : 404 not found error

I am trying to list files from a folder. It works with folder name with spaces but doesn't work when folder name contains '#'. I am getting below error office36

Using fstring with nested quotation marks for a xpath - triple quotes didn't work

/!\ The problem here is a f-string problem; I know how to click the "onclick" element in another ways, but I want to understand why it doesnt work THAT way /!\

Stop a function after a thread process is done runnig

i made a little GUI to take input from the user one of the main process is withing a thread and since that command starts there's an event that triggers an endl

Python: Extract r,g,b values from point cloud

I have a point cloud (ply file) with X,Y,Z and r,g,b values only. Here is my ply header file. ply format ascii 1.0 comment generated by pdal element veryex 6245

How to pass python 2d matrix to C function ctypes

I tried to pass my matrix from python to C++ based on ctypes to multiply by 2 but I could not get the result that I want because it says inf instead. C code (DL

Python lxml cannot handle XML element with over 1GB of text

The lxml library for Python can handle extremely large XML files, up to (and over?) 100 GB in size. But can it handle extremely large (1 billion characters or m

Pandas Merging 101

How can I perform a (INNER| (LEFT|RIGHT|FULL) OUTER) JOIN with pandas? How do I add NaNs for missing rows after a merge? How do I get rid of NaNs after merging?

convert a CSV file to JSON file

I am trying to convert CSV file to JSON file based on a column value. The csv file looks somewhat like this. ID Name Age CSE001 John