Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [python]

Python is a dynamically typed, multi-purpose programming language. It is designed to be quick to learn, understand, and use, and enforces a clean and uniform syntax. Note that Python 2 reached end-of-life on January 1st, 2020. For version-specific Python questions, add the version tag (e.g. [python-3.x] or [python-3.9]). When using a Python variant (e.g. Jython, PyPy) or library (e.g. Pandas, NumPy), please include it in the tags.

0 votes
0 answers
4 views

Calling module from jupyter notebook inside of poetry project reults in 'No module named' error

I'm working on a module with poetry with a directory structure like ./ /my_module (module files) /tests test_thing.py /jupyter demo.ipynb In the test files and jupyter ...
learnvst's user avatar
  • 16k
0 votes
0 answers
5 views

Python seaborn kdeplot - how to use background image

I have been recording the xy cordinates of the ball bounce location on a tennis serve. I am just using this data to play around with different visualisations, and keen to try a heatmap using seaborn (...
Marc01's user avatar
  • 3
0 votes
0 answers
6 views

TypeError: 'NoneType' object is not subscriptable while fetching information for rejected reason from jira

for issue in issues: fields = issue['fields'] results.append({ 'key': issue['key'], 'summary': fields['summary'], 'description': fields['description'], '...
anurag's user avatar
  • 11
0 votes
0 answers
6 views

removal of lines in an image using Python

I am trying to use Python and cv2, numpy, skimage, etc to remove a 'shadow line' from a black and white image if one exists in the image. Essentially my image can have 1 or 2 curved lines like the ...
digital1's user avatar
0 votes
0 answers
6 views

Using pymongo installed via virtualenv and Ansible returns an error

Since it's good practice to install pip modules in virtual environment, I have the following task in place: - name: Install python packages ansible.builtin.pip: name: - pymongo ...
matteo-g's user avatar
  • 329
0 votes
0 answers
4 views

Getting NAN in Tensorflow weights and biases. How to troubeshoot?

I have input data (x,y,v) each with the shape of (200,10000). I.e. I have 200 samples where x,y and v are of size (10000,). The code basically predicts velocity by getting x and y as 1D array. I ...
user_04248753498's user avatar
0 votes
0 answers
14 views

What to do after cross validation?

After using cross-validation to see how a custom predictive function performs on unseen data, I applied to function to the original dataset, and the performance (based on coefficient of determination) ...
Beginner's user avatar
0 votes
0 answers
4 views

Unet from segmentation_models_pytorch stalling in training

I have been following a tutorial on training a segmentation model on a custom dataset, but it refuses to make any progrees in training the model. This is my model setup import ...
Mushanya's user avatar
0 votes
1 answer
15 views

assign rank and maintain sequence across duplicates

I'm assigning an incremental rank based on a value, but need to assign the same rank to duplicate values and maintain the overall sequence. Instead of this: Value Rank 400 1 500 2 175 3 250 4 ...
map cowboy's user avatar
0 votes
0 answers
7 views

Python async_playwright

Ich schreibe ein Programm was von der ilovemusic Website die Streams abspielen soll. Das funktioniert auch. Nur das Problem ist wenn ich die Scraper Klasse in der main.py aufrufe über scraper_task = ...
Tarzan's user avatar
  • 1
0 votes
0 answers
12 views

auto-py-to-exe expected str, bytes or os.PathLike object, not NoneType

I'm using auto-py-to-exe to convert my django project in an exe file but I couldn´t: Traceback (most recent call last): File "C:\Users\gerar\AppData\Local\Programs\Python\Python312\Lib\site-...
Gerar's user avatar
  • 1
-1 votes
0 answers
10 views

pickle serialization not persisting after closing program

Ive made a program to track my barbell lifts. The code I've shown below is opening up a serialized pickle dictionary called users, and if users is empty it prompts the user to create a profile. import ...
Matt's user avatar
  • 1
0 votes
0 answers
16 views

What is the most efficient way to multiprocess over a very large dataframe?

I have a large Dataframe that I need to do a lot of matching operations over, and in the past have always used the below method for doing it. However, the Dataframe that I am currently attempting to ...
Zach Frank's user avatar
0 votes
0 answers
8 views

hosting a flask app in AWS lambda with API requests from teams bot

I am trying to host a teams bot on AWS, the message endpoint is set to the api gateway from the lambda function. The goal is for it to just send "message" back, however upon testing it gives ...
Ryan Chan's user avatar
0 votes
0 answers
12 views

Python: trying to access instance attributes in self.__setattr__

I was trying to create a dataclass with shorter aliases for longer fields. Since I wanted to be able to add new fields (with long and short names) without having to write a @property decorated "...
Lukas's user avatar
  • 498
4 votes
2 answers
28 views

How do I categorize projects in a dataframe according to its title?

I have a dataframe where I want to categorize energy releated projects in 4 different topics according to its title. For that I want to use pre-defined keywords to identify which topic the project ...
Barbara Bressan Rocha's user avatar
0 votes
1 answer
16 views

Why does my Pydantic model contain an extra attribute when popupated from an object with extra=ignore?

The title says it all: Why does my Pydantic model contain an extra attribute when popupated from an object with extra=ignore? from pydantic import BaseModel, ConfigDict # pydantic 2.4.2 class Test(...
Joe's user avatar
  • 6,963
2 votes
1 answer
27 views

for j in os.system("ls *.out") Doesn't iterate. Changing the name of files depending on extension

I am trying to write a script that will help me run a model several times changing the input of one value of the input files. The model over writes the output files so I need to rename the outputs ...
Rafaella Chiarella's user avatar
0 votes
0 answers
30 views

Column value lookup based on multiple conditions and wild cards

I have a dataframe: df = pl.DataFrame({'Col1': ['a', 'a', 'a', 'b', 'b', 'b', 'b', 'aa', 'aa', 'aa'] , 'Col2': ['c', 'd', 'e', 'c', 'd', 'e', 'f', 'd', 'e', 'f'] ,...
Greg Vaysman's user avatar
2 votes
1 answer
17 views

Attempting to put data from database onto dashboard in Django

So I am following this guide: https://www.youtube.com/watch?v=_sWgionzDoM and am at around 55 mins so far I have the login stuff all working however I am unable to get the dashboard to show my data ...
John.R's user avatar
  • 23
0 votes
0 answers
17 views

Matplotlib contour line without drawing

I am trying to compute the contour lines of a numpy NDarray. However, I do not want to plot them but simply to do some analysis with the obtained lines. So far I managed to get a very similar result ...
Giancarlo Mattia's user avatar
1 vote
1 answer
16 views

Maximizing sum of signed numbers by not skipping more than one consecutive value: DP goes wrong

I am trying to solve this code challenge: A user maintains a list of negative and positive ratings for movies in a collection. The user wants to choose some subsequence of movies from the collection ...
R M's user avatar
  • 11
1 vote
1 answer
8 views

How to add trigger for run dag into another dag (with decorators) in Airflow?

I got 2 dags in same dags folder: dag_update_database (dag_update_database.py) dag_add_client_loyalty (dag_updade_clients_loyalty.py) I need run second dag right after successfully run first dag. I'...
John Doe's user avatar
  • 327
0 votes
0 answers
11 views

Can't get form elements to align properly using pymupdf and reportlab

I'm writing a program that takes form files and turns them into interactive PDF forms by using markers to locate and draw form elements. I've gotten my radio buttons to align on the page properly but ...
 BurgundyE30's user avatar
0 votes
0 answers
17 views

Python griddata() and Matlab griddata(): different results at some grid points

While converting some (pretty big physics) Matlab code to Python, I have stumbled upon this situation. Python/Scipy's griddata() function gives different results than Matlab's counterpart griddata() ...
Lit_try's user avatar
1 vote
1 answer
21 views

TypeError: the first argument must be callable - self.job_func = functools.partial(job_func, *args, **kwargs)

I seem to be experiencing an issue with the following Python Scheduler tasks. I have the below code which has a function to refresh all workbooks in a set bunch of directories. I have attempted to ...
MBrann's user avatar
  • 235
0 votes
0 answers
12 views

How To Register Model For Admin Page in Core App?

I defined a model (File) in core app(uploader) and tried to register it for admin page but didnt work. then i tried adding core apps name to installed_apps in setting . after that admin page shows ...
Moeid's user avatar
  • 1
2 votes
0 answers
6 views

Method `new_page` of `BrowserContext` doesn`t work as expected in `Playwright`

I use playwright with pytest. Here are content of my coftest.py file and file with tests test_keplr.py. For some reason, method new_page works as expected in fixture context_use_args_async, but fails ...
blnk.off's user avatar
-2 votes
1 answer
18 views

time.perf_counter() or time.perf_counter_ns() giving weird and incorrect values

enter image description here I have written this simple while I was working with multi-processing. Well, everything in my code was going perfectly, except the time.perf_counter() giving like 7000 ...
Yeasin Al Yeasa's user avatar
0 votes
0 answers
27 views

How do i check specific values in columns in csv

I am working on a project and need a login system that can verify the username and password. The usernames are stored in column 2 and passwords in column 3. The code below checks the rows? I could not ...
Rongan Deka's user avatar
0 votes
0 answers
27 views

Python requests.get() call returning no data

I'm making an API call to a web service in OTRS via Python's requests library. I know the request is valid since I tested it with curl and it works. However, when I add the parameters in a dictionary ...
AmberT's user avatar
  • 11
0 votes
0 answers
12 views

What's the simplest way to annotate a function/method parameter to accept an overlapping Union of types?

In all my functions that allow an overlapping union of types, I already have special handling that checks all parameters to ensure that there are no types which don't support operations with each ...
I Like Python's user avatar
0 votes
0 answers
16 views

Does Image.fromarray works only with numpy.array objects?

That's a simple question, but I'm using numpy for the first time so I'm quite confused. I think I understand the how should it works: my function named img_PILarray below creates an array object ...
gravy's user avatar
  • 1
-3 votes
0 answers
25 views

Pyinstaller not installing due to "externally managed enviroment" [duplicate]

So I've just finished making a game in pygame and I wanted to publish it, you would think this is simple however, on running the command: sudo pip install pyinstaller I get the error: error: ...
Luka22r's user avatar
0 votes
1 answer
40 views

Numpy 2 has a separate float64(nan) - how to get rid of it?

It appears that Numpy 2 introduced its own separate float64(nan) - different from np.nan. Now regression tests fail because while >>> np.nan is np.nan True we now have >>> np.nan is ...
sds's user avatar
  • 59.5k
0 votes
0 answers
11 views

Python monorepo packaging, using Poetry

I want to organize my Python source code into a monorepo, with the below basic structure: projectrootdir - libraryone - pyproject.toml - README - src/orgname/libraryone - __init__....
shyam's user avatar
  • 6,731
-3 votes
0 answers
26 views

How much space does Pygame take up? [duplicate]

This isn't a coding problem, but I was just wondering. How much space does Pygame take up? I was just downloading Pygame, but then thought to myself about this. I mean, I am a bit concerned. It may ...
Mohammed H.'s user avatar
0 votes
0 answers
26 views

how can i get the value that is displayed when printing a np.float32 value as float? (or int)

I am loading an openEXR files that I have rendered int values into. Of course they are stored as float32 internally, which can/will cause issues. But here i am a bit stumped. When I load the values, ...
Marcel 's user avatar
  • 121
0 votes
0 answers
7 views

Hysteresis modelling as a control constraint for MPC in Python GEKKO

I am trying to introduce a hysteresis constraint in an MPC optimization problem for control signal dispatch using Python GEKKO. This has become a daunting task as I am unable to transform the ...
Jean Pierre Dib's user avatar
0 votes
0 answers
7 views

Virtual Environment Packages Affecting Global Environment: How to Resolve the Issue

I recently bought a MacBook Pro with an M3 chip and started my first Python project. I created a virtual environment and installed some packages there, which allowed my code to run correctly. However, ...
Yashvardhan Thakker's user avatar
2 votes
1 answer
16 views

Plotly updatemenus - Only update specific parameters

I'm looking for a way to have two updatemenu buttons on a plotly figure. One changes the data and the y-axis title and one switches from linear to log scale. Broadly the code below works but I lose ...
Sobigen's user avatar
  • 2,159
0 votes
0 answers
19 views

How do I transfer the time from the local time zone to a specific one?

I want to execute the function at 08:00 Yerevan time, but by default it will be executed at 08:00 local time, depending on the location of the server. In the future, my server will be moved to ...
Aleksey Kostitsun's user avatar
-1 votes
0 answers
9 views

KeyError scraping with Beautiful Soup

I am trying to use beautiful soup to scrape data, I have a .env file with ENV, API_KEY, AND SEARCH_ENGINE_API identified. For some reason I am still running into a KeyError. Here are my errors: FAILED ...
WhyBless's user avatar
0 votes
1 answer
21 views

Reuse overloaded method in python class with most parameters

I have LCD class which is run by micropython on raspberry pi pico which i initialise like this: class Lcd: def __init__(self, width, height, channel, sdaPin, sclPin, contrast): from time ...
shifras's user avatar
0 votes
1 answer
28 views

how do i decrypt a cyphertext encrypted with AES with pycryptodome?

I'm making a password manager with python that stores and encrypts passwords (using the pycriptodome module) with a main password set by the user, but the decryption does not work Here's the function ...
vghbjc's user avatar
  • 11
-3 votes
0 answers
30 views

I've managed to save captchas from a website but can't seem to save more titled sequentially [closed]

import requests def download_image(url, save_as): response = requests.get(url) print(response.status_code, response.reason) with open(save_as, 'wb') as file: file.write(response....
Gifro's user avatar
  • 1
0 votes
0 answers
6 views

How to create an API authorization with the latest IOS SST and AWS

I want to create an API with the new SST v3 aka ION SST. Docs don't say much about auth-related things and I feel confused. I have a separate Next.js app and now I want to create a backend ...
Karol's user avatar
  • 620
-7 votes
0 answers
25 views

How to code using prim's algorithm using lists or priority queues to generate a maze? [closed]

For my NEA project I chose to generate mazes for my game using python. Prim's algorithm feels so complicated and I'm a beginner in coding python. I really need help with this because as I read other ...
Evangeline's user avatar
0 votes
0 answers
10 views

AWS Lambda python log file is not created

I have a Python AWS lambda with a logger that generates two different log files: LOG = f"/tmp/{uuid.uuid1()}_log.log" SLOW_LOG = f"/tmp/{uuid.uuid1()}_slow.log" logging....
PloniStacker's user avatar
-3 votes
0 answers
25 views

How do I Install pytorch without GPU dependencies?

I have a project that depends on torch==2.0.1, but it will run on CPU not GPU. torch has some large cuda/cublas/cudnn dependencies that I believe are only needed when running on GPU. These packages, ...
codeech's user avatar

15 30 50 per page
1
2 3 4 5
9