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
79,749,806
10,416,012
How to typehint functools.partial classes
<p>I'm struggling to type hint correctly a python dataclass (or any class) with partial initialization, it seems that the type is lost somewhere but not sure where:</p> <pre class="lang-py prettyprint-override"><code>from dataclasses import dataclass from functools import partial @dataclass class Test: a : int ...
<python><python-typing><partial>
2025-08-29 03:54:44
1
2,235
Ziur Olpa
79,749,770
6,514,559
Pandas read_csv: Skip rows contains invalid data that can cause data_type parsing errors
<p>The csv file can contain string values to certain integer columns and I want to ignore/handle via callback if that happens, tried using <code>on_bad_lines='skip/warn'</code> however it gets triggered only on wherever there are parsing issues due to delimiter/num of columns mismatch. Here is the code I am using</p> ...
<python><pandas>
2025-08-29 02:27:39
2
774
Despicable me
79,749,646
13,014,864
Create unique index for each group PySpark
<p>I am working with a relatively large dataframe (close to 1 billion rows) in PySpark. This dataframe is in &quot;long&quot; format, and I would like to have a unique index for each group defined by a groupBy over multiple columns. An example dataframe:</p> <pre><code>+--------------+-------+---------+------+------+ |...
<python><apache-spark><pyspark>
2025-08-28 21:58:15
2
931
CopyOfA
79,749,636
1,275,942
Redirect stdout at a file-descriptor level to silence noisy module import
<p>I have a module that I need to use. However, when it is imported, it helpfully prints out some status information.</p> <pre class="lang-py prettyprint-override"><code>&gt; import problematic_module Connected to local cache! Detected version 1.0.0! &lt;several more lines of startup info&gt; &gt; </code></pre> <p>The ...
<python><windows><stdout>
2025-08-28 21:46:27
3
899
Kaia
79,749,580
1,253,006
How to retrieve one data value from the result of a pandas DataFrame.groupby().mean()
<p>Using Pandas 2.3.2 on Python 3.9.2 via JupyterLab.</p> <p>I've collected a bunch of thermal data from a thing. I've already collated that data into <code>DataFrame</code> chunks that look like this:</p> <pre><code> zone data Setpoint 9 zone1 40.34347 40 13 zone1 40.07553 40 17 zo...
<python><pandas>
2025-08-28 20:44:44
2
1,577
Brian A. Henning
79,749,522
6,514,559
Pandas read_csv, load empty/missing column values as NaN while loading empty string for quoted empty strings values in csv file
<p>My csv file contains empty string <code>&quot;&quot;</code> as well as missing column values <code>,,</code>. When i am loading with read_csv(), both are loaded as either empty string or NaN depending on keep_default_na and na_values configuration. I want to distinguish between these two different values such that ...
<python><pandas><string>
2025-08-28 19:34:02
3
774
Despicable me
79,749,411
4,518,341
What is NaT in Pandas?
<p>I have a dataframe with some &quot;NaT&quot; values in a datetime column. What does that mean?</p> <pre class="lang-none prettyprint-override"><code> project status completed 0 windows done 2025-08-20 1 doors done 2025-08-21 2 hvac delayed NaT </code></pre> <p>I checked the docs page <a ...
<python><pandas><datetime>
2025-08-28 17:08:43
1
33,775
wjandrea
79,749,374
2,398,143
'Failed to communicate with agent at http://127.0.0.1:5001 Tried multiple endpoint variations.', type=<ContentType.ERROR: 'error'>)
<p>I have written a sample script using python-a2a package and hitting the following error. I am not sure if the issue is with the specific version of the package.</p> <pre><code>A2ACalcClient initialized for URL: http://127.0.0.1:5001/a2a Sending calculation request: add(a=5, b=3) Unexpected response type from A2A age...
<python><python-3.x><agent><python-a2a>
2025-08-28 16:30:03
1
2,183
AnilJ
79,749,292
1,719,931
Export Excel timetable spreadsheet to ics calendar
<p>I have made a timetable in Excel, with one row for each event, and columns for the start and end date and time of those event.</p> <p>For instance:</p> <div class="s-table-container"><table class="s-table"> <thead> <tr> <th>Start</th> <th>End</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>2025-06-07 12:00...
<python><excel><icalendar>
2025-08-28 15:15:19
1
5,202
robertspierre
79,749,291
1,175,788
What would be a suitable way to receive run-time arguments and combine them into an iterable object?
<p>I'm struggling to get runtime arguments and combine them into a list. I'd like for run-time arguments to be like the following <code>python main.py --all</code> or <code>python main.py --endpoint1 --endpoint2</code>. I only have 2 endpoints to worry about right now, possibly more in the future, so I'd like the solut...
<python><command-line-arguments>
2025-08-28 15:13:45
1
3,011
simplycoding
79,749,250
56
How to use variable tables with SQLAlchemy Core
<p>With SQLAlchemy Core you can run &quot;raw&quot; SQL queries, which can include parameters. However, I can't find an &quot;official&quot; way to use variable identifiers. Take the function <code>get_entity</code> below. It returns a row from a table and key specified by the function arguments.</p> <p>For the moment,...
<python><python-3.x><sqlalchemy>
2025-08-28 14:40:11
1
19,370
doekman
79,749,231
856,804
How to type a wrapper function without Any
<p>Is there a way to type the following function without using <code>Any</code>?</p> <pre><code>from typing import Any import tenacity @tenacity.retry def foo_with_retry(*args: Any, **kwargs: Any) -&gt; None: foo(*args, **kwargs) </code></pre> <p>Is <a href="https://docs.python.org/3/library/typing.html#typing.Pa...
<python><python-typing>
2025-08-28 14:27:26
0
9,110
zyxue
79,749,129
11,318,472
Use `curve_fit` with `partial` using named parameters instead of positional parameters
<p>I'm trying to use <code>curve_fit</code> on a function for which I want to freeze one or more parameters using <code>partial</code>.</p> <p>E.g. this pattern, which is working:</p> <pre class="lang-py prettyprint-override"><code>from scipy.optimize import curve_fit from functools import partial # Irrelevant xdata =...
<python><scipy-optimize>
2025-08-28 13:03:29
1
1,319
euronion
79,749,001
1,022,138
Removing frame/outside of the text from red LED dotted display
<p>I am building a MAUI app and need to preprocess photos of a red dotted LED display so OCR can read the digits. The photos often include a bezel/frame, screw holes around the LEDs. I must remove that noise (top/right/left/bottom depending on the photo) while preserving every LED dot. Many preprocessing attempts eithe...
<python><c#><opencv><image-processing><imagesharp>
2025-08-28 11:23:59
0
1,638
boss
79,748,854
1,659,599
Not able to get selection of PDF document
<p>With <code>PySide6</code> <code>getSelection</code> returns an invalid <code>QPdfSelection</code>. No matter what arguments we pass to it.</p> <p>We'd expect a valid <code>QPdfSelection</code> with a non-zero <code>boundingRectangle</code>.</p> <p><strong>How to reproduce it</strong></p> <p>We call <code>getAllText<...
<python><pyside6>
2025-08-28 08:58:37
0
7,359
wolfrevo
79,748,530
1,316,365
Setting global variables for python multiprocessing
<p>I have a large array and an object I'd like to call multiple times with multiprocessing. Neither the data nor the object internals get modified.</p> <p>This works:</p> <pre><code>import numpy as np from multiprocessing import Pool data = np.arange(400).reshape(20, 20) class MyClass(): def __call__(self, indx):...
<python><numpy><multiprocessing>
2025-08-27 23:13:51
2
995
I.P. Freeley
79,748,461
5,629,527
how to pass pre-computed folds to successiveHalving in sklearn
<p>I want to undersample 3 cross-validation folds from a dataset, using say, RandomUnderSampler from imblearn, and then, optimize the hyperparameters of various gbms using those undersampled folds as input.</p> <p>The code I have so far is:</p> <pre><code>def train_model_with_undersampling(undersampler, estimator, scal...
<python><scikit-learn><hyperparameters><imblearn>
2025-08-27 20:41:58
1
1,134
Sole Galli
79,748,388
2,807,964
It is possible to create a Python package that installs partially?
<p>Recently, I have faced several libraries that support installs like:</p> <pre class="lang-bash prettyprint-override"><code>pip3 install library[all] </code></pre> <p>How can I do it? I'm not finding any documentation regarding that style of installation.</p> <p>Is it related to the <code>setup.cfg</code> configurati...
<python><packaging>
2025-08-27 19:11:53
0
880
jcfaracco
79,748,307
3,817,456
cuda commands from python in opencv fail
<p>I've compiled opencv with cuda support and am trying to use some cuda functions - to that end I'm trying the following test:</p> <pre><code>import cv2 if cv2.cuda.getCudaEnabledDeviceCount() &gt; 0: print(&quot;OpenCV was built with CUDA support.&quot;) else: print(&quot;OpenCV was not built with CUDA suppor...
<python><opencv><gpu>
2025-08-27 17:36:16
0
6,150
jeremy_rutman
79,748,241
7,036,941
Silent crash when adding emoji to button label in PySide6 / Qt Creator
<p>I'm using Qt Creator to design the GUI for an app. I wanted to add some emoji to the button labels but the app silently crashes when I do. I followed the error to the <code>retranslateUI()</code> function (which is autogenerated code, when generating a <code>py</code> file from a <code>ui</code> one with <code>pysid...
<python><qt><user-interface><pyside6>
2025-08-27 16:27:10
1
408
Joel Santos Rico
79,748,162
38,666
Using SQLAlchemy 2.0 to scope database transactions to pytest modules via Postgres
<p>I am working to migrate an older codebase from SQLAlchemy 1.3 to 2.0. I successfully migrated to 1.4, but I am running into trouble with the testing suite. The tests are using Postgres SAVEPOINTs and monkeypatching <code>session.commit</code> =&gt; <code>session.flush</code> to add two nested layers of isolation:</p...
<python><postgresql><sqlalchemy><pytest>
2025-08-27 15:24:36
2
19,277
One Crayon
79,748,065
1,145,666
Why is _cp_dispatch not routing to another method?
<p>I have this CherryPy object to process some simple REST API, but I fail to understand how <code>_cp_dispatch</code> is supposed to work.</p> <pre><code>class Products(object): def __init__(self, product_database): self.product_database = product_database def _cp_dispatch(self, vpath): # batc...
<python><routes><cherrypy>
2025-08-27 13:44:30
2
33,757
Bart Friederichs
79,747,670
633,961
error: "get" is not a known attribute of "None" (reportOptionalMemberAccess)
<p>I use PyRight to check my Django code. It complains about that</p> <pre class="lang-py prettyprint-override"><code> class FooForm(ModelForm): def clean(self): cleaned_data = super().clean() start = cleaned_data.get(&quot;start_date&quot;) # &lt;------- here </code></pre> <blockquote> <p>error: ...
<python><django><python-typing><pyright>
2025-08-27 07:34:49
1
27,605
guettli
79,747,645
1,482,820
Simple_Salesforce Python Connected App Sandbox
<p>I am trying to use simple-salesforce to connect to a sandbox.</p> <p>Refer: <a href="https://simple-salesforce.readthedocs.io/en/stable/user_guide/examples.html" rel="nofollow noreferrer">https://simple-salesforce.readthedocs.io/en/stable/user_guide/examples.html</a></p> <p>I can successfully connect with a username...
<python><salesforce><simple-salesforce><salesforce-conntected-apps>
2025-08-27 07:10:53
0
314
G-Man
79,747,603
633,961
Activate virtualenv in .envrc in poetry managed project
<p>I want to activate a Python virtual env by changing into a directory.</p> <p>This should activate the virtual env:</p> <pre><code>cd ~/projects/myproject </code></pre> <p>The project gets managed with <code>poetry</code>.</p> <p>Background: I am too lazy to type <code>poetry run mycommand</code>. I want to type only...
<python><virtualenv><python-poetry><direnv>
2025-08-27 06:25:10
1
27,605
guettli
79,747,317
252,873
How to sort pandas groups by (multiple/all) values of the groups?
<p>I am trying to do a somewhat complicated group and sort operation in pandas. <strong>I want to sort the groups by their values in ascending order, using successive values for tiebreaks as needed.</strong></p> <p>I have read the similar question <a href="https://stackoverflow.com/questions/68250141/pandas-dataframe-h...
<python><pandas><dataframe><sorting><group-by>
2025-08-26 20:54:39
3
1,813
Jessica
79,747,123
1,107,474
Python websocket library, how to print handshake?
<p>I am using the Python <code>websocket</code> library. I need to see the handshake payload.</p> <p>My code effectively looks like this:</p> <pre class="lang-py prettyprint-override"><code>from websocket import create_connection ws = create_connection(&quot;the websocket url&quot;) </code></pre> <p>I found:</p> <pre ...
<python><websocket>
2025-08-26 17:04:46
1
17,534
intrigued_66
79,747,037
2,637,604
VScode does not use the correct Python interpreter
<p>On ubuntu 24, I have installed anaconda and created a virtual environment myenv. I can see myenv when I search for a python interpreter with VScode, I select it, and in the dedicated terminal I activate the environment and check the python version</p> <pre><code>conda activate myenv which python </code></pre> <p>but...
<python><visual-studio-code><anaconda>
2025-08-26 15:51:34
0
1,792
Xavier Prudent
79,746,907
13,845,688
No model seems to support supports_parallel_function_calling to LiteLLM
<p>I'm using <strong>LiteLLM</strong> in a Python project and I'm testing support for <em>parallel function calling</em> on different models.<br /> Here’s a minimal reproducible example:</p> <pre class="lang-py prettyprint-override"><code>from litellm import completion from litellm.utils import supports_function_callin...
<python><openai-api><litellm>
2025-08-26 13:39:13
0
308
EnzoDeg40
79,746,620
7,456,317
LlamaIndex Python: Metadata filter with `None` value does not retrieve documents
<p>I’m working with <strong>LlamaIndex</strong> in Python and ran into an issue with metadata filtering.</p> <p>I have a <code>TextNode</code> that includes a metadata field explicitly set to <code>None</code>. When I try to retrieve it using a metadata filter where value is <code>None</code>, no documents are returned...
<python><llama-index>
2025-08-26 09:03:43
1
913
Gino
79,746,618
7,465,516
Number of arguments was 3 and is now 3 -- Strange Pylint(W0221:arguments-differ) on overriding log_message of BaseHTTPRequestHandler
<p>When I try to override the logging behaviour in my <code>BaseHTTPRequestHandler</code>-subclass like this:</p> <pre class="lang-py prettyprint-override"><code>from http.server import BaseHTTPRequestHandler class MyHandler(BaseHTTPRequestHandler): def log_message(self, fmt, *args): pass </code></pre> <p...
<python><pylint>
2025-08-26 09:03:22
1
2,196
julaine
79,746,460
3,381,858
CFAST + zero out complete media
<p>I have a SATA CFAST media of 32GB. And a bootloader (which creates 4 partitions) and copies some files to 3 partitions, like copying in 1,2, and 4 partitions, and the 3rd partition is empty.</p> <p>After this, my next task is to burn the same media with a different bootloader (which creates 3 partitions) and write f...
<python><storage>
2025-08-26 06:03:53
0
569
atulya
79,746,431
13,825,658
Why does mypy issubclass type narrowing only work on "type" instances?
<p>Code snippet:</p> <pre class="lang-py prettyprint-override"><code>from typing import Any class MyClass: pass def f(o: Any) -&gt; None: if isinstance(o, type) and issubclass(o, MyClass): reveal_type(o) # Revealed type is &quot;Type[MyClass]&quot; if issubclass(o, MyClass): reveal_type(...
<python><python-typing><mypy>
2025-08-26 05:11:05
1
1,368
Leonardus Chen
79,746,389
9,191,983
Python snowpark print()/.show() is not working
<p>I tried to create snowpark program in snowsight. There's already some code example showing when I add a sheet as following:</p> <pre><code>import snowflake.snowpark as snowpark from snowflake.snowpark.functions import col def main(session: snowpark.Session): # Your code goes here, inside the &quot;main&quot; h...
<python><dataframe><snowflake-cloud-data-platform>
2025-08-26 03:50:35
1
623
user9191983
79,746,308
5,483,457
Extending sympy variable definition to binary
<p>I am trying to extend the symbol class to a binary variable, where <code>+</code> would mimic an XOR operator such that</p> <p>x + y -&gt; x + y</p> <p>x + y + x -&gt; y</p> <p>x + x -&gt; 0</p> <p>I have referenced the this code <a href="https://stackoverflow.com/questions/63587691/sympy-binary-variable-definition"...
<python><sympy>
2025-08-26 00:57:05
2
496
albusSimba
79,746,284
4,996,797
One liner for printing python's path
<p>I am trying to put in my Bash script a one-liner that would print my python's path</p> <pre class="lang-bash prettyprint-override"><code>python -c 'import sys; for p in sys.path: print(p)' </code></pre> <p>the <code>for</code> keyword is flagged as an invalid syntax</p> <p>I was expecting that the semicolon would wo...
<python><python-import>
2025-08-26 00:09:22
2
408
Paweł Wójcik
79,746,181
20,591,261
How to display Polars list columns in NiceGUI
<p>I’m migrating from Streamlit to NiceGUI and noticed a difference in how DataFrames with list columns are handled.</p> <p>With Streamlit:</p> <pre class="lang-py prettyprint-override"><code>import polars as pl import streamlit as st df = pl.DataFrame({ &quot;a&quot;: [1, 2, 3], &quot;b&quot;: [4, 5, 6], ...
<python><python-polars><nicegui>
2025-08-25 20:46:34
2
1,195
Simon
79,746,113
856,804
Python injector doesn't work for NewType based on tuple[str, str]
<p>I'm trying to use <a href="https://github.com/python-injector/injector" rel="nofollow noreferrer">injector</a> to inject a <code>tuple[str, str]</code>, but it doesn't work.</p> <pre><code>import injector from typing import NewType Foo = NewType(&quot;Foo&quot;, tuple[str, str]) class MyModule(injector.Module): ...
<python><dependency-injection><python-typing>
2025-08-25 19:13:29
1
9,110
zyxue
79,745,977
11,741,232
Starting multiprocessing.Process() in a Pytest test/Python creates a Windows fatal exception: access violation
<p>On windows, running the below code with Python or pytest makes it print out <code>Windows fatal exception: access violation</code> (but the script will continue with no issue)</p> <p>Reproduction:</p> <pre class="lang-py prettyprint-override"><code>import multiprocessing as mp import faulthandler faulthandler.enable...
<python><python-3.x><multiprocessing>
2025-08-25 16:04:39
1
694
kevinlinxc
79,745,957
13,568,108
Cloud Composer Upgrade: composer-2.13.9-airflow-2.9.3 -> composer-2.13.9-airflow-2.10.5
<p>I am trying to upgrade my cloud composer instance from composer-2.13.9-airflow-2.9.3 to composer-2.13.9-airflow-2.10.5. I am getting many warnings in the dependency resolver like so:</p> <pre><code>WARNING: google-cloud-aiplatform 0.7.1 does not provide the extra 'evaluation' WARNING: google-cloud-aiplatform 0.7.0 d...
<python><google-cloud-platform><google-cloud-composer>
2025-08-25 15:42:14
2
317
FVCC
79,745,940
885,650
Debugging parallel python program in interruptible sleep
<p>I have a mpi4py program, which runs well with <code>mpiexec -np 30 python3 -O myscript.py</code> at 100% CPU usage on each of the 30 CPUs.</p> <p>Now I am launching 8 instances with <code>mpiexec -np 16 python3 -O myscript.py</code>. That should be fine, I have 64 cores with 4 units each, <code>nproc</code> shows <c...
<python><linux><mpi><hpc><mpi4py>
2025-08-25 15:26:02
1
2,721
j13r
79,745,913
3,110,740
Hide legend labels with underscore in matplotlib>3.10
<p>I create a plot with seaborn that has several lines and error bands. In the legend, I only want to show some of the labels and hide others.</p> <p>Previously, it was possible to call <code>ax.legend(['one', '_', 'two'])</code> to hide specific labels/artists from appearing in the legend. However, in the newest matpl...
<python><matplotlib><seaborn><legend>
2025-08-25 14:58:47
2
2,270
skjerns
79,745,352
1,942,868
Get the attribute data by another attribute beautifulsoup
<p>I want to parse the HTML like this below with beautiful soup</p> <pre><code>. . &lt;meta property=&quot;og:image&quot; content=&quot;https://test.com/test.jp&quot; /&gt; &lt;meta property=&quot;og:description&quot; content=&quot;mydescription&quot; /&gt; &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;...
<python><beautifulsoup>
2025-08-25 04:44:00
2
12,599
whitebear
79,745,232
824,624
pandas conert date failed - pd.to_datetime(df['xxx'], format='%Y-%m-%d').dt.date
<p>I am facing one little problem. I am storing some date time data and the data is</p> <pre><code>#secCode,secName,announcementTitle,announcementId,announcementTime 003816,xxx name,2024report,1222913141,1743004800000 </code></pre> <p>the date time column is clearly string - 1743004800000, so when I try to convert it<...
<python><pandas>
2025-08-24 23:44:24
1
8,168
user824624
79,744,904
12,415,855
How to copy a picture cell using python with xlwings?
<p>I try to copy the picture cells in column B using xlwings with the following code-snippet to first read all the images:</p> <pre><code>import os import sys import xlwings as xw path = os.path.abspath(os.path.dirname(sys.argv[0])) fn = os.path.join(path, &quot;Interactive Price List-Schnellstartneu (1).xlsx&quot;)...
<python><xlwings>
2025-08-24 13:34:19
1
1,515
Rapid1898
79,744,744
1,224,075
Why is mypy ignoring stub file?
<p>I have the two files in the following directory structure -</p> <pre><code>. ├── mymod.py └── mymod.pyi </code></pre> <p>The files are as follows -</p> <pre class="lang-py prettyprint-override"><code>def add(a, b): return a + b if __name__ == &quot;__main__&quot;: add(None, None) </code></pre> <pre class="l...
<python><mypy>
2025-08-24 08:15:04
0
2,107
tinkerbeast
79,744,735
9,087,250
Trigger DBT core jobs for Snowflake using Airflow
<p>Airflow is installed using Docker and it is running fine. Now I am trying to add dbt-core, dbt-snowflake and astronomer-cosmos python packages to the Airflow image in order to run the DBT core jobs using Airflow.</p> <p>I am trying to add the Python libraries using <code>requirements.txt file</code>. The contents of...
<python><snowflake-cloud-data-platform><airflow><dbt><astronomer>
2025-08-24 07:55:35
0
1,584
Teja Goud Kandula
79,744,440
703,421
How in python can I transform negative secs into struct time?
<p>I'd like to transform <code>-238204800</code> seconds to <code>&quot;1962:06:15 00:00:00&quot;</code>, using python 3.8.</p> <p>My code is :</p> <pre><code>from time import strftime, localtime secs = -238204800 print(strftime(&quot;%Y:%m:%d %H:%M:%S&quot;, localtime(secs)) </code></pre> <p><code>localtime()</code> g...
<python><time><negative-number><localtime>
2025-08-23 16:48:44
1
2,279
Eric H.
79,744,397
4,794
Tiny numbers in ReportLab's table of contents
<p>I followed an <a href="https://docs.reportlab.com/reportlab/userguide/ch9_other_useful_flowables/#tableofcontents" rel="nofollow noreferrer">example</a> from the ReportLab documentation on how to add a table of contents, and it works fine in most situations. However, if a section title is very close to the full page...
<python><pdf><reportlab><tableofcontents>
2025-08-23 15:56:39
0
56,676
Don Kirkby
79,744,396
3,138,436
ouput unicode character by suppressing original keystroke of physical keyboard using evdev-python in linux
<p>I am using Kali 2022 (Linux) with xfce 4.16. I am experimenting with python <code>evdev</code> module. What I am trying to achieve is when pressing certain key on the keyboard (like letter 'a'), instead of letter 'a', I want to post a specific Unicode character on the focus element.In other words, I want to map key_...
<python><linux><unicode><evdev><uinput>
2025-08-23 15:55:36
1
9,194
AL-zami
79,744,362
315,168
import tensorflow statement crashes or hangs on macOS
<p>I have the following Python statement, which I cannot execute in Jupyter Notebook or Python REPL:</p> <pre class="lang-py prettyprint-override"><code>import tensorflow </code></pre> <pre class="lang-none prettyprint-override"><code>Python 3.11.10 (main, Sep 20 2024, 14:23:57) [Clang 16.0.0 (clang-1600.0.26.3)] on da...
<python><tensorflow><pyarrow>
2025-08-23 15:16:34
1
84,872
Mikko Ohtamaa
79,744,130
12,415,855
Get url of second tab using selenium?
<p>I'm trying to get the second tab url using the following code -</p> <pre><code>import time import os, sys from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service from selenium.webdriver.support.ui import WebDriverWait from selenium.we...
<python><selenium-webdriver><webdriver><webdriverwait><window-handles>
2025-08-23 09:17:49
2
1,515
Rapid1898
79,744,026
11,649,567
Ram Memory leak when scripting a Sampling Trainer for a Bert Encoder and LSTM Decoder Tensorflow on GPU
<p>I wrote the module attached below. However, I notice a constant increase of RAM until I get an out of memory error. The code runs on CPU without a problem (except the slow training time). It can finish the first training step, however the memory doesn't get release after the first training cycle and it crashes out. ...
<python><python-3.x><tensorflow><deep-learning><lstm>
2025-08-23 05:40:46
1
400
mashtock
79,743,969
15,745,459
Python Win32Com: How do I open a password-protected Powerpoint?
<p>I tried to use the below code to open a password-protected ppt, but I got error: TypeError: Open() got an unexpected keyword argument 'Password'</p> <p>Is it possible to use Win32Com to open a password-protected powerrpoint? Thank you</p> <pre><code> import win32com.client as win32 xl = win32.Dispatch('PowerPoint.Ap...
<python><powerpoint><win32com>
2025-08-23 01:56:10
1
395
Peter
79,743,851
10,708,345
Django cannot register oauth2_provider and rest_framework to INSTALLED_APPS
<p>I am working on <a href="https://github.com/FeelHippo/django_authentication" rel="nofollow noreferrer">this</a> weekend project, to learn Django and I am stuck.</p> <p>Before adding the REST framework (<a href="https://github.com/FeelHippo/django_authentication/commit/3afb0f3d4b9c8b7c41fc862098e49758eae07e43" rel="n...
<python><django><pip><venv>
2025-08-22 21:01:22
2
320
Fi Li Ppo
79,743,751
16,706,763
Elasticsearch index creation from Python, results in error, for known mapping
<p>I have the following code:</p> <pre class="lang-py prettyprint-override"><code>from elasticsearch import Elasticsearch client = Elasticsearch( &quot;https://myhost&quot;, api_key=&quot;mykey&quot;, request_timeout=30, # Increase timeout duration max_retries=10, retry_on_timeout=True ) dest_inde...
<python><python-3.x><elasticsearch>
2025-08-22 18:42:06
1
879
David Espinosa
79,743,607
2,434,094
Modifying the character representation of stdout Pipe values
<p>I'm trying to use <code>subprocess.popen()</code> to execute a Linux command and then process the stdout streams to extract the average CPU load. Here is my code:</p> <pre><code>#!/usr/bin/env python import subprocess Answers = &quot;&quot; IPs = [&quot;192.168.70.13&quot;] IPName = [&quot;xxx&quot;] for x in IPs:...
<python><python-3.x><linux><popen>
2025-08-22 15:53:44
1
415
RDK
79,743,175
2,889,733
Show a user input popup that waits for user input without rerunning entire app
<p>I'm making a streamlit app in which I want to show a popup to the user to get some interim input from them. The problem is that I'm not able to get it to re-run in isolation. Here's my popup code for reference. This resides in a <code>utils.py</code> that I've imported into the main page script <code>page.py</code>:...
<python><streamlit>
2025-08-22 08:46:13
0
371
user9343456
79,743,154
393,010
How to let pylsp find imports in local project?
<p>When starting my editor with pylsp inside a projects folder I can see the LSP root dir is chosen to be the top folder, where <code>.git</code> is. However the python code is located in a subfolder so the corresponding python imports are not understood by the lsp. (goto_definition results in &quot;No location found&q...
<python><neovim><pylsp><python-lsp-server>
2025-08-22 08:31:23
0
5,626
Moberg
79,743,002
4,577,688
How do I create a Pytorch Dataset from multiple files where each file has multiple batches
<p>How do I create an dataset that reads in data from multiple files, but where each file has lots of rows or batches.</p> <p>For example, I have a partitioned parquet dataset (created with <code>pandas.to_parquet</code>), with text or embeddings in each row.</p> <p>The multiple batches per file, multiple file setup se...
<python><machine-learning><pytorch><nlp>
2025-08-22 05:35:23
1
3,840
dule arnaux
79,742,770
15,229,911
'Variable not allowed in type expression' warning when creating SQLAchemy session using DI
<p>I have a basic SQLAlchemy setup for a FastAPI project. I made a dependency for a database session like most tutorials suggest doing:</p> <pre class="lang-py prettyprint-override"><code>from sqlalchemy.orm import sessionmaker SessionLocal = sessionmaker(engine, **sqlalchemy_session_options) def get_session() -&gt; ...
<python><sqlalchemy><python-typing><pyright>
2025-08-21 21:08:35
1
324
postcoital-solitaire
79,742,629
2,829,355
Convert dictionary rows to new dataframe
<p>After importing some nested JSON data, I'm trying to create a new dataframe from all of the dictionary key / value pairs in an existing column.</p> <p>Starting point:</p> <pre><code>&gt;&gt;&gt; df['schedules'] 0 {'3263524': 'Group 1 CORE DAYS', '3263525': 'Group 1 CORE NIGHTS', '3263526': 'Group 1 EDUCATION', '...
<python><json><pandas>
2025-08-21 17:46:44
1
831
skohrs
79,742,395
243,031
GitHub Actions Docker build not able to reach to GCP artifacts
<p>I have Python package in GCP Artifactory and want to access that in Docker image.</p> <p>GitHub Actions workflow:</p> <pre class="lang-yaml prettyprint-override"><code>jobs: publish: runs-on: ubuntu-latest permissions: contents: 'read' id-token: 'write' # Required for OIDC steps: - na...
<python><docker><google-cloud-platform><github-actions><google-artifact-registry>
2025-08-21 13:41:11
1
21,411
NPatel
79,742,342
7,483,211
Cannot activate conda/mamba environment in Claude Code session
<p>I'm trying out Claude Code and want it to activate and use a pre-existing conda environment.</p> <p>I told it to run <code>micromamba activate py12</code> to activate the <code>py12</code> environment. This doesn't seem to work: afterwards there's still no <code>python</code> available.</p> <p>This is what I've trie...
<python><conda><mamba><micromamba><claude-code>
2025-08-21 13:08:04
2
10,272
Cornelius Roemer
79,742,202
13,045,595
Create a Pip Wheel for OpenCV Built from Source to Prevent Overwriting with Library Dependencies
<p>I have a Dockerfile that builds OpenCV from source with cuda. The build itself succeeds, but pip doesn’t recognize this custom installation. As a result, when I later install a Python package that depends on OpenCV, pip fetches a prebuilt opencv-python wheel, which then overrides (or hides) my source build. Accordin...
<python><docker><opencv><pip><python-wheel>
2025-08-21 11:14:00
0
335
M.Akyuzlu
79,742,136
785,523
How to read table names from a MySQL file containing PARTITION keyword using sqlglot?
<p>I am trying to read a <code>MySql</code> <code>SQL</code> file containing <code>PARTITION</code> keyword. I am getting the below error</p> <pre><code>An error occurred during parsing: Expecting ). Line 19, Col: 26. created_at`) USING BTREE ) PARTITION BY RANGE ( UNIX_TIMESTAMP(audit_ts)) ( PARTITION p2401 ...
<python><sqlglot>
2025-08-21 10:04:15
1
6,954
tuk
79,742,127
1,432,694
What to do when the pandas error position overflows?
<p>So, I'm experimenting with pandas with the <a href="https://datasets.imdbws.com/" rel="nofollow noreferrer">IMDB files</a>, especially <code>title.basic.tsv</code>. When trying to parse the <code>runtimeMinutes</code> column to <code>&quot;Int64&quot;</code>, I get an error</p> <pre><code>ValueError: Unable to parse...
<python><pandas><integer-overflow>
2025-08-21 09:59:25
2
685
red_trumpet
79,742,073
416,983
Export a PyTorch custom hash table lookup OP to ONNX
<p>I have implemented a PyTorch OP which accepts a torch.int64 tensor and outputs another torch.int64 tensor by looking up a hash table with predefined key-value pairs.</p> <p>The torch part is implemented like this, where <code>table</code> is a wrapper around a C++ hash table:</p> <pre><code>class TableLookup(torch.a...
<python><pytorch><onnx>
2025-08-21 09:06:49
0
1,106
user416983
79,741,635
6,162,679
How to automatically insert parentheses () when autocompleting functions in Python using Positron IDE?
<p>I am new to the Positron IDE and I'd like to automatically insert parentheses () when coding in Python. For example, when I type <code>len</code> and hit Enter to confirm, it does not automatically insert parentheses ().</p> <p>After searching online, it seems that in VS Code, there is a setting:</p> <p><code>&quot;...
<python><autocomplete><positron>
2025-08-20 22:04:00
2
922
Yang Yang
79,741,568
2,648,504
Pandas - return the -2 row
<p>If I have an input.txt file:</p> <pre><code>apples grapes alpha pears chicago paris london yellow blue red +++++++++++++++++++++ apples grapes beta pears chicago paris london car truck van +++++++++++++++++++ apples grapes gamma pears chicago paris london white purple black +...
<python><pandas>
2025-08-20 20:40:26
3
881
yodish
79,741,525
145,682
pycryptodome decryption (aes-128 cbc) is yielding incorrect result
<p>I have simple code to encrypt and decrypt as follows...</p> <p>(1) To encrypt:</p> <pre class="lang-py prettyprint-override"><code>from Crypto.Cipher import AES from Crypto.Util.Padding import pad, unpad from Crypto.Hash import SHA256 as sha256 def sha(text): _sha = sha256.new(text) return _sha.hexdigest() ...
<python><cryptography><aes><pycryptodome>
2025-08-20 19:39:09
2
11,985
deostroll
79,741,492
1,324,833
resetting data limits on zoom in Matplotlib python program (long)
<p>I've created a program to display very high sample rate data in profile. There are 6 channels (mag[0..2] &amp; diff[0..2]) sampled at 30 kHz. I display them in 3 profiles, mag[0] with diff[0], etc. All plots share the same x axis (nptime), which is numpy timedate64, with different scales for the mag and diff. Axes 0...
<python><matplotlib>
2025-08-20 19:06:35
1
1,237
marcp
79,741,348
5,118,421
Mypy: Source file found twice under different module names
<p><a href="https://results.pre-commit.ci/run/github/37489525/1754726473.T4bKKoTUTfG-t4riT2_Kjg" rel="nofollow noreferrer">https://results.pre-commit.ci/run/github/37489525/1754726473.T4bKKoTUTfG-t4riT2_Kjg</a></p> <pre><code>Source file found twice under different module names: &quot;example_scripts.rewrite.src.main&q...
<python><mypy>
2025-08-20 16:28:28
1
1,407
Irina
79,741,334
10,997,667
Populate folium TimestampedGeoJson features using lambda functions?
<p>I am following some code examples to plot time aware coordinates on a folium map using the <code>folium.plugins.TimestampedGeoJson</code> method. As in the example, I'm using a for-loop to tie coordinates and timestamps in a list of <code>GeoJson</code> features. In other work I have formatted styling of <code>GeoJs...
<python><leaflet><geojson><folium><folium-plugins>
2025-08-20 16:11:58
0
787
osprey
79,741,271
1,390,012
Google Chat App on Cloud Functions (2nd gen) – response fails
<p>I’m building a very simple Google Chat App on Cloud Functions (2nd gen) (Python). The app should just reply &quot;OK&quot; when I send a message from <code>mail.google.com/chat</code>.</p> <p>But in the logging error area always returns this error:</p> <blockquote> <p>Can't post a reply. The Chat app didn't respond ...
<python><google-cloud-functions><google-cloud-run><google-chat>
2025-08-20 15:16:31
2
699
mesompi
79,741,190
11,793,491
Reduce x newlines into x-1 newlines using regex
<p>I have this text: <code>&quot;&quot;Anna lives in Latin America.\n\nShe loves the vibes from the cities\n and the good weather.\n\n\nAnna is great&quot;</code></p> <p>And I want to reduce the x newlines into x-1 newlines. So the expected result is: <code>&quot;Anna lives in Latin America.\nShe loves the vibes from t...
<python><regex>
2025-08-20 14:24:11
3
2,304
Alexis
79,741,096
9,217,084
Oauth client authorization fails because of the Google ADC
<p>I'm trying to work on my home project where I contact Google services like Gmail, Sheets, Drive. Services that are not Google Cloud per se.</p> <p>I've implemented GmailApi quickstart guide for python, but when I try to run I've got error about:</p> <pre><code>Traceback (most recent call last): File &quot;c:\Users...
<python><google-cloud-platform><google-oauth><gcloud>
2025-08-20 13:05:00
0
451
Kacper
79,741,057
9,715,816
Django connection_created signal is causing problems when testing
<p>In my django application I have a list of notification types and I want to allow customers to subscribe to one or more notification types.</p> <p>Each notification type has somewhat of a custom logic so the code of each notification has to be in a different class but I have created a singleton class that gathers all...
<python><django><django-signals><pytest-django>
2025-08-20 12:15:26
1
2,019
Charalamm
79,740,944
5,722,359
How to fix Gtk.FileChooserDialogue height and resizing issues?
<p>I am experiencing a strange phenomenon with the <code>Gtk.FileChooserDialogue</code> widget (Gtk3).</p> <ol> <li><p>I can't get it to appear at the correct height. Output state height is 500px but its height is definitely much larger. Screen height is 1080px. This widget is almost reaching to the bottom of screen.</...
<python><gtk><gtk3>
2025-08-20 10:19:36
1
8,499
Sun Bear
79,740,866
9,072,753
How to type annotate a "unique" function?
<p>I want to make a small alias for <code>sorted(list(set(...)))</code>. I do:</p> <pre><code>from typing import Iterable, TypeVar H = TypeVar(&quot;H&quot;) def unique(x: Iterable[H]) -&gt; list[H]: return sorted(list(set(x))) unique(a for a in [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]) </code></pre> <p>but...
<python><python-typing><mypy>
2025-08-20 09:09:38
0
145,478
KamilCuk
79,740,816
270,043
Faster way to filter for matching records between 2 PySpark dataframes
<p>I'm trying to write a PySpark program that filters for records in a very large dataframe (700M to 1B records) that matches some conditions on another smaller reference dataframe (450K records). This is done using a left join between the 2 dataframes, and then writing the results to a parquet file. However, I'm facin...
<python><dataframe><pyspark>
2025-08-20 08:27:57
0
15,187
Rayne
79,740,656
1,581,090
How to fix pyenv on windows 11?
<p>On windows 11 I use pyenv to be able to select a specific python version. I want to select python 3.11.9, and the output of</p> <pre><code>pyenv versions </code></pre> <p>is:</p> <pre><code> 3.10.11 3.11.8 * 3.11.9 (set by C:\Users\WORK\.pyenv\pyenv-win\version) </code></pre> <p>However, the installed python vers...
<python><windows-11><pyenv>
2025-08-20 05:40:06
1
45,023
Alex
79,740,643
11,082,866
Why does MQTT subscription adds a lag in data streaming after using clean session
<p>I have an RFID reader which is connected to my code via MQTT. I want to design the system in such a way that the user should have a Start API and a Stop API and an API which receives the data and transform it to make data readable.</p> <p>Now the reader keeps on sending the data to a topic but my code connects and s...
<python><mqtt>
2025-08-20 05:20:44
0
2,506
Rahul Sharma
79,740,626
13,352,657
How to generate a typed Python SDK for a GraphQL API
<p>I'm trying to set up a nice Python client for a GraphQL API managed by a separate team (in a different language): We want to provide useful type hints + autocomplete without introducing overly onerous maintenance requirements for our Python layer.</p> <p>I saw that <code>gql</code> looks popular and <a href="https:/...
<python><graphql><ariadne-graphql>
2025-08-20 04:48:55
0
1,069
dingus
79,740,460
1,604,008
Trying to run selenium in linux but can't find driver
<pre><code>-rwxr-xr-x 1 kyle kyle 6132584 Feb 24 09:27 /usr/local/bin/geckodriver echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/kyle/.dotnet/tools </code></pre> <p>It is my understanding selenium should be able to find the driver automatically. That...
<python><selenium-webdriver><geckodriver><selenium4><seleniummanager>
2025-08-19 22:35:30
2
1,159
user1604008
79,740,439
894,827
Deploying a python web app on Azure the page isnt displaying
<p>I appreciate that this isn't a reproducable issue because of the fact that I cannot place the code in the public domain, I have a python app that I am trying to deploy on an Azure web app, I have followed the instructions on the readme page and changed a few things within the configuration settings of the app.</p> <...
<python><azure-web-app-service>
2025-08-19 22:02:22
0
1,099
learner
79,740,398
46,521
polars streaming: downsample & write parquet based on shift(-1)
<p>I'm trying to downsample a large parquet file with polars.</p> <p>Does polars support the following workflow in a streaming manner?</p> <p>As written, it uses &gt;60GB of RAM. It should be easy to achieve in O(1) memory:</p> <pre><code>import os ; os.environ['POLARS_MAX_THREADS'] = '4' import polars as pl import tim...
<python><dataframe><parquet><python-polars>
2025-08-19 20:54:34
1
6,651
tba
79,740,335
759,880
Python mutex.cc lock issue
<p>I have a python program that hangs in a library call on this message:</p> <pre><code>[mutex.cc : 452] RAW: Lock blocking 0x6000009e1158 @ </code></pre> <p>I started the program with <code>trace</code> to see what is going on, and I get (a lot of):</p> <pre><code>&lt;frozen importlib._bootstrap&gt;(668): &lt;frozen...
<python><python-3.x><mutex>
2025-08-19 19:36:03
0
4,483
ToBeOrNotToBe
79,740,174
524,368
How to unpack a buffer of 12-bit values into an array of normalized float32
<p>A measurement system (in our lab) produces data of 12 bits per sample in a packed format, i.e. 2 samples of 12 bits each are packed into 3 bytes:</p> <pre class="lang-none prettyprint-override"><code> buf[l + 2] | buf[l + 1] | buf[l + 0] 7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0 ---------------------...
<python><numpy><matlab><bit-manipulation><data-conversion>
2025-08-19 16:22:11
4
163,045
datenwolf
79,740,068
1,549,950
release-please not updating uv.lock when creating a new release
<p>We are using <code>uv</code> to manage our Python packages and <code>release-please</code> to create our releases. The workflow that creates the new releases in GitHub currently does not update the version of our package in <code>uv.lock</code>.</p> <p><code>release-please</code> currently updates the following file...
<python><github-actions><uv><release-please>
2025-08-19 14:36:00
1
8,360
Michael Lihs
79,740,047
8,595,891
uv dependency resolution error: "conflicting URLs for package" with pyproject.toml workspace and optional dependencies
<p>I am using <code>uv</code> to manage my dependency. My <code>pyproject.toml</code> looks like</p> <pre class="lang-toml prettyprint-override"><code>[project] name = &quot;project_1&quot; version = &quot;2.3.0&quot; description = &quot;My Project description.&quot; requires-python = &quot;&gt;=3.12&quot; dependencie...
<python><uv>
2025-08-19 14:24:00
0
1,362
Pranjal Doshi
79,739,849
4,423,458
Get the first non-null value for a key in multiple mappings/dictionaries
<p>I have an object which stores its internal attributes in a <code>TypedDict</code>. I am implementing a flyweight pattern by allowing subclasses to freeze values and/or define defaults at the class-level to save memory.</p> <pre class="lang-py prettyprint-override"><code>from typing import ClassVar, TypedDict class...
<python>
2025-08-19 11:39:34
1
642
Valentin Calomme
79,739,748
1,581,090
How to fix DpiAwarenessContext Qt error in the context of pytest on Windows 11?
<p>On Windows 11 I am trying to run pytest using Poetry and a very complex test setup, which uses Qt for some things. However, when running this complex test (which worked before, and seems to work for everyone else) I get an error:</p> <pre class="lang-none prettyprint-override"><code>qt.qpa.window: SetProcessDpiAware...
<python><windows><qt><pytest><python-poetry>
2025-08-19 09:58:00
1
45,023
Alex
79,739,660
2,836,175
How to correctly type hint a mapping (dict) with Literal keys?
<p>I want to type hint a dictionary (or equivalent object) that maps from a set of <code>Literal</code> choices to some outputs. I'm using <a href="https://google.github.io/pytype/" rel="nofollow noreferrer">pytype</a> as my type checker.</p> <p>The ideal behaviour would be something like:</p> <pre class="lang-py prett...
<python><python-typing><pytype>
2025-08-19 08:47:15
1
939
theo-brown
79,739,357
759,880
mutex.cc : 452 RAW: Lock blocking in HuggingFace/sententce-transformers
<p>I'm in python 3.11.13 with these versions:</p> <pre><code>huggingface-hub 0.31.4 transformers 4.52.4 sentence-transformers 5.1.0 </code></pre> <p>And this OS (Mac):</p> <pre><code>Darwin G9XFDK7K6J 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025; root:xn...
<python><python-3.x><huggingface-transformers><sentence-transformers>
2025-08-19 00:38:39
1
4,483
ToBeOrNotToBe
79,739,172
7,295,599
How to rotate a page by arbitrary angle in pymupdf?
<p>I couldn't find how to rotate a text page of a PDF by an arbitraty angle in the <a href="https://pymupdf.readthedocs.io/en/latest/" rel="nofollow noreferrer">pymupdf documentation</a>.</p> <p>There is <code>page.set_rotation(angle)</code>, however, which only allows for <code>0, 90, 180, 270</code> degrees, which is...
<python><pdf><rotation><pymupdf>
2025-08-18 19:37:09
3
27,030
theozh
79,739,170
1,779,973
PyCharm Debugger Stuck on "Collecting data..." When Debugging Pytest Unit Test
<p>I'm encountering a persistent issue with PyCharm when trying to debug a <code>pytest</code> unit test.</p> <p>Running the project normally and attaching the debugger works fine. Debugging regular scripts behaves as expected. But when I debug a <code>pytest</code> unit test:</p> <ul> <li>The debugger halts at the fir...
<python><unit-testing><debugging><pycharm><pytest>
2025-08-18 19:36:14
0
536
Ido
79,739,054
11,222,417
how to browse lines in vscode debug console?
<p>Suppose I execute a few lines in vscode python debug console</p> <pre><code>a = 1 b = 1 print(a + b) </code></pre> <p>Then I want to re-run this snippet, but to edit the second line to <code>b = 99</code>. To do this I click <kbd>up arrow</kbd> to display the previous snippet and the cursor is at the first snippet l...
<python><visual-studio-code><debug-console>
2025-08-18 17:07:07
0
305
J. Doe
79,738,840
10,911,376
Authenticating a user with NextCloud using oauth2 with authlib in flask fails at getting access token
<p>I am writing a flask app that authenticates users via oauth2 with a NextCloud instance (and later will use file synchronisation). From what I read this should be fairly straightforward. For example authlib describes how to create a oauth2 client with flask: <a href="https://docs.authlib.org/en/latest/client/index.ht...
<python><flask><oauth-2.0><nextcloud><authlib>
2025-08-18 14:04:44
1
696
Etienne Ott
79,738,668
3,732,793
Python package upgrade with uv behaves as in old version
<p>for an old project I have upgraded jsonschema. For a prototype project I have added jsonschema to check the new functionality with jsonschema Draft7Validators.</p> <pre><code>uv pip show jsonschema </code></pre> <p>shows in both cases the same version.</p> <p>Also</p> <pre><code>uv tree </code></pre> <p>shows the sa...
<python><jsonschema><uv>
2025-08-18 11:53:56
1
1,990
user3732793