2,207,530 questions
Best practices
0
votes
2
replies
13
views
Implementing HTMX in a Django app: Should I use two templates per view?
When trying to integrate HTMX into my Django app, I'm facing a design issue. My base.html file contains fixed layout elements (a navigation bar and a title). I created a container section with the ID #...
Advice
0
votes
5
replies
55
views
How do i fix the print code to give me the grades for 100 students instead of the 100th student
for i in range(1, 101):
score = random.randint(1, 100)
print(f"Student {i}: {score}")
if score >= 80:
grade = "A"
elif score >= 60:
grade = "B"
...
0
votes
0
answers
24
views
Fitting linear regression and computing metrics in python
I have two data series of model prediction and observations. I am able to make line plots of these series. I would like to add a linear regression fit of the two data series. i would also like to add ...
Tooling
0
votes
0
replies
17
views
Applying Kolmogorov-Smirnov (KS) test to evaluate multivariate synthetic tabular data (TVAE/TabDDPM vs. Empirical baseline)
I am benchmarking several tabular Generative AI models (including TVAE, TabDDPM, and WGAN-GP) to synthesize sensor data. I need to rigorously evaluate the statistical similarity between my generated ...
0
votes
0
answers
12
views
Browser not Responsive when using Profile
I'm using NoDriver Python with a chrome profile and I'm running into an issue where the browser some times enters into a corrupted state and NoDriver can't control it.
For example if I run the script ...
0
votes
0
answers
32
views
How can I reliably recover and preserve page numbers from legal-document HTML/PDF text in Python at scale?
I have a Python pipeline that processes legal opinions into structured JSON and rendered HTML. The extraction mostly works, but page numbers are inconsistent across source formats.
I’m trying to ...
1
vote
1
answer
49
views
Can't install pywifi in python terminal [duplicate]
While I was making a project, I realised that I needed the pywifi module to connect to Wi-Fi. When I tried to install it, it said that the word "install" was invalid. How do I fix this?
>&...
1
vote
2
answers
37
views
Why doesn't copy_on_write work when modifying a copy of an entire DataFrame?
With pd.options.mode.copy_on_write = True, the original should not be modified when writing to a copy. However, when I reassign a column of the copy, it affects the original.
import pandas as pd
pd....
Tooling
0
votes
0
replies
15
views
Broadcasting list of pytrees with each other without knowing the prefix a priori
I want to broadcast a list of jax pytrees with each other, where it is assumed that one pytree is the prefix for all others (but we don't know which pytree is the prefix in advance).
The solution I ...
Best practices
0
votes
1
replies
27
views
Looking for Easier Ways to Manage Data Objects with Value-Based Minimum Distribution Requirements
Idea
I want to take a relatively large cache of data (108k items, 80 data points per item) and sift through it to grab items at semi-random and generate small pools of items. Each of the pools need to ...
Best practices
0
votes
2
replies
52
views
FastAPI int model field
I have been trying to learn FastAPI, with a small project and now I need to add a database table with an auto generated int id as a field.
I want to know how to write this id field in Python models ...
-1
votes
0
answers
19
views
Regridding netcdf from lat/lon to Lambert conic conformal regular grid
I would like to regrid variables from a netcdf file defined on a regular lat/lon grid to the Belgian Lambert conic conformal projection (EPSG:31370: X, Y in meters).
The input netcdf file has the ...
0
votes
1
answer
45
views
Avoid re-running tests when using unittest with multiprocessing
We recently upgraded from Python 3.9 to 3.14 and it appears that the default start method for multiprocessing has switched from 'fork' to 'spawn' and it is causing some tests to fail, trying to ...
Best practices
0
votes
3
replies
71
views
Dataclass from dynamically created class
I am trying to create a dataclass from a dynamically created class. I am doing something like
[1] A = dataclass(type("ClsA", (), {"a":1}))
However, the attribute a is not ...
-1
votes
1
answer
70
views
Backend question with CSRF (FastAPI, AuthX, SQLalchemy, Pydantic...)
I'm trying to create simple API with login system and roles. I have a problem with my code:
from fastapi import FastAPI, Response, HTTPException, Request, Depends
from fastapi.responses import ...