Category "python"

API view returning { "detail": "Not found." },

class User(models.Model): user_id = models.CharField(max_length=255, unique=True) mobile = models.CharField(max_length=12) first_name = models.CharF

How to exclude future dates from excel data file using pandas?

I'm trying to limit my dataset to dates before today. Below creates a graph but the mask doesn't have any impact. Any help appreciated. df = pd.read_excel("./da

Plotting Multiple Series of Lines on the Same Plot

I am attempting to graph battery cycling data similar to this . Each line is one cycle worth of datapoints and should be one line on the graph. At first the cod

Python 3.10.2 anti-aliased fonts not smoothing in Tkinter under SUSI Linux

I have a problem with font smoothing AKA anti-aliasing not working. I have provided a small Tkinter test code snippet that shows a grid of Tkinter labels that s

AttributeError: module 'gym.envs.box2d' has no attribute 'CarRacing' / box 2d doesn't install successfully

environment_name = 'CarRacing-v0' env = gym.make(environment_name) AttributeError: module 'gym.envs.box2d' has no attribute 'CarRacing' and i did pip install b

What is the correct OOP way to add functionality to a set of classes deriving from an abstract base class?

Setting My friend told me that in OOP, you generally don't want to modify any abstract base classes in an existing codebase, because that means you have to impl

Why memory usage increases when reopening a Parquet file with pandas?

I generated a Pandas dataframe of 8.481.288 rows and 451 columns, where most of the columns have integer values. When I generate this dataframe, the total memor

Exception when trying to use saved Spark ML model for distributed computations with SHAP

I am having this error Exception: It appears that you are attempting to reference SparkContext from a broadcast variable, action, or transformation. SparkConte

socketio.send() does not send data to client

I am trying to send data from server to flutter app using socketIO. Although I am able to connect and emit, the server is not able to send data to client side.

Pandas pick the higher value for each unique id

I have a df of customers CUST_ID | SEGMENT | AREA 1 | B | CAD 1 | A | RAM 2 | B | CAD 2 | C | RAM 3 | B

Prevent mypy errors in platform dependent python code

I have something akin to the following piece of python code: import platform if platform.system() == "Windows": import winreg import win32api def do_cr

Calculate value based on previous value and multiplication

I am trying to do something which is very simple in excel, but I cant seem to find the way the way to do it in python. I want to calculate the next value in a d

How do I superimpose an image in the back of a matplotlib plot?

I'm trying to superimpose an image in the back of a matplotlib plot. It is being rendered as HTML in a flask website so I am saving the plot as an image before

How to deal with edge cases where fuzzy matching does not return a result?

I have two tables in a MySQL database: address that includes a description field which at most has a city name and a country buried somewhere inside it. There a

How to get pandas to return the row index on which a CSV read error occurs

I have a CSV: '1\n2\na'. If I read it with something like pd.read_csv(io.StringIO('1\n2\na'), names=['A'], dtype={'A': 'float'}) specifying that the first colum

Combining various image channels after gaussian filtering produces white image

I am trying to implement a gaussian filter for an image with dimensions (256, 320, 4). I first generated a gaussian Kernel for the same and then individually pe

Check if substring with leading and trailing whitespaces is in string

Imagine I need to check if in longString = "this is a long sting where a lo must be detected." the substring lo as a word is contained. I need to use the leadi

Flink Python Datastream API Kafka Consumer

Im new to pyflink. Im tryig to write a python program to read data from kafka topic and prints data to stdout. I followed the link Flink Python Datastream API K

printing a board in python

I'm trying to create a chess game in python without uses pygame I know I'm not so far to finish it but I have a problem, I don't achieve to print my board in a

Setting Data Frame Column Names with Data Frame includes extra characters: ('ColumnName',)

I've got a python script set to pull data and column names from a Pervasive PSQL database, and it then creates the table and records in MS SQL. I'm creating dat