QuestionId int64 74.8M 79.8M | UserId int64 56 29.4M | QuestionTitle stringlengths 15 150 | QuestionBody stringlengths 40 40.3k | Tags stringlengths 8 101 | CreationDate stringdate 2022-12-10 09:42:47 2025-11-01 19:08:18 | AnswerCount int64 0 44 | UserExpertiseLevel int64 301 888k | UserDisplayName stringlengths 3 30 β |
|---|---|---|---|---|---|---|---|---|
78,351,027 | 940,259 | Getting ErrorCode:AuthorizationPermissionMismatch when listing blobs from Python while AZ CLI works with the same creds | <p>I've got an existing storage account / container where I can list all the blobs using AZ CLI:</p>
<pre><code>[ ~ ]$ az storage blob list --account-name storageaccount20122022 --container-name test
There are no credentials provided in your command and environment, we will query for account key for your storage accou... | <python><azure> | 2024-04-19 02:10:54 | 1 | 1,420 | MLu |
78,350,937 | 390,388 | Spacy textcat multilabel config validation error | <p>I am trying to train a spacy textcat_multilabel model. I thought I had everything set up correctly, but I continue to get a validation error.</p>
<p>This is the label section of my config:</p>
<pre><code>[components.textcat_multilabel]
factory = "textcat_multilabel"
scorer = {"@scorers": "sp... | <python><spacy> | 2024-04-19 01:27:21 | 1 | 43,620 | John |
78,350,841 | 2,270,422 | Mypy complains about poetry packages I included from the project subdirectories in src | <p>Here is my poetry packages in my pyproject.py:</p>
<pre><code>packages = [
{include = "api", from = "src"},
{include = "another_api", from = "src"},
{include = "infra"}
]
</code></pre>
<p>And when I import some symbol in my <code>api</code> package like <... | <python><python-3.x><mypy><python-poetry> | 2024-04-19 00:30:01 | 0 | 685 | masec |
78,350,697 | 13,605,694 | Hosting a Django application on azure app service | <p>After following the official <a href="https://learn.microsoft.com/en-us/azure/app-service/tutorial-python-postgresql-app" rel="nofollow noreferrer">host python with postgres tutorial</a>, and making modifications in my gh actions file because my django apps isn't present in the root on the repo, I get a 404 error wh... | <python><django><azure><continuous-integration><azure-web-app-service> | 2024-04-18 23:15:04 | 1 | 392 | ayitinya |
78,350,601 | 16,406 | How to avoid "ImportError: attempted relative import with no known parent package" error | <p>Background: I have a bunch of small-to-medium python programs that I'm trying to simplify by factoring out common code into a module that all the programs import.</p>
<p>The problem I run into is that when I put the common code into <code>common.py</code> in the same directory as all the programs, and do <code>from... | <python><python-3.x> | 2024-04-18 22:41:03 | 1 | 127,309 | Chris Dodd |
78,350,510 | 7,031,021 | Running Multiline py files in Azure Maschine Learning Studio Notebooks | <p>I'd like to know the best practice of running multiline shell commands in a ml notebook</p>
<p>Here is some pseudocode and how i would run IT in a notebook cell.</p>
<pre><code>%%bash
conda activate myenv &&
torchrun
--standalone
--nnodes=1
--nproc-per-node=$NUM_TRAINERS
YOUR_TRAINING_SCRIP... | <python><azure-machine-learning-service> | 2024-04-18 22:08:27 | 1 | 510 | RSale |
78,350,475 | 1,729,649 | What is the equivalent for HTTP method LIST in the Ansbile `uri` module? | <p>I am trying to look for the HTTP method equivalent for the following playbook code for method <code>LIST</code>.</p>
<pre class="lang-yaml prettyprint-override"><code>- name: List all folders
ansible.builtin.uri:
url: https://{{ My_vault_url }}
method: LIST
return_content: true
body_format: json
... | <python><ansible><python-requests><ansible-2.x> | 2024-04-18 21:55:18 | 1 | 570 | Sukh |
78,350,341 | 1,509,695 | How to make argparse not mention -h and --help when started with either of them? | <p>When running with <code>--help</code>, the help output includes the description of the <code>--help</code> argument itself. How can that line be avoided in the output of <code>--help</code>?</p>
<p>I could not get <a href="https://stackoverflow.com/a/73380185/1509695">this answer</a> to work, as the following code d... | <python><argparse> | 2024-04-18 21:11:19 | 1 | 13,863 | matanox |
78,350,242 | 3,507,584 | Uninstall last pip installed packages | <p>I have just installed a package in my virtual environment which I shouldn't have installed. It also installed many dependency packages.</p>
<p>Is there a way to roll back and uninstall the package and its dependencies just installed?</p>
<p>Something like "uninstall packages installed in the last 1 hour" o... | <python><python-3.x><pip> | 2024-04-18 20:46:36 | 2 | 3,689 | User981636 |
78,350,224 | 610,569 | Avoiding repetitive checking of function output before storing into a dictionary | <p>I've a repeating code block of iterating through inputs, checking some functions to return a list and the populating dictionary if the function did return a list, e.g.</p>
<pre><code>def some_func(i):
""" This function returns a filled list of a condition is met, otherwise an empty""&quo... | <python><dry> | 2024-04-18 20:40:29 | 1 | 123,325 | alvas |
78,350,183 | 6,451,746 | GStreamer 1.24 Python bindings are blacklisted | <p>I am trying to install Python bindings for GStreamer, but the library is blacklisted. My Dockerfile is below. Everything installs without issue, but the <code>libgstpython.so</code> library is blacklisted. I have tried different Python versions, specifying the Python path, and random keyboard bashing without success... | <python><gstreamer><glib> | 2024-04-18 20:27:35 | 1 | 332 | mentoc3000 |
78,350,133 | 16,845 | What is the correct type annotation for "bytes or bytearray"? | <p>In Python 3.11 or newer, is there a more convenient type annotation to use than <code>bytes | bytearray</code> for a function argument that means "An ordered collection of bytes"? It seems wasteful to require constructing a <code>bytes</code> from a <code>bytearray</code> (or the other way around) just to ... | <python><python-typing> | 2024-04-18 20:16:38 | 1 | 1,216 | Charles Nicholson |
78,349,934 | 3,240,688 | Polars - check for null in dataframe | <p>I know I can do <code>.null_count()</code> in Polars, which returns a dataframe telling me the null count for each column.</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
data = {"foo": [1, 2, 3, None], "bar": [4, None, None, 6]}
df = pl.DataFrame(data)
df.null_count()
<... | <python><dataframe><python-polars> | 2024-04-18 19:32:29 | 3 | 1,349 | user3240688 |
78,349,813 | 610,569 | Generate list of list round-robin without repetition of items with itertools | <p>If the goal is to achieve <code>f"{x1}-{x2}"</code> pairs where <code>x1 != x2</code> from a combination, I can do:</p>
<pre><code>import itertools
>>> X = ['1','2','3','4']
>>> [f"-".join(xx) for xx in itertools.combinations(X, 2)]
['1-2', '1-3', '1-4', '2-3', '2-4', '3-4']
</... | <python><python-itertools><round-robin> | 2024-04-18 19:08:50 | 1 | 123,325 | alvas |
78,349,807 | 1,182,299 | Split image file in lines from ALTO groundtruth coordinates for TrOCR | <p>I want to train a model for TrOCR. I have a personal transcribed groundtruth (ALTO). TrOCR only works with lines and not full pages so I need to crop the image files in lines with the coordinates from the ALTO files and match them with the transcription. My code:</p>
<pre><code>import os
import cv2
import numpy as n... | <python><numpy><ocr><polygon><alto> | 2024-04-18 19:08:04 | 0 | 1,791 | bsteo |
78,349,569 | 1,489,990 | Pass Multiple Inputs to Terminal Command Python | <p>I have this terminal command I need to run programmatically in Python:</p>
<p><code>awssaml get-credentials --account-id **** --name **** --role **** --user-name ****</code></p>
<p>It will first ask for your password, and then prompt you for a 2 factor authentication code. I have these as variables in python that I ... | <python><pexpect> | 2024-04-18 18:21:35 | 1 | 10,259 | ez4nick |
78,349,513 | 5,502,917 | Pytesseract doesnt recognize plate correctly | <p>I am using pytesseract to try to recognize car plates but it does not return the correct result.</p>
<p>This is my code</p>
<pre><code>text = pytesseract.image_to_string(cropped_License_Plate, lang='eng', config='--psm 9')
</code></pre>
<p>I have tried using many different psm but the result is never correct.</p>
<p... | <python><ocr><python-tesseract> | 2024-04-18 18:08:12 | 1 | 1,731 | GuiDupas |
78,349,270 | 3,120,266 | using pandas to number and coerce to force values to ints and still not working | <p>Confused when I am trying to coerce dataframe to numeric. It appears to work when I look at structure but then I still get errors:</p>
<p>TypeError: unsupported operand type(s) for +: 'int' and 'str'</p>
<p>Code:</p>
<pre><code>df = df_leads.apply(pd.to_numeric, errors='coerce') code here
df.info()
</code></pre>
<p... | <python><pandas><string><numeric> | 2024-04-18 17:15:25 | 1 | 425 | user3120266 |
78,349,268 | 14,224,948 | Changing command order in Python's Typer | <p>I want Typer to display my commands in the order I have initialized them and it displays those commands in alphabetic order.
I have tried different approaches including this one: <a href="https://github.com/tiangolo/typer/issues/246" rel="nofollow noreferrer">https://github.com/tiangolo/typer/issues/246</a>
In this ... | <python><python-3.x><python-click><typer> | 2024-04-18 17:15:13 | 1 | 1,086 | Swantewit |
78,349,111 | 2,386,113 | Does passing class variables Stop Paralellization in Numba? | <p>I have a <strong>wrapper method</strong> to call a <strong>Numba-compatible</strong> function. In the code below, the method <code>get_neighbours_wrapper()</code> is just a wrapper to call the Numba function <code>get_neighbours_Numba()</code>.</p>
<p>I want to call the <code>neighbours.get_neighbours_wrapper(point)... | <python><numba> | 2024-04-18 16:46:54 | 1 | 5,777 | skm |
78,349,201 | 1,046,013 | Python script in "Task Scheduler" runs forever | <p>I can't figure out why my Python script works perfectly in the console when I execute it like this (runs for 1-2 seconds):</p>
<p><a href="https://i.sstatic.net/9QQCd2LK.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9QQCd2LK.png" alt="Execution result" /></a></p>
<p>But if I run it in the task sched... | <python><scheduled-tasks><windows-task-scheduler><python-3.x> | 2024-04-18 16:17:33 | 0 | 3,866 | NaturalBornCamper |
78,348,882 | 179,014 | Dynamically alter formulas in Excel templates with jinja2? | <p>I'm searching for a way to fill in pandas dataframes into a given Excel template (keeping all the formatting). I stumbled upon the following interesting blog post using jinja2 templating in Excel sheets:</p>
<p><a href="https://hugoworld.wordpress.com/2019/01/21/easy-excel-reporting-with-python-and-jinja2/" rel="nof... | <python><excel><excel-formula><jinja2> | 2024-04-18 16:02:38 | 1 | 11,858 | asmaier |
78,348,878 | 10,053,485 | Middleware inheritance in mounted FastAPI SubAPI's | <p>The project I'm working on has grown to the point one massive API doesn't suffice, so I have split it into sub applications.</p>
<p>To ensure this refactor goes well, I wanted to test if and how middleware is inherited across parent/daughter applications.</p>
<pre class="lang-py prettyprint-override"><code>from fast... | <python><fastapi><middleware> | 2024-04-18 16:02:15 | 1 | 408 | Floriancitt |
78,348,739 | 8,021,207 | Converting cyclic DiGraph to Acyclic DiGraph (DAG) | <p>How can I remove cycles from my directed graph? It's a big graph (100k+ nodes 200k+ edges) so the method needs to be efficient. I need to make the digraph acyclic in order to use functions like <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.dag.topological_gener... | <python><algorithm><networkx><graph-theory><directed-acyclic-graphs> | 2024-04-18 15:42:47 | 1 | 492 | russhoppa |
78,348,714 | 278,521 | How to change numbers received from text file to integer | <p>I used python script to read numbers form *.txt file and use that number for future works, but the number when I parse I am getting error "TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'"</p>
<p>BUt when I hard code number its working</p>
<pre><code>with open(r'... | <python><python-2.7> | 2024-04-18 15:38:16 | 1 | 4,010 | Sijith |
78,348,637 | 455,796 | make child window always stay above the main window, but not other applications | <p>How to make a modeless (that is, I can still interact with the main window) child always stay above the main window? <code>Qt.WindowStaysOnTopHint</code> makes the child stay above other applications, so this is not what I want. I am using Plasma 6.0 Wayland. A.I.'s said that setting the main window as the parent wo... | <python><pyside><pyside6> | 2024-04-18 15:25:58 | 0 | 12,654 | Damn Vegetables |
78,348,490 | 23,260,297 | json.decoder.JSONDecodeError error python | <p>I have an automation that runs and passes a JSON object to a Python script.</p>
<p>My objective is to read the JSON and convert it to a dictionary.</p>
<p>My JSON looks like this:</p>
<pre class="lang-json prettyprint-override"><code>{
"Items": [
{
"Name": "baz",... | <python><json> | 2024-04-18 15:00:34 | 1 | 2,185 | iBeMeltin |
78,348,470 | 1,141,798 | XGBoost AFT survival model with external memory iterator | <p>How to make <a href="https://xgboost.readthedocs.io/en/latest/tutorials/external_memory.html" rel="nofollow noreferrer">XGBoost external memory</a> and <a href="https://xgboost.readthedocs.io/en/stable/tutorials/aft_survival_analysis.html" rel="nofollow noreferrer">XGBoost survival AFT model</a> work together?</p>
<... | <python><xgboost><survival-analysis> | 2024-04-18 14:58:09 | 1 | 1,302 | Dominik Filipiak |
78,348,446 | 13,294,364 | Fast / Efficient method to retrieve value of specified field with BLPAPI | <p>The reason why I ask this question is because of the manner in which bloomberg sends its data via BLPAPI. Following on from this <a href="https://stackoverflow.com/questions/75958741/blpapi-retrieve-value-of-specific-field/75959836">post</a>, I want to establish an efficient method of obtaining the value of a specif... | <python><bloomberg><blpapi> | 2024-04-18 14:55:40 | 1 | 305 | Harry Spratt |
78,348,385 | 3,872,452 | AsyncClient logging input/output body | <p>Can AsyncClient be extended and parametrized to log the body of input and output of every external call for reuse in multiple methods that use the same AsyncClient?</p>
<pre><code>import json
import logging
from fastapi import FastAPI, HTTPException
from httpx import AsyncClient
# Set up basic configuration for lo... | <python><httpx> | 2024-04-18 14:46:06 | 1 | 418 | Levijatanu |
78,348,320 | 769,922 | Python subclasses function | <p>I have an abstract class defined (BaseClass). And then I define a subclass in a different "folder" or file (SubClass).</p>
<p>In my "main" function, I try to check what are the subclasses of the base class. Ideally, I was hoping it would show me all the subclasses regardless of where they are. Ho... | <python><oop> | 2024-04-18 14:36:26 | 1 | 1,037 | Serendipity |
78,348,285 | 8,262,535 | Pandas time series split shows gaps | <p>I am splitting a continuous timeseries (powerconsumption by the hour) into train/val/test but see unexpected gaps in the split dataframes. What might be the cause?</p>
<pre><code>train_split_end = round(len(df) * (1 - val_ratio))
val_split_end = len(df)
train = df.iloc[:train_split_end]
val = df.iloc[train_split_en... | <python><pandas><dataframe><datetime> | 2024-04-18 14:31:55 | 2 | 385 | illan |
78,348,245 | 2,393,597 | How to uniformly sample from space of orthonormal matrices | <p>A simple way of generating a random orthonormal matrix is to first sample a random matrix and subsequently apply the singular value decomposition</p>
<pre><code>def random_orthonormal_matrix(n):
random_matrix = np.random.normal(0., 1., (n, n))
u, _, _ = np.linalg.svd(random_matrix)
return u
</code></pre>... | <python><random><linear-algebra><numeric> | 2024-04-18 14:24:46 | 1 | 599 | Genius |
78,348,182 | 9,274,726 | Airflow - K8s- Unable to mount HostPath using KubenetesPodOperator | <p>I have a ADF's Airflow managed instance provisioned. And, I'm trying to schedule a DAG.
In this DAG, I'm trying to run a shell script which is present in the HOSTPATH "/opt/airflow/dags" using KubernetesPodOperator. The shell script will submit some kubectl commands to a k8s cluster. However the pod is not... | <python><kubernetes><airflow><directed-acyclic-graphs><kubernetespodoperator> | 2024-04-18 14:17:22 | 0 | 913 | Tad |
78,348,036 | 8,934,639 | How to call AWS Bedrock asynchronously | <p>Is there a way to call Bedrock claude3 model with Python SDK asynchronously?</p>
<p>More specifically, I want the results to be sent to S3.</p>
| <python><large-language-model><amazon-bedrock> | 2024-04-18 13:59:57 | 3 | 301 | Chedva |
78,347,931 | 710,955 | Python: Add a trailing slash to the URL but only if the URL doesn't end in a slash already or a file extension | <p>I want, in Python, normalize a URL. My main purpose is to add slash / at the end of the URL if it is not already present but only if the URL doesn't end in a slash already or a file extension (so images, .php ,files pages, etc. aren't affected).</p>
<p>For example, if it is <code>http://www.example.com</code> then i... | <python><regex><url> | 2024-04-18 13:46:04 | 3 | 5,809 | LeMoussel |
78,347,920 | 8,781,465 | How to integrate a glossary of abbreviations into LangChain for better SQL query generation (NL2SQL)? | <p>I am using <code>LangChain</code> to interface with an Oracle database where many column names include abbreviations. I want to provide <code>LangChain</code> with a glossary that explains these abbreviations to improve its ability to accurately select the right columns for queries. How can I incorporate a glossary ... | <python><langchain><py-langchain> | 2024-04-18 13:43:56 | 0 | 1,815 | DataJanitor |
78,347,898 | 11,586,490 | Emojis appearing as chinese symbols when I share to whatsapp from python | <p>I've built a scorecard app where users can share the results of their scores to WhatsApp. I'm trying to use the medal emojis (first place, second place and third place). It works fine when I print to console on PyCharm with my Windows laptop. However, now I've packaged my apk and deployed my app onto my android phon... | <python><android><kivy><whatsapp> | 2024-04-18 13:41:56 | 1 | 351 | Callum |
78,347,675 | 6,212,530 | Typesafe abstract attributes in Python with Pylance | <p>I followed this <a href="https://stackoverflow.com/a/41897823/6212530">answer for python 3.3</a>:</p>
<pre class="lang-py prettyprint-override"><code>class Abstract(ABC):
@property
@abstractmethod
def title(self) -> str: ...
class Concrete(Abstract):
title = "Test" # pylance error
</cod... | <python><python-typing><pyright> | 2024-04-18 13:03:18 | 2 | 1,028 | Matija Sirk |
78,347,580 | 2,583,417 | Generate buttons programmatically in PyQT | <p>I need to generate buttons within a loop, and inside that loop assign to every button a different task.<br />
I know something like this was already asked, and by doing some search I achieved the following code:</p>
<pre><code>def pressed_0():
print(0)
def pressed_1():
print(1)
def pressed_2():
print(2... | <python><pyqt><pyqt5> | 2024-04-18 12:52:19 | 1 | 585 | Ferex |
78,347,474 | 8,781,465 | How to integrate Oracle Column Comments into LangChain for enhanced SQL query generation (NL2SQL)? | <p>I'm working with an Oracle database that uses column comments to detail cryptic column names, crucial for data retrieval operations. These comments are visible in Oracle SQL Developer but are not included in the <code>CREATE</code> table statement:</p>
<pre><code>COMMENT ON COLUMN "SCHEMA"."TABLE_NAME... | <python><oracle-database><langchain><py-langchain> | 2024-04-18 12:34:02 | 1 | 1,815 | DataJanitor |
78,347,470 | 10,770,967 | Reading UTC timestamp in python pandas and converting it to European dates | <p>I have an issue with a timestamp column, hoping you can provide me some support. I checked here few already posted questions, but somehow I couldn't find the right approach from them.</p>
<p>I have a pandas frame with multiple columns,among others a timestamp. This timestamp column contains utc dates. My goal is to ... | <python><pandas><datetime><utc> | 2024-04-18 12:33:44 | 2 | 402 | SMS |
78,347,434 | 8,588,743 | Problem setting up Llama-2 in Google Colab - Cell-run fails when loading checkpoint shards | <p>I'm trying to use <a href="https://huggingface.co/meta-llama/Llama-2-7b-chat-hf" rel="nofollow noreferrer">Llama 2 chat</a> (via hugging face) with 7B parameters in Google Colab (Python 3.10.12). I've already obtain my access token via Meta. I simply use the code in hugging face on how to implement the model along w... | <python><huggingface-transformers><large-language-model><llama> | 2024-04-18 12:28:02 | 1 | 903 | Parseval |
78,347,363 | 10,012,856 | Upload a photo returns 'Item type not valid.' | <p>I'm trying to upload a photo using the code below based on ArcGIS Python API:</p>
<pre><code>def handle_attachments_api(
portal_domain: str,
portal_username: str,
portal_password: str,
data_type: str = None,
data_url: str = None,
filename: str = None,
type_keywords: str = None,
descri... | <python><arcgis> | 2024-04-18 12:15:45 | 1 | 1,310 | MaxDragonheart |
78,347,354 | 893,254 | Python find index of element in list based on evaluation of a function | <p>I am trying to find the index of an item in a Python list based on the evaluation value of a lambda function (or other callable).</p>
<p>This would be similar to a combination of an <code>.index()</code> operation with a <code>find_if</code> operation.</p>
<p>Here is an example:</p>
<pre><code># self contains `self.... | <python> | 2024-04-18 12:12:57 | 2 | 18,579 | user2138149 |
78,347,277 | 3,906,713 | How to modularize dependent unit tests in Python | <p>Here is a hypothetical composite unit test. It calls two algorithms, checks some properties of the results independently, and then compares them to each other.</p>
<pre><code>class MyTestCase(unittest.TestCase):
def test_composite(self):
# Test 1. Testing first algorithm
result1 = algorthm1()
as... | <python><unit-testing> | 2024-04-18 12:00:47 | 0 | 908 | Aleksejs Fomins |
78,347,183 | 14,923,149 | Title: How to visualize hierarchical data with nested pie charts in Python? | <p>I have hierarchical data that I would like to visualize using nested pie charts in Python. The data consists of Phylum, Genus, and Species levels, and I want to create a nested pie chart where each level represents a ring in the chart.</p>
<p>I have already attempted to implement this using Matplotlib, but I'm facin... | <python><pandas><matplotlib> | 2024-04-18 11:49:14 | 1 | 504 | Umar |
78,346,963 | 6,717,444 | Write file extensions and their occurrences in a list into a dictionary? | <p>How can I solve this with loops, without regular expressions?</p>
<p>Write a function that accepts a list of file names and returns a dictionary with extensions as keys and their occurrences as value.</p>
<p>Example:</p>
<pre><code>#print(count_file_types(["image1.jpg", "image2.jpg", "preso.... | <python><python-3.x><list><dictionary> | 2024-04-18 11:09:46 | 4 | 350 | Evanto |
78,346,937 | 6,278,424 | gettign json.decoder.JSONDecodeError at random | <p>I have implemented this function given by this answer: <a href="https://quant.stackexchange.com/a/70155/33457">https://quant.stackexchange.com/a/70155/33457</a></p>
<p>when I run this code sometimes it goes well while most of the time it returns this error:</p>
<pre><code>raise JSONDecodeError("Expecting value&... | <python><request><yahoo-finance> | 2024-04-18 11:05:31 | 1 | 530 | k.dkhk |
78,346,892 | 7,267,640 | gRPC client request streaming: - "The client reset the request stream." | <p>I am trying to implement request streaming from my python client to my C# server using gRPC.
This is my protofile:</p>
<pre class="lang-protobuf prettyprint-override"><code> syntax = "proto3";
service PerceiveAPIDataService {
rpc UploadResource (stream UploadResourceRequest) returns (... | <python><c#><grpc><grpc-python><grpc-c#> | 2024-04-18 10:57:56 | 1 | 6,888 | Luuk Wuijster |
78,346,868 | 10,811,647 | How to reduce my Tensorflow docker image? | <p>I have a Dash app running fine locally. The app uses tensorflow and ultralytics to detect some events on a graph using yolo8. I am trying to deploy this app to a server inside a docker container. The first image I built was based on the <code>tensorflow:latest-gpu</code> docker image. The resulting image size was 19... | <python><docker><tensorflow><plotly-dash> | 2024-04-18 10:55:26 | 0 | 397 | The Governor |
78,346,757 | 5,931,672 | Overriding multiprocessing.queues.Queue put method | <p>I want to implement a <code>multiprocessing.Queue</code> that does not add an element that already exists.
Using Python STL Queue I had no problem, following <a href="https://stackoverflow.com/a/16506527/5931672">this</a> response. For multiprocessing I had some issues that I solved thanks to <a href="https://stacko... | <python><multiprocessing><queue> | 2024-04-18 10:36:02 | 2 | 4,192 | J Agustin Barrachina |
78,346,628 | 10,595,871 | Scrape contents of Network section of an element in a page | <p>I need to scrape a page, the website is the following:
<a href="https://commercialisti.it/iscritti" rel="nofollow noreferrer">https://commercialisti.it/iscritti</a>
It's only in italian but still, it is a list of professional people that I'm able to search via "Cap".</p>
<p>For example, by filling the Cap ... | <python><beautifulsoup> | 2024-04-18 10:15:28 | 1 | 691 | Federicofkt |
78,346,215 | 7,219,400 | Python Flask Sqlite is not creating a column in a specific line or name | <p>This is just mind blowing
I am trying to use in-memory table for small data that can be got easily but I dont want to send request all the time, so I save it in in-memory sqlite table
here is my <strong>init</strong>.py file:</p>
<pre><code>from flask import Flask
from .models import db
from apscheduler.schedulers.b... | <python><sqlite><flask><sqlalchemy> | 2024-04-18 09:09:32 | 1 | 1,464 | Sahin |
78,346,156 | 7,295,936 | pd dataframe applymap tries to modify col names | <p>Hello i have a dataframe containing datetime infos and i'd like too format those infos so i've used this command :</p>
<pre><code>df2[["month", "day", "hour", "min", "s"]] = df2[["month", "day", "hour", "min", "s"]]... | <python><python-3.x><pandas><dataframe><lambda> | 2024-04-18 08:59:57 | 1 | 1,560 | FrozzenFinger |
78,346,024 | 2,803,777 | How to fill an nd array with values from a 1d-array? | <p>The following is a real-world problem in <code>numPy</code> reduced to the essentials, just with smaller dimensions.</p>
<p>Let's say I want to create an n-dimensional array <code>all</code> with dimensions (10, 10, 100):</p>
<pre><code>all = np.empty((10, 10, 100))
</code></pre>
<p>I also have a 1d array <code>data... | <python><numpy><numpy-ndarray><numpy-slicing> | 2024-04-18 08:35:57 | 1 | 1,502 | MichaelW |
78,345,829 | 11,586,490 | Making text line up vertically when sharing to WhatsApp | <p>I've created a simple scorecard app, that sums users scores while they're playing games (card games, golf etc). I've added in the ability to share the result of their game to WhatsApp and I'd like it to appear a bit like a table, with the player name and then the player score, each player on a new line.</p>
<p>I'm t... | <python><android><whatsapp> | 2024-04-18 08:06:33 | 1 | 351 | Callum |
78,345,753 | 13,200,217 | mypy checking pyi in venv despite excluding it | <p>I have a PySide project set up using a pyproject.toml file, with venv+pip.</p>
<p>I have set up mypy in the pyproject.toml file as follows:</p>
<pre class="lang-ini prettyprint-override"><code>[tool.mypy]
disable_error_code = ["import-untyped"]
exclude = ["^.venv/", "^myproject/somefolder/&q... | <python><mypy><pyproject.toml> | 2024-04-18 07:54:14 | 0 | 353 | Andrei MiculiΘΔ |
78,345,731 | 2,739,700 | Azure alerting for KQL query using Python | <p>I could not able to create alert using Python code, Manually It got created</p>
<p>Below is the code:</p>
<pre><code>from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.monitor import MonitorManagementClient
from azure.mgmt.monitor.v2018_04_16.mo... | <python><azure><azure-media-services><azure-monitoring><azure-alerts> | 2024-04-18 07:48:33 | 1 | 404 | GoneCase123 |
78,345,554 | 3,793,935 | Python file.save saves empty file | <p>I retrieve files from a frontend upload, and convert an hash over the file this way:</p>
<pre><code>blob_file = convert_to_blob(file)
</code></pre>
<p>with this function:</p>
<pre><code>def convert_to_blob(file: file_storage.FileStorage) -> bytes:
os_path = os.path.join(config('UPLOAD_CONVERT'), "convert... | <python><file> | 2024-04-18 07:18:16 | 2 | 499 | user3793935 |
78,345,428 | 108,390 | How to avoid Mypy Incompatible type warnings in Chained when/then assignments? | <p>I have the following code</p>
<pre><code>expr = pl.when(False).then(None)
for pattern, replacement in replacement_rules.items():
expr = expr.when(pl.col("data").str.contains(pattern))
expr = expr.then(pl.lit(replacement))
expr = expr.when(pl.col("ISO_codes").str.len_chars() > 0)
e... | <python><mypy><python-typing><python-polars> | 2024-04-18 06:55:37 | 1 | 1,393 | Fontanka16 |
78,345,364 | 51,816 | How to draw waveform as curve using matplotlib? | <p>I wrote this code:</p>
<pre><code>def plotWaveforms(audioFile1, audioFile2, imageFile, startSegment=30, endSegment=35, amp1=0.5, amp2=0.5):
# Load audio files
y1, sr1 = librosa.load(audioFile1, sr=None, offset=startSegment, duration=endSegment - startSegment)
y2, sr2 = librosa.load(audioFile2, sr=None, o... | <python><matplotlib><audio><visualization><waveform> | 2024-04-18 06:45:08 | 1 | 333,709 | Joan Venge |
78,345,271 | 8,510,149 | Pandas shift operation with condition | <p>Below I have a small dataset with 3 columns, ID; tag and value. Tag represent the source of the information that the feature 'value' is based on.</p>
<p>I want to create a lag feature for 'value'. Below I do that in an easy way. However, for index 3 and 4 we can see that 'tag' has the same value. This situation I do... | <python><pandas> | 2024-04-18 06:27:24 | 1 | 1,255 | Henri |
78,345,055 | 4,987,648 | Static type checking for union type and pattern matching | <p>In functional languages like Ocaml/Haskell/β¦ I can type something like:</p>
<pre class="lang-ocaml prettyprint-override"><code>type expr =
| Nb of float
| Add of expr * expr
| Soust of expr * expr
| Mult of expr * expr
| Div of expr * expr
| Opp of expr
let rec eval x = match x with
| Nb... | <python><pattern-matching><python-typing> | 2024-04-18 05:30:55 | 1 | 2,584 | tobiasBora |
78,344,781 | 9,951,273 | How can I infer return type for object based on parameter? | <p>Let's say we have a function</p>
<pre><code>def get_attr_wrapper(obj: object, attr: str) -> ???:
return getattr(obj, attr)
</code></pre>
<p>How can I infer the return type of <code>get_attr_wrapper</code> based on the parameters given?</p>
<p>Maybe with a generic somehow?</p>
<p>For example, if I passed in</p... | <python><python-typing> | 2024-04-18 03:55:38 | 1 | 1,777 | Matt |
78,344,729 | 1,601,580 | How do I have multiple src directories at the root of my python project with a setup.py and pip install -e? | <p>I want to have two src dirs at the root of my project. The reason is that one is code I want to work without modifying any of the imports. The second is new code indepdent of the "old code". I want two src's with and <code>pip install -e .</code> to work. My <code>setup.py</code> is:</p>
<pre class="lang-p... | <python><pip><setuptools><setup.py><python-packaging> | 2024-04-18 03:34:08 | 2 | 6,126 | Charlie Parker |
78,344,695 | 20,898,396 | Type checking for pipeline similar to Langchain LCEL | <p>I am trying to write a pipeline with types that will give errors if the steps are not compatible <code>step1() | step2()</code>.</p>
<pre><code>from typing import Any, Callable, Generic, TypeVar
I = TypeVar('I')
O = TypeVar('O')
R = TypeVar('R')
class Runnable(Generic[I, O]):
def __init__(self, func: Callable[... | <python><langchain> | 2024-04-18 03:22:04 | 0 | 927 | BPDev |
78,344,611 | 12,314,521 | How to random a number depend on length of a given sring Python | <p>I want to random an integer from a range which the probability correlates with the number of tokens string.</p>
<p>For example:</p>
<p>Given max possible number of tokens = 64. Random integer's range is from 0 to 7</p>
<p>Given a string has 46 tokens.</p>
<p>I want to use the function <code>random.choices([0,1,2,3,4... | <python> | 2024-04-18 02:55:11 | 2 | 351 | jupyter |
78,344,486 | 2,740,376 | Permission denied errors using docker image glue_libs_4.0.0_image_01 for AWS Glue | <p>I'm trying to build a pipeline that is using glue_libs_4.0.0_image_01. A step in the pipeline is running the docker instance as follows:</p>
<pre><code> docker run \
--mount=type=bind,source=./test,target=/home/glue_user/workspace/test \
--mount=type=bind,source=./libs,target=/home/glue_user/workspace/libs... | <python><amazon-web-services><docker><aws-glue> | 2024-04-18 02:02:29 | 1 | 319 | Iulian |
78,344,470 | 292,502 | How to have a programmatical conversation with an agent created by Agent Builder | <p>I created an agent with No Code tools offered by the Agent Builder GUI: <a href="https://vertexaiconversation.cloud.google.com/" rel="nofollow noreferrer">https://vertexaiconversation.cloud.google.com/</a>
I created a playbook and added a few Data store Tools for the agent to use for RAG.
I'd like to call this agent... | <python><google-cloud-platform><google-cloud-vertex-ai><dialogflow-cx><rag> | 2024-04-18 01:56:24 | 2 | 10,879 | Csaba Toth |
78,344,353 | 2,488,207 | Create new columns and assign their values from existing column's values | <p>I have a Dataset downloaded from Kaggle for my project, I would like to create new columns and assign their values based on an existing column.</p>
<p>My actual Dataset is complicated, I will give a similar but simpler dataset for easy discussion.</p>
<p><strong>Input:</strong></p>
<pre><code>Month | Fruit | Weigh... | <python><dataframe> | 2024-04-18 01:04:27 | 1 | 868 | vyclarks |
78,344,349 | 16,717,009 | Can a list comprehension that builds a list of lists referring to itself be done in one line? | <p>I have a number of list comprehensions that build a variety of lists of lists. To keep this simple, consider:</p>
<pre><code>foo = []
for i in range(1,3): # dummy loop for the example
if len(foo) == 0:
foo = [[x] for x in (0, 1, -1)] # can I avoid this step?
else:
foo = [f + [x] for f in fo... | <python> | 2024-04-18 01:02:25 | 1 | 343 | MikeP |
78,344,145 | 8,876,025 | buildx build --platform linux/amd64 significantly increases image size with poetry | <p>Packages installed by poetry significantly increases the image size when it's built for amd64.</p>
<p>I'm building a docker image on my host machine(MacOS, M2 Pro), which I want to deploy to an EC2 instance. Normal build will make an image size of 2GB, which is good. But it will result in system compatibility issue ... | <python><docker><python-poetry> | 2024-04-17 23:30:34 | 4 | 2,033 | Makoto Miyazaki |
78,344,061 | 4,766 | How do I install avdec_h264 for use with GStreamer in Python on macOS? | <p>I answered my own question <a href="https://stackoverflow.com/q/78281985/4766">How do install gst-python on macOS to work with the recommended GStreamer installers?</a> by using <a href="https://stackoverflow.com/a/78295888/4766">miniconda</a>.</p>
<p>Then I moved on to creating a GStreamer pipeline. But I get an er... | <python><macos><conda><gstreamer><h.264> | 2024-04-17 22:53:45 | 1 | 150,682 | Daryl Spitzer |
78,344,022 | 219,153 | Why is this seemingly redundant Python import statement necessary? | <p>This snippet of Python 3.12 code:</p>
<pre><code>import paho
import paho.mqtt.client # line 2
client = paho.mqtt.client.Client(paho.mqtt.enums.CallbackAPIVersion(2))
</code></pre>
<p>fails when line #2 is commented out. <code>paho</code> module is imported by the first line. I'm using the full name <code>paho.mqtt... | <python><python-3.x><python-import> | 2024-04-17 22:38:48 | 2 | 8,585 | Paul Jurczak |
78,344,011 | 14,083,003 | ValueError: For a sparse output, all columns should be a numeric or convertible to a numeric | <p>I am doing a pre-processing for my data before applying sklearn models, but I am having trouble identifying why an error keeps happening. When I run the code for each individual column index in <code>ColumTransformer</code>, it works well for each variable. However, the error happens when I apply it to multiple colu... | <python><scikit-learn><transformation><one-hot-encoding><categorical> | 2024-04-17 22:31:51 | 1 | 411 | J.K. |
78,343,931 | 1,972,982 | Creating Scheduled Posts with an Image using Facebook Graph API | <p>I'm using a Python script to try and create a post on a Facebook page. I've been able to create the post and schedule it for the future. It all goes wrong when I try to add an image.</p>
<p>First question, is this a limit of the Facebook API?</p>
<p>Here is my Python code (I've redacted the access token and page ID)... | <python><facebook-graph-api> | 2024-04-17 21:58:40 | 0 | 333 | Jamie |
78,343,897 | 8,021,207 | An async/parallel approach to working a (potentially) growing task queue | <p>I have a list of items that need to be processed and I want to be able to process them in parallel for efficiency. But during the processing of one item I may discover more items that need to be added to the list to be processed.</p>
<p>I've looked at the <a href="https://docs.python.org/3/library/multiprocessing.ht... | <python><multithreading><concurrency><multiprocessing> | 2024-04-17 21:43:15 | 1 | 492 | russhoppa |
78,343,854 | 3,512,538 | python object cleanup order - can I use object reference to force GC to collect another object first? | <p>I have 2 objects <code>a, b</code> (instances of <code>A,B</code> respectively) that are created inside my app:</p>
<pre class="lang-py prettyprint-override"><code>class A:
def __del__(self):
print("A.__del__")
class B:
def __del__(self):
print("B.__del__")
a = A()
b = ... | <python><garbage-collection><pybind11> | 2024-04-17 21:32:06 | 1 | 12,897 | CIsForCookies |
78,343,764 | 23,260,297 | JSON text as command line argument when running python script | <p>I have read similar questions relating to passing JSON text as a command line argument with python, but none of the solutions have worked with my case.</p>
<p>I am automating a python script, and the automation runs a powershell script that takes a JSON object generated from a power automate flow. Everything works g... | <python><json><powershell> | 2024-04-17 21:05:59 | 2 | 2,185 | iBeMeltin |
78,343,713 | 9,092,669 | scrape rotowire MLB player news and form into a table using python | <p>i would like to scrape <a href="https://www.rotowire.com/baseball/news.php" rel="nofollow noreferrer">https://www.rotowire.com/baseball/news.php</a> which contains news about MLB players and save the data in a table format like so:</p>
<div class="s-table-container"><table class="s-table">
<thead>
<tr>
<th>date</th>... | <python><web-scraping><beautifulsoup> | 2024-04-17 20:54:49 | 1 | 395 | buttermilk |
78,343,506 | 345,660 | Split concave object mask into 1 or more convex sub-sections | <p>I am working with an object detection model. It works pretty well, but the output is a mask, and I need bounding boxes. Naively, I can just use OpenCV to draw a bounding box around the contours of the mask, but if the mask is very concave that can include large non-image regions.</p>
<p>I've figured out how to use ... | <python><opencv><geometry><object-detection><semantic-segmentation> | 2024-04-17 19:56:17 | 0 | 30,431 | Zach |
78,343,430 | 595,305 | Mock or stub a QEvent? | <p>Is there a way to mock a <code>QEvent</code> and pass it as a parameter?</p>
<p>I have a test like this which I want to include:</p>
<pre><code>def test_table_resize_event_sets_column_widths():
table = results_table_classes.ResultsTableView(None)
with mock.patch.object(table, 'setColumnWidth') as mock_set:
... | <python><testing><pyqt><pytest><pytest-qt> | 2024-04-17 19:36:57 | 0 | 16,076 | mike rodent |
78,343,313 | 8,382,028 | Adding HTML Button to Draftail Editor Action Buttons in Wagtail | <p>I am having an issue wrapping my head around adding a custom button in Wagtail to the RichTextEditor buttons, where when clicked, a user of the editor is able to add a link with an html <code>button</code>.</p>
<p>The code I used for this in TinyMCE was originally provided here: <a href="https://dev.to/codeanddeploy... | <python><django><wagtail><draftail> | 2024-04-17 19:06:53 | 1 | 3,060 | ViaTech |
78,343,287 | 7,921,684 | influxd TypeError: <lambda>() got an unexpected keyword argument 'key_key_password' | <p>I am using the guide and copying the lines and token from the generated code in the document but when I run I face this error which refers to this line <strong>write_api.write(bucket=bucket, org=org, record=point).</strong>
influxdb 2.7.5</p>
<pre><code>client = influxdb_client.InfluxDBClient(url=url, token=token, o... | <python><influxdb><influxdb-2> | 2024-04-17 19:00:52 | 1 | 586 | Gray |
78,343,089 | 7,938,217 | Ensuring VSCode Python Autocompletion | <p>How can I ensure that when I instantiate a data structure in VSCode+Jupyter+Python, the attributes of the data structure are available for autocompletion throughout the notebook.</p>
<pre><code>
# %% Jupyter Cell #1
#This cell is executed before attempting autocompletes in cell 2
@dataclass
class ExistingItemNames:
... | <python><visual-studio-code><jupyter-notebook><pylance><python-jedi> | 2024-04-17 18:21:16 | 1 | 400 | Kelley Brady |
78,343,052 | 5,722,359 | Lifted ttk.Label widget can't redraw promptly? | <p>Here is my minimum representative example (MRE) on how I create <code>ttk.Button</code> widgets with an image via a multithreaded approach. However, I am experiencing an issue with a task that occurs before the multithreading task. Whenever the <code>self.label</code> widget is lifted, it can't be redrawn promptly; ... | <python><tkinter><tcl> | 2024-04-17 18:12:29 | 2 | 8,499 | Sun Bear |
78,343,028 | 8,484,885 | Remove any observations containing only characters (or a zip code with no other numeric values) | <p>I'm trying to create a flag for flawed addresses and my idea is to remove all observations that have no numeric value in them. I don't want zip codes, so first step would be to remove those) and then apply a second filter to remove anything without non-remaining numeric values.</p>
<p>In the following data frame, I ... | <python><pandas> | 2024-04-17 18:07:21 | 1 | 589 | James |
78,342,932 | 15,100,030 | Django annotate over multi records forignkeys | <p>I Work on a KPI system in which every manager can put specific questions for each user and answer them every month from 1 to 10
we have 4 departments, and every department says to have 4 question
these answers have to be calculated to return the % number for each department</p>
<p><strong>Models</strong></p>
<pre cl... | <python><django><postgresql> | 2024-04-17 17:48:20 | 0 | 698 | Elabbasy00 |
78,342,889 | 1,644,352 | Poetry can't install setuptools? | <p>I'm trying to use Poetry to run <a href="https://jenkins-job-builder.readthedocs.io/en/latest/" rel="nofollow noreferrer">jenkins-job-builder</a> 4.3 (yes it's old but IIUC upgrading is non-trivial). However, it fails with:</p>
<pre class="lang-none prettyprint-override"><code>ERROR:stevedore.extension:Could not loa... | <python><setuptools><python-poetry> | 2024-04-17 17:41:04 | 0 | 2,842 | Matthew |
78,342,736 | 15,098,472 | Collecting varying element indices from a tensor across multiple dimensions | <p>Assume I got the following tensor:</p>
<pre><code>arr = torch.randint(0, 9, (100, 50, 3))
</code></pre>
<p>What I want to achieve is collecting, for example, 2 elements of that tensor, let's start with collecting the 6th and 56th one:</p>
<pre><code>indices = torch.tensor([5, 55])
partial_arr = arr[indices]
</code><... | <python><indexing><pytorch> | 2024-04-17 17:12:39 | 1 | 574 | kklaw |
78,342,468 | 12,190,301 | Is the result of pyperf in real time or in CPU seconds? | <p>I would assume the output of <a href="https://github.com/psf/pyperf/tree/main" rel="nofollow noreferrer"><code>pyperf</code></a> is in real time, but I couldn't find confirmation anywhere.</p>
| <python><profiling> | 2024-04-17 16:20:11 | 1 | 2,109 | Schottky |
78,342,414 | 11,233,365 | How to check Python environment for hidden modules (not listed, but can be imported) | <p>To expand on the title, my question comes in two parts:</p>
<ol>
<li>Is it possible for a Python package to be installed in an environment as a dependency for another package, but not show up when you list down all installed packages in that environment using commands such as <code>conda list</code>, <code>mamba lis... | <python><installation><package><environment> | 2024-04-17 16:08:59 | 0 | 301 | TheEponymousProgrammer |
78,342,362 | 16,717,009 | Finding existing subtotals in a pandas dataframe or a list of numbers | <p>Here's an interesting problem. Given a pandas Dataframe (or even a Python list) how would one go about finding the subtotals that might be in that list? For example:</p>
<pre><code> running value
0 False 50709
1 False 26715
2 False 1715
3 False 79139
4 False 34447
5 False -7256
6 ... | <python><pandas><algorithm> | 2024-04-17 15:58:31 | 1 | 343 | MikeP |
78,342,315 | 1,422,096 | Reorder dict with custom order | <p>Given a dict <code>d</code>, now that we know since Python 3.7 that (insertion) order is preserved, is there a built-in way to ask for <strong>the same dict with the same keys, except that some keys k1, k2, ... should come first?</strong></p>
<p>Example:</p>
<ul>
<li>key <code>a</code> (if present) should be first,<... | <python><dictionary> | 2024-04-17 15:51:40 | 2 | 47,388 | Basj |
78,342,289 | 6,197,439 | Very bizarre: tzlocal.get_localzone() different output based on python3 aliasing? | <p>I just noticed this, I'm completely puzzled so as to why it happens, and how I can prevent it.</p>
<p>The computer I work on is Windows 10, and is set up in city Copenhagen. My platform is this:</p>
<pre class="lang-none prettyprint-override"><code>$ for ix in "uname -s" "python3 --version"; do e... | <python><python-3.x><timezone><mingw-w64> | 2024-04-17 15:47:54 | 1 | 5,938 | sdbbs |
78,342,216 | 7,217,960 | Suppress GLib-GIO-WARNING originating from Weasyprint/GTK3 | <p>I'm using Weasyprint in Python to generate PDF files from HTML files.
After a recent system update of my Windows machine, I started to observe waring log messages printed on the console such as this one:</p>
<blockquote>
<p>(process:41316): GLib-GIO-WARNING **: 10:36:44.529: Unexpectedly, UWP
app <code>Microsoft.Out... | <python><gtk3><glib><weasyprint> | 2024-04-17 15:38:20 | 0 | 412 | Guett31 |
78,342,036 | 16,759,116 | Cartesian product without reuse | <p>I have two generators producing data, for example:</p>
<pre class="lang-py prettyprint-override"><code>def xs():
yield [1, 2]
yield [3, 4]
def ys():
yield [5, 6]
yield [7, 8]
</code></pre>
<p>And I want to process all possible (x,y) pairs:</p>
<pre class="lang-py prettyprint-override"><code>process(... | <python><generator><cartesian-product> | 2024-04-17 15:10:22 | 3 | 10,901 | no comment |
78,341,826 | 1,422,058 | Extract feature names from XGBRegressor used in scikit-learn pipeline with OneHotEncoded categorical features | <p>I have a dataset with a few numierical and a few categorical features. After calling fit on the XGBRegressor, I want to check the feature importance. Fo this, I want to map the feature importance scores to the feature names the regressor is used in a scikit learn pipeline.</p>
<pre><code>categorical_encoder = Pipeli... | <python><scikit-learn><xgbregressor> | 2024-04-17 14:36:57 | 1 | 1,029 | Joysn |
78,341,724 | 3,341,533 | KustoBlobError When Performing Queued Ingestion with azure-kusto-ingest python client | <p>I am able to successfully ingest data from a local pandas DataFrame into Azure ADX using the python azure-kusto-ingest library when I run this from my windows laptop.<br />
However, when I run this from an Azure compute Windows VM, a KustoBlobError is raised with the following message:</p>
<blockquote>
<p>azure.kust... | <python><azure-data-explorer> | 2024-04-17 14:23:07 | 0 | 1,032 | BioData41 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.