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,097,219
5,790,653
python for loop over different lists not to be equal shows incorrect output
<p>This is my python code:</p> <pre class="lang-py prettyprint-override"><code>statuses = [ {'id': '1', 'plan_id': '124124124', 'ip': '1.1.1.1', 'name': 'Saeed1', 'status': 'active'}, {'id': '2', 'plan_id': '124224124', 'ip': '2.2.2.2', 'name': 'Saeed2', 'status': 'suspended'}, {'id': '3', 'plan_id': '16412...
<python>
2024-03-03 16:59:17
1
4,175
Saeed
78,097,177
9,601,258
How to get specific unique combinations of a dataframe using only dataframe operations?
<p>I have this data that contains entries of 2 players playing a game one after another then after they both gain a win or lose they get a shared score (logic of this is unimportant numbers are random anyway this is just an example to describe what I want).</p> <p>So there are scores obtained for every possible outcome...
<python><pandas><dataframe>
2024-03-03 16:48:58
1
925
Cem Koçak
78,097,126
1,290,485
How do I resolve the TypeError with databricks.proto for databricks-registry-webhooks?
<p>I am trying to create webhooks for <a href="https://docs.databricks.com/en/_extras/notebooks/source/mlflow/mlflow-model-registry-webhooks-python-client-example.html" rel="nofollow noreferrer">MLflow in Databricks</a>. However, I am getting the following TypeError when importing <code>from databricks_registry_webhook...
<python><typeerror><databricks><webhooks><mlflow>
2024-03-03 16:36:33
1
6,832
Climbs_lika_Spyder
78,096,938
16,667,620
Selective Thresholding in OpenCV
<p>I am exploring OpenCV and struck at this point. here wanted to do kind of selective threshold a image ,so that RGB / non-text image dont get distorted am able to do threshold to get the following result :<br> code :</p> <pre><code>Mat adap_threshold(Mat img) { Mat img_gray; cvtColor(img, img_gray, COLOR_BGR2...
<python><c++><opencv><image-processing><ocr>
2024-03-03 15:37:32
1
426
Ayush Yadav
78,096,863
13,130,804
Working outside of application context when using flask_api_key
<p>Based on <a href="https://pypi.org/project/flask-api-key/" rel="nofollow noreferrer">https://pypi.org/project/flask-api-key/</a> I am trying to implement:</p> <pre><code>from flask import Flask from flask_api_key import APIKeyManager, api_key_required app = Flask(__name__) my_key_manager = APIKeyManager(app) my_ke...
<python><flask><api-key>
2024-03-03 15:14:08
1
446
Miguel Gonzalez
78,096,759
632,472
How to edit windows file details?
<p>In <strong>windows explorer</strong>, there is a long list of details you can choose to view:</p> <p><a href="https://i.sstatic.net/jLsz3.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jLsz3.jpg" alt="right click in columns and select More..." /></a></p> <p>How can I programaticaly edit theses itens ...
<python><windows><powershell><windows-explorer>
2024-03-03 14:48:28
0
12,804
Rodrigo
78,095,982
4,429,265
Having one vector column for multiple text columns on Qdrant
<p>I have a products table that has a lot of columns, which from these, the following ones are important for our search:</p> <ol> <li>Title 1 to Title 6 (title in 6 different languages)</li> <li>Brand name (in 6 different languages)</li> <li>Category name (in 6 different languages)</li> <li>Product attributes like size...
<python><vector><embedding><vector-search><qdrant>
2024-03-03 10:46:29
3
417
Vahid
78,095,746
20,292,449
FileNotFoundError: rtfparser python package
<p>Any one experienced with this package, i have tried many thing and it does not work , i have checked whether the file exists or not many times, absolute | relative path, it does not work</p> <pre><code>D:\pythonCodePycharmProjects\carProject\venv\Scripts\python.exe D:\pythonCodePycharmProjects\carProject\main.py Tr...
<python><pip><rtf>
2024-03-03 09:21:25
1
532
ayex
78,095,743
1,626,977
python ldap search returns error when ou is filtered
<p>I have a python script to search in an LDAP server. I used to search filtering the DC in my base DN. Now, I want to expand my filter to OU too. But when I use OU in my base DN, I get following error:</p> <pre><code>/usr/bin/python3.6 /home/zeinab/PycharmProjects/ldap-test/main.py Traceback (most recent call last): ...
<python><ldap><ou>
2024-03-03 09:18:48
1
10,557
Zeinab Abbasimazar
78,095,712
18,483,009
ValueError: The following model_kwargs are not used by the model: ['return_full_text'] when using RetrievalQA in LangChain
<p>I'm encountering a ValueError while using the RetrievalQA class in LangChain. The error message indicates that the model_kwargs parameter contains an unused parameter, 'return_full_text'. I've reviewed my code and ensured that this parameter is not being passed to the model initialization or the RetrievalQA instanti...
<python><large-language-model><langchain-js>
2024-03-03 09:08:34
0
583
AmrShams07
78,095,645
922,712
How do I get Selenium on python to connect to an existing instance of Firefox - I am unable to connect to the marionette port
<p>I am trying to use Selenium to connect to existing instance of Firefox - the documentation says to use something like this</p> <pre><code>options=webdriver.FirefoxOptions() options.binary_location = r'C:\Program Files\Mozilla Firefox\firefox.exe' webdriver_service = Service(r'c:\tmp\geckodriver.exe') driver = webd...
<python><selenium-webdriver><firefox><automation>
2024-03-03 08:41:10
2
14,081
user93353
78,095,616
16,813,096
Syncing audio/video in pyav decoding
<p>I am making a simple video player with pyav, and using the <code>container.decode(video=0, audio=0)</code> method to decode both audio and video frames, then syncing them using PIL and pyaudio.</p> <p>Here is the summary code/method I used:</p> <pre class="lang-py prettyprint-override"><code>import av import pyaudio...
<python><playback><pyaudio><video-player><pyav>
2024-03-03 08:31:25
0
582
Akascape
78,095,596
4,522,501
How to continue looping a list without wait for new messages telethon python
<p>I'm new with telethon and I have a telethon python script that is listening for telegram messages, all this part works correctly, but I'm improving my script, what I need to achieve is the following:</p> <p>I'm looping a list, that needs to do something that takes around 10-15 seconds for each item in the list, If I...
<python><for-loop><telegram><telethon>
2024-03-03 08:24:35
0
1,188
Javier Salas
78,095,381
23,106,915
Is it possible to host a selenium app on a server?
<h2>Description:</h2> <p>Hi there, I have created a Selenium app that's interactive and changeable according to users need with the help of Streamlit interface. The app itself is working perfectly fine without any issue, additionally all the packages that needs to be installed are added inside of the <code>requirements...
<python><selenium-webdriver><selenium-chromedriver><streamlit>
2024-03-03 06:48:21
1
546
AshhadDevLab
78,095,361
1,418,326
Not able to debug unittest in vscode for python
<p>I am able to Run unittest for python in vscode, but not debug it. what did I do wrong?</p> <p>Structure:</p> <pre><code>myproject \mymodule \matrix.py \test \matrix_test.py </code></pre> <p>in matrix_test.py:</p> <pre><code>import unittest from mymodule import matrix class MyTestCase(unittest.TestCas...
<python><python-unittest><vscode-debugger>
2024-03-03 06:37:31
0
1,707
topcan5
78,095,320
713,200
How to grab a text from a particular tag?
<p>I have the following source and I want to get text from a particular attribute of tag <code>image</code> <a href="https://i.sstatic.net/Cokj3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Cokj3.png" alt="enter image description here" /></a></p> <p>I'm able to get to the image tag using the following...
<python><selenium-webdriver><xpath>
2024-03-03 06:23:20
1
950
mac
78,095,279
1,226,676
Create a queryset that automatically queries onetoone objects
<p>I'm building a django application that has a model with multiple <code>OneToOne</code> relationships:</p> <pre><code>class MyApp(BaseModel): site_1 = models.OneToOneField( Site, on_delete=models.CASCADE, related_name=&quot;site1&quot;, null=True ) site_2 = models.OneToOneField( Site, on_d...
<python><django><django-queryset>
2024-03-03 06:00:35
1
5,568
nathan lachenmyer
78,094,992
4,159,833
How to obtain and click the URL of a dynamically loaded website?
<p>I would like to scrape the marathon results from the link (call it page A): <a href="https://www.marathon.tokyo/2023/result/index.php" rel="nofollow noreferrer">https://www.marathon.tokyo/2023/result/index.php</a></p> <p>Suppose I choose the 'Marathon Men' in the first option and then search, I get to the following ...
<javascript><python><selenium-webdriver><web-scraping><beautifulsoup>
2024-03-03 03:09:51
1
3,068
Physicist
78,094,964
2,739,700
Example for Azure Alert create using Python SDK
<p>I am trying to create Azure Alert using Python SDK and Below is the code</p> <pre><code>from azure.mgmt.monitor import MonitorManagementClient from azure.mgmt.monitor.models import RuleMetricDataSource from azure.identity import DefaultAzureCredential from azure.mgmt.monitor.models import ThresholdRuleCondition from...
<python><azure><azure-monitoring><azure-alerts>
2024-03-03 02:51:59
1
404
GoneCase123
78,094,928
2,585,024
CommandError: Could not load shell runner: 'IPython Notebook'
<p>I'm having an issues starting using jupyter on my system (Mac OSX 14.2.1) even on new django projects.</p> <pre class="lang-bash prettyprint-override"><code>django-admin startproject mysite cd mysite/ pip install virtualenv virtualenv --python=$(pyenv root)/versions/3.9.18/bin/python3 env pip install jupyter ipython...
<python><django><jupyter-notebook>
2024-03-03 02:33:49
1
1,262
Android
78,094,841
11,170,350
Django save post via celery
<p>I have a particular use case where i write text for a blog post in admin dashboard. Then i want to generate the embeddings of post. I am doing this in <code>admin.py</code></p> <pre><code>@admin.register(Post) class PostAdmin(admin.ModelAdmin): list_display = ('title', 'author', 'created_at') readonly_fields...
<python><django><celery>
2024-03-03 01:23:06
0
2,979
Talha Anwar
78,094,521
3,259,222
How to shift matrix upper right triangular values to lower right
<p>Given the following upper triangular matrix, I need to shift the values to the bottom as shown:</p> <pre><code>input_array = np.array([ [np.nan, 1, 2, 3], [np.nan, np.nan, 4, 5], [np.nan, np.nan, np.nan, 6], [np.nan, np.nan, np.nan, np.nan], ]) result = np.array([ [...
<python><numpy>
2024-03-02 22:33:14
2
431
Konstantin
78,094,405
10,292,638
how to append a distinct value for each iteration to a pandas dataframe through a loop?
<p>I am trying to add the stock name value for each iteration to it's corresponding data bulk upload to a pandas dataframe:</p> <p>This is what I've tried so far:</p> <pre><code>from pandas_datareader import data as pdr import requests from bs4 import BeautifulSoup import json, requests import pandas as pd import re im...
<python><pandas><sorting><for-loop><row>
2024-03-02 21:46:11
1
1,055
AlSub
78,094,377
1,743,843
Handling "InterfaceError: another operation is in progress" with Async SQLAlchemy and FastAPI
<p>I'm developing a FastAPI application where I use SQLModel with the <code>asyncpg</code> driver for asynchronous database operations. Despite following the asynchronous patterns and ensuring proper await usage on database calls, I encounter the following error during my <code>pytest</code> tests:</p> <p><code>Interfa...
<python><asynchronous><fastapi><sqlmodel>
2024-03-02 21:32:32
0
34,339
softshipper
78,094,364
16,332,690
using list of strings in Numba jitclass
<p>What is the proper way to include a list of strings in a Numba jitclass? The documentation here is very limited and I am currently encountering DeprecationWarnings.</p> <p>Should I use an array of strings instead?</p> <p>For example:</p> <pre class="lang-py prettyprint-override"><code>import numpy as np from numba.e...
<python><numba>
2024-03-02 21:27:22
0
308
brokkoo
78,094,346
395,857
How can I find out the location of the endpoint when using openai Python library and Azure OpenAI?
<p>E.g., when I make a basic Azure OpenAI request, I don't see the endpoint in the response object:</p> <pre><code>#Note: This code sample requires OpenAI Python library version 1.0.0 or higher. import json import pprint from openai import AzureOpenAI client = AzureOpenAI( azure_endpoint = &quot;https://xxxxxx.opena...
<python><openai-api><azure-openai><gpt-4>
2024-03-02 21:20:36
1
84,585
Franck Dernoncourt
78,094,136
1,830,639
How to create strongly typed langchain Runnables and pass data through several steps?
<p>The latest langchain LCEL enable us to create <code>Runnable</code>s. <code>Runnable</code> abstraction can be used for a lot of things, even outside of <em>chains</em> or <em>prompts</em>.</p> <p>In my scenario, as part of the chain pipeline, the first steps are not LLM or Prompts.</p> <p>I want that every step (<c...
<python><langchain><py-langchain>
2024-03-02 19:56:59
0
1,033
JobaDiniz
78,093,891
1,043,882
Ensuring Deterministic Outputs in Neural Network Training
<p>I am new to neural networks and currently working with TensorFlow. For an experiment, I would like to build a model that consistently produces the same output for identical inputs. However, my initial attempt using a trivial test and setting the <code>batch_size</code> equal to the size of the training data did not ...
<python><tensorflow><machine-learning><keras><neural-network>
2024-03-02 18:30:36
1
14,064
hasanghaforian
78,093,582
1,592,764
Tuple problem with parameterized SQLite query
<p>I'm working on a telethon-based telegram chatbot that can query a customer db given a last name in the following format: <code>/search thompson</code>, but am having some trouble using the fill function to keep the queries safe.</p> <p>I'm getting one of two errors - one is <code>tuple index out of range</code> when...
<python><tuples><parameterization><sqlite3-python>
2024-03-02 17:02:17
1
1,695
Marcatectura
78,093,343
4,575,197
ValueError: invalid on specified as date_x, must be a column (of DataFrame), an Index or None
<p>Trying to take a Monthly Rolling average from my DF based on 'ISIN' column on Tone column. this is the df:</p> <pre><code>import pandas as pd # Given data lists tone = [-0.397617, -1.217575, 0.101528, -0.736255, 1.077126] date_x = [&quot;2014-01-01 00:00:00&quot;, &quot;2014-02-01 00:00:00&quot;, &quot;2014-03-01 0...
<python><pandas><dataframe><rolling-computation>
2024-03-02 15:58:22
1
10,490
Mostafa Bouzari
78,093,025
3,362,334
ERR_TUNNEL_CONNECTION_FAILED when using proxy in undetected chromedriver
<p>WHen I set up my proxy this way:</p> <pre><code>options = uc.ChromeOptions() options.add_argument(f'--proxy-server={host}:{port}') </code></pre> <p>I get ERR_TUNNEL_CONNECTION_FAILED error on many websites.</p> <p>When I folowed advice <a href="https://stackoverflow.com/questions/65156932/selenium-proxy-server-argum...
<python><selenium-webdriver><proxy><undetected-chromedriver>
2024-03-02 14:24:08
1
2,228
user3362334
78,092,914
5,747,092
Django can't change username in custom User model
<p>I have the following User model in Django's <code>models.py</code>:</p> <pre><code>class User(AbstractBaseUser): username = models.CharField(max_length=30, unique=True, primary_key=True) full_name = models.CharField(max_length=65, null=True, blank=True) email = models.EmailField( max_length=255, ...
<python><django><django-models>
2024-03-02 13:48:43
2
383
Daniyal Shahrokhian
78,092,833
474,563
Delegate class construction leads to recursion error
<p>I'm building a framework and want to allow users to easily influence the construction of an object (e.g. singletons)</p> <p>However no matter what I've tried I always get recursion. I wonder if there's a way to achieve this <strong>without altering <code>create_instance</code></strong>. I'm sure I can probably achie...
<python><python-3.x><recursion><constructor><metaclass>
2024-03-02 13:25:30
2
20,558
Pithikos
78,092,770
68,862
What is the correct way to set multiple columns in Pandas from a list?
<p>This must be burried somewhere in Pandas docs but I think I am so overwhelmed at this point, I can't find the right doc page. I have some code that worked with python3.9 pandas==1.4.3/numpy==1.23.1 but recently started failing with the newer version on python3.11 pandas==2.2.1/numpy==1.26.4.</p> <p>I have some multi...
<python><pandas><numpy>
2024-03-02 13:05:25
1
2,226
sneg
78,092,742
7,212,686
How to graph rolling average dated-expenses per category?
<h3>Goal</h3> <p>I have data that represent expenses, with date and category, and I want to plot the <strong>rolling average per category over time</strong></p> <hr /> <h3>Sources</h3> <p>I have tried using and combining the following without success</p> <ul> <li><a href="https://stackoverflow.com/questions/53339021/py...
<python><pandas><matplotlib>
2024-03-02 12:55:36
1
54,241
azro
78,092,661
4,181,509
which one should I used in order to check the uniqueness of enum values in python?
<p>I have an enum in Python, which I want to make sure that its values are unique. I see that there are 2 ways I can use to achieve it:</p> <ul> <li>Wrapping the class with <code>@verify(UNIQUE)</code></li> <li>Wrapping the class with <code>@unique</code></li> </ul> <p>What is the difference with using each one of them...
<python><python-3.x><enums>
2024-03-02 12:27:45
3
10,102
Yuval Pruss
78,092,648
2,604,247
How to Make Batch Jobs Logs Available When the Jobs Run Inside Ephemeral Docker Containers?
<h4>Context</h4> <p>So, basically I am running a cron job (python ETL script) via a docker container. That means, every day at 12.30 am my cron job runs</p> <pre class="lang-bash prettyprint-override"><code>docker run $IMAGE </code></pre> <p>In the Dockerfile I have the script like</p> <pre><code># Run the script at c...
<python><docker><google-cloud-platform><logging><cron>
2024-03-02 12:24:06
2
1,720
Della
78,092,404
11,267,783
Display 3D Matrix with colors Pyqtgraph
<p>I want to display a 3D matrix in Pyqtgraph using GLVolumeItem (with x, y and z axis) with the specific colors corresponding to the input data.</p> <p>How can I proceed with my code ?</p> <pre class="lang-py prettyprint-override"><code>import numpy as np import pyqtgraph as pg import pyqtgraph.opengl as gl from pyqt...
<python><pyqtgraph>
2024-03-02 11:09:00
1
322
Mo0nKizz
78,092,146
12,314,521
How to calculate euclidean distance between 2D and 3D tensors in Pytorch
<p>Given:</p> <ul> <li>a tensor A has shape <code>(batch_size, dim)</code></li> <li>a tensor B has shape <code>(batch_size, N, dim)</code></li> </ul> <p>I want to calculate euclidean distance between each row in A and the correspond row in B which has shape <code>(N, dim)</code></p> <p>The expected result has shape <co...
<python><pytorch><tensor>
2024-03-02 09:40:08
1
351
jupyter
78,091,649
14,250,641
Finding overlapping regions in large DataFrame
<p>I have a Pandas DataFrame in pandas with genomic regions represented by their chromosome, start position, and stop position. I'm trying to identify overlapping regions within the same chromosome and compile them along with their corresponding labels. I'm not sure if the way that I'm doing is correct-- also I want an...
<python><pandas><dataframe>
2024-03-02 06:15:32
0
514
youtube
78,091,510
489,088
How can I iterate through a Pandas dataframe and get the value for all columns associated with a given datetime, forward filling values that are -1?
<p>Suppose you have a pandas dataframe with 5 columns: one called <code>code</code> which contains a string, one named named <code>calendardate</code> of <code>datetime</code> format, which contains date and time information, and three others named <code>A</code>, <code>B</code> and <code>C</code>, each containing an i...
<python><pandas><dataframe>
2024-03-02 04:55:31
1
6,306
Edy Bourne
78,091,460
6,182,064
Can you concatenate some, but not all, entries of a Pandas Series using str.cat when using a search string to iterate over a different column?
<p>I'm using the data and dataframe below to use a search_string to query one column/series, and then when the string is a match, update information in different column/series. I can get it done, but not how I want to - I want spaces between the text updates. I have exhausted my searching and looking at the documenta...
<python><pandas><string><series><string-concatenation>
2024-03-02 04:24:51
2
765
wiseass
78,091,298
5,178,988
Minimal example of docker oci_image with custom python toolchain in bazel
<p>I am trying to produce a docker image using the <code>rules_oci</code> bazel repo.</p> <p>I am using a custom python toolchain I have registered in my <code>WORKSPACE</code>. The following code builds a docker image that contains the python toolchain and <code>run_api_server.py</code> and its relevant dependencies.<...
<python><docker><bazel><rules-oci>
2024-03-02 02:46:30
0
1,178
niko
78,091,161
6,449,621
Pytroch segmentation model(.pt) not converting to CoreML
<p>According to apple article <a href="https://developer.apple.com/videos/play/tech-talks/10154/#" rel="nofollow noreferrer">link</a> we need Wrap the Model to Allow Tracing which is be followed the same.</p> <pre><code>class WrappedDeeplabv3Resnet1011(nn.Module): def __init__(self): super(WrappedDeeplabv3...
<python><machine-learning><coreml><faster-rcnn>
2024-03-02 01:26:48
2
465
anandyn02
78,091,058
1,576,804
can't we vectorize code with nested loops to update matrix values
<p>I wrote a piece of code but I am not sure if we can get rid of the loops and vectorize it to make it faster. Can you please give suggestions? I am just updating the co-occurence matrix .</p> <pre><code> M = np.zeros((num_words,num_words)) word2Ind = {words[i]:i for i in range(len(words))} for document in c...
<python><numpy><refactoring>
2024-03-02 00:28:40
1
4,234
vkaul11
78,091,050
902,657
Unable to configure safety settings in gemini-pro: google.api_core.exceptions.InvalidArgument
<p>The code below runs find but when I uncomment any of the safety settings it throws:</p> <pre><code>google.api_core.exceptions.InvalidArgument: 400 Request contains an invalid argument </code></pre> <p>The reason I'm trying to customize the safety settings is because in a real scenario gemini-pro is throwing me an er...
<python><google-gemini>
2024-03-02 00:25:24
1
2,717
Ya.
78,090,683
3,316,842
Python Dependecies for DataprocCreateBatchOperator
<p>Cannot submit Python job onto dataproc serverless when third party python dependencies are needed. It's working fine when dependencies are not needed. I push up the pyspark python file to a cloud storage bucket and then the DataprocCreateBatchOperator reads in that file. I was hoping I can just pass in a list of pip...
<python><google-cloud-platform><pip><airflow><dataproc>
2024-03-01 22:06:18
2
782
baskInEminence
78,090,576
4,928,433
Two figures in one plot
<p>I'm trying to plot two figures from colour.plotting in one plot. I know there's a show-Parameter so I tried to show only second figure but it won't work:</p> <pre><code>import colour colour.plotting.plot_planckian_locus_in_chromaticity_diagram_CIE1931([&quot;A&quot;, &quot;B&quot;, &quot;C&quot;],show=False); colou...
<python><colors>
2024-03-01 21:39:30
1
311
FLX
78,090,575
13,454,049
Bug when using typing & daemon threads
<p>When I run this code on Python 3.11 it runs fine, but if I import <code>typing_minimal</code> (or <code>typing</code>) in <code>reader.py</code> I get this error:</p> <pre class="lang-none prettyprint-override"><code>Fatal Python error: _enter_buffered_busy: could not acquire lock for &lt;_io.BufferedReader name='&l...
<python><multithreading>
2024-03-01 21:39:22
2
1,205
Nice Zombies
78,090,424
1,561,777
Getting Error Attempting to Debug Python Azure Function - attempted relative import with no known parent package
<p>I need to be able to debug an Azure function that was written in Python. I am just starting to learn Python, so I apologize if this is overly simplistic. I do not understand why I am getting this error <code>attempted relative import with no known parent package</code>.</p> <p>I am using <code>VS Code</code> and a P...
<python><azure><azure-functions>
2024-03-01 20:58:30
1
772
David.Warwick
78,090,257
3,446,927
Azure Functions Core Tools fails to start: Value cannot be null. (Parameter 'provider')
<p>When attempting to start my Azure Functions project in local debug mode in Visual Studio Code on my dev box on prem, I receive the following error:</p> <pre><code>[2024-03-01T20:11:07.673Z] Error building configuration in an external startup class. [2024-03-01T20:11:07.675Z] Error building configuration in an extern...
<python><azure><azure-functions>
2024-03-01 20:18:43
1
539
Joe Plumb
78,090,245
10,251,414
OpenVINOInferencer on GPU
<p>I've trained a model (Padim with resnet 50_2) with the anomalib package (python). The recall &amp; precision are quite good, so I want to implement it for a demo.</p> <p>Currently I'm using this code:</p> <pre><code>inferencer = OpenVINOInferencer( path=openvino_model_path, metadata=metadata_path, device...
<python><deep-learning><anomaly-detection><openvino>
2024-03-01 20:14:30
1
5,850
Karel Debedts
78,090,095
825,227
Relatively easy way to overlay a seaborn historigram with normal distribution plot
<p>Have a dataframe for which I've created a histogram in Seaborn:</p> <pre><code>import seaborn as sns sns.histplot(df, bins=100) </code></pre> <p><a href="https://i.sstatic.net/0rr5x.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0rr5x.png" alt="enter image description here" /></a></p> <p>I'm also abl...
<python><pandas><statistics><seaborn><visualization>
2024-03-01 19:41:26
1
1,702
Chris
78,089,788
759,880
Scikit-learn t-SNE plot
<p>I am doing a t-SNE plot for a time series of vectors, showing that the vectors end up in different clusters depending on &quot;jumps&quot; in the values of some components of the vectors. The visualization clearly shows 3 clusters corresponding to the 3 average vectors in the time series. But to highlight the tempor...
<python><scikit-learn><tsne>
2024-03-01 18:31:27
0
4,483
ToBeOrNotToBe
78,089,666
12,305,582
Why is 'None' in builtins.__dict__
<p>The following are true:</p> <ul> <li><code>'None' in keyword.kwlist</code></li> <li><code>'None' in builtins.__dict__ # import builtins</code></li> </ul> <p>My understanding:</p> <ul> <li>Python evals identifier <code>x</code> by getting object <code>builtins.__dict__[x]</code></li> <li>Python evals keyword <code>x<...
<python><keyword><python-builtins>
2024-03-01 18:06:08
1
579
user615536
78,089,594
164,171
Python: Reading long lines with asyncio.StreamReader.readline()
<p>The asyncio version of <code>readline</code>() (1) allows reading a single line from a stream asynchronously. However, if it encounters a line that is longer than a limit, it will raise an exception (2). It is unclear how to resume reading after such an exception is raised.</p> <p>I would like a function similar to ...
<python><asynchronous><io><python-asyncio>
2024-03-01 17:51:26
4
56,902
static_rtti
78,089,551
12,390,973
how to create a simple capacity expansion model while maximizing the revenue using PYOMO?
<p>I have create a capacity expansion model using PYOMO, where there are 2 main generators <strong>gen1</strong> and <strong>gen2</strong> and one backup generator <strong>lost_load</strong>. The logic is pretty simple, gen1 and gen2 will run to fulfill the demand profile and they will get the money for that and there ...
<python><pyomo><capacity-planning>
2024-03-01 17:43:28
1
845
Vesper
78,089,393
395,857
Why is my response JSON object missing `prompt_filter_results` when serializing the Azure OpenAI response object into a JSON object?
<p>I run some Azure OpenAI request, and try to convert the response object into JSON:</p> <pre><code>#Note: This code sample requires OpenAI Python library version 1.0.0 or higher. import json import pprint from openai import AzureOpenAI client = AzureOpenAI( azure_endpoint = &quot;https://xxxxxx.openai.azure.com/&q...
<python><json><serialization><azure-openai>
2024-03-01 17:16:34
1
84,585
Franck Dernoncourt
78,089,384
5,799,799
A scalable way of checking if a string column is contained within another string column in Polars
<p>Is there a scalable way of creating the column <code>B_in_A</code> below that doesn't rely on map_elements?</p> <pre class="lang-py prettyprint-override"><code>import polars as pl df = pl.DataFrame({&quot;A&quot;:[&quot;foo&quot;,&quot;bar&quot;,&quot;foo&quot;],&quot;B&quot;:[&quot;f&quot;,&quot;b&quot;,&quot;s&qu...
<python><dataframe><python-polars>
2024-03-01 17:14:30
1
435
DataJack
78,089,288
759,991
Bar Chart Not Stacking
<p>I have been trying to adapt this tutorial, <a href="https://simpleisbetterthancomplex.com/tutorial/2020/01/19/how-to-use-chart-js-with-django.html" rel="nofollow noreferrer">How to Use Chart.js with Django</a>, to my AWS billing reports. I want to tweak this graph from the tutorial:</p> <p><a href="https://i.sstati...
<javascript><python><django><chart.js>
2024-03-01 16:57:55
0
10,590
Red Cricket
78,089,263
17,323,391
Python UDP socket not sending all packets, or not all packets are received on the other end
<p>I'm working on an implementation of a logical data diode, which means that data can only flow in one direction. No ACKs are allowed. Therefore, I have chosen UDP. This is the gist of the protocol:</p> <ol> <li>Split the payload into small chunks</li> <li>Give each chunk a sequence number</li> <li>Transmit the chunk ...
<python><sockets><network-programming><udp><python-sockets>
2024-03-01 16:54:26
1
310
404usernamenotfound
78,089,139
1,504,082
FastAPI / pydantic: field_validator not considered when using empty Depends()
<p>I am following <strong>Method 2</strong> of this <a href="https://stackoverflow.com/a/70640522/1504082">answer</a> to be able to upload multiple files in combination with additional data using fastapi. It is working fine.</p> <p>After starting to implement the handling of the additional data including validation usi...
<python><dependency-injection><enums><fastapi><pydantic>
2024-03-01 16:30:42
1
4,475
maggie
78,089,081
5,759,359
Release redis connection back to pool using python
<p>I have a job scheduled which writes data to Redis cache. For each data set row, I fetch a connection from the pool and use redis.pipeline to insert it into Redis, but when I monitor via info clients the connected_clients number keeps on increasing, I see maxclients as 7500 but when connected_clients reach 1049, its ...
<python><caching><redis>
2024-03-01 16:20:23
1
477
Kashyap
78,089,057
1,145,808
Accessing `self` and method name from dynamically-created methods
<p>I have a class of which several methods could be dynamically generated, which would save some boilerplate:</p> <pre><code>class A: def save_foo(self, **kwargs): do_foo_stuff_here() def save_bar(self, **kwargs): do_bar_stuff_here() def save_foobar(self, **kwargs): do_foobar_stuff_h...
<python>
2024-03-01 16:16:52
1
829
DobbyTheElf
78,088,987
2,707,864
Msys2: Python 2.7 and Python 3.8 side by side, how to load correct site.py
<p>I have portable msys2 under Windows. It works great.</p> <p>I have both python 2.7 and python 3.8 installed. If I load python 3.8 it works fine.</p> <pre><code>$ python Python 3.8.2 (default, Apr 16 2020, 15:31:48) [GCC 9.3.0] on msys Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license...
<python><msys2>
2024-03-01 16:04:02
1
15,820
sancho.s ReinstateMonicaCellio
78,088,922
5,987
Create TZ string from Python ZoneInfo
<p>I can easily get a <code>ZoneInfo</code> object for the time zone of my choice:</p> <pre><code>import zoneinfo ct = zoneinfo.ZoneInfo('America/Chicago') </code></pre> <p>I need to create a <code>TZ</code> environment variable for an embedded system that doesn't have a timezone database, so I can't simply reuse the l...
<python><timezone><zoneinfo>
2024-03-01 15:54:55
1
309,773
Mark Ransom
78,088,887
12,691,626
No response when getting a table from a web using BeautifulSoap library
<p>I'm trying to get two data tables from a <a href="https://www.avamet.org/" rel="nofollow noreferrer">web</a>. I'm using the BeautifulSoup Python library from Google Colab. The URL to download is the following: <a href="https://www.avamet.org/mx-consulta-diaria.php?id=%%25%%2525&amp;ini=2024-02-27&amp;fin=2024-02-28&...
<python><html><web-scraping><beautifulsoup><google-colaboratory>
2024-03-01 15:48:31
1
327
sermomon
78,088,608
4,704,065
Save the Matplotlib plot in html format
<p>I have a plot written in matplotlib.</p> <p>Currently I saved that plot in pdf ,but i also want to save it in .html format for better visualization.</p> <p>I am not aware of any html stuff , so need inputs here</p> <p>Below is my code:</p> <pre><code> output_file = config[&quot;output_dir&quot;] / &quot;report.p...
<python><html><matplotlib>
2024-03-01 14:57:34
1
321
Kapil
78,088,237
6,891,461
Encountering Race Conditions Despite Using Django's Atomic Transactions and select_for_update
<p>I'm encountering race conditions in my Django application despite implementing atomic transactions and utilizing the select_for_update method. Here's an overview of the problem and the steps I've taken so far:</p> <p><strong>Problem</strong>: I have two Django models, Transaction and Account, where Transaction insta...
<python><django><postgresql><transactions><race-condition>
2024-03-01 13:55:16
1
1,209
l.b.vasoya
78,088,133
13,086,128
All columns to uppercase in a DataFrame?
<p>Suppose there are hundreds of columns in a DataFrame. Some of the column names are in lower and some are in upper case.</p> <p>Now, I want to convert all the columns to upper case.</p> <pre><code>import polars as pl df = pl.DataFrame({ &quot;foo&quot;: [1, 2, 3, 4, 5, 8], &quot;baz&quot;: [5, 4, 3, 2, 1, 9]...
<python><python-3.x><dataframe><python-polars>
2024-03-01 13:38:12
2
30,560
Talha Tayyab
78,088,123
4,593,642
tesseract opens console with pyinstaller
<p>I have a program that does ocr using tesseract and pyqt5</p> <p><strong>thread.py</strong></p> <pre><code>class SearchThread(QThread, QObject): signal = pyqtSignal(str) finished = pyqtSignal() def __init__(self, data): super(QThread, self).__init__() super(QObject, self).__init__() ...
<python><pyqt5><pyinstaller><python-tesseract>
2024-03-01 13:36:56
0
2,339
Amine Messaoudi
78,088,003
534,238
How to get IDEs (VS Code) to work with syntax highlighting with Protobufs (Python)
<p>I am using VS Code, but I suspect the following problem exists across all IDEs.</p> <hr /> <p>When compiling a protobuf file (<code>.proto</code>) to Python (<code>_pb2.py</code>), the Messages <em>will be available as classes, but Google's mechanism to expose the classes is difficult for IDEs to discover</em>.</p> ...
<python><ide><protocol-buffers>
2024-03-01 13:14:02
1
3,558
Mike Williamson
78,087,955
11,222,963
Key Error when slicing in Pandas, but column exists?
<p>My columns:</p> <pre><code> df = pd.read_excel('data.xlsx') print(df.columns) Index(['ID', 'Start time', 'Completion time', 'Email', 'Name', 'Last modified time', 'Report #1 Name', 'Type of Report', 'Location of Report', 'Purpose of Report', 'Report Owner / Creator', 'How often do you use this...
<python><pandas>
2024-03-01 13:07:56
1
3,416
SCool
78,087,811
2,938,491
Unable to deploy function on Azure Function App requiring pytorch
<p>I am unable to make successful deployment of Azure Function when I require torch for my service. Earlier, I could deploy if I comment-out torch from requirements.txt file, which is explained after the following Update section:</p> <p><strong>UPDATE:</strong> I partially solved it. The problem is with dependencies li...
<python><azure><azure-functions>
2024-03-01 12:37:20
1
683
Amir
78,087,806
874,829
Unexpected numpy image reshape into grid problem
<p>I'm trying to reshape a numpy array image into a grid image of 16x16 elements per cell. I think that</p> <pre><code>grid_image = image.reshape((h//16, w//16, -1)) </code></pre> <p>should do the trick. In the example below grid_image has a (1, 2, 256) shape. However, when I compare elements grid_im...
<python><numpy>
2024-03-01 12:36:54
1
2,784
martinako
78,087,630
5,726,057
Are there conventional UDF in Spark 3.5.0 not using arrow?
<p>I have used Pandas UDF and I am aware they use pyarrow to avoid object translation between JVM and the Python interpreter running in the workers. I am also aware of the property <code>spark.sql.execution.arrow.enabled</code> that can be set to <code>true</code> in order to optimize interactions between Pandas DF and...
<python><apache-spark><pyspark><user-defined-functions><pyarrow>
2024-03-01 12:06:56
0
368
Pablo
78,087,560
11,809,811
Selenium in a for loop reuses first value
<p>I want to use selenium to check multiple accounts on a website.</p> <p>I have a url and then a list with the data</p> <pre><code>url = 'website.com' data = [(username1, password1), (username2, password2), (username3, password3)] </code></pre> <p>And then I am using a for loop to get the data:</p> <pre><code>for use...
<python><selenium-webdriver><web-scraping>
2024-03-01 11:55:27
1
830
Another_coder
78,087,546
1,714,692
Type hint a Python dictionary having integers as keys
<p>Suppose I have a function that returns a dictionary having integers as keys and instances of a defined custom class as values:</p> <pre><code>from typing import Dict class A: a = 4 def my_f() -&gt; dict: return {0: A()} </code></pre> <p>I want to type hint the type of keys and values. Many posts suggest to use...
<python><python-typing>
2024-03-01 11:53:23
1
9,606
roschach
78,087,517
11,749,309
Is this the most performant way to rename a Polars DF column?
<h2>Issue:</h2> <p>I have a column name that can change its prefix and suffix based on some function arguments, but there is a section of the column name that is always the same. I need to rename that column to something easy for reference in a different workflow. I am in search of the quickest way to find the column I...
<python><dataframe><for-loop><rename><python-polars>
2024-03-01 11:46:42
2
373
JJ Fantini
78,087,223
5,195,209
"psycopg.OperationalError: sending query and params failed: another command is already in progress" when trying to update table
<p>I am trying to efficiently update a row in a postgresql table. For that I use a temp table and try to use <code>COPY</code>. My code looks like this:</p> <pre class="lang-py prettyprint-override"><code>conn = psycopg.connect( host=&quot;localhost&quot;, dbname=DB_NAME, user=DB_USER, password=DB_PASSWORD ) with...
<python><postgresql><psycopg3>
2024-03-01 10:48:03
1
587
Pux
78,087,188
3,358,488
Is Python's copyreg supposed to be used in regular Python code?
<p>Python's <a href="https://docs.python.org/3/library/copyreg.html" rel="nofollow noreferrer">copyreg documentation</a> looks like it's just a way to customize the pickling of specific classes defined in Python.</p> <p>However, <a href="https://github.com/python/cpython/blob/010aac7c1a43afd63b4c4019c4f217f1e3a72689/Li...
<python><pickle>
2024-03-01 10:41:59
1
5,872
user118967
78,087,152
5,618,856
pandas compare dataframes and write/read result to/from excel - how to get the compare format back into a dataframe
<p>How can I read the pandas.dataframe.compare result back from excel into an equivalent dataframe?</p> <p>If I do</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd df1 = pd.DataFrame({ 'A': [1, 2, 3], 'B': [4, 5, 6] }) df2 = pd.DataFrame({ 'A': [1, 2, 4], # Changed here, '3' to '4'...
<python><pandas><excel><dataframe>
2024-03-01 10:36:57
1
603
Fred
78,086,980
885,770
Merging multiple dataframes (time series)
<p>I'm trying to merge a list of dataframe. It's a time series, each dataframe has the same columns. They contain the same id points, the only variables that change are the <code>utc</code> and <code>temp</code>.</p> <p>df1</p> <pre><code>id name2 geom utc temp ...
<python><pandas>
2024-03-01 10:07:03
0
1,971
Gago-Silva
78,086,896
13,242,312
SHA1 implementation differs from builtin SHA1
<p>I'm trying to reimplement the SHA1 algorithm in python, but the result of my function differs from the one in builtin hashlib, at first I thought the problem was in my rotate function, but after fixing it, there is still a difference in the outputs, here is my code:</p> <pre class="lang-py prettyprint-override"><cod...
<python><hash><sha1>
2024-03-01 09:51:49
1
1,463
Fayeure
78,086,853
6,207,773
python P8000 unable to connect: no pg_hba.conf entry for host
<p>I am using pg8000==1.30.5 in python 3.12</p> <p>I was migrating from psycopg2</p> <p>But connection I got an error:</p> <pre><code>pg8000.Connection(self.db_username, database=self.schema_name, host=self.db_host, password=self.db_password, port=self.db_po...
<python><postgresql><pg8000>
2024-03-01 09:43:03
0
316
Lucke
78,086,715
963,844
How to check a character is belong or not belong to specific code page?
<p>I want to print the character only if it is not belong to specific code page.</p> <p>What function I can use for this purpose?</p> <pre><code>with open('in.txt', 'r', encoding=&quot;utf-16-le&quot;) as f: while True: c = f.read(1) if not c: break if not c.isprintable(): ...
<python><python-3.x><unicode><python-unicode><codepages>
2024-03-01 09:23:46
1
3,769
CL So
78,086,553
2,107,030
symbol lookup error: undefined symbol: __pow_finite
<p>I am trying to run <a href="https://github.com/scottransom/presto/tree/master" rel="nofollow noreferrer">a software</a> that ran flawlessly before upgrading from Ubuntu 20.04 to 22.04, but now I receive the error</p> <pre><code>symbol lookup error: /Softwares/presto/lib/libpresto.so: undefined symbol: __pow_finite <...
<python><clang><shared-libraries><glibc>
2024-03-01 08:52:54
0
2,166
Py-ser
78,086,541
4,106,261
Pandas resample behaves differently with SUM and MEAN
<pre><code>python==3.8.10 pandas==2.0.3 (cannot update to python &gt;= 3.9, so I am stuck to this version) </code></pre> <p>A dataframe contains some hourly data for a year. I filter the data to remove the months from April to October, and then aggregate by DAY. That should mean 151 days are left.</p> <p><strong>Is the...
<python><pandas><dataframe><pandas-resample>
2024-03-01 08:51:11
2
2,566
Alex Poca
78,086,235
3,179,698
Using exclamation followed by command in jupyter cell and directly using command in terminal has different result, windows system
<p>I just noticed, in windows 11, running jupyter</p> <p>We have the command <code>where pip</code></p> <p>however, we run this command in four different places, has different result.</p> <p>1 I run inside jupyter notebook's cell:</p> <pre><code>!where pip </code></pre> <p>I got the pip's location.</p> <p>2 I run using...
<python><powershell><jupyter>
2024-03-01 07:47:12
0
1,504
cloudscomputes
78,086,220
11,793,491
Expand a grouped value in pandas
<p>I have this dataset:</p> <pre class="lang-py prettyprint-override"><code>df = pd.DataFrame({'prod':['A','A','A','B','B'],'quant':[2,3,4,3,1]} prod quant 0 A 2 1 A 3 2 A 4 3 B 3 4 B 1 </code></pre> <p>And I want to aggregate the values by <code>prod</code> but to keep th...
<python><pandas>
2024-03-01 07:43:10
1
2,304
Alexis
78,085,989
17,729,094
Deprecation warning: explicitly call ax.remove() as needed
<p>I have the following code that works correctly for me with <code>matplotlib==3.8.2</code>:</p> <pre class="lang-py prettyprint-override"><code>import matplotlib.pyplot as plt import numpy as np # Random data r = np.random.randn(1000) theta = np.random.randn(1000) fig = plt.figure() # Ignore all other subplots for...
<python><matplotlib>
2024-03-01 06:52:01
0
954
DJDuque
78,085,938
23,461,455
Pandas pd.read_csv() using single quote as quotechar throws SyntaxError: incomplete input
<p>I am currently trying to read in a <code>.csv</code> with the following structure:</p> <pre><code> samplecsv = &quot;&quot;&quot; 'column A', 'column b', 'column c', 'valueA', 'valueb', 'valuec,d', 'valueA', 'valueb', 'valuecd', 'valueA', 'valueb', 'valuecd', 'valueA', 'valueb', 'valuec,d' &quot;&quot;&quot; </...
<python><pandas><dataframe><csv>
2024-03-01 06:39:12
1
1,284
Bending Rodriguez
78,085,909
31,352
How can I see past versions of a Google sheet when I update it via the API
<p>I am updating a Google sheet via the api, Python code snippet that I'm using here (this works fine):</p> <pre><code>sheet = service.spreadsheets() result = ( sheet.values() .update( spreadsheetId=SPREADSHEET_ID, range=&quot;Sheet1!A1:A4&quot;, valueInputOption='RAW', body=dict( ...
<python><google-sheets><google-drive-api><google-sheets-api>
2024-03-01 06:32:27
0
748
Brad
78,085,841
12,314,521
How to reduce mean ignore padded rows in 3D tensor
<p>I have and a 3D tensor <code>A</code> has shape <code>(batch_size, N, dim)</code> and a 3D tensor <code>B</code> has shape <code>(batch_size, N, 2)</code>. In which <code>B</code> has some padding row to fill to N (which is not a zero vector, as it already passed in some functions). To know which row is padded, I ha...
<python><pytorch><tensor>
2024-03-01 06:16:01
1
351
jupyter
78,085,597
9,707,286
processing hundreds of csv files one row at a time for embedding, upload to pinecone using OpenAI embeddings
<p>This is my current code which works for a while and then throws an error of &quot;can't start a new thread.&quot; Tried both threading and multi-processing and both cause this error eventually.</p> <pre><code>def process_file(file_path): print(f'file: {file_path}') def process_row(row): text = row['text...
<python><multithreading><multiprocessing><langchain><pinecone>
2024-03-01 04:51:41
0
747
John Taylor
78,085,526
15,093,600
Simulate stdout in fake subprocess.Popen
<p>I would like to test a function, which invokes <code>subprocess.Popen</code> and captures <code>stdout</code>. In particular, I need to test <code>stdout</code> content physically captured in a file on disc without ever calling the actual process.</p> <p>Sample function:</p> <pre class="lang-py prettyprint-override"...
<python><testing><mocking><subprocess>
2024-03-01 04:20:31
1
460
Maxim Ivanov
78,085,327
15,474,507
Remove links using myjdapi
<p>I try to remove link that have .opus in the filename using <a href="https://github.com/mmarquezs/My.Jdownloader-API-Python-Library/blob/master/myjdapi/myjdapi.py" rel="nofollow noreferrer">myjdapi</a> but it fails to remove</p> <p>JD API reference : <a href="https://my.jdownloader.org/developers/" rel="nofollow nore...
<python><jdownloader>
2024-03-01 02:51:18
0
307
Alex Doc
78,085,129
673,167
Installing Python BeautifulSoup package with Homebrew on macOS
<p>I installed Python on my macOS using Homebrew. Now, I'm attempting to use <code>BeautifulSoup</code>, so I executed the following command: <code>brew install python-beautifulsoup4</code>. However, I encountered a message stating, 'Warning: No available formula with the name <code>python-beautifulsoup4</code>.</p> <p...
<python><beautifulsoup><homebrew>
2024-03-01 01:34:44
2
1,548
notGeek
78,085,119
4,549,682
How can I pre-warm a Python azure function or set up pre-warmed instances?
<p>We have Python Azure httpTrigger functions that have a cold start problem when we scale out. The response time spikes to 10-40s after creating a new instance for scale out. I found 2 possible solutions for this:</p> <ul> <li>use a <a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-wa...
<python><azure><serverless>
2024-03-01 01:29:05
1
16,136
wordsforthewise
78,085,089
21,935,028
Antlr Python error processing simple PLSQL
<p>Antlr4 was installed on Ubuntu 22.04 with Python as follows:</p> <pre class="lang-bash prettyprint-override"><code>wget https://github.com/antlr/grammars-v4/blob/master/sql/plsql/Python3/PlSqlLexerBase.py wget https://github.com/antlr/grammars-v4/blob/master/sql/plsql/Python3/PlSqlParserBase.py wget https://github....
<python><antlr4>
2024-03-01 01:12:40
1
419
Pro West