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,121,685
12,886,610
Airflow branching: A task that only sometimes depends on an upstream task
<p>I have two tasks: <code>task_a</code> and <code>task_b</code>. There are DAG-parameters <code>run_task_a</code> and <code>run_task_b</code> that determine whether each task should be run. There is further parameter that is an input for <code>task_a</code>. Here's the important part:</p> <p><strong>If <code>task_a</c...
<python><airflow><airflow-taskflow>
2024-03-07 13:17:30
3
1,263
dwolfeu
78,121,643
842,622
How to create alias for first active item in reverse relation in Django models?
<p>I have a model called Item:</p> <pre class="lang-py prettyprint-override"><code>class Item(models.Model): ... </code></pre> <p>Also I have another model called Content. It has relation to Item and a ChoiceField to select is the content is active or not:</p> <pre class="lang-py prettyprint-override"><code>class C...
<python><django><django-models><django-queryset>
2024-03-07 13:09:23
1
651
Mirat Can Bayrak
78,121,558
7,422,392
Translated Fields not Rendering Correctly in Django CMS Plugin
<p>Am encountering an issue with rendering translated fields in a <code>Django CMS</code> <a href="https://github.com/django-cms/django-cms/blob/release/4.1.x/cms/plugin_base.py" rel="nofollow noreferrer">Plugin</a> using <code>django-modeltranslation</code>. The plugin is supposed to display translated content based o...
<python><django><django-cms><django-modeltranslation>
2024-03-07 12:57:12
0
1,006
sitWolf
78,121,507
4,867,977
python subprocess calling the local interpreter instead of the linked one
<p>I am attempting to execute a function within a Python script as a subprocess using its own interpreter, specified in the subprocess.run() call. This interpreter may include packages not present in my local Python environment. When I debug the file, errors occur due to these missing libraries in my local python inste...
<python><python-3.x><subprocess><interpreter>
2024-03-07 12:49:39
1
1,494
Novice_Developer
78,121,376
12,858,691
Mocking Flask's request.get_json raises "RuntimeError: Working outside of request context" in unit test
<p>I develop unit tests for the backend of a large flask app. I am testing whether the helper function get_post_args() is handling empty requests correctly:</p> <pre><code>from flask import request from unittest.mock import patch from errors import NoPostArguments def get_post_args() -&gt; Dict[str, Any]: args = ...
<python><unit-testing><flask>
2024-03-07 12:28:11
1
611
Viktor
78,120,924
10,551,444
An error occurred while initializing Chrome with profile and logging: Message: unknown error: cannot parse internal JSON template: Line: 1
<p>I think there is an incompatibility issue:</p> <p><strong>Environment:</strong></p> <p>Windows 10</p> <p>Selenium 4.10</p> <p>Python 3.10.7</p> <p>webdriver-manager 4.0.1</p> <p>Chrome Version 122.0.6261.112 (Build officiel) (64 bits)</p> <p><strong>I am making a python script. I want to open the Chrome browser with...
<python><selenium-chromedriver><webdriver-manager>
2024-03-07 11:18:31
1
1,223
Gauthier Buttez
78,120,824
15,991,297
Unknown IMAP4 command: 'idle' When Accessing Inbox
<p>I am trying to check for new emails in real time. I believe the code below should work but I get an &quot;AttributeError: Unknown IMAP4 command: 'idle'&quot; error. Can anyone see what the issue is?</p> <pre><code>import imaplib import email username = &quot;test@xxxxx.com&quot; password = &quot;xxxxx&quot; # Conn...
<python><imaplib>
2024-03-07 11:03:50
1
500
James
78,120,471
2,508,672
Read s3 binary csv file python
<p>A lambda function uploads a csv file in 'wb' mode.</p> <p>Code for uploading csv file which has read from email:</p> <pre><code>open('/tmp/' + filename, 'wb').write(part.get_payload(decode=True)) s3r.meta.client.upload_file('/tmp/' + filename) </code></pre> <p>Now I want to read the file, and have below code</p> <p...
<python><amazon-web-services><amazon-s3>
2024-03-07 10:16:12
0
4,608
Md. Parvez Alam
78,120,376
3,723,306
ThreadPoolExecutor too fast for CPU bound task
<p>I'm trying to understand how ThreadPoolExecutor and ProcessPoolExecutors work. My assumption for this test was that CPU-bound tasks such as increasing a counter wouldn't benefit from running on ThreadPoolExecutors because it doesn't release the GIL, so it can only use one process at a time.</p> <pre><code>@measure_e...
<python><concurrency><multiprocessing><threadpool><python-multithreading>
2024-03-07 10:00:12
2
1,480
JaviOverflow
78,120,278
5,640,161
Why is the lexsort warning thrown for some levels of pandas DataFrames but not others?
<p><strong>BACKGROUND</strong></p> <p>Consider the MultiIndexed pandas DataFrame from the following code</p> <pre><code>import numpy as np import pandas as pd N = 3 rangeN = list(range(1, N + 1)) index = pd.MultiIndex.from_product( [rangeN, rangeN], names=[&quot;level1&quot;, &quot;level2&quot;] ) columns = [ ...
<python><pandas>
2024-03-07 09:46:16
1
863
Tfovid
78,120,062
1,473,517
How to draw a circle which should be clipped only within the diagonal line in Python?
<p>I am trying to draw a circle which is clipped by a diagonal line. Here is my non-working code:</p> <pre><code>import matplotlib.pyplot as plt # Create the circle with radius 6 circle = plt.Circle((0, 0), 6, color='r', fill=False) # Set up the plot (reuse the previous grid settings) plt.figure(figsize=(8, 8)) plt.x...
<python><matplotlib>
2024-03-07 09:14:11
2
21,513
Simd
78,120,042
14,953,535
Pytest IndexError: tuple index out of range
<p>Currently I'm trying to configure my django rest API with pytest. When I tried to use models with <code>@pytest.mark.django_db</code> I get an error mentioning that <code>tuple index out of range</code> even though I do not refer any tuples in the test case. But everything works fine when I do not do any database qu...
<python><django-models><django-rest-framework><pytest><pytest-django>
2024-03-07 09:09:33
1
622
Shakya Peiris
78,120,007
3,383,722
FastAPI - Python - overrides dependencies
<p>Is it possible to override dependencies like this in FastAPI?</p> <p><a href="https://i.sstatic.net/uBojS.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uBojS.png" alt="override dependencies " /></a></p> <p>I need to overide it from APIRouter</p>
<python><fastapi>
2024-03-07 09:03:06
0
1,965
Piotr
78,119,926
12,314,521
How to get index of different top-k at each row in a 2D tensor in Pytorch?
<p>Given:</p> <ul> <li>a positive integer tensor A: (batch_size, N) in which zero is the smallest value. For example:</li> </ul> <pre><code>tensor([[4, 3, 1, 4, 2], [0, 0, 2, 3, 4], [4, 4, 3, 0, 3]]) </code></pre> <p>I want get the index of different k of k-th largest value at each row?</p> <ul> <li>k ...
<python><pytorch>
2024-03-07 08:49:20
1
351
jupyter
78,119,798
14,739,428
install python3.11.7 get no module named '_ssl'
<p>Here is the server OS version</p> <pre><code>[root@hdp1 bin]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch Distributor ID: CentOS Description: CentOS ...
<python><linux><ssl><openssl><centos>
2024-03-07 08:26:28
1
301
william
78,119,454
2,056,878
How to configure `gr.ChatInterface` to return multiple outputs (response & source documents)?
<p>I have this <code>gr.ChatInterface</code> that I want to adjust to also show to the user document sources that were used on retrieval (meaning, adding another output)</p> <pre class="lang-py prettyprint-override"><code>import gradio as gr def generate_response(message, history): print(f&quot;\n\n[message] {m...
<python><user-interface><huggingface><gradio>
2024-03-07 07:25:54
0
1,150
devio
78,119,437
14,114,654
Keep selected pages from PDF
<p>I have a pandas dataframe, pdf_summary, which is sorted and has 50 unique rows. Each row is a particular combination of file_pages. How could I create a folder and PDF for each file_name?</p> <pre><code>pdf_path = &quot;Documents/menu.pdf&quot; </code></pre> <pre><code>pdf_summary file_name ...
<python><pandas><pdf><pypdf>
2024-03-07 07:21:58
1
1,309
asd
78,119,374
3,467,698
How do I dynamically import a function by its pythonic path?
<p>I have a function in a submodule that normally can be imported like this:</p> <pre><code>from core.somepack import my_func </code></pre> <p>Instead I would like to import it lazily by a given pythonic string <code>core.somepack.my_func</code>. What is the best way to do it?</p> <pre><code>my_func = some_function_i_a...
<python>
2024-03-07 07:09:56
1
9,971
Fomalhaut
78,119,223
12,379,095
Neural Language Model: Getting error - ValueError: cannot reshape array of size 380 into shape (1,1,10)
<p>I am trying to follow a tutorial on character based Neural Language Model, which attempts to predict &quot;words in a sequence based on the specific words&quot;.</p> <p>As instructed, I have generated the sequence of texts to a file, defined the language model and saved the model as well as the mapping characters (a...
<python><machine-learning><keras><nlm>
2024-03-07 06:41:41
0
574
Stop War
78,119,131
4,429,265
CERTIFICATE_VERIFY_FAILED when trying to use qdrant with docker-compose and https
<p>I have two containers, qdrant and searchai. qdrant is my qdrant container with this docker-compose setup:</p> <pre><code>version: '3' services: qdrant: image: qdrant/qdrant:latest restart: always container_name: qdrant ports: - &quot;6333:6333&quot; - &quot;6334:6334&quot; volumes: ...
<python><docker><ssl><qdrant><qdrantclient>
2024-03-07 06:19:07
0
417
Vahid
78,118,909
3,223,818
Drawing the outermost contour of a set of data points without losing resolution
<p>I have a set of data points (as scattered data points in black) and I want to draw their outermost contour. I have tried to calculate the convex hull of my points (code below) but I lose too much resolution and the shape loses its nuances.</p> <pre><code># load usual stuff from __future__ import print_function impo...
<python><numpy><matplotlib><convex-hull>
2024-03-07 05:12:52
1
813
mdpoleto
78,118,772
5,567,893
How to get the values from the list of tensors by matching indices in pytorch?
<p>I have a question about calling the values from the list of tensors with multiple indices.<br /> Although I think that there are similar questions such as <a href="https://stackoverflow.com/questions/75504084/select-multiple-indices-in-an-axis-of-pytorch-tensor/75505948#75505948">here</a>, I couldn't completely use ...
<python><pytorch><pytorch-geometric>
2024-03-07 04:26:08
1
466
Ssong
78,118,754
5,635,892
Fit for a parameter when the function is obtained by numerical integration in Python
<p>I have the code below in python. What it does is to integrate numerically the function <code>func</code> between 2 values and save the last value in <code>counts_list</code>. One of the parameters of <code>func</code> is <code>omega_Rabi</code>. What I need to do is, after I obtain <code>counts_list</code> I would l...
<python><scipy><curve-fitting><numerical-integration>
2024-03-07 04:17:28
1
719
Silviu
78,118,612
1,765,397
python __init_subclass__ with multiple classes. why doesn't __init_subclass get called twice?
<p>I was searching for information on using __init_subclass__ with multiple classes and I came across this bug report: <a href="https://bugs.python.org/issue42674" rel="nofollow noreferrer">https://bugs.python.org/issue42674</a></p> <p>the submitter stated that __init_subclass__ was only called once instead of twice</p...
<python>
2024-03-07 03:29:29
2
1,730
kdubs
78,118,542
759,991
How can I pass a Django url parameter to template's url method?
<p>I have this urls.py file:</p> <pre><code>... urlpatterns = [ path('region_service_cost/&lt;str:region&gt;/', views.region_service_cost, name='region_service_cost'), path('monthly-region-service-cost/&lt;str:region&gt;/', views.monthly_region_service_cost, name='monthly-region-service-cost') ] </code></pre> ...
<python><python-3.x><django>
2024-03-07 03:03:52
2
10,590
Red Cricket
78,118,524
2,562,927
Better way to check dictionary for alternative keys
<p>I'm parsing a dictionary which may have the value I want under 4 possible keys (I have no control over the dictionary).</p> <p>The key could be <code>&quot;value&quot;</code> <code>&quot;_value&quot;</code> <code>&quot;amount&quot;</code> or <code>&quot;_amount&quot;</code></p> <p>Currently my only idea is</p> <pre>...
<python><dictionary>
2024-03-07 02:57:12
3
1,133
desired login
78,118,164
1,717,931
PyG dataset showing more than 1 graph
<p>I am a newbie to PyG and attempting to build a PyG dataset from a small json file (with 5 records: 5 nodes, 8 edges). After building the dataset, when I print out the properties of the graph, I see that the number of graphs is 3 and number of nodes is 20. I expect only 5 nodes and only 1 graph. The number of edges i...
<python><pandas><dataframe><pytorch-geometric>
2024-03-07 00:41:23
0
2,501
user1717931
78,118,100
9,422,114
Pandas: Filter dataframe by difference between adjacent rows
<p>I have the following data in a dataframe.</p> <div class="s-table-container"><table class="s-table"> <thead> <tr> <th>Timestamp</th> <th>MeasureA</th> <th>MeasureB</th> <th>MeasureC</th> <th>MeasureD</th> </tr> </thead> <tbody> <tr> <td>0.00</td> <td>26.46</td> <td>63.60</td> <td>3.90</td> <td>0.67</td> </tr> <tr> <...
<python><python-3.x><pandas><dataframe>
2024-03-07 00:15:11
1
1,401
Jacobo
78,118,020
1,879,366
Qdrant client scroll filter does not work
<p>I'm using Qdrant database through its Python client. I need to find entries in the database that have some metadata field set to a certain value (without using vector similarity). I'm trying to do it this way:</p> <pre><code>from qdrant_client.http import models condition = models.FieldCondition(key=&quot;field_nam...
<python><langchain><qdrant><qdrantclient>
2024-03-06 23:48:46
1
872
Lovro
78,117,968
4,107,537
`buildozer` does not place Python package in `site-packages` when compiling apk for android
<p>I have made a basic project skeleton <code>myapp</code> that replicates the general structure of my usual Python development flow, but adds Buildozer in for android targets. It looks like this.</p> <pre><code>myapp-proj ├── buildozer.spec ├── main.py ├── myapp │ ├── cli │ │ ├── cli.py │ │ └── __init__.py │...
<python><android><kivy><buildozer>
2024-03-06 23:27:57
1
419
Bradley Evans
78,117,884
1,689,987
dtreeviz python package is showing a split as being at 0 instead of the actual number
<p>The dtreeviz python package is showing a split at .216 as &quot;0.000&quot; as seen in this screenshot: <a href="https://i.sstatic.net/qN2xc.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qN2xc.png" alt="enter image description here" /></a></p> <p>The code is:</p> <pre><code>self.clf = DecisionTreeCl...
<python><dtreeviz>
2024-03-06 23:00:03
1
1,666
user1689987
78,117,535
1,082,438
Attaching timeseries to a dataframe
<p>I have a dataframe which looks like this:</p> <pre><code>&quot;2023-09-07 13:22&quot; type1 12.7 &quot;2023-09-07 14:07&quot; type2 101.1 </code></pre> <p>And separately a dataframe with reg spaced timeseries for each type:</p> <pre><code> type1 type2 2023-09-07 08:00 1 2 2023-09...
<python><pandas><merge>
2024-03-06 21:22:38
2
506
LazyCat
78,117,522
7,480,820
How do you hide the terminals that spawn from subprocess.run?
<p>I have packaged my python application into a standalone executable with pyinstaller and every time <code>subprocess.run</code> is called, a terminal pops up, then disappears when the command finished executing. This can be quite distracting when dozens of terminals spawn in quick succession. How do I keep these term...
<python><subprocess>
2024-03-06 21:20:32
1
1,282
Philip Nelson
78,117,414
2,593,383
precedence of python exception raised from within finally block
<p>I have some (python 3.12) code which really belongs in a finally block, but unfortunately that code can (in rare cases) raise an exception. Are exceptions raised in finally blocks guaranteed to take precedence over exceptions explicitly re-raised from exception blocks:</p> <pre><code>try: raise Exception('1') e...
<python><exception>
2024-03-06 20:58:06
1
3,593
nonagon
78,117,347
1,188,878
Improve performance on Networkx graphviz_layout for large volume of nodes and edges
<p>I have a network graph dataset which has around 12.5k root nodes and 70k edges which obviously would end up creating a huge graph. However, the end user would not be consuming the graph in its entirety but would be filtering on certain root nodes to see the network chart accordingly. The network is basically a linea...
<python><networkx><graphviz><pygraphviz>
2024-03-06 20:47:40
0
859
Kausty
78,117,318
7,233,155
Do wheels for a target have to be constructed on a machine with that architecture?
<p>I have used <code>maturin build</code> to build a distribution for a Python package on PyPi with a Rust extension using pyo3 bindings.</p> <p>I am trying to build for the following common architectures:</p> <pre><code>win_amd64 : aarch64-pc-windows-msvc win_x86_64 : x86_64-pc-windows-gnu / msvc macosx_11_0_arm64...
<python><rust><build><packaging><maturin>
2024-03-06 20:41:01
0
4,801
Attack68
78,117,197
1,543,042
Azure DevOps Pipeline - intermittently unable to load python
<p>I created a ADO pipeline to deploy some code to a PyPi repo; however, intermittently the pipeline fails with the error</p> <pre><code>python3: error while loading shared libraries: libpython3.9.so.1.0: cannot open shared object file: No such file or directory </code></pre> <p>The structure of the pipeline is a <code...
<python><azure-devops>
2024-03-06 20:19:08
1
3,432
user1543042
78,117,090
12,390,973
how to model if else condition in the objective function in PYOMO?
<p>I am trying to understand how can model if-else conditions in the objective function. I know how to do it in a constraint using binary variable but I am not sure how to do that in the objective function itself. For example, I have created a very simple energy supply model, here are its configurations:</p> <ol> <li>T...
<python><pyomo>
2024-03-06 19:54:31
0
845
Vesper
78,117,058
5,640,161
Is there anyway to avoid the lexsort warning without sorting the columns of a MultiIndexed DataFrame?
<p>I understand that there is some <a href="https://stackoverflow.com/questions/54307300/what-causes-indexing-past-lexsort-depth-warning-in-pandas">performance rationale</a> for sorting the columns (or indices) in a MultiIndexed pandas DataFrame. However, I have my own &quot;user-interface&quot; reasons for choosing th...
<python><pandas>
2024-03-06 19:47:15
1
863
Tfovid
78,117,038
22,437,734
Matplotlib shrinking Value from thousands to 1's
<p>I have created a DataFrame from an object called <code>car_data</code>:</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd class Car: def __init__(self, make, year, price, mileage, color, buy_rate): self.make = make self.year = year self.price = price self.mi...
<python><pandas><dataframe><matplotlib><plot>
2024-03-06 19:43:48
1
473
Gleb
78,117,019
4,706,711
Should I expect the http data to be out of order in my http server for connections comming from a single client socket?
<p>I am implementing my own http server:</p> <pre><code>import socket import threading import queue import ssl from manipulator.parser import LineBuffer,LoggableHttpRequest class SocketServer: &quot;&quot;&quot; Basic Socket Server in python &quot;&quot;&quot; def __init__(self,host,port,max_threa...
<python><http><sockets><server><tcp>
2024-03-06 19:40:01
1
10,444
Dimitrios Desyllas
78,116,950
1,231,450
Group reversed pandas dataframe
<p>I have the following code</p> <pre><code>df = pd.read_csv(&quot;some_data.csv&quot;) candles = [Candle(candle[&quot;close&quot;].iloc[0], candle[&quot;close&quot;].iloc[-1], max(candle[&quot;close&quot;]), min(candle[&quot;close&quot;])) for _, candle in df.groupby(df.index // ticks)] candles.reverse() <...
<python><pandas>
2024-03-06 19:29:43
1
43,253
Jan
78,116,908
6,769,082
pandas slice 3-level multiindex based on a list with 2 levels
<p>Here is a minimal example:</p> <pre><code>import pandas as pd import numpy as np np.random.seed(0) idx = pd.MultiIndex.from_product([[1,2,3], ['a', 'b', 'c'], [6, 7]]) df = pd.DataFrame(np.random.randn(18), index=idx) selection = [(1, 'a'), (2, 'b')] </code></pre> <p>I would like to select all the rows in <code>df</...
<python><pandas><dataframe><slice><multi-index>
2024-03-06 19:20:52
2
481
Chachni
78,116,727
1,299,669
How to overcome a precision error in Python when summing a list of floating point numbers?
<p>In Python3, <code>0.35 * 10</code> does not show the same result as summing a list of 10 numbers <code>0.35</code>.</p> <pre><code>Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53) [Clang 6.0 (clang-600.0.57)] on darwin Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; f...
<python><math><precision>
2024-03-06 18:44:40
1
1,687
Raiyan
78,116,518
19,198,552
How can I switch the title of a tkinter window when it gets minimized?
<p>iI have an tkinter application which has in the window title the full path-name of the file which is loaded into the application. As the path-name is usually long it can only be displayed when the window is not minimized. When it is minimized (to an icon) only the start of the path-name is visible. So I want to swit...
<python><tkinter>
2024-03-06 18:03:45
1
729
Matthias Schweikart
78,116,450
8,615,884
Rasa Install ERROR: Could not install packages due to an OSError:
<p>So I am trying to install rasa with</p> <pre><code>pip install rasa </code></pre> <p>I have python version 3.9.0</p> <p>I get this error:</p> <pre><code>ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: &lt;directory&gt; </code></pre> <p>Please help me I have no idea whats go...
<python><rasa>
2024-03-06 17:49:41
0
1,665
randomUser786
78,116,432
3,446,051
Use Python.exe located in a shared folder
<p>Sounds like a simple question, but I was not able to find an answer about that.<br /> I have my python and the environment installed on a different machine but in a shared folder which is accessible via UNC path.<br /> I wanted to use this python to run a python script from my machine (which is a different machine c...
<python><windows>
2024-03-06 17:46:20
1
5,459
Code Pope
78,116,222
4,427,777
Mouseover annotation/highlight of seaborn `pairplot`
<p>For the sake of mcve, I build the following <code>pairplot</code>:</p> <pre><code>from sklearn.datasets import make_blobs import pandas as pd from sklearn.cluster import HDBSCAN import seaborn as sns import numpy as np ; np.random.seed(0) centers = 4 data, c = make_blobs(n_samples = 20, cen...
<python><pandas><matplotlib><seaborn><mplcursors>
2024-03-06 17:10:17
1
14,469
Daniel F
78,116,178
6,694,814
Python folium - only last record is shown on the map
<p>I am fetching data from the .csv file, but I don't know why just only the last file is visible on my map.</p> <p>The code is like here:</p> <pre><code>df = pd.read_csv(&quot;sur_geo.csv&quot;) su = MarkerCluster(name=&quot;Surveyors&quot;).add_to(m) su1 = plugins.FeatureGroupSubGroup(su, &quot;Build Manager PAYE&qu...
<python><folium>
2024-03-06 17:02:34
0
1,556
Geographos
78,116,013
1,214,800
Can I perform a Mypy assertion inside of a function that affects a primitive arg?
<p>Let's say I have a simple validation function:</p> <pre><code>def is_valid_build_target(target: Any, throw=False) -&gt; bool: target = str(target) allowed_targets = [&quot;dev&quot;, &quot;prod&quot;] is_allowed = target.lower() in ALLOWED_TARGETS if not is_allowed and throw: raise ValueError...
<python><python-3.x><mypy><python-typing>
2024-03-06 16:36:50
1
73,674
brandonscript
78,115,786
10,037,034
Kernel Dying when importing unstructured.partition.pdf
<p>I tried the following import but my kernel dies all the time, how can i solve this problem?</p> <pre><code>from unstructured.partition.pdf import partition_pdf path = 'data/llama.pdf' raw_pdf_elements=partition_pdf( filename=path, extract_images_in_pdf=True, infer_table_structure=True, chunking_strat...
<python><kernel>
2024-03-06 16:00:27
1
1,311
Sevval Kahraman
78,115,726
11,001,493
How to adjust parameter from equation based on desirable output?
<p>I am trying to adjust an specific value (di) based on equation (Arps - for decline curve analysis) so the sum of my original + predicted values (new_sum) match my reference value (sum_reference).</p> <p>The original values:</p> <pre><code>df = pd.DataFrame({&quot;YEAR&quot;:[2019, 2020, 2021, 2022, 2023], ...
<python><prediction><hypothesis-test>
2024-03-06 15:49:04
0
702
user026
78,115,451
10,480,181
How to set type hints for a function that can return multiple values?
<p>I have a function that runs mysql select query and returns a list of values. However I am struggling with type hints.</p> <p>Function:</p> <pre><code>def my_function( self, param1: List[str], param2: date, param3: int, param4: List[str], param5: List[int], param6: List[str], param7: i...
<python><mypy><python-typing>
2024-03-06 15:09:43
1
883
Vandit Goel
78,115,382
4,329,853
Second celery task in chain executing before database updates from first task are completed
<p>I have a a chain of celery tasks and the second task needs to run, not just after the first task is complete, but after the database updates from the first task are complete. I've managed to get this working in my test by using a <code>while</code> loop to wait for the first chord in the chain to end but that seems ...
<python><django><celery>
2024-03-06 14:57:50
0
962
Brett Elliot
78,115,234
6,435,921
Checking derivative tensor in Pytorch
<p>In <a href="https://math.stackexchange.com/questions/4561173/derivative-tensor-of-fracaxx-top-ax-top-aa-x-with-a-symmetric-positiv">this</a> question on Math StackExchange people are discussing the derivative of a function <code>f(x) = Axx'A / (x'AAx)</code> where <code>x</code> is a vector and <code>A</code> is a s...
<python><pytorch><derivative><autograd>
2024-03-06 14:37:08
1
3,601
Euler_Salter
78,114,974
2,335,020
Trying to use Python to upload a blob to Azure using a SAS_TOKEN
<p>I'm trying to follow the official documentation here (<a href="https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-upload-python" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-upload-python</a>) to upload a file to Azure.</p> <p>I got the URL and SAS_TOKE...
<python><azure><azure-blob-storage>
2024-03-06 13:58:11
1
8,442
576i
78,114,957
5,576,938
Is it possible to find the source code where mpmath.siegelz(t) is implemented?
<p>I want to do some work with Riemann zeta functions in Python similar to <a href="https://github.com/azeynel/jupyter-riemann/blob/main/horton-zeros.ipynb" rel="nofollow noreferrer">this code</a> (The code is broken the way it is now)</p> <p>But I would like to dig a little deeper and understand how <code>siegelz(t)</...
<python>
2024-03-06 13:56:21
0
353
zeynel
78,114,944
5,197,329
Not seeing any speedup when multiprocessing c++ code in python?
<p>I have some python code, which relies on a piece of c++ code that essentially does a large tree search. I need to run this tree search n times in a for loop and since each iteration was taking several second I figured this would be an obvious place to add some multiprocessing in python to speed things up. My multipr...
<python><c++><performance><multiprocessing>
2024-03-06 13:54:23
1
546
Tue
78,114,871
11,064,604
Turning list of indices into numpy array
<p>I have an <code>nxd</code> numpy array of zeros. For every row in this array, I am tasked with converting a specified column to be a 1. To this end, I have been given a list of size <code>n</code> such that the <em>ith</em> value of this list is the index to be turned into a 1.</p> <p>This task can be accomplished...
<python><arrays><numpy>
2024-03-06 13:42:05
2
353
Ottpocket
78,114,862
1,662,268
What is the "underlying code" of a Python `with` statement?
<p>Suppose you have:</p> <pre><code>with with_target_expression() as with_variable: with_block_contents(with_variable) </code></pre> <p>I understand the basic high-level intent here - that the target / <code>with_variable</code> will be &quot;gotten rid of&quot; sensibly after the <code>with_block_contents</code> c...
<python>
2024-03-06 13:41:28
1
8,742
Brondahl
78,114,392
661,589
Wrong Hungarian (hu_HU) sort order
<pre><code>import locale locale.setlocale(locale.LC_COLLATE,'hu_HU.ISO8859-2') print(sorted(['c', 'á', 'b', 'z', 'é', 'a', 'd', 'e', 'f', 'Ő', 'Ű', 'ő', 'ű'], key=locale.strxfrm)) </code></pre> <p>Expected: ['a', 'á', 'b', 'c', 'd', 'e', 'é', 'f', 'Ő', 'ő', 'Ű', 'ű', 'z']</p> <p>Actual: ['a', 'á', 'b', 'c', 'd', 'e', '...
<python><locale>
2024-03-06 12:28:34
1
19,251
Gavriel
78,114,361
7,233,155
Building package for noarch with Maturin for Python >= 3.9
<p><strong>Current Version</strong></p> <p>I have published a package previously to PyPi and Conda. It was written in pure Python and used some of the following settings in <code>pyproject.toml</code> and was built with the native <code>python -m build</code>:</p> <pre class="lang-py prettyprint-override"><code>[build-...
<python><rust><packaging><pyo3><maturin>
2024-03-06 12:23:27
1
4,801
Attack68
78,113,717
7,447,867
Why Python is running as 32 bit on 64 bit Windows 10 with 64-bit Python installed?
<p>I have a Python script that runs on Windows 10 Pro x64.</p> <p>When I open Task Manager, it shows that Python is running as 32-bit application.</p> <p><a href="https://i.sstatic.net/Uyf9F.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Uyf9F.png" alt="enter image description here" /></a></p> <p>This i...
<python><python-3.x>
2024-03-06 10:46:55
1
722
Araneus0390
78,113,572
13,520,498
can't load trained keras model with custom regularization class
<p>I'm training the PointNet3D object classification model with my own dataset following the Tutorial here in Keras: <a href="https://keras.io/examples/vision/pointnet/#point-cloud-classification-with-pointnet" rel="nofollow noreferrer">https://keras.io/examples/vision/pointnet/#point-cloud-classification-with-pointnet...
<python><tensorflow><keras><deep-learning><classification>
2024-03-06 10:24:55
1
1,991
Musabbir Arrafi
78,113,411
20,075,659
Partitioning Parquet AWS Wrangler with LakeFs
<p>I was trying to partition the parquet on S3 and it worked with AWS Wrangler.</p> <pre><code>basename_template = 'part.' partitioning = ['cust_id', 'file_name', 'added_year', 'added_month', 'added_date'] loop = asyncio.get_event_loop() s3_path = &quot;s3://customer-data-lake/main/parquet_data&quot; await loop.run_in_...
<python><dataframe><aws-data-wrangler><lakefs>
2024-03-06 10:01:24
0
396
Anon
78,113,333
4,269,851
Python list of lists to one dimensional using comprehension
<p>What would be the syntax to convert this loop into one line comprehension operator?</p> <pre><code>lst = [ [1,2,3], [4,5,6], [7,8,9], [10,11,12] ] all_records = [] for entry in lst: all_records.extend(entry) #[1, 2, 3, 3, 0, 1, 5, 2, 5, 10, 11] </code></pre> <p>When i am doing</p> <pre><code>al...
<python><list-comprehension>
2024-03-06 09:51:02
1
829
Roman Toasov
78,112,900
2,794,152
How do I set no "ticks" at all in the color bar?
<p>I want to set the colorbar with no ticks in any form. I've searched and set the tick parameter at two places. However, still there are some ticks at right boarder.</p> <pre><code>cb = mpl.colorbar.ColorbarBase(ax2, cmap=cmap, norm=norm, spacing='proportional', boundaries=bounds, format='%.1f') ax2.set_xlabel('t', s...
<python><python-3.x><matplotlib><colorbar>
2024-03-06 08:40:46
2
4,904
an offer can't refuse
78,112,700
3,727,079
Why am I getting "Mean of empty slice" warnings without NaNs?
<p>I've got a dataframe <code>keptdata</code>. I have a for loop to search through the rows of <code>keptdata</code>, and at one point need to average the previous values.</p> <p>This is the relevant line in my code, that produces the warning:</p> <pre><code>avg = np.average(keptdata.iloc[i-500:i].price[keptdata.price ...
<python><pandas>
2024-03-06 08:06:01
2
399
Allure
78,112,570
12,494,839
Saving data to JSON file in Python - Issue with appending multiple keys
<p>I have big data. from the data I want create script. From the big data , I want save data like this :</p> <p>In pAccountIds1 it will save first 99 ids then go pAccountIds2 next 99 ids as strings and so on. then save it in Parameters directory. Everything ids are saved in pAccountIds1.</p> <p>This is my expected out...
<python><json><list>
2024-03-06 07:40:34
1
3,533
Krisna
78,112,526
513,140
Adding 1KM grids to Folium map
<p>Could someone suggest a way to adding 1KM wide grids/graticules to folium map? The folium example here uses lat/longitude intervals but doesn't render the grid.</p> <pre class="lang-py prettyprint-override"><code> import folium # Bangkok coordinates center_lat = 13.7563 center_lon = 100.4911 m = folium.Map(locatio...
<python><maps><folium>
2024-03-06 07:31:38
1
390
Arky
78,112,459
2,316,068
How can you access the patch register in a python test?
<p>I have python test which is part of a larger test suite. Inside that test there is a <code>patch</code> expression similar to this:</p> <pre><code>def test_my_feature(): [...] with patch(&quot;my.module&quot;) as mocked_method: [...] mocked_method.assert_called </code></pre> <p>The problem is tha...
<python><testing>
2024-03-06 07:17:21
0
3,121
David Jiménez Martínez
78,112,288
10,715,700
How do I get the dot products of corresponding rows in two arrays?
<p>How do I perform this without using for loops and just numpy functions?</p> <pre class="lang-py prettyprint-override"><code>import numpy as np arr_x = np.array([[1,2,3], [4,5,6]]) arr_y = np.array([[1,2,3], [4,5,6]]) res = [] for x, y in zip(arr_x, arr_y): res.append(np.dot(x, y)) np.array(res) # array([14, 77...
<python><numpy>
2024-03-06 06:42:28
2
430
BBloggsbott
78,112,247
11,720,066
truth value of empty user-defined data objects
<p>This is more of a philosophical question.</p> <p>In python, <code>bool([])</code> evaluates to <code>False</code>. On the other hand, consider the following:</p> <pre><code>from dataclasses import dataclass @dataclass class Lists: items: list[str] other_items: list[str] assert bool(Lists(items=[], other_...
<python><boolean><pydantic><python-dataclasses>
2024-03-06 06:34:19
1
613
localhost
78,112,229
4,633,735
Can someone explain the difference between the two and why one produces a wrong result; Python instance variables
<p>Maybe a very noob question but the below gives wrong results when vecDict is initialized outside of init. Can someone please explain why..</p> <pre><code>class Vector: #vecDict = {} ## vecDict declared here gives wrong results vs in the init method. def __init__(self, nums): &quot;&quot;&quot; ...
<python><constructor>
2024-03-06 06:31:10
1
640
Hemanth Gowda
78,111,859
3,904,031
Gmsh example t4.py unable to find t4_image.png, other examples run fine
<p>Goal is to solve my previous question <a href="https://stackoverflow.com/q/78055800/3904031">Generate a mesh from my polygon geometry to iterate FEM for geometry optimization?</a> by myself using Gmsh</p> <p>I've installed <a href="https://gitlab.onelab.info/gmsh/gmsh/-/tree/master" rel="nofollow noreferrer">Gmsh</a...
<python><python-3.x><macos><finite-element-analysis><gmsh>
2024-03-06 04:47:05
1
3,835
uhoh
78,111,803
9,795,817
How is scikit-learn's RFECV `cv_results` attribute ordered by?
<p>I fit an <code>RFECV</code> instance on my training data using a binary classifier <code>clf</code>.</p> <p>My training data has 154 features and I used 10-fold cross-validation to drop five features per iteration.</p> <pre class="lang-py prettyprint-override"><code>rfecv = RFECV( estimator=clf, step=5, ...
<python><scikit-learn><rfe>
2024-03-06 04:25:45
0
6,421
Arturo Sbr
78,111,656
272,920
How to validate a copy of the pydantic model created with `model_copy`?
<p>Consider the following code</p> <pre class="lang-py prettyprint-override"><code>from pydantic import BaseModel, ConfigDict, ValidationError class MyModel(BaseModel): model_config = ConfigDict( frozen=True, extra='forbid', strict=True, ) a: int # will fail with a ValidationErr...
<python><pydantic>
2024-03-06 03:18:46
1
5,093
Anton Koval'
78,111,355
11,628,437
Unable to import functions from modules
<p>I tried to create a module using <code>setup.py</code> to practise my understanding of packages and <code>__init__.py</code> files. But I get the following error -</p> <pre><code>Traceback (most recent call last): File &quot;/home/thoma/PycharmProjects/test_gymnasium/test.py&quot;, line 1, in &lt;module&gt; fr...
<python><python-3.x><setup.py>
2024-03-06 01:26:02
0
1,851
desert_ranger
78,111,214
2,774,885
how can I detect if a file is open by windows app in WSL and either overwrite or rename?
<p>I have a python script that dumps data into an Excel file. My most common user error is that I have the Excel file open, and then I run the script again which attempts to write the same file. This fails silently within the Python program and does NOT update the excel file with the new data, leaving me to facepalm ...
<python><windows-subsystem-for-linux><file-handling>
2024-03-06 00:30:32
0
1,028
ljwobker
78,111,191
3,261,292
Invalid predicate error due to double quote inside an html attribute
<p>I have the following html script:</p> <pre><code>&lt;body class=&quot;item&quot;&gt; &lt;a title=&quot;spre_|_&quot;Marketing_|_Specialist&quot;&quot;&gt; Marketing Specialist &lt;/a&gt; &lt;/body&gt; </code></pre> <p>As you can see in <code>&lt;a&gt;</code> tag, the value of title attribute has double quotes inside...
<python><html><beautifulsoup><double-quotes>
2024-03-06 00:23:42
0
5,527
Minions
78,111,001
3,606,192
Periodic/sinusoid MSE loss in the custom implementation of linear regression
<p>I was implementing PyTorch-like modules (for educational purposes), and ran a simple training routine to check. However, my loss is oscillating, and I am not sure why.</p> <p>Below is the code. I put the loop first, but the implementation of the layers is below (might need to rearrange if running locally).</p> <h1>D...
<python><pytorch><linear-regression><mse>
2024-03-05 23:06:33
0
4,642
RafazZ
78,110,934
310,370
How to draw a moving line as slider for the image comparison video generator script in Python with FFmpeg
<p>I have the below script to generate a video slider with FFmpeg</p> <p>You can see example here (first 10 seconds) : <a href="https://youtu.be/F_wf1uHqZRA" rel="nofollow noreferrer">https://youtu.be/F_wf1uHqZRA</a></p> <p>I am trying to replicate effect of imgsli like a person is moving the slider smoothly</p> <p>Her...
<python><ffmpeg><python-3.10><image-slider>
2024-03-05 22:43:12
1
23,982
Furkan Gözükara
78,110,879
5,790,653
python how to concatenate dynamic parts of html template together and then print them as one html
<p>this is my <code>template.py</code>:</p> <pre class="lang-py prettyprint-override"><code>first = '''&lt;html&gt;&lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;h1&gt;This is header H1&lt;/h1&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;ID&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Phone&lt;/th&gt; &lt;t...
<python>
2024-03-05 22:28:28
1
4,175
Saeed
78,110,735
19,130,803
dash library error library is not registered
<p>I am developing a dash app using docker. On running I am getting this error for <code>dash_bootstrap_components</code> and <code>dash_ag_grid</code>. This error occurs randomly, no fix pattern or time so I can not pin point on specific code block. But on clicking the refresh button of browser the error goes off and ...
<python><plotly><plotly-dash>
2024-03-05 21:49:04
0
962
winter
78,110,698
11,918,054
Concatenate dictionary of lists into a single list
<p>I have the following dictionary:</p> <pre><code>myDict = dict({'red': [1, 2], 'blue': [3, 4]}) </code></pre> <p>And I would like to concatenate the key and value pairs into a single list:</p> <pre><code>['red_1', 'red_2', 'blue_3', 'blue_4'] </code></pre> <p>What is the most efficient way to accomplis...
<python>
2024-03-05 21:39:14
2
555
djc55
78,110,697
16,332,690
converting numpy datetime64 in a numba jitclass to unix timestamp
<p>For the sake of readability I want to be able to supply a numpy.datetime64 object to a numba jitclass which is converted to a unix epoch timestamp in float format within the class itself.</p> <p>I currently have to resort to calculating the unix timestamp prior to creating the jitclass object and supply this as a pa...
<python><numba>
2024-03-05 21:38:42
1
308
brokkoo
78,110,543
3,388,962
Save Jupyter notebook as a functional custom-format / single-page PDF
<p>The Jupyter ecosystem offers different ways to create a PDF, however, none suits me well so far – either because the process is buggy, because not all features are supported, or because it looks cluttered.</p> <p>To narrow down the question: I generally like the output of <code>pdfviahtml</code>:</p> <pre class="l...
<python><pdf><jupyter-notebook><file-conversion>
2024-03-05 21:04:52
0
9,959
normanius
78,110,521
20,075,659
boto3 change the endpoint of session
<p>I want to use LakeFS configurations for my boto session. I tried using this, but still, it gives me the default one</p> <pre><code>s3 = boto3.resource('s3', endpoint_url=lakefsEndPoint, aws_access_key_id=lakefsAccessKey, aws_secret_access_key=lakefsSecretKey ) s3_session = boto3.Session( aws_acces...
<python><lakefs>
2024-03-05 20:58:59
1
396
Anon
78,110,407
22,407,544
'ProgrammingError: column does not exist' in Django
<p>I've been moving development of my website over to using Docker. I replaced sqlite as my database with postgresql then ran the command <code>docker-compose exec web python manage.py migrate</code> in my Docker environment. I also updated <code>MEDIA ROOT</code> and <code>MEDIA</code> settings in my settings.py file ...
<python><sql><django><postgresql><docker-compose>
2024-03-05 20:29:53
1
359
tthheemmaannii
78,110,341
8,547,986
Rectangle appearing before replacement transform
<p>So I am trying to re-create googles logo using manim. The part where I am struggling is, the blue slab appears before transformation. My understanding of ReplacementTranform is, that the target does not appear before transformation and as animation proceeds it start to appear. But in my case somehow, the blue slab a...
<python><manim>
2024-03-05 20:15:46
1
1,923
monte
78,110,149
53,491
Can I get a copy of the raw request from python's requests library?
<p>code with requests working correctly, using requests_AWS4auth to connect to AWS.</p> <pre><code> from requests_aws4auth import AWS4Auth aws4auth = AWS4Auth(access_key, secret_key, 'us-east-1', 's3') response = requests.put( url, auth=aws4auth, data=content) </code></pre> <p>I'm trying to get this to wo...
<python><python-requests>
2024-03-05 19:31:28
1
12,317
Brian Postow
78,109,993
1,047,788
Prepend a marker string in front of each line of another program's output, while preserving aligned tab-formatted tables
<p>I have a program that prints tab-formatted output. (SO renders tabs below as spaces, in question edit mode it is tabs.)</p> <pre><code>Some Key: Value Another: Different value </code></pre> <p>When I run this program as subprocess, I intentionally prepend <code>&gt;:</code> in front of every line, to di...
<python><unicode><vertical-alignment><ansi-escape><tabstop>
2024-03-05 19:00:12
0
29,820
user7610
78,109,990
4,852,094
Ignore a Field in a type annotation
<p>If I have a pydantic class like:</p> <pre><code>from typing import Annotated, get_origin from pydantic import BaseModel class IgnorableBaseModel(BaseModel): _ignored: ClassVar[dict[str, Any]] = {} def __getattr__(self, attr): &quot;&quot;&quot;do something with _ignored, else fallback to default&qu...
<python><python-typing><pydantic>
2024-03-05 18:58:55
1
3,507
Rob
78,109,742
12,309,386
Polars scan_ndjson does not work with streaming?
<p>I am attempting to read data from a large (300GB) newline-delimited JSON file, extract specific fields of interest and write them to a parquet file. This question is a follow-up on <a href="https://stackoverflow.com/questions/78104587/polars-efficiently-extract-subset-of-fields-from-array-of-json-objects-list-of">m...
<python><json><dataframe><python-polars>
2024-03-05 18:11:42
1
927
teejay
78,109,592
1,217,178
Pytest/Mock keeping around extra object references in case of caught exceptions
<p>I am running into a strange issue using pytest and mock: I am trying to create a call to <code>__del__</code> by deleting an object using <code>del ...</code>. According to the documentation, <code>del</code> only reduces the reference counter on the object that is being &quot;deleted&quot; and only actually deletes...
<python><mocking><pytest><reference-counting><del>
2024-03-05 17:43:23
1
12,842
Markus A.
78,109,543
10,020,283
ValueError when calling inspect.signature on hashlib.md5
<p>I am encountering an exception when attempting to retrieve the signature of the hashlib.md5 function:</p> <pre><code>inspect.signature(hashlib.md5) ValueError: 'usedforsecurity=?' is not a valid parameter name </code></pre> <p>on Python 3.10.8. What could be the reason and how can I avoid this?</p>
<python><gcc><conda><hashlib>
2024-03-05 17:35:06
1
6,792
mcsoini
78,109,262
893,254
How do I fix this circular dependency in Python?
<p>I have a circular dependency between two classes in Python. I am not sure how to resolve this circular dependency.</p> <p>Both classes should be in their own module. At the moment, I am constrained to have both classes in the same module because of the dependency between them.</p> <p>Example:</p> <ul> <li>There are ...
<python>
2024-03-05 16:44:33
1
18,579
user2138149
78,109,250
1,557,060
Running a python file that imports from Airflow package, requires airflow instance?
<p>I am running into a weird import issue with Airflow. I want to create a module from which others can import. I also want to run unit tests on this module. However, I noticed that as soon as you import anything from the airflow package, it will try and run Airflow.</p> <p>Example:</p> <pre class="lang-py prettyprint-...
<python><airflow><python-import>
2024-03-05 16:42:46
2
5,604
JarroVGIT
78,109,019
22,371,917
how to use subdomains in flask?
<pre class="lang-py prettyprint-override"><code>from flask import Flask app = Flask(__name__) @app.route('/') def index(): return 'This is the main domain.' @app.route('/', subdomain='&lt;subdomain&gt;') def subdomain(subdomain): return f'This is the subdomain: {subdomain}' if __name__ == '__main__': ap...
<python><flask>
2024-03-05 16:01:52
1
347
Caiden
78,108,984
4,269,851
Find all overlapping records in multiple lists
<p>How to find overlapping records in multiple lists (about 100)?</p> <pre><code>dct = {'One': [1,2,3], 'Two': [3], 'Three': [0,1,5], 'Four': [2,5,10,11]} </code></pre> <p>I have difficulty on the planning stage, if I to draw block diagram with sequence what steps it should include?</p> <p>My ...
<python>
2024-03-05 15:54:01
2
829
Roman Toasov