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. Please note that Python 2 is officially out of support as of 2020-01-01. For version-specific Python questions, add the [python-2.7] or [python-3.x] tag. When using a Python variant (e.g. Jython, PyPy) or library (e.g. Pandas, NumPy), please include it in the tags.

python
Filter by
Sorted by
Tagged with
0 votes
0 answers
3 views

How to convert dataframes to arrays in a for loop

I have imported data from multiple csv files, creating multiple data frames. I need to use a for loop for the rest of my code and for that code, I need the data frames to be in an array. I have tried ...
Postman's user avatar
0 votes
0 answers
4 views

alternative to SageConv to support edge weights in PyTorch Geometric

I want to use graphSAGE to find abnormal nodes. I want to use edge weights for my graphs which is not supported in graphSAGE using (PYG) PyTorch Geometric library. If I use GraphConv instead of ...
kami2024's user avatar
0 votes
0 answers
4 views

Vectorize stop loss / take profit backtesting of multiple positions with python pandas

Introduction I am using python pandas to backtest own strategies on local stored market data. As I'd like to backtest those strategies fast and the data is large (7+ million rows) I am trying to ...
snky's user avatar
  • 25
0 votes
0 answers
6 views

Am I missing something with Django's makemigrations?

I am working on a Django project and am struggling with adding a new field to a models class. I am still pretty new, but this is what my models class look like: class Manager(models.Model): ''' ...
ItsCardiBBaby's user avatar
0 votes
0 answers
3 views

Disable a button only during an expensive operation in streamlit

python 3.12.2 streamlit 1.33.0 I have an expensive operation and would like to disable a button to execute it only during the operation. In other words, there is an enabled button. When you press it, ...
dixhom's user avatar
  • 2,794
-1 votes
0 answers
13 views

Minimax Algorithm doesn't work as expected in Tic Tac Toe [closed]

Right now i am learning about Minimax algorithm and trying to add it to my Tic Tac Toe, Although my function works the moves it selects are not the best or at least not close to good but i can't seem ...
Peshi's user avatar
  • 1
0 votes
0 answers
10 views

Can't install PyAudio on Kubuntu

I'm trying to install PyAudio on my system, but I encountered an error during the installation process. Here's the error message I received when I try pip install PyAudio : Collecting pyaudio Using ...
Clément NOGUES's user avatar
0 votes
0 answers
13 views

Why does the simple python server / javascript socketio communication fail?

I have a simple flask-socketio server that emits a stream of floats and serves an html file with a javascript socket.io listener. The initial connection appears to immediately disconnect, the server ...
data-dancer's user avatar
1 vote
0 answers
22 views

Errors with method overloading in a generic class

In the toy example below, I define a generic class Foo. I overload the class initializer, to impose a type dependency on the parameters: import enum import typing class EValType(enum.Enum): ...
user1109069's user avatar
0 votes
0 answers
13 views

Data structure to order by sequence of appearance based on logical relationship?

I only have access to basic python. I do not have access to use DataFrames. The problem scenario: When a ticket is opened, one or multiple files are checked out by the ticket, once the ticket is ...
JO46's user avatar
  • 1
-1 votes
0 answers
11 views

Psycopg3 : Execute a plain text stored in variable without warning

With Psycopg3 library in Python, I want to execute a query stored in a file. I tried that : conn.execute(tmp_file.read()) The code is correctly executed but a warning is displayed : Expected type '...
user24408596's user avatar
-1 votes
0 answers
21 views

Same code differen results: simple lists in python [closed]

So we had a python beginners class, and all well and good, but in the exercise of the day, even if I copy my professors code to the letter, we get different results. d={'ana':10, 'hermina':41, 'miha':...
Katpton Liamfuppinshire's user avatar
0 votes
0 answers
9 views

How do I insert content from one Word document into another using python-docx-template?

I'm working on a project that automates the creation of some Word document reports that can get a little formatting-heavy. The body of the report consists of a bunch of entries for tests run, and what ...
jdsp522's user avatar
  • 15
0 votes
0 answers
13 views

Validation Taking too long

I am currently training a UNet-like architecture to reconstruct audio. The training is going smoothly. The issue is that I am performing certain evaluations (like rt60 and drr) that need to be ...
mahnoor.fatima's user avatar
0 votes
0 answers
19 views

Column value update issue

import pandas as pd import numpy as np from itertools import combinations data = {'FFC': [200, 52880], 'CLUB': [0, 0], 'PBC': [200, 0], 'ESC': [200, 0], 'LPLC': [250, 0], 'FPLC': [...
arvin's user avatar
  • 9
0 votes
0 answers
11 views

python difflib adding an additional html column when making tables using difflib.HtmlDiff()

I am working with the python library difflib and specifically the class HtmlDiff. For some reason, the function make_table is adding a blank column in when generating an HTML table, throwing off ...
user24291779's user avatar
-2 votes
0 answers
15 views

Yahoo finance Python API stock.options is empty

Something has change recently with Yahoo finance Python API stock.options - this object is empty. It was working fine at the end of 2023 and I tried it today with this problem. I used commonly traded ...
Michael D's user avatar
0 votes
0 answers
10 views

How to Catch Error and Resume API Call (Smartsheet API Python SDK)

I am trying to write an API call using list_sheets and get_sheet to first, gather a list of all sheets, and second, add the additional sheet data for each sheet ID (Sheet Owner, Workspace Name, and ...
tomgr's user avatar
  • 1
-1 votes
1 answer
13 views

I use mac, starting django using visual code studio. I fail to start a new app “startapp” I get syntax error “ File ‘Manage.py’, line 17 ) from exc”

I am starting django with visual code studio. I fail to start a new app “startapp” I get syntax error “ File ‘Manage.py’, line 17 ) from exc” I tried changing in manage.py putting “except Exception ...
Isaac Mabuba's user avatar
0 votes
0 answers
21 views

Python subprocess.Popen with PIPE shows significant slowness

When Python subprocess.Popen is used with stdout=subprocess.PIPE, I've noticed that run time noticeably increases. I'm using mussh or ssh to get some directories of multiple hosts using multiple ...
so0jong's user avatar
0 votes
0 answers
9 views

Deskew image using opencv in Python

I am preprocessing images of PDFs which will eventually have text extracted from them. I am using opencv for the bulk of the preprocessing work and due to constraints of the client environment, I can ...
carousallie's user avatar
0 votes
0 answers
14 views

Infinite Loop Trying to Navigate Maze using Rule Based AI

I'm creating a Rule Based AI that can solve a maze, it should be able to remember where its been so if it reaches a dead end it can go back on itself and know to use a different rule when it reaches a ...
Manolis Dame's user avatar
0 votes
0 answers
6 views

asyncio.exceptions.CancelledError when using Dask LocalCluster with processes=False and progress

This is an example: import numpy as np import zarr from dask.distributed import Client, LocalCluster from dask import array as da from dask.distributed import progress def same(x): return x x = ...
Kang Liang's user avatar
0 votes
0 answers
14 views

How to keep only rows with max value in column B for each value in column A? [duplicate]

I have a dataframe where, for each unique system in Column A, I need to find the max date in Column B and then keep only those rows for the new dataframe. (The original dataframe contains a history of ...
Bbamber's user avatar
  • 11
-3 votes
0 answers
34 views

I got a zero error division on Python coding

I'm trying to make a program that calculates the best utilization (horizontal) for a plotter. import math resp_dimensoes_larg = float(0) resp_dimensoes_alt = float(0) resp_qtd_peca = int(input("...
Controller Personalize's user avatar
-1 votes
0 answers
10 views

My Fast Forward button will only work once, and wont work again

The Fast Forward button goes forward ten seconds, but it will only do it once All of this is happening in fast_forward_music. The base of the problem seems to be in the variable current_time never ...
Starwarsdan30000's user avatar
0 votes
0 answers
12 views

Not a valid choice for Flask WTForms SelectField

enter image description here This is my Form Class: class ProfileForm(FlaskForm): login = StringField("Login", validators=[DataRequired()]) bday = DateField("Birthday", ...
Федя Тукан's user avatar
0 votes
0 answers
9 views

routing a view through blueprint in another module doesn't work

I have a flask project with following three files: # app.py from flask import Flask from userbp import bp app = Flask(__name__) app.register_blueprint(bp) @app.route("/") def index(): ...
AK-CHP's user avatar
  • 89
1 vote
1 answer
31 views

Partition by column, order by another

I am simulating a SQL query with the following values: rows = [(1, '2021/04', 'Shop 2', 341227.53), (2, '2021/05', 'Shop 2', 315447.24), (3, '2021/06', 'Shop 1', 1845662.35), (4, '2021/04', 'Shop 2', ...
David542's user avatar
  • 108k
-1 votes
4 answers
41 views

How to replace a word to another word in a list python

If I have this list: ['hello world', 'latest.png', 'have a good day', 'stack overflow', 'the best' 'latest .png', 'i believe somebody will help me', 'latest.png', 'latest.png'] Is it possible to ...
Max Sikorsky's user avatar
0 votes
0 answers
5 views

Pyinstrument ProfilerState object is not callable

I am working on using PyInstrument to profile FastAPI requests. When I am trying to make this post call: curl -X 'POST' \ 'http://0.0.0.0:8000/api/model/lumalee/decisions/result/file/?shap_values=0&...
Partho's user avatar
  • 19
0 votes
2 answers
15 views

Scipy Quad integration, The integral is probably divergent or slowly convergent

I am trying to use scipy's integrate.quad and it isn't working for my function. import numpy as np from scipy.integrate import quad def cos_func (x): return np.cos(np.power(x, 3) + 1) ...
Joliver's user avatar
  • 19
0 votes
1 answer
14 views

Drawing function, according to the instructions from a text file

I have implemented a small program, that has one function to open and read a text file with instructions for drawing, whereas the second one is targeted at drawing. The second one was already utilised,...
Lucky's user avatar
  • 11
0 votes
0 answers
6 views

Writing data to Elasticsearch 8 over NGINX reverse proxy fails when code running on Ubuntu

I have an Elasticsearch 8.12 cluster on an internal network. I use self certified certificates and everything is running well, I push data into it all the time using Python, no errors and no warnings. ...
Aj_ruba's user avatar
0 votes
0 answers
10 views

AWS CDK building a docker image

I'm currently using AWS CDK to test building out a docker image and pushing it to ECR. From what I've gathered, this is the constructs that I'm using: user = iam.User(self, 'User') ecr....
chinahalffull's user avatar
0 votes
0 answers
14 views

Python ASyncio Error, CancelledError. How can I solve this?

As the title says, Im having problems with asyncio as it keeps popping up with CancelledError, my lines of code that are saying this are as following. They use SQL Database. bot.command() async def ...
Thomas Sebastian Prants's user avatar
0 votes
0 answers
23 views

Mysterious "Killed" message

I am trying to run a program that consumes a large, but not infeasible amount of memory (see below). I checked that my computer has 15.6GiB according to htop. However, this exits with the message ...
Test's user avatar
  • 1,396
-1 votes
0 answers
10 views

Outlook automation with Selenium - outlook.office wants to. open email links popup block in selenium

Screenshot for reference I am trying to use selenium to automate outlook. but I am getting this pop up, while accessing outlook with selenium, this doesnt show up in inspect as well and is from ...
user23940203's user avatar
1 vote
1 answer
29 views

Strip all column values, but check if any tuples exist

I have multiple dataframes that use the same functions to strip all the values. However, some of the values are tuples and it is throwing an error whenever I come across stripping a tuple. My function ...
iBeMeltin's user avatar
  • 237
0 votes
0 answers
22 views

Promote a QWidget to a QAxWidget using Qt Designer y PyQt5

I want to promote a QWidget to a QAxWidget. I want to avoid using QWebengineView to display a PDF file (I can't zoom it) so I decide to implement this solution instead (bottom solution): Solution In ...
Ismael Santana's user avatar
0 votes
1 answer
17 views

(Python) Error for getting Kivy Label ID: AttributeError: 'super' object has no attribute '__getattr__'. Did you mean: '__setattr__'?

Consider following Code: from kivy.app import App from kivy.uix.widget import Widget from kivy.uix.label import Label from kivy.uix.boxlayout import BoxLayout from kivy.lang import Builder from kivy....
Faruk Nergiz's user avatar
1 vote
3 answers
39 views

Use DataFrame with an imported excel file

I used the following code to import an Excel file into Python: import pandas as pd file_name = (file.direction) ExcelData = pd.read_excel(file_name, sheet_name = "File Name", header = 0) ...
alfredocarrascor's user avatar
0 votes
0 answers
6 views

Pycharm isn't showing Camera window

I was running "Remote development" from Pycharm IDE on my pi5. I was trying to run basic script using Picamera2; basically that script shows preview of Arducam camera module. Script is like ...
fwiz's user avatar
  • 11
0 votes
0 answers
8 views

Python function running via systemd not logging less than ERROR level

I have a python script that sets up the logger like this: logging.basicConfig( format="%(asctime)s %(levelname) 9s: %(message)s", level=getattr(logging, parsedArgs.log.upper()), ) ...
swagrov's user avatar
  • 1,328
0 votes
1 answer
31 views

Having trouble understanding this problem

A Paladrome is a special class of warriors derived from Paladins that are strong at holy magic. However, for a Paladin to achieve Paladrome level, they must be able to construct special spells. Each ...
potatokid432's user avatar
0 votes
0 answers
8 views

How do I use PymuPDF/fitz to denormalize xobjects?

I have a PDF that contains some xobjects. I need to denormlize them, i.e. make a copy of each xobject in every place it appears in the document. How can I do this using PymuPDF/fitz? I've been reading ...
W.P. McNeill's user avatar
  • 16.7k
0 votes
0 answers
14 views

python script doesn't run correctly when run by a crontab

I have a python script that runs properly when i execute it manually, but not when i use a crontab. The script recuperate information from a file and store them in a database. When the script is run ...
rira's user avatar
  • 11
-1 votes
0 answers
17 views

Why is ResNet18 performing better than ResNet50 on a small image?

I have two very similiar, almost identical images. I calculate the cosine similarity on them. For some reason ResNet50 gave me a very low score, so I experimented and ended up using ResNet18 which ...
Bodo's user avatar
  • 1
0 votes
1 answer
20 views

pre-commit with mirrors-mypy shows errors i already fixed

i cleaned cache with pre-commit clean && pre-commit gc but it still shows me errors i already fixed: $ git commit -m "fake commit" [WARNING] Unstaged files detected. [INFO] Stashing ...
swats-the-floran's user avatar
1 vote
2 answers
18 views

Unable to cancel asyncio.task from another function

I was expecting to cancel foo_wrapper using cancel function, however, it still generates result. If I change foo_wrapper as non-async function and change self.lock to threading.Lock solves the issue. ...
flexwang's user avatar
  • 641

1
2 3 4 5
43873