2,206,484 questions
1
vote
1
answer
40
views
One aync lock call or multiple async lock calls, what is better and safer in Python?
I trying to make ratelimiter for users in aiogram bot with middlware, now I created class for requests and class for ratelimiter, where reuqest are. My problem is what is better for performance and ...
0
votes
0
answers
7
views
Loading pytest fixtures from separate Poetry package
I am trying to move some test configuration into a common Poetry package to avoid repetition of the same fixtures.
In a project there is a package named user-service with tests folder inside. Inside ...
5
votes
1
answer
254
views
Unable to use webbrowser.open in PIL: Exception: fromstring() has been removed. Please call frombytes() instead
I'm working on a simple CV project making use of SimpleCV on Arch Linux. Displaying images and feeds through the repl in individual windows works fine, however using a browser for displaying does not ...
10
votes
1
answer
9k
views
import cv2 works but import cv2.cv as cv not working
I think the sys path is correct, cv.pyd and cv.pyd reside in c:\OpenCV2.3\build\Python\2.7\Lib\site-packages.
>>> import sys
>>> sys.path
['', 'C:\\Python27\\Lib\\idlelib', 'C:\\...
1
vote
1
answer
57
views
How to make the try except function easier to read - Python 3 [closed]
import random
chars = list('abcdefghijklmnopqrstuvwxyz1234567890')
password_char_list = []
password = ''
while True:
try:
password_length = int(input('Give the length of the password: '))...
2
votes
1
answer
110
views
Drawing LaTeX image in pyside6 using TextObject
I want to draw rendered LaTeX in a pyside6 application using TextObjectInterface where an object is stored as TextObject and LaTeX is painted on it. I wish to avoid TextImage as it works but there is ...
Advice
0
votes
4
replies
53
views
Why the R^2 value of test data is significantly different from R^2 value of train data?
I am working on a dataset for Housing pricing prediction problem. While I am trying to find an estimation between the features and the dependent variable price, I found there is a significant ...
Advice
0
votes
0
replies
15
views
Python code in train.py how to update it into confusion matrix
I have a project on iris classifier, I have done most of the steps but I am stuck. How do I:
1 Update the Python code in train.py so that it can:
Save the confusion matrix as a PNG image in an outputs/...
3
votes
3
answers
5k
views
How to round up timedelta by seconds?
I am trying to get time measurement of my script in format HH:MM:SS. datetime.timedelta does not have a strftime function. I want to get rid of the microsecond indication. duration is a timedelta ...
-2
votes
0
answers
74
views
Why does my model keep getting stuck in one spot? [closed]
Problem Description
The RL code implements a Gymnasium-compatible environment (DoomEnv) for training reinforcement learning agents in DOOM Retro. It captures game state (observations) via shared ...
22
votes
8
answers
68k
views
Resource punkt not found. Please use the NLTK Downloader to obtain the resource: >>> import nltk >>> nltk.download('punkt')
I have NLTK installed and it is giving me an error:
Resource punkt not found.
Please use the NLTK Downloader to obtain the resource:
import nltk
nltk.download('punkt')
For more information see: https:...
1
vote
2
answers
125
views
How can I set a placeholder (sentinel) without using None?
I have a value that always needs to be defined but may not always be meaningful, and I need a placeholder for when it doesn't yet have a meaningful value. Usually, I would use None as that placeholder ...
10
votes
3
answers
137k
views
Error 'AttributeError: 'DataFrameGroupBy' object has no attribute' while groupby functionality on dataframe
I have a dataframe news_count. Here are its column names, from the output of news_count.columns.values:
[('date', '') ('EBIX UW Equity', 'NEWS_SENTIMENT_DAILY_AVG') ('Date', '')
('day', '') ('...
1
vote
2
answers
8k
views
How to handle and convert images with extension .nii.gz?
I have always work with images with extensions .png, .jpg, .jpeg Now, I have seen medical images with extension .nii.gz
I'm using python and I have read it with the following code:
path = "./...
2
votes
3
answers
2k
views
Getting data from World Bank API using pandas
I'm trying to obtain a table of data obtaining just the country, year and value from this World Bank API but I can't seem to filter for just the data I want. I've seen that these types of questions ...