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
2 votes
0 answers
160 views

Rotated and deformed object detect by template on python

I am a python beginner, we have a project where we need to detect and crop out the desired pattern from a photo: This is the original picture: Each picture has such a regular border, but it is not ...
Fry's user avatar
  • 31
2 votes
0 answers
308 views

How do I get FROM/TO/CC and BCC using pypff?

In pypff there is the attribute sender_name for messages, but I can't get the destinataries. Tried using message.trasnport_headers and parsing it, but it seems some messages don't have ...
Oliveira's user avatar
2 votes
0 answers
67 views

Pandas pd.concat or R rbind - Error after merging

I have two data frames df1 and df2 with the same data types and the same column names. now when I extract df1 from the merged frame and compare it with the original data frame I have an error!! I mean ...
ar_mm18's user avatar
  • 455
2 votes
1 answer
33 views

why it's works when I use a integer index but don't whit a i itterable variable inside a loop in Django template engine

this is gives a none values : {%for i in l%} <tr> <td>{{con.hotel.i}}</td> </tr> {%endfor%} while this works and give the correct values {%for i in l%} <tr> &...
Mohamed chouai's user avatar
2 votes
1 answer
316 views

Django + apache2 error: [Errno 13] Permission denied: '/photos'

I have a ubuntu server hosting my application, which consists of a front-end made with angular, and an API made with django. When I try to upload images through the API, I get the error: [Errno 13] ...
RandomBeginner's user avatar
2 votes
0 answers
229 views

slack unfurling link with attachment blocks included

So my goal is to include an image, with buttons, in a message. However, the file is not public and files_upload method takes away the functionality of the buttons, issue similar to this https://github....
cozzymotto's user avatar
2 votes
0 answers
43 views

import python module (which contains other imports) with full path

I know there are a lot of similar questions, but I couldn't find an appropriate answer to my "problem". I want to import my own module from full path, but this module contains imports from ...
Lennart's user avatar
  • 21
2 votes
1 answer
128 views

Tuple to display keys in a binary tree

I want to create helper function to display all the keys in a tree-like structure for easier visualization. Indeed, tuple's print is opaque. My function should work like tuple_to_display = ((1, 3, ...
Joelinton's user avatar
2 votes
0 answers
298 views

Understanding winfo_exists()

