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
⌀
77,707,507
2,423,198
How to Include System Prompt and Instruction in Vertex AI LLaMA 2-7B Chat Model
<p>I'm working with the LLaMA 2-7B chat model deployed on Google Cloud's Vertex AI, and I'm facing a challenge in including a system prompt and user instruction within the model's prompt format.</p> <p>For local versions, I've been using a formatted prompt structure as follows:</p> <pre class="lang-py prettyprint-overr...
<python><google-cloud-platform><google-cloud-vertex-ai><llama>
2023-12-23 11:43:17
0
3,400
deltascience
77,707,364
893,254
How should I structure my code when using SQL Alchemy and Reflection?
<p>I appologize for this question being slightly lengthy. The TLDR is:</p> <ul> <li>I am struggling to understand how to structure my code when using the reflection features of SQL Alchemy ORM</li> <li>This is because in order to construct &quot;an instance of a table type&quot; I appear to have to pass around a <code>...
<python><sqlalchemy>
2023-12-23 10:48:05
1
18,579
user2138149
77,707,308
896,112
Why do attributes that are being set by a custom type initializer need to be protected?
<p>The <a href="https://septatrix.github.io/cpython-dark-docs/extending/newtypes_tutorial.html#adding-data-and-methods-to-the-basic-example" rel="nofollow noreferrer">CPython Tutorial</a> defines a custom initializer for a custom type which has the following lines :</p> <pre class="lang-cpp prettyprint-override"><code>...
<python><cpython><python-c-api>
2023-12-23 10:20:35
1
9,259
Carpetfizz
77,707,014
5,591,958
How to efficiently find second-order neighbors in graph-tool?
<p>I'm using graph-tool and would like to find the second-order neighbors of a node (neighbors of neighbors who are not the node itself or the original neighbors). I thought it might be faster to use graph-tool's built-in topology functions, so I tried</p> <pre><code># Here g is the digraph, and node is the vertex whos...
<python><graph-theory><graph-tool>
2023-12-23 08:09:43
1
489
geofurb
77,706,826
3,050,341
Manim animate group and child at the same time
<p>I have two mobjects which are grouped into one <code>VGroup</code>. I want to animate some properties of group and, in the same time, animate children porperties:</p> <pre class="lang-py prettyprint-override"><code>from manim import * class Visualisation(Scene): def construct(self): circle1 = Circle(1, ...
<python><manim>
2023-12-23 06:33:52
0
3,111
CMTV
77,706,773
13,520,498
`AssertionError` while installing `deepface` via pip
<p>I'm trying to install <code>deepface</code> library via <code>pip</code> but it fails with <code>AssertionError</code>.</p> <p>My system specs are:</p> <ul> <li>OS : POP-OS 22.04</li> <li>Python: Python-3.10.12</li> <li>Pip: pip-22.0.2</li> </ul> <h4>update 01</h4> <p>I did the following with <code>pip</code>:</p> <...
<python><python-3.x><pip><deepface>
2023-12-23 06:07:13
4
1,991
Musabbir Arrafi
77,706,694
10,633,596
How to modify my Python Slack Bolt Socket mode code to reload automatically during any code changes
<p>I have the following Python code which works fine using the Web Socket mode. When I type a slash command (<code>/hello-socket-mode</code>) on my Slash application then it very well invokes my method, <code>handle_some_command()</code>:-</p> <pre><code>import os from slack_bolt import App from slack_bolt.adapter.sock...
<python><uvicorn><slack-bolt>
2023-12-23 05:17:29
1
1,574
vinod827
77,706,666
8,554,833
Python Selenium JavaScript Horizontal Scroll
<p>I'm not very good at using pyhton/selenium on a website using javascript.</p> <p>I have a website that will only read the source for what is visible. So I am trying to scroll to the right a handful of pixels at a time to get the whole table eventually.</p> <p>The scroll element looks like this:</p> <p><div class="sn...
<javascript><python><selenium-webdriver>
2023-12-23 04:54:29
0
728
David 54321
77,706,615
9,586,195
How to initialize env variable in current process with bash script when importing python package
<p>I have a custom python package which wraps some C code in library files (.so/.a). This C code depends on some env variables and I cannot change the C code.</p> <p>To initialize them, I have a bash script like so:</p> <pre class="lang-bash prettyprint-override"><code>PACKAGE_PATH=/path/to/package export PYTHONPATH=$P...
<python><bash>
2023-12-23 04:12:44
0
408
Sunchock
77,706,557
14,055,985
Can `cmake` ignore `cmake_minimum_required` (or can `conan` leave my changes alone?)
<p>I am trying to build <a href="https://github.com/Ultimaker/Cura/wiki/Running-Cura-from-Source" rel="nofollow noreferrer">Cura</a> using <code>conan</code> and a dependency fails to build because my version of <code>cmake</code> is 3.20, but it wants 3.23. I can manually change it to 3.20 and it builds just fine, b...
<python><c++><cmake><conan><ninja>
2023-12-23 03:36:52
1
1,981
KJ7LNW
77,706,529
23,002,898
In Django i can't display a form in index, from another page. I only see the button, but i don't see the textboxes
<p>I would like to view the registration form directly on the index<code>.html</code> page (home page). In index.html, i would like to display <code>register.html</code>.</p> <p>The registration form was created in registration/register.html. I call it in index.html using:</p> <pre><code>{% block content %} {% include ...
<python><python-3.x><django><django-forms>
2023-12-23 03:21:59
2
307
Nodigap
77,706,103
22,285,820
Replacing google slides images using slides api
<p>I have the following scripts to update the images in google slides, it works fine but sometimes it gives me 400 error, service account has a write permission to the drive/images and the presentation</p> <pre><code>image_mappings = { &quot;id_in_presenation&quot;: &quot;name_of_the_image&quot;, &quot;id_in_pr...
<python><service-accounts><presentation><google-slides-api><google-slides>
2023-12-22 22:43:38
1
596
nisakova
77,706,064
13,264,143
How do you get all the classes in another package so they can be instantiated in Python3?
<p>I read the question <a href="https://stackoverflow.com/questions/54699587/importing-a-whole-folder-of-python-files">&quot;Importing a whole folder of python files&quot;</a>, but it does not include a way to do it without one import per file.</p> <p>Beside the requirement of avoiding several imports, it is required t...
<python><python-3.x><module><python-import><global>
2023-12-22 22:31:14
1
966
John Glen
77,706,005
5,633,063
How can I more efficiently use the Python REPL for package development?
<h2>My current workflow</h2> <ol> <li>I install my package in <a href="https://setuptools.pypa.io/en/latest/userguide/development_mode.html" rel="nofollow noreferrer">editable mode</a> (usually in a virtual environment): <pre class="lang-bash prettyprint-override"><code>&gt; python -m pip install -e . </code></pre> </l...
<python><visual-studio-code><python-packaging>
2023-12-22 22:10:32
0
2,818
wurli
77,705,916
2,179,222
Reset prometheus metric if it was not reported for period of time in python
<p>I have a python app with Gauge metric where I report latest value reported by some device. I want to create a mechanism that will reset the value to zero if the metric was not reported for more than 30 min. Is there a way to do it without keeping the map of last report times? Is there a way to get the last report ti...
<python><prometheus><prometheus-python-client>
2023-12-22 21:37:57
1
349
Eduard Grinberg
77,705,875
2,755,307
Trying to get a Gaussian GLM to simply match OLS but is either very wrong or has perfect separation
<p>I'm trying to make a GLM do what an OLS does, just to get a baseline understanding of GLM. But it doesn't seem to do what I'm after. Consider this code:</p> <pre><code>import numpy as np import statsmodels.api as sm from scipy import stats print(&quot;### This is dummy data that clearly is y = 0.25 * x + 5: #####...
<python><statsmodels><glm>
2023-12-22 21:23:36
1
953
James Madison
77,705,849
1,228,906
ModuleNotFoundError when trainng on a custom Azure environment
<p>I have a tensorflow script that works perfectly when trained on ACR image: AzureML-tensorflow-2.7-ubuntu20.04-py38-cuda11-gpu (mcr.microsoft.com/azureml/curated/tensorflow-2.7-ubuntu20.04-py38-cuda11-gpu:28)</p> <p>I need to include a few additional dependencies so I'm creating a custom environment (conda.yml and co...
<python><azure><tensorflow><azure-machine-learning-service><azure-container-registry>
2023-12-22 21:15:59
1
1,896
webber
77,705,565
15,019,223
Slice array along axis with list of different indices
<p>I have a 3-dimensional array/tensor of shape <code>(a, b, c)</code>, and I have a list of length <code>a</code> of different indices, each in the range <code>[0, b)</code>. I want to use the indices to get an array of size <code>(a, c)</code>. Right now I do this with an ugly list comprehension</p> <pre class="lang-...
<python><numpy><pytorch><numpy-slicing>
2023-12-22 19:49:22
1
1,953
mhenning
77,705,521
5,335,180
Why is pdb showing Blank line or comment, but there is a line?
<p>I'm trying to interactively run pdb on a remote system I don't own (I'm not sure if that's relevant), and it's behaving a bit differently than I expect. Listing the source shows there is clearly a line 22, but when I try to set the breakpoint, it tells me the line is blank. Fiddling a bit, I can get it to break on l...
<python><pdb>
2023-12-22 19:35:49
1
489
reas0n
77,705,520
6,432,861
Python argparse: accessing the same ArgumentParser/argument in multiple files
<p>I have a script, <code>main.py</code>, that sets up an <code>argumentParser()</code> object to read in <code>commandline</code> arguments before calling a <code>main()</code> file that lives in another module, <code>alation_cronjob.py</code>.</p> <p>in <strong>main.py</strong>. I actually made <code>make_parser()</c...
<python><python-3.x><argparse>
2023-12-22 19:35:43
0
607
Byron Smith
77,705,471
2,414,957
cannot import name 'CppEGLRenderer' from 'lib.egl_renderer'
<p>I connect to destination machine (ada) like this:</p> <pre><code>connect to globalprotect vpn ssh -X machine 1 (machine 1) : ssh -X ada </code></pre> <p>my own machine is Ubuntu and the other two I ssh to also same version of Ubuntu. How can I fix this error?</p> <pre><code>(gdrnpp) mona@ada:~/gdrnpp_bop2022$ ./core...
<python><x11><egl>
2023-12-22 19:22:04
1
38,867
Mona Jalal
77,705,421
8,231,763
access aspen plus through COM interface -- using python vs matlab
<p>I have successfully accessed many different Aspen Plus variables through COM interface using Python (win32com), but failed to do so for the following variable, using the same command.</p> <pre><code>AspenPlus.Tree.FindNode(&quot;\Data\Reactions\Reactions\ReactionABC\Input\RVALUE_LIST\#1&quot;).Value = 11 </code></pr...
<python><matlab><com><win32com><aspen>
2023-12-22 19:07:38
1
325
Shu Pan
77,705,303
14,923,227
Sympy get valid integer range for each variable in expression
<p>Given that I have the following expression:</p> <pre><code>from sympy import * a,b,c,d = var('a b c d') variables = { 'a': a, 'b': b, 'c': c, 'd': d } string = &quot;(a &gt; 1548) | (a &gt; 2090) | (b &gt; 2662) | ((c &gt; 838) &amp; (c &lt; 1801)) | ((d &gt; 2770) &amp; (d &lt; 3448))&quot; expr = eval(string,varia...
<python><sympy>
2023-12-22 18:36:50
3
3,418
Kevin
77,705,227
7,745,011
scikit-image RAG mergine leaves black areas
<p><a href="https://scikit-image.org/docs/stable/auto_examples/segmentation/plot_rag_merge.html#sphx-glr-auto-examples-segmentation-plot-rag-merge-py" rel="nofollow noreferrer">Following this example on the scikit-image homepage</a>, in my example the image has some black areas after merging the RAG in case the thresho...
<python><scikit-image>
2023-12-22 18:17:45
1
2,980
Roland Deschain
77,705,220
19,916,174
Remove Annotations from typing.Annotated
<p>Let's say I have some type aliases, maybe</p> <pre class="lang-py prettyprint-override"><code>Point3D = Annotated[tuple[float, float, float], &quot;A 3D Point&quot;] Points = Annotated[list[Point3D, list[float]], &quot;A collection of points&quot;] </code></pre> <p>If I try to print Points, I get</p> <pre class="lan...
<python><regex><python-sphinx><python-typing>
2023-12-22 18:16:44
2
344
Jason Grace
77,705,194
23,106,915
Facing prob. while importing font in Tkinter
<p><strong>Description:</strong> So I am using customtkinter for my project and I used Armin Grotesk font in my project the problem is if the project is running on my system it works like a charm as soon as I transfer the files over to a new pc the font disappears, I think sans-serif replaces it.</p> <p><strong>Expecti...
<python><tkinter>
2023-12-22 18:11:22
1
546
AshhadDevLab
77,705,175
8,194,777
Unable to pass parameters when using pyodbc in Django for large query
<p>Working on: Django framework pyodbc package (MSSQL Version 18) DS: Azure synapse</p> <p>I would like to know what is the best way to go about when trying to load a large number of parameters into the SQL query for Azure synapse.</p> <p>The scale I'm looking for is in millions.</p> <p>I can split the parameters into ...
<python><django><t-sql><pyodbc><azure-synapse>
2023-12-22 18:06:50
0
361
SagarM
77,705,122
5,924,264
How to speedup a dataframe's apply function on a custom input function
<p>I have a dataframe with millions of rows. I want to compute another column <code>new_col</code> based on an existing <code>col</code>.</p> <pre><code> df[&quot;new_col&quot;] = (df[&quot;col&quot;].apply(my_obj.move, args=(1,))) </code></pre> <p><code>my_obj</code> is a class instance with an <code>instance</code> ...
<python><pandas><dataframe>
2023-12-22 17:51:03
1
2,502
roulette01
77,705,057
12,425,004
How to pass a .pem key in GitHub actions via environment variable without characters causing YAML parsing issues
<p>I have a GitHub environment secret <code>{{ secrets.GITHUBAPP_KEY }</code> that holds a .pem key, in a workflow step, I'm trying to pass the secret to an env variable <code>GITHUBAPP_KEY</code></p> <pre><code> - name: Do Certain Step run: Insert fancy command here env: GITHUBAPP_KEY: &quot;${{ secret...
<python><yaml><cryptography><github-actions><ssh-keys>
2023-12-22 17:34:16
1
1,826
yung peso
77,704,843
10,595,871
recursively create new keys in dictionary if len(value) is greater than x
<p>I have a dictionary where tha values are list of strings. I need to perform the sum of the word in the whole strings and, when I reach a number x, I need to go back to the previous string, duplicate the key (with maybe a _i as suffix) and insert the remaining strings in the new value. Also, I need to delete the rema...
<python><dictionary>
2023-12-22 16:42:47
0
691
Federicofkt
77,704,835
11,426,624
calculate weighted_average of pandas df in a function
<p>I have a function and in this function I would like to calculate the weighted average of the column <code>other_column</code> (weighted with column <code>amount</code>). If I did not have this in a function then it would work, but like this I am not sure how to pass the dataframe? I'm also getting an error: <code>Na...
<python><pandas><dataframe><group-by><aggregate>
2023-12-22 16:40:57
2
734
corianne1234
77,704,793
7,262,393
Simulating mutation in a population of cells. Numpy arr size manipulation efficiency
<p>I am working on a project where we would like to figure out a way to estimate the mean generation a mutation first appears in a replicating population of cells through simulating the frequency in the population. I realize I could just track the first instance of it but this isn't going to be very helpful when dealin...
<python><numpy>
2023-12-22 16:34:21
1
773
Dan
77,704,523
1,775,010
Sounddevice + big array + OOP = Segfault / Bus Error
<p>I'm having a very strange problem, which I managed to reduce as much as possible like this:</p> <pre class="lang-py prettyprint-override"><code>import sounddevice import time class SamplerBox: def __init__(self): self.samples = {} def audio_callback(self, outdata, frame_count, time_info, status): ...
<python><audio><python-sounddevice>
2023-12-22 15:33:26
1
1,068
theredled
77,704,416
17,835,120
Delete label using Gmail API Python
<p><strong>Trying to use Gmail API to delete a label</strong>. But it doesn't seem to be working and triggering an <strong>insufficient permission</strong> error in python. It doesn't seem correct because in google shows all permissions checked off. Is there a code fix that I can apply to resolve or is it something els...
<python><gmail-api>
2023-12-22 15:12:43
1
457
MMsmithH
77,704,291
4,865,723
Problems getting results of MatchIt with rpy2 / How to debug R function with rpy2?
<p>I wasn't able to reproduce this in an MWE. I was using this code in the past and it worked. Some might have changed since then.</p> <p>There is no error. The problem is that <code>get_balance</code> is of <code>NoneType</code>. The self build R function did not return something.</p> <pre><code>get_balance = robjects...
<python><r><rpy2><matchit>
2023-12-22 14:43:14
1
12,450
buhtz
77,704,283
22,213,065
The script is not skipping the lines mentioned in my skip list
<p>I wrote a very simple python script that must apply some changes in my input txt file<br /> for example my input txt file is:</p> <pre><code>ari2600 ARI 304,975 nnelun CHALF185,406 Magnassey PHPS119,353 dioI 69,671 ari5200 ARI 0 ari7800 ARI 0 assesion EPOCH0 Coleion QUECO0 Gatch Nido® 0 Mavsion MEL 0 NESSD Ndo® 0 SG...
<python><regex>
2023-12-22 14:41:31
1
781
Pubg Mobile
77,704,187
929,732
PIP Python not installing latest version of package
<p>So installing the JIRA python package. The PyPi repo says there is a 3.5.2 but when asking for the specific version I get. the below... the generic install give me 3.2 which is not the latest version.</p> <pre><code>pip install jira==3.5.2 or pip install jira </code></pre> <blockquote> <p>ERROR: Could not find a ver...
<python><jira><python-jira>
2023-12-22 14:23:49
0
1,489
BostonAreaHuman
77,704,029
7,474,589
Pandas - calculate rolling standard deviation over all columns
<p>Say I have a pd.DataFrame and want to calculate the rolling Standard deviation. In pandas I can use <code>rolling(window=x).std()</code>, but it gives me the SD by column. I however want the standard deviation over all columns in a given row.</p> <p>As an example consider the pd dataframe</p> <pre><code>df = pd.Data...
<python><pandas><rolling-computation><standard-deviation>
2023-12-22 13:49:56
2
349
W. Walter
77,703,777
625,350
No TypeError raised for missing abc.abstractmethod when deriving a PySide6 widget
<p>I have an object that inherits both from a <code>QWidget</code> and an <code>abc.ABC</code> interface. See <code>MyWindow</code> in my example below.</p> <pre><code>import abc from PySide6 import QtCore, QtWidgets #from PyQt6 import QtCore, QtWidgets # It works as expected in PyQt6 #from PyQt5 import QtCore, QtWi...
<python><pyqt><pyside6><abc>
2023-12-22 12:58:03
0
5,596
titusjan
77,703,763
1,771,155
dbt python models and unitests
<p>I have a dbt python model in my folder <code>foo</code></p> <pre><code> |-foo | |-post_to_api.py | |-test_post_to_api.py | |-foo.sql </code></pre> <p>How can I exclude all my python tests when I do <code>dbt run</code>?</p> <pre><code>dbt run --models foo --exclude foo.test_post_to_api Parsing Error in model ...
<python><dbt>
2023-12-22 12:55:31
1
4,886
Vincent Claes
77,703,591
3,747,486
Debug mode not stop at breakpoint when VS Code workspace is under Python installation directory and justMyCode is true
<p>I am trying to learn how to use break points.</p> <p>As you can see in below screenshot, the program didn't stop at break point and the variables window is empty.</p> <p>I press the button in orange circle. I have also tried press F5 Start debugging. Both have same result.</p> <p>What could be the problem?</p> <p><a...
<python><visual-studio-code><vscode-debugger>
2023-12-22 12:17:14
4
326
Mark
77,703,490
2,526,586
PyQt/PySide: QFileDialog to select both existing and non-existing directory
<p>In my Python GUI(PyQt/PySide) application, I am using <code>QFileDialog</code> to let users to pick <strong>ONLY ONE directory</strong> so that the application will save multiple files in that directory. This directory can be either exiting or non-existing. If the directory does not exist, my application will create...
<python><directory><pyqt><pyside><qfiledialog>
2023-12-22 11:53:09
1
1,342
user2526586
77,703,424
9,182,414
Differences between import filename and import directoryname in Python
<p>In Python, when we do <code>import modulename</code>, is there any material difference between</p> <ul> <li>a file <code>modulename.py</code></li> <li>a directory with the same contents in <code>modulename/__init__.py</code>?</li> </ul> <p>Concretely: consider a file <code>m.py</code> containing <code>s = &quot;hell...
<python>
2023-12-22 11:38:12
0
449
jonathanjo
77,703,309
8,275,139
Dump dictionary with a field containing an already encoded JSON string
<p>I'm JSON encoding a Dictionary using its avro schema to make it a stringify JSON:</p> <pre><code>import json from datetime import datetime import fastavro message = { &quot;name&quot;: &quot;any&quot;, &quot;ingestion_ts&quot;: datetime.utcnow(), &quot;values&quot;: { &quot;amount&quot;: 5, ...
<python><json><avro>
2023-12-22 11:10:25
1
1,077
Luiscri
77,703,296
2,062,965
Can I combine pip installation based on requirements.txt with optional extra packages PEP508?
<p>For some while, I have been looking for a method to use a <code>requirements.txt</code> file (see <a href="https://pip.pypa.io/en/stable/reference/requirements-file-format/" rel="nofollow noreferrer">format specification</a>) with optional package extras depending on the use case, e.g., for testing purposes:</p> <pr...
<python><pip><requirements.txt>
2023-12-22 11:07:49
2
2,784
strpeter
77,703,244
20,176,161
Generate a simple id from string
<p>I have a dataframe where I am trying to generate an id (without the complexity of a hash etc) based on an information from a string. The code is as follows:</p> <pre><code>df['id'] = df.City.str[:3] + '-' + df.Name.str[:3] +'-' + df.index.astype(str) City Name Id Paris John Par-Joh-1 Paris Paul...
<python><pandas>
2023-12-22 10:56:56
1
419
bravopapa
77,703,108
7,556,522
Resolving Type Support Errors in Polars Series
<p>I am working with the Polars library in Python and encountering type support errors while trying to implement a series operation function.</p> <p><strong>minimal reproducible example</strong></p> <pre class="lang-py prettyprint-override"><code>from polars import Series, Float64 def range_norm(serie: Series) -&gt; S...
<python><python-typing><python-polars><pyright>
2023-12-22 10:30:31
0
968
Olivier D'Ancona
77,703,068
22,221,987
How to precompile large text in QTextEdit to avoid freezes on widget first screen appearance
<p>I have <code>QTextEdit</code> widget, located in a <code>QTabWidget</code> tab with <code>index 1</code>. I set html file with this code.</p> <pre><code> def set_help_text_edit_html(self): f = QFile(&quot;app/resources/help_tab.html&quot;) f.open(QFile.ReadOnly | QFile.Text) stream = QText...
<python><python-3.x><qt><pyqt><pyside6>
2023-12-22 10:22:20
0
309
Mika
77,703,015
10,240,072
Dataframe sum columns according to dictionary of list of columns
<p>I am trying to find the most pytonic way to do the following :</p> <p>I have a dataframe and a dictionary</p> <pre><code>import pandas as pd df = pd.DataFrame([[4,8,52,7,54],[0,20,2,21,35],[2,33,12,1,87]], columns = ['A', 'B', 'C', 'D', 'E']) dic = {'x':['A','D'], 'y' : ['E'], 'z':['B','C']} </code></pre> <p>I am tr...
<python><pandas><dataframe>
2023-12-22 10:12:44
3
313
Fred Dujardin
77,702,922
3,274,299
Pytorch in docker with read-only mode
<p>I'm running pytorch in docker. The requirements from security team is to run docker in read-only mode.</p> <p>I need to fork main process with models, that's why I use function <code>module.share_memory()</code> to move all models to shared memory and use <code>torch.multiprocessing.set_sharing_strategy('file_system...
<python><docker><pytorch>
2023-12-22 09:56:32
1
695
Tipok
77,702,581
16,436,095
How to send .xml file with correct name using as2?
<p>I have a partner with whom we exchange .edi messages using the as2 protocol.</p> <p>Now we need to switch to messaging in the .xml format. Moreover, my partner wants the files to have the correct names.</p> <p>I use my own library (based on pyas2lib). Judging by the information I found on the internet, I need to cha...
<python><xml><edi>
2023-12-22 08:44:46
1
370
maskalev
77,702,579
11,038,017
Cannot add data to a ComplexField using Python SDK for Azure AI Search
<p>I want to upload a payload with a nested dictionary to Azure AI Search index. I am using a ComplexField in the index for a nested dictionary in my payload. The nested dictionary is not being recognized by the index and I get a null-error. Here is my code:</p> <pre><code> ComplexField, CorsOptions, SearchI...
<python><azure><indexing><azure-cognitive-search>
2023-12-22 08:44:44
2
333
Irina Kärkkänen
77,702,504
3,364,871
pydantic: exclude computed field from dump
<p>In pydantic v2, the following code:</p> <pre class="lang-py prettyprint-override"><code>from __future__ import annotations import pydantic from pprint import pprint class System(pydantic.BaseModel): id: int name: str subsystems: list[System] | None = None @pydantic.computed_field() @property ...
<python><pydantic><pydantic-v2>
2023-12-22 08:28:20
2
5,735
Maxim Suslov
77,702,135
268,581
F8 the first time evaluates line in PowerShell, not in Python
<h1>Demonstration of Issue</h1> <p>I open a new python file:</p> <pre><code>code -n C:\temp\test-a.py </code></pre> <p>The contents of the file:</p> <p><a href="https://i.sstatic.net/2j4q7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2j4q7.png" alt="enter image description here" /></a></p> <p>If I mov...
<python><visual-studio-code>
2023-12-22 07:01:25
1
9,709
dharmatech
77,702,109
11,279,970
Extract concatenated p tags and table tag separately into a list
<p>I have a number of p tags with table tags I am retrieving in order into a list <code>content_items</code>. I am trying to join all p tags and then, once a table is found, append what I have collected already and then parse the table as a separate item in the list. I am able to collect the tables yet for some reason ...
<python><beautifulsoup><htmltext>
2023-12-22 06:55:38
1
508
Simon Palmer
77,701,997
2,003,079
How to display the legend over another Axes in Matplotlib?
<p>As shown in the following example, the legend for the left Axes is always occluded by the right Axes, even if I change its zorder and the clip_on property. However, the legend for the right Axes is displayed over the left Axes by default (tested in Matplotlib 3.1.3).</p> <pre><code>import matplotlib.pyplot as plt f...
<python><matplotlib>
2023-12-22 06:23:29
3
6,540
herrlich10
77,701,199
7,999,936
Concatenate/bind polars dataframes in a single dictionary with names
<p>I have a dictionary created by importing data from multiple Excel sheets using <code>polars.read_excel</code>. I'd like to combine them all, by row, into a single dataframe and preserve the sheet name as a column in the new combined dataframe to record which sheet the observation came from.</p> <p>I found a solution...
<python><python-polars>
2023-12-22 00:33:26
1
3,215
hmhensen
77,701,135
13,838,385
How can I get IronPython in C# to run a script that requires an active VENV? Is this possible?
<p>I've installed IronPython 3.4 (<a href="https://github.com/IronLanguages/ironpython3/releases/tag/v3.4.1" rel="nofollow noreferrer">https://github.com/IronLanguages/ironpython3/releases/tag/v3.4.1</a>) and I'm trying to run several font-related python scripts that depend upon an active VENV (FontTools, ftCLI, and so...
<python><c#><ironpython>
2023-12-22 00:06:25
1
577
fmotion1
77,701,100
13,844,017
Github self-hosted runner complains of python version -
<p>I am trying to set a GitHub self-hosted runner for my project and I keep getting the following error:</p> <blockquote> <p>Run actions/setup-python@v3<br /> Version 3.9 was not found in the local cache<br /> Error: Version 3.9 with arch x64 not found<br /> The list of all available versions can be found here: <code>h...
<python><github><continuous-integration><github-actions>
2023-12-21 23:52:32
1
373
Matthew D.
77,701,070
11,037,602
How to split a tree in branches based on depth
<p>I'm unsure if this is a hard problem, or I'm just way too rusty in DSA, but I can't find a way to write a function to split a tree in multiple branches, based on an arbitrary value of depth.</p> <p><strong>What I mean is:</strong> I want to write a function <code>split_tree</code> that receives AT LEAST, the paramet...
<python><algorithm><data-structures><tree><logic>
2023-12-21 23:42:11
2
2,081
Justcurious
77,701,068
1,232,087
Referenced Notebook not found
<p>I'm given a <code>notebook</code> to run in <code>Azure Databricks</code>. I imported the notebook to my user folder <code>Workspace\Users\MyUserName@CompanyName.com</code>. Following command in the notebook gives the error shown below.</p> <p><strong>Question</strong>: Where is the referenced notebook <code>qc_note...
<python><jupyter-notebook><databricks><azure-databricks><azure-notebooks>
2023-12-21 23:41:34
1
24,239
nam
77,700,850
15,163,418
How to prevent python from auto closing the terminal
<p>I created a CLI with python and built it as a exe with pyinstaller. When I double click the exe the terminal opens and if my code encounters few condition it will display some warning message and do <code>sys.exit()</code>. on <code>sys.exit()</code> the terminal closes automatically. So I cant even read that warnin...
<python><terminal><command-line-interface><pyinstaller>
2023-12-21 22:31:07
1
541
Raghavan Vidhyasagar
77,700,822
443,854
Numpy large square matrix with repetition
<p>I need to construct a large square <code>N*M</code> by <code>N*M</code> matrix to be used with <code>numpy.matmul</code>. There is a lot of repetition, such that the elements of each <code>M</code> by <code>M</code> square segment are repeated <code>N*N</code> times. To illustrate, for <code>M=2</code> and <code>N=3...
<python><numpy>
2023-12-21 22:20:57
1
7,543
user443854
77,700,760
11,154,841
Can a Named Entity Recognition (NER) spaCy model or any code like an entity ruler around it catch my new further date patterns also as DATE entities?
<h2>Anonymization of entities found by a NER model</h2> <p>I try to anonymize files by means of a NER model for German text that sometimes may have a few English words. If I take spaCy NER models for German and English like de_core_news_sm and en_core_web_sm, they find town names or persons, and at least the English mo...
<python><python-3.x><spacy><named-entity-recognition><spacy-3>
2023-12-21 22:02:13
1
9,916
questionto42
77,700,738
11,748,924
No space device left tensorflow docker cloud shell with buildpacks
<p>I got this error after I run this script:</p> <pre><code>#/bin/bash # Build Image pack build deepcare_image --builder gcr.io/buildpacks/builder:v1 --path . &amp;&amp; # Push to GCR gcloud auth configure-docker &amp;&amp; docker tag deepcare_image:latest gcr.io/deep-care-capstone/deepcare_image:latest &amp;&amp; do...
<python><docker><tensorflow><google-cloud-platform>
2023-12-21 21:56:32
1
1,252
Muhammad Ikhwan Perwira
77,700,603
2,440,517
Generate a CSV object without a file (in python)
<p>So, I need to generate a CSV object just to POST it to an API (part of the script). I would prefer to avoid saving the file in the server storage (even if it's a temp file) before sending it in the request.</p> <p>So far, I found the CSV file to upload is a <strong>&lt;_io.TextIOWrapper name='file.csv' mode='r' enco...
<python><csv><generate>
2023-12-21 21:24:50
1
611
Alejandro
77,700,489
1,472,253
How to perform a conditional sort in Polars
<p>I'm performing a binary classification and I want to manually review cases where the model either made an incorrect guess or it was correct but with low confidence. I want the most confident incorrect predictions to appear first, followed by less confident predictions, followed by correct predictions sorted from lea...
<python><python-polars>
2023-12-21 20:55:25
2
8,467
Andrew Brēza
77,700,357
2,976,366
Google API Python Client Firebase App Distribution HTTP 400
<p>I'm trying to list my builds that I have uploaded to Firebase App Distribution with the help of the <a href="https://googleapis.github.io/google-api-python-client/docs/dyn/firebaseappdistribution_v1.html" rel="nofollow noreferrer">google-api-python-client</a> however I always get a HTTP status code 400.</p> <p>I hav...
<python><firebase><google-api-python-client><firebase-app-distribution>
2023-12-21 20:21:06
1
6,992
timr
77,700,324
11,188,487
Pandas Removing Rows Based on Previous Row
<p>Suppose I have a Pandas dataframe with columns first_date, label, last_date, where first_date &lt; last_date for all rows. I would like to remove any row (let's call this row z) if first_date of row Z is in between first_date and last_date of <em><strong>ANY</strong></em> row above row z of the same label (not just ...
<python><pandas><dataframe>
2023-12-21 20:15:00
4
587
atjw94
77,700,314
6,632,214
detecting named pipe reader disconnect using select.poll fails on macOS, works on Linux
<p>I want to detect on the <strong>writer</strong> (producer) end of a named pipe, when the reader (consumer) disconnects. In particular, this should work on Linux and macOS (Windows is already requires a separate method anyway, so it's out of scope here).</p> <p>The general idea of using Python's <code>select.poll()</...
<python><macos><named-pipes>
2023-12-21 20:12:43
0
2,761
TheDiveO
77,700,259
21,144,042
Problem in GitHub Actions when running a Python script
<p>I'm trying to write an action to automatically generate markdown summaries for a repository by running a <em>Python</em> script:</p> <pre class="lang-py prettyprint-override"><code>import os if __name__ == &quot;__main__&quot;: # Walk through all directories and files for root, dirs, files in os.walk('.'): ...
<python><github><github-actions>
2023-12-21 19:57:07
1
2,435
Diego Borba
77,699,984
1,790,485
python 2 vs 3 compatibility test with pylint is giving error
<p>I'm currently working on migrating our codes from Python 2 to Python 3. For that, we thought of using <code>pylint</code> to check the compatibility test with below code with simple print.</p> <p>File_1.py</p> <pre><code>print &quot;Hello&quot; </code></pre> <p>File_2.py</p> <pre><code>print(&quot;Hello&quot;) </cod...
<python><python-3.x><python-2.7><pylint>
2023-12-21 18:51:40
1
2,992
Rao
77,699,651
1,245,281
How to log OpenTelemetry data with python logger in an async app?
<p>So I've got this Python app. Basically it takes a job request, and runs a task. It is using asyncio so the methods are async/await. I wanted to create a logging Filter which added some trace context (trace/span IDs along with some attributes) to the log messages. But what ends up happening is it ends up calling <cod...
<python><python-asyncio><open-telemetry>
2023-12-21 17:38:21
0
551
RedBullet
77,699,632
10,466,809
Why can I omit the space after -m when executing python scripts at the command line?
<p>If I make a file like</p> <pre><code># test.py print('Hello World') </code></pre> <p>and I run</p> <pre><code>python -m test </code></pre> <p>then the python script runs. But if I run</p> <pre><code>python -mtest </code></pre> <p>the program ALSO runs.</p> <p>I would expect omitting that space causes some kind of ...
<python><command-line-arguments>
2023-12-21 17:34:39
2
1,125
Jagerber48
77,699,631
15,959,591
Empty rows in confusion matrix of a neural network
<p>Could you please say what's wrong with my confusion matrix? Two rows are empty, however, when I print out the confusion matrix (without plotting) the rows are not empty. That is the code that I use:</p> <pre><code>num_classes = 2 confusion_mat = confusion_matrix(y_test, predicted_labels) # Calculate total counts fo...
<python><tensorflow><neural-network><seaborn><confusion-matrix>
2023-12-21 17:34:34
0
554
Totoro
77,699,561
903,011
How to reset py's database?
<p>A vscode extension needs to use <a href="https://docs.python.org/3/using/windows.html#launcher" rel="nofollow noreferrer"><code>py</code></a> launcher. I installed Python via <a href="https://scoop.sh/" rel="nofollow noreferrer"><code>scoop</code></a> and it works:</p> <pre><code>PS C:\Users\W&gt; python --version P...
<python><windows><scoop-installer>
2023-12-21 17:18:21
1
30,596
WoJ
77,699,459
2,551,923
Extract the output path from step function trasnform job in python script
<p>I have a step function which has a infrence/tranform job and it needs to do thigs calculate prediction result and prediction probablity .</p> <pre><code>{ &quot;Comment&quot;: &quot;A description of my state machine for model onboarding&quot;, &quot;StartAt&quot;: &quot;Transform&quot;, &quot;States&quot;: { ...
<python><amazon-sagemaker><aws-step-functions>
2023-12-21 16:59:06
1
970
divyanayan awasthi
77,699,109
13,147,413
Replace nan values in a column with values from a different column from the same df in polars
<p>I'm very new to polars and i'm trying to translate some pandas statements.</p> <p>The pandas line is as follows:</p> <pre><code>df.loc[df['col_x'].isna(), 'col_y'] = df['col_z'] </code></pre> <p>that is to say: replace the values of col_y corresponding to null values of col_x with values of col_z.</p> <p>In polars i...
<python><python-polars>
2023-12-21 15:57:19
1
881
Alessandro Togni
77,699,086
607,846
Wrap a Model instance field
<p>I have a model instance which has an attribute called parent which is a string containing the parent's id.</p> <p>When I serialise this instance, I want to wrap the parent id so that it appears as follows:</p> <pre><code>{ name = &quot;John&quot; parent = {&quot;id&quot;: &quot;123-345&quot;} } </code></pre> <p>...
<python><marshmallow>
2023-12-21 15:52:53
1
13,283
Baz
77,698,979
532,054
Django Rest Framework Token Auth > Remove user foreign Key from POSTs while keeping it for GETs
<p>I'm struggling to make this work. I have the following model:</p> <pre><code>class Message(models.Model): text = models.CharField(max_length=500) date = models.DateTimeField(&quot;date published&quot;) user = models.ForeignKey(User, on_delete=models.CASCADE) room = models.ForeignKey(Room, on_delete=m...
<python><django><django-rest-framework>
2023-12-21 15:29:46
1
1,771
lorenzo
77,698,907
9,686,037
Pytorch problem with shape of model output
<p>I'm trying to use an implementation of the D-Linear model in Pytorch.</p> <p>Here is the model architecture</p> <pre><code>from re import X import torch import torch.nn as nn import torch.nn.functional as F import numpy as np class moving_avg(nn.Module): &quot;&quot;&quot; Moving average block to highlight ...
<python><deep-learning><pytorch><neural-network><tensor>
2023-12-21 15:18:25
1
425
ianux22
77,698,870
10,192,593
Aggregating within Numpy array in Python
<p>I have a multi-dimensional numpy array where one of the dimensions is age in years. I would like to convert this into 5 year increments.</p> <p>So I have array with (10,2) where the first dimension represents age in years and the second dimension represents sex. I would like to calculate the mean for every 5 years f...
<python><numpy>
2023-12-21 15:11:40
2
564
Stata_user
77,698,776
13,142,245
SageMaker pipelines CDK: All steps defined in Python script
<p>I'm interested in using SageMaker pipelines for the full ML Life cycle. From <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/build-and-manage-steps.html" rel="nofollow noreferrer">AWS SageMaker Documentation</a> I see that discrete steps can be defined in python, such steps could include Processing, Trainin...
<python><pipeline><amazon-sagemaker>
2023-12-21 14:54:41
0
1,238
jbuddy_13
77,698,625
10,972,079
Alexa Skills Kit widget - "Problem installing widget - There were problems in your install widget request"
<p>I have a rather simple widget with APL, however, when I attempt to install said widget onto my Echo Show 10&quot;, a pop-up appears titled, &quot;Problem installing widget&quot; and with the message &quot;There were problems in your install widget request&quot; followed by a time stamp. For reference, here is the AP...
<python><json><widget><alexa-skills-kit>
2023-12-21 14:28:36
1
1,338
CauseYNot
77,698,393
8,456,253
SQLAlchemy error on replacing child in an one-to-one relationship
<p>I want to have a one-to-one relationship between a user and their last message. I expect that when I update their last message, the previous last message will get deleted from the database. Below is the minimal reproducible example</p> <pre class="lang-py prettyprint-override"><code>from sqlalchemy import ForeignKey...
<python><sqlalchemy><orm>
2023-12-21 13:49:01
1
830
kuco 23
77,698,326
13,566,716
render cloud pre-deploy error: "alembic": executable file not found in $PATH
<p>Im trying to deploy my Python app to Render cloud and it doesn't recognize alembic:</p> <pre><code>==&gt; Starting pre-deploy: alembic upgrade head ==&gt; Pre-deploy has failed ==&gt; There was a problem running your pre-deploy command: &quot;alembic&quot;: executable file not found in $PATH </code></pre> <p>I have ...
<python><python-3.x><sqlalchemy><fastapi><alembic>
2023-12-21 13:36:48
1
369
3awny
77,698,169
11,046,379
Create multiple columns by splitting value from other column with one assignment
<p>There is DataFrame as:</p> <pre><code>timestamp filename 2023-12-20 10:09:52.011 2023/12/20/1703056183.log </code></pre> <p>How to create new columns &quot;year&quot;,&quot;month&quot;,&quot;day&quot; in one assignment by splitting of &quot;filename&quot; column?</p> <p>Wished result is :</p> <pre>...
<python><pandas><dataframe>
2023-12-21 13:08:06
2
1,658
harp1814
77,697,685
5,805,893
Python generic type annotation for pandas series
<p>I am encountering a type checking error when running my code through <code>typeguard</code>.</p> <p>I the following file in my package:</p> <pre><code>from __future__ import annotations import pandas as pd def col_sum(x: pd.Series[float]) -&gt; pd.Series[float]: return x*(x.sum()-1) </code></pre> <p>Originally, ...
<python><pandas><mypy><typeguards><nox>
2023-12-21 11:33:02
1
1,261
Michael Barrowman
77,697,080
2,604,247
How to Read the Result of Query into a Dask Dataframe in a Distributed Client?
<p>Trying to read the results of a query (from an AWS athena database) to a dask dataframe. Following the <a href="https://docs.dask.org/en/latest/generated/dask.dataframe.read_sql_query.html#dask.dataframe.read_sql_query" rel="nofollow noreferrer"><code>read_sql_query</code></a> method of the official documentation.</...
<python><sql><dask><dask-distributed>
2023-12-21 09:52:42
0
1,720
Della
77,697,045
8,030,794
How to check status service on remote server Ubuntu using python?
<p>I have couple servers with services on Ubuntu 22.04</p> <ol> <li>Local server addresses = [<code>*.*.*.*</code>, <code>*.*.*.*</code>, <code>*.*.*.*</code>]</li> <li>Services name = [<code>my_service1.service</code>,<code>my_service2.service</code>,<code>my_service3.service</code>]</li> </ol> <p>How to check service...
<python>
2023-12-21 09:48:05
1
465
Fresto
77,696,915
6,694,814
Python problem with opening password protected Excel file
<p>I would like to open my Excel file which is password protected. I've used some of the ways but without any success so far.</p> <p>My recent approach is based on the Pandas library, which cannot read the password-protected Excel file.</p> <p>The code looks like this:</p> <pre><code> import pandas as pd import os, sy...
<python><excel>
2023-12-21 09:25:48
1
1,556
Geographos
77,696,881
4,429,265
Scraping indicator results from tradingview - steps and instructions
<p>Before you deem this question duplicated, I read all the questions with the topic of scraping and tradingview, none of those question covered the points here completely, so I asked my own question. Thank you very much for your time and help.</p> <p>I want to extract indicator results from TradingView's website. Ther...
<python><selenium-webdriver>
2023-12-21 09:19:58
5
417
Vahid
77,696,759
5,533,078
code documentation with calls traceback (python)
<p>I am trying to find an automatic documentation tool that tells me what happens (which other functions or classes are called, and when) e.g. when I instantiate a given (python) class, or run one of its methods, in terms of calls traceback (but better rendered than a usual error log)</p> <p>Ideally without running the...
<python><static-analysis><documentation-generation>
2023-12-21 08:56:41
0
1,168
jjrr
77,696,537
2,964,428
Can finding patterns between numbers in the rock paper scissors game improve program performance?
<p>I recently read a book for computer beginners listing a code snip about the rock paper scissors game. The program uses primitive integers 0, 1, and 2 to represent rock, scissors, and paper.</p> <p>The most straightforward algorithm is to enumerate all the 3x3=9 situations.</p> <pre class="lang-py prettyprint-overrid...
<python><algorithm><performance><performance-testing>
2023-12-21 08:07:48
2
393
da_miao_zi
77,696,429
5,466,652
ConnectTimeout: HTTPSConnectionPool(host='fc.yahoo.com', port=443) - Error attempting yfinance.Ticker(..).info
<p>I am trying to work with yfinance library (This is my first time attempting to work with it).</p> <p>I attempted the following and it worked <code>pip install yfinance --upgrade --no-cache-dir </code></p> <p>I attempted the following in jupyter notebook and it worked <code> import yfinance as yf sp500=yf.Ticker(&quo...
<python><jupyter-notebook><yahoo-finance><yfinance>
2023-12-21 07:40:34
0
1,877
kathikeyan A
77,696,389
23,002,898
In Django, i can't see the user registration form on the home page
<p>I'm new to Django, i would like to display the <code>register.html</code> registration form on the home page (<code>index.html</code>) and NOT on <code>http://127.0.0.1:8000/register</code> or similar. On the home page I want to see the various input textboxes. I don't get any errors, but the form doesn't display.</...
<python><python-3.x><django><django-forms><django-templates>
2023-12-21 07:31:16
3
307
Nodigap
77,696,381
10,832,127
Same records being added on unique constraints
<p>I have added a unique together (badge_id, speech_id, badge_type) however I can still add data with same information, Attaching my schema as well <a href="https://i.sstatic.net/vA41r.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/vA41r.png" alt="enter image description here" /></a></p> <p>I can explai...
<python><mysql><django><django-migrations><unique-constraint>
2023-12-21 07:30:08
0
799
ThunderMind
77,696,211
4,382,305
predict float number by neural network
<p>I want to create a neural network to predict some outputs. two samples of data are here:</p> <pre><code>290,11,2,2700,14.7,43.7,77.6 320,2.1,2,2700,2.2,31.6,62.3 </code></pre> <p>The first 4 columns are inputs and The last 3 columns are outputs. I use torch. how many layers are needed for this problem. or what is be...
<python><pytorch><neural-network><prediction>
2023-12-21 06:50:39
3
2,091
Darwin
77,696,099
5,800,969
Click a dropdown search result item at random location in the dropdown result python selenium library
<p>I have been trying my head around to select the searched elements in the screenshot below. I tried the below methods none of them seems to be able to find the dropdown searched results elements.</p> <p><a href="https://i.sstatic.net/wUq6m.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wUq6m.png" alt=...
<python><selenium-webdriver><web-scraping><selenium-chromedriver>
2023-12-21 06:22:17
1
2,071
iamabhaykmr
77,696,017
3,789,703
How can I pass a parameter or value from a test case to a fixture?
<p>I have a fixture <code>pretest()</code> like the example below which is intended to be called before every test case. I understand that this fixture is run before running the test case code.</p> <p>Is there any way to get a value from the test case function so that I can use it inside the fixture?</p> <p>For example...
<python><pytest><pytest-fixtures>
2023-12-21 05:59:26
2
417
Sunil Kumar