I’m trying to test the existence of a toplevel using the winfo_exists() method made available by Tkinter. However, I cannot test the existence of a Toplevel by passing the name of this to winfo_exists(...
1966bc's user avatar
  • 1,180
2 votes
1 answer
146 views

Text Classification Using spaCy

I was trying to do some text classification with spacy but i get an error about my vucabulary being empty. I tried a classic dataset but i get the same error, i've seen some suggestion to split the ...
Gabry's user avatar
  • 33
2 votes
0 answers
44 views

Comparing strings between columns in Pandas Dataframe [duplicate]

I want to build a function that compare rows between two columns. The objective is to discover if a string is similar to other and replace them. These strings might have errors (some unwanted letter ...
Matheus Castro's user avatar
2 votes
1 answer
137 views

Assigned 20 people to 4 tables four times without repetition and each person must be at each table only one time

I want to randomly assign 20 people to 4 tables to do 4 tasks without repetition, and each person must be at each table only once. There are five people at each table. There are four tables. Five ...
Penguin Learning's user avatar
2 votes
0 answers
280 views

Why is cls() allowed in Python mypy?

Why is cls() accepted by mypy in from __future__ import annotations from typing import TypeVar T = TypeVar("T", bound="A") class A: @classmethod def create(cls: type[T]) -...
joel's user avatar
  • 6,912
2 votes
0 answers
1k views

Yolov5 model not validating after training

I am trying to run a custom object detection model using yolov5. Did the following steps; %cd yolov5 %pip install -qr requirements.txt # install dependencies import torch import os from IPython....
programmer's user avatar
2 votes
1 answer
53 views

Counting days on a non-unique index

I have a piece a code which works nicely to sequentially order days between Plan_Start variable. Setup code: tx1 = pd.DataFrame({'Patient':[123,456,789,789,101], 'Plan':['Drug1','Drug43','...
Gabe Verzino's user avatar
2 votes
1 answer
287 views

environment returns dictionary in env.observation_space

I have the following code. I have tried in multiple ways to somehow parse the data but failed. env = MtEnv() inputlist = [] balance = Input(shape=(1,), name="balance") inputlist.append(...
Adrian Belmans's user avatar
2 votes
1 answer
1k views

Plot duration of processes along with date, start and end timestamps

I am trying to plot duration of processes, starting from the following data frame variable year start end seconds hours start_time start_date 0 10m_u_component_of_wind 2005 2022-04-25 13:14:45 2022-...
Nikos Alexandris's user avatar
2 votes
1 answer
796 views

How to customize the default help text for the command line python-fire by google?

I am trying to make a small command line tool using python-fire module by google. My filename is my_tools.py. Inside my_tools.py I have code class MainFunction(): def __init__(self): self....
Johnty Gomes's user avatar
2 votes
1 answer
1k views

streamlit AgGrid deleting row doesnt refresh data in the backend

I have two AgGrid's in python streamlit application. Two AgGrid's are connected and GridUpdateMode.MANUAL . I have to select rows in first grid and click on update so that second grid will get ...
sitaram chikkala's user avatar
2 votes
1 answer
583 views

How to fine tune the last layers of neural network in target model for transfer learning?

I am learning how transfer learning works using this data https://www.kaggle.com/competitions/santander-customer-satisfaction/data .. so this is my simple source model code in tensorflow. and I am ...
user12's user avatar
  • 751
2 votes
0 answers
278 views

missing folders and data in wheel when created in gitlab pipeline

I am creating a python wheel file where I need to include some specific folders and non-python files. I used a manifest.in file to graft the main folder containing all the other folders and files ...
econoline's user avatar
2 votes
0 answers
56 views

Can some explain this pandas df.str.contains behavior? (removes <NA>)

Hello pandas users/experts, I am trying to filter a dataframe for rows where a particular column does not contain matches to a list of strings. I was able to accomplish this partially by using the ...
Akimon's user avatar
  • 75
2 votes
0 answers
560 views

Testing an async helper function in a fastapi project with beanie

I'm using FastAPI for my server and I've added a feature that uses background tasks for doing some processing after the request was served. I've written alot of tests for my routes but I'm finding it ...
override's user avatar
2 votes
1 answer
5k views

PIP or PIP3 broken. AttributeError: module 'lib' has no attribute 'ERR_load_RAND_strings'

This error message appears when I attempt to install something using pip or pip3. I tried numerous approaches to fix the problem, but none were successful. Using PIP Traceback (most recent call last): ...
Chess's user avatar
  • 31
2 votes
1 answer
982 views

prophet_model.bin error on Jupyter notebook

I installed Prophet library in accordance to the Python API here but when I try to run the same model here on the Python API: df = pd.read_csv('https://raw.githubusercontent.com/facebook/prophet/main/...
forecasting's user avatar
2 votes
0 answers
571 views

Python project dependency on external Git repo

I have a project that depends on an external Github repo. What's the correct way to include this dependency in my project? Note: the dependency is not a pip package, but a Python project hosted in ...
Shahar's user avatar
  • 81
2 votes
0 answers
132 views

Ask to user credentials to access Google Drive Api

I'm creating a cli tool to move file around in a user Google Drive space. I'm using Python and Google Drive Api Python SDK to do that and I've created this repo. Now I have to run every midnight this ...
Daniele Tentoni's user avatar
2 votes
0 answers
1k views

Why does conda package install complain about both python abi 3.7 and 3.9?

I'm trying to install a package in a conda environment (python=3.9), and I get the following error: Encountered problems while solving: nothing provides python_abi 3.7.* *_cp37m needed by [package] ...
bread's user avatar
  • 21
2 votes
1 answer
248 views

Python imaplib to gmail - Fetches only incoming emails

I've a simply python script which basically tries to fetch all the email from a gmail account with the following - not great at all - code: conn = imaplib.IMAP4_SSL('imap.googlemail.com') conn.login(...
user2194805's user avatar
  • 1,299
2 votes
0 answers
222 views

How to forecast a univariate time series 20/30 days ahead using tensorflow LSTM?

I have used below code for training and validation. It gives decent result but I don't know the code to forecast n periods ahead (like 30/50 days ahead) using the trained model. GitHub Link for the ...
Hemil Shah's user avatar
2 votes
0 answers
38 views

Console buffers when I clear during loops

Code: import os, ctypes, threading cool = 0 started_t = True threads = 10 lock = threading.Lock() def output(): global cool cool += 1 lock.acquire() os.system("cls") ...
David's user avatar
  • 21
2 votes
0 answers
2k views

Pytest execution result in json format?

I am working on pytest and want result in json format, see this problem. There is single file which is tested using monkeypatch for custom inputs now I need result for each test cases. I know we can ...
shraysalvi's user avatar
2 votes
0 answers
613 views

Problem with loadUi in PyQt6, wrong rendering

I'm trying to render the view through the method: uic.loadUi ("ui.ui", self), everything starts but the rendering is wrong. Below I report the code and the .ui file generated with QtDesigner....
Studet's user avatar
  • 23
2 votes
1 answer
204 views

matplotlib reusing axes in Jupyter

This is a question I have been wanting an answer to for a while. I have spent much time searching for answers on SO. This question is related: Matplotlib - How to edit the same plot with different ...
Connor Ferster's user avatar
2 votes
0 answers
642 views

Why does pylance point out a type issue when using ABCMeta.register?

Example code using register to add C as a virtual subclass of A: from abc import ABC, abstractmethod class A(ABC): @abstractmethod def f(self) -> int: ... class B(A): # normal ...
myke's user avatar
  • 499
2 votes
2 answers
1k views

PySpark DataFrame showing different results when using .select()

Why is .select() showing/parsing values differently to I don't use it? I have this CSV: CompanyName, CompanyNumber,RegAddress.CareOf,RegAddress.POBox,RegAddress.AddressLine1, RegAddress.AddressLine2,...
AK91's user avatar
  • 701
2 votes
1 answer
404 views

Scrap Linkedin Connections Data - Selenium

I've been trying to obtain contact details - emails from my connections on LinkedIn. Unfortunately, the code does not progress beyond scrolling through my connection list. Any ideas? import re import ...
S.M.A.D Productions's user avatar
2 votes
1 answer
3k views

How do I create a custom handler in torchserve?

I am trying to create a custom handler on Torchserve. The custom handler has been modified as follows # custom handler file # model_handler.py """ ModelHandler defines a custom model ...
Takayama-Shin's user avatar
2 votes
2 answers
57 views

Trying to move image around screen, but "animation" is choppy

If I hit a key it won't show the new position until I let off it. It almost teleports to the new spot instead of seeing it move to it. I previously made a square to move around with no issue. Tried ...
user16818230's user avatar
2 votes
0 answers
691 views

Is there a feature to add text on the Polyline? (Python Folium)

I want to add text on the lines added using Polyline from within the folium library.(etc "1km" or "1ft") m = folium.Map(location=[41.08468198029149, 28.8180159802915]) points = [[...
Tugrul Gokce's user avatar
2 votes
0 answers
2k views

Simpleaudio doesn't install: legacy-install-failure

I am trying to install Simpleaudio on Windows in order to use Pydub but I get a legacy-install-failure in the cmd. Here is the complete output: C:\WINDOWS\system32>pip install simpleaudio ...
FulvioD 23's user avatar
2 votes
0 answers
101 views

Determine whether a `call` event is a class definition in settrace

When you use settrace, you can track call events in code execution (among others). However, the documentation mentions: A function is called (or some other code block entered). The global trace ...
Austin Cory Bart's user avatar
2 votes
0 answers
23 views

importing questions when starting programming in python [duplicate]

I all, I'm starting study Python and I'm reading many tutorials, python reference, video courses.... So, like many others, I'm learning by examples and I'm trying to improve my skills reading piece of ...
boerig's user avatar
  • 17
2 votes
0 answers
468 views

Cannot install python packages due to missing site-packages folder on Linux

On Linux, every time I try to install a python package I get an error that the site-packages directory is missing. For example: error: [Errno 2] No such file or directory: '/opt/python/cp39-cp39/Lib/...
mbs9's user avatar
  • 75
2 votes
2 answers
147 views

NetworkX isomorphism - how to find edge mapping

I have the following two isomorphic graphs with different edge labels: G1 = nx.Graph() G1.add_edges_from([(1,2), (2,3), (3,4), (4,2)]) attrs1 = {(1, 2): {'label': 'Albert'}, (2, 3): {'label': 'Bob'}, (...
coaxialquantum's user avatar
2 votes
2 answers
910 views

Simulate electric vehicle (EV) charging demand in Python

I'm trying to simulate electric vehicle charging demand in python, given the vehicle's energy consumption per second, a charging rate for the charger, and a starting state of charge. The true end goal ...
llamawithgrass's user avatar
2 votes
0 answers
306 views

Request- response scenario using BLE (python)

I am building a mechanism for syncing data between two sqlite instances (master on Raspberry and slave on mobile). I want to do this over BLE using dedicated Characteristic and combination of Write ...
KrzysztofP's user avatar
2 votes
0 answers
426 views

shutil.copytree unable to avoid FileExistsError Python 3.7

I know that with Python 3.8 has been introduced 'dirs_exist_ok=True' argument but I am constrained on Python 3.7 I have tried with no success shutil.copytree(homePath, dst, symlinks=False, ignore=None)...
federico 's user avatar
2 votes
0 answers
59 views

How can I align text to a baseline grid using reportlab's platypus?

In DTP software you can set up a baseline grid and force all the text in a document to be aligned to baselines (example here with inDesign). Is there a simple way to achieve this with reportlab's ...
Nicolas Seiller's user avatar
2 votes
1 answer
84 views

Dropping dimension of Tensor with size bigger then one tensor, in Tensorflow

First i splitted the original tensor and then after some operations i want to combine the tensor to the original shape and the original tensor, before splitting it. I'm not sure i can just use the old ...
hndrkk's user avatar
  • 31