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,221,822
3,296,786
Pytest - Test passes when ran individually but not all together using pytest -s
<p>this method</p> <pre><code>def test_clear(self): url = self._api(&quot;progress?_=123&amp;__=456&quot;) import time time.sleep(60) print(url) response_out = requests.get(url) response_out.raise_for_status() </code></pre> <p>fails when ran using <strong>pytest -s</strong> with error - HTTPEr...
<python><pytest>
2024-11-25 06:09:09
0
1,156
aΨVaN
79,221,807
874,380
How to share code in different Jupyter notebooks in subfolders?
<p>I need to create a Github repository where I can organize Jupyter notebooks by topic as tutorials. Some notebooks will require to load large(r) data files, which I don't want to be part of the repository themselves.</p> <p>My idea is to provide all data files in a different online resource, and download the required...
<python><jupyter-notebook><jupyter>
2024-11-25 06:05:51
2
3,423
Christian
79,221,718
16,525,263
How to check if specified file path exists using pyspark
<p>I have a 2 dictionaries as below</p> <pre class="lang-py prettyprint-override"><code>data_path = { &quot;person&quot;: &quot;/data/raw/person/*&quot;, &quot;location&quot;: &quot;/data/raw/location/*&quot;, &quot;person_int&quot;: &quot;/data/test/person_int/&quot;, ...
<python>
2024-11-25 05:19:56
1
434
user175025
79,221,652
24,758,287
How to find the last non-null value before the current row in Polars?
<p>I'd like to perform the following:</p> <p>Input:</p> <pre class="lang-py prettyprint-override"><code>import polars as pl df = pl.DataFrame({ &quot;a&quot;: [1,15,None,20,None] }) </code></pre> <p>Output:</p> <pre class="lang-py prettyprint-override"><code>expected = pl.from_repr(&quot;&quot;&quot; β”Œβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€...
<python><dataframe><null><python-polars><rolling-computation>
2024-11-25 04:28:19
1
301
user24758287
79,221,555
10,054,520
For reach row in dataframe, how to extract elements from an array?
<p>I'm working with a third party dataset that includes location data. I'm trying to extract the Longitude and Latitude coordinates from the location column. As stated in their doc:</p> <blockquote> <p>The <code>location</code> column is of the <code>point</code> datatype.</p> </blockquote> <p>When I ingest the data a...
<python><python-3.x><pandas><pyspark><pyspark-pandas>
2024-11-25 03:26:18
2
337
MyNameHere
79,221,525
7,887,965
Apache Nifi (ExecuteStreamCommand): Executable command python3 ended in an error:
<p>I am trying to run the following script in the <code>executestreamcommand</code> processor, which will read the data from <code>listfile</code> and <code>fetchfile</code> processor. Then I am trying to merge the content of Excel files in parquet format in the following script but giving the <code>python3 ended in an...
<python><apache-nifi>
2024-11-25 03:12:01
0
407
Filbadeha
79,221,167
7,917,771
blip2 type mismatch exception
<p>I'm trying to create an image captioning model using hugging face blip2 model on colab. My code was working fine till last week (Nov 8) but it gives me an exception now.</p> <p>To install packages I use the following command:</p> <pre><code>!pip install -q git+https://github.com/huggingface/peft.git transformers bit...
<python><artificial-intelligence><huggingface-transformers><large-language-model>
2024-11-24 22:05:23
2
571
Soroush Hosseinpour
79,220,947
4,451,315
Write DuckDB csv to Python string
<p>I have a DuckDBPyRelation and I'd like to get it as a csv</p> <p>For example, if I have</p> <pre><code>import polars as pl import duckdb data = pl.DataFrame({&quot;a&quot;: [1, 2, 3]}) rel = duckdb.sql('select * from data') </code></pre> <p>then I'd like to do something like</p> <pre><code>out = rel.to_csv() </code...
<python><duckdb>
2024-11-24 19:45:24
1
11,062
ignoring_gravity
79,220,838
21,395,742
Create a scaled molecule rdkit
<p>I am using RDKit in python to draw a molecule, and I want to get a high-definition image</p> <p>This is my current code</p> <pre><code>mol = Chem.MolFromSmiles(&quot;CCO&quot;) mol = Chem.AddHs(mol) img = Draw.MolToImage(mol) </code></pre> <p>I want it to be ~ 2000x1000 pixels</p> <p>I tried: <code>img = Draw.MolToI...
<python><chemistry><rdkit>
2024-11-24 18:51:25
2
845
hehe
79,220,668
561,243
Is it possible to teach TOML Kit how to dump an object?
<p>I am generating TOML files with several tables using TOML Kit without any problem in general.</p> <p>So far all the values were either strings or numbers, but today I first bumped into a problem. I was trying to dump a <code>pathlib.Path</code> object and it fails with a ConvertError <code>Unable to convert an objec...
<python><toml><tomlkit>
2024-11-24 17:11:00
1
367
toto
79,220,660
4,752,738
Possible fields values to depend on other values
<p>I have those 3 fields: event, category, subcategory Depending on the name I allow different categories and depending on the category I allow different subcategories. Example:</p> <ul> <li>If name is &quot;foo&quot; then category can be &quot;foo_1&quot; or &quot;foo_2&quot;.</li> <li>If category is foo_1 then subcat...
<python><fastapi><pydantic>
2024-11-24 17:05:49
1
943
idan ahal
79,220,412
12,520,740
Fresh install of pythonpy gives SyntaxWarnings
<p>I just freshly installed <code>pythonpy</code>. However, the package gives <code>SyntaxWarning</code>s during installation:</p> <pre class="lang-bash prettyprint-override"><code>$ sudo apt install pythonpy [sudo] password for melvio: Reading package lists... Done Building dependency tree... Done Reading state infor...
<python><apt><python-py>
2024-11-24 15:20:39
1
1,156
melvio
79,220,232
8,185,618
Mediapipe gives different results in two cases image file path and numpy array input
<p>As you may know, <strong>Mediapipe</strong> provides landmark locations based on the <strong>aligned output image</strong> rather than the <strong>input image</strong>.</p> <p><strong>Objective</strong>: I intend to perform <strong>landmark detection</strong> on multiple images. Below, I’ve included code that uses <...
<python><numpy><opencv><mediapipe>
2024-11-24 13:59:43
1
978
BarzanHayati
79,219,875
1,613,983
How to perform forward-fill along 0th dimension of N-D tensor in Tensorflow
<p>For example, take the following tensor:</p> <pre><code>tf.constant([ [0, np.nan, 2, 1], [np.nan, 3, 3, 4], ]) </code></pre> <p>I'd like to implement a forward-fill operation like <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.ffill.html" rel="nofollow noreferrer"><code>pd.DataFr...
<python><tensorflow>
2024-11-24 10:44:48
0
23,470
quant
79,219,823
4,710,828
'n' vs 's' command for Python debugger (pdb)
<p>I'm new to <code>pdb</code> and trying to learn. There is one thing that's bugging me a lot. Lot of examples that I read on blogs mention a code like this below:</p> <pre class="lang-py prettyprint-override"><code>import pdb def buggy_function(x): result = 0 for i in range(x): result += i / (i - 4) ...
<python><pdb>
2024-11-24 10:11:18
0
373
sdawar
79,219,726
4,054,314
Problem in passing dictionaries from one notebook to another in Pyspark
<p>I am new to PySpark. My current project requirement is to do ETL in Databricks. I have a CSV file which has almost 300 million rows, and this is only one such source. There will be 2 more data sources. Below will be my approach to solve it:</p> <p>Step1 : Create Abstract class and method to read data from various so...
<python><apache-spark><pyspark><apache-spark-sql><databricks>
2024-11-24 09:11:37
1
1,304
sam
79,219,651
7,972,317
reserve space for a legend in pyplot while fixing plot size and x-axis position
<p>here are two of my plotting functions and example use:</p> <pre><code>import matplotlib.pyplot as plt def set_legend(ax, item_count, title=None): legend = ax.legend( title=title, loc='upper center', bbox_to_anchor=(0.5, -0.1), ncol=item_count, frameon=False, prop=...
<python><matplotlib><plot><visualization>
2024-11-24 08:27:27
1
1,391
Moran Reznik
79,219,592
4,755,229
How to properly convert between types in Cython?
<p>I have a function which looks like</p> <pre class="lang-py prettyprint-override"><code>cdef double __test_func(double x, double y, double z): return (x-y)/((2*x-y)*y)**(0.5*z) def test_func(x, y, z): return __test_func(&lt;double&gt;x, &lt;double&gt;y, &lt;double&gt;z) </code></pre> <p>What I want to do is t...
<python><types><double><cython><floating>
2024-11-24 07:44:45
0
498
Hojin Cho
79,219,382
6,042,172
How to keep only some fields in json of list of json?
<p>I have this data structure:</p> <pre><code>[ { 'field_a': 8, 'field_b': 9, 'field_c': 'word_a', 'field_d': True, 'children': [ { 'field_a': 9, 'field_b': 9, 'f...
<python><json><hierarchy>
2024-11-24 05:34:53
2
908
glezo
79,219,193
229,075
Is duckdb table persisted
<p>I have a huge parquet file. I only want to explore a specific sunset of it. That is hundreds of rows out a hundred of million rows.</p> <p>So I do this to create a temporary table <code>vloc1</code></p> <pre><code>CREATE OR REPLACE TABLE vloc1 AS FROM '.data/muni_vloc_202101.parquet' WHERE vid=5773 </code></pre> <p>...
<python><duckdb>
2024-11-24 01:57:47
0
18,924
Wai Yip Tung
79,219,190
7,034,613
Twilio inbound call recording - keeps calling "incoming-call" and "recording-callback"
<p>I'm trying to use the official <a href="https://github.com/twilio-samples/speech-assistant-openai-realtime-api-python" rel="nofollow noreferrer">Twilio &lt;&gt; OpenAI realtime API tutorial</a> for realtime LLM-based agents.</p> <p>Now, when trying to introduce call recording to be able to analyze the code afterward...
<python><twilio><openai-api>
2024-11-24 01:57:19
0
2,519
DsCpp
79,219,163
6,312,979
Polars Read Excel file from Form (ie. request.FILES.get('file'))
<p>All the Polars examples show reading an Excel file from a path string.</p> <pre><code>df = pl.read_excel(&quot;docs/assets/data/path.xlsx&quot;) </code></pre> <p>But I am passing in the Excel file from a Django Form Post.</p> <pre><code>file_name = request.FILES.get('file') df = pl.read_excel(file_name) </code></pr...
<python><django><excel><dataframe><python-polars>
2024-11-24 01:27:07
1
2,181
diogenes
79,219,137
6,843,153
VSC debugger fails to import my own project modules in a Dev Container even when the script can be run from VSC terminal
<p>I have a python project in Ubuntu 24.04.1 LTS and I have a DevContainer in VSC with Debian GNU/Linux 11, and If I run the application from the terminal with <code>streamlit run myfile.py</code>, it runs perfectly, but launching the debugger raises this exception:</p> <pre><code>/usr/bin/python3: No module named stre...
<python><visual-studio-code><streamlit><vscode-debugger>
2024-11-24 00:51:19
0
5,505
HuLu ViCa
79,219,125
13,279,557
How can I let a shared library, called by Python, access the same Python instance's globals?
<p>So I've created this <code>main.py</code>:</p> <pre class="lang-py prettyprint-override"><code>#!/usr/bin/python3 import ctypes foo = 1 # Should print 2, but prints 1 def print_foo(): global foo print(foo) def main(): global foo foo = 2 dll = ctypes.PyDLL(&quot;./foo.so&quot;) foo = ...
<python><shared-libraries><ctypes>
2024-11-24 00:39:12
1
672
MyNameIsTrez
79,219,057
1,613,983
How to efficiently represent a matrix product with repeated elements
<p>I have a tensor <code>a</code> that is of shape <code>(n/f, c, c)</code> that I want to multiply by another tensor <code>b</code> of shape <code>(n, c, 1)</code>. Each row of <code>a</code> represents <code>f</code> rows of <code>b</code>, such that the naiive way of implementing this would be to simply repeat each ...
<python><tensorflow>
2024-11-23 23:37:22
1
23,470
quant
79,219,035
913,098
How to hide webapi url and show a "pretty" url?
<p>I need to generate a pretty URL for my own URL shortening service.<br /> My web server address looks something like <code>https://my-backend-api-server.us-central1.run.app/redirectapp/redirect/wAzclnp3</code></p> <p>and I wouldn't want to expose that, nor is it short.</p> <p>Assuming I have a domain <code>www.mydoma...
<javascript><python><django><dns><friendly-url>
2024-11-23 23:25:06
1
28,697
Gulzar
79,218,827
65,659
What does a trailing slash mean when reading Python function documentation?
<p>I'm reading the Python documentation in order to become familiar with the enormous library of functions and modules available. A few times I've seen a trailing slash in the parameter list, such as <a href="https://docs.python.org/3/library/stdtypes.html#str.removeprefix" rel="nofollow noreferrer">this</a>:</p> <pre>...
<python>
2024-11-23 21:02:42
0
4,968
Chuck
79,218,768
1,833,028
Why do I need to execute a getch() before ncurses will display anything?
<p>I have an curses application with a getch() loop.</p> <p>I found that the application would only display after accepting user input. In other words, I could not draw anything to the terminal before accepting user input; I had to do it after. This code fixes it:</p> <pre><code>stdscr.nodelay(True) while stdscr.getc...
<python><curses><python-curses>
2024-11-23 20:26:48
0
963
user1833028
79,218,764
11,550,339
CrewAI SeleniumScrapingTool canΒ΄t initialize the Chrome Driver inside Docker container
<p>I have a docker image as follows:</p> <pre><code>FROM python:3.12-slim WORKDIR /usr/src/app COPY ./requirements.txt ./ RUN pip install --no-cache-dir --upgrade -r ./requirements.txt COPY ./app ./ ENV ENVIRONMENT prod ENV PORT 3000 EXPOSE 3000 CMD [&quot;fastapi&quot;, &quot;run&quot;, &quot;main.py&quot;, &quot;--po...
<python><docker><selenium-chromedriver><crewai>
2024-11-23 20:26:17
0
535
Matheus Carvalho
79,218,748
561,243
peewee: cannot find reference db_url
<p>I am playing with <a href="https://docs.peewee-orm.com/en/latest/index.html" rel="nofollow noreferrer">peewee</a> for my next project involving a database.</p> <p>My first impression is rather good because it offers a good ORM and at the same time is not as big as SQLAlchemy.</p> <p>Nevertheless I have a question fo...
<python><pycharm><peewee>
2024-11-23 20:13:22
0
367
toto
79,218,720
12,415,855
Clicking on expand button using Selenium not possible?
<p>i try to click the &quot;Expand All&quot; Button <a href="https://i.sstatic.net/fzTSZbz6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fzTSZbz6.png" alt="button" /></a></p> <p>using the following code:</p> <pre><code>import time import os, sys from bs4 import BeautifulSoup from selenium import webdr...
<python><selenium-webdriver>
2024-11-23 20:01:05
2
1,515
Rapid1898
79,218,567
7,886,968
keyboard_trigger = Event() returns "NameError: name 'Event' is not defined"
<p>I am trying to write a simple &quot;Object avoidance&quot; program for my robot.</p> <p>The initial version works, but when I try to exit with a Ctrl-C, the <em>program</em> halts but the <em>robot</em> keeps moving until I physically turn it off.</p> <p>I'm trying to use a trick that was used in a different program...
<python><event-handling>
2024-11-23 18:39:22
1
643
Jim JR Harris
79,218,490
12,466,687
Problem with recognizing single-cell tables in pdfplumber
<p>I have sample medical report and on <strong>top of each page</strong> in pdf there is a <strong>table</strong> that contains personal information.</p> <p>I have been trying to <strong>remove/crop</strong> the personal information <strong>table</strong> from that sample <strong><a href="https://github.com/johnsnow09/...
<python><pdfplumber>
2024-11-23 17:51:38
1
2,357
ViSa
79,218,262
202,807
Filter pandas DataFrame by multiple thresholds defined in a dictionary
<p>I want to filter a DataFrame against multiple thresholds, based on the ID's prefix.</p> <p>Ideally I'd configure these thresholds with a dictionary e.g.</p> <pre class="lang-py prettyprint-override"><code>minimum_thresholds = { 'alpha': 3, 'beta' : 5, 'gamma': 7, 'default': 4 } </code></pre> <p>For e...
<python><pandas>
2024-11-23 15:52:47
2
409
Chris
79,218,166
13,259,162
Determine in which cluster goes a new element with scipy linkage
<p>I have the following program where <code>data</code> is a <code>pandas.DataFrame</code>:</p> <pre class="lang-py prettyprint-override"><code>from scipy.cluster.hierarchy import linkage Z = linkage(data, method='ward', metric='euclidean') clusters = fcluster(Z, 2, criterion='maxclust') </code></pre> <p>Now, consider...
<python><pandas><scipy>
2024-11-23 15:17:08
0
309
NoΓ© Mastrorillo
79,218,073
2,414,934
Sympy - return Real solution
<p>I'm using the GeoSolver package to solve 3D constraints.<a href="https://pypi.org/project/GeoSolver/" rel="nofollow noreferrer">link to GeoSolver - PyPI</a>. When I solve a parallel constraint I get a complex solution while a Real solution exist. Is it possible to get only the Real solution?</p> <p>code:</p> <pre><c...
<python><sympy>
2024-11-23 14:43:40
2
673
Achaibou Karim
79,217,960
17,487,457
Plotting cumulative distribution from data
<p>I have a large data to plot the <code>ECDF</code> but got confused, so I decided using small data subset, which still didn't make sentence to me (as complete to what I read from the source).</p> <p>For that, I produced a synthetic <code>MWE</code> to replicate the problem. Say I have the following <code>df</code>:</...
<python><pandas><matplotlib><cdf><ecdf>
2024-11-23 13:52:54
1
305
Amina Umar
79,217,872
15,946,347
SQL {ADD PRIMARY KEY} Error via python/sqlite3 with {c.execute("ALTER TABLE
<p>Could anyone please help meπŸ™πŸΎ resolve below error from Python code on Google Colab while executing an SQL query:</p> <pre><code>import sqlite3 conn=sqlite3.connection(':memory:') c=conn.cursor() c.execute(&quot;ALTER TABLE Persons ADD PRIMARY KEY (ID)&quot;) </code></pre> <h2>ERROR</h2> <p>OperationalError ...
<python><sql><sqlite><memory>
2024-11-23 12:51:32
1
341
Jay eMineM
79,217,778
893,254
How to list all files and folders of a file or directory target in Python?
<h1>Function Description</h1> <p>I am trying to write a function which takes an input <code>target</code> which is a target to a path on the filesystem. It could be a directory itself, or it could be a file.</p> <p>This function should return a list of all files and folders which are sub-targets below <code>target</cod...
<python>
2024-11-23 11:59:33
4
18,579
user2138149
79,217,608
4,499,832
Python 3.12.7 module ssl has no attribute wrap_socket
<p>Here is a sample of a python script:</p> <pre><code>import mysql.connector ... mydb = mysql.connector.connect( host=&quot;localhost&quot;, user=&quot;root&quot;, passwd=&quot;********&quot;, database=&quot;mydatabase&quot;, auth_plugin='mysql_native_password' ) mycursor = mydb.cursor() </code></...
<python>
2024-11-23 10:18:55
1
811
klaus
79,217,488
7,797,146
XLA PJRT plugin on Mac reveals only 4 CPUs
<p>On my MacOS M3, I have compiled the pjrt_c_api_cpu_plugin.so and I'm using it with JAX.</p> <p>My Macbook has 12 CPUs but with a simple python script &quot;jax.devices()&quot; the pjrt plugin reveals just 4 cpus.</p> <p>Can you tell me why ?</p>
<python><jax><xla>
2024-11-23 09:06:40
0
304
lordav
79,217,350
7,643,771
How to compute disk I/O usage percentage in Windows, exactly like Task Manager, for the current process?
<p>I'm trying to compute the disk I/O usage percentage for the current process in Windows, similar to what the Task Manager displays under the &quot;Disk&quot; column. However, I haven't been able to get an accurate match.</p> <p>I used psutil.Process.io_counters() to retrieve the read/write byte counts for the current...
<python><io><taskmanager><yara>
2024-11-23 07:25:22
1
678
Pedram
79,217,331
3,875,610
Function to convert a pandas dataframe into JSON
<p>I have a pandas dataframe that I want to convert to JSON in the required format. The JSON is basically a tree structure of the dataframe.</p> <p><strong>Input:</strong></p> <pre><code>Total Resolution Category Escalated Count Total Tickets False IT False 4 Total Tickets False...
<python><json>
2024-11-23 07:09:54
0
1,829
Anubhav Dikshit
79,216,981
317,563
expect: make two python scripts communicate
<p>I want to have two scripts communicating by exchanging messages. I have to use pexpect because of other restrictions. I am trying to make a minimal working example before I build it out for my application.</p> <p>I have tried to do a minimal working example by following the tutorials I could find on the internet. Bu...
<python><automation><expect><pexpect>
2024-11-23 01:47:38
2
911
Mikkel Rev
79,216,975
1,680,980
how to uninstall specific opencv
<p>I am getting an error on running <code>cv2.imshow()</code></p> <pre><code>cv2.imshow(&quot;Image&quot;, image) </code></pre> <pre><code>cv2.error: OpenCV(4.9.0) /io/opencv/modules/highgui/src/window.cpp:1272: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or...
<python><opencv><pip><apt>
2024-11-23 01:45:12
2
624
Stephen
79,216,878
2,603,579
Is Tkinter's askopenfilename safe?
<p>I'm developing an app with Tkinter as the UI. Currently, I'm using <code>tkinter.filedialog</code>'s <code>askopenfilename</code> function to let a user choose a file.</p> <p>I then create a hidden file for [redacted] purposes with the same filename. As a result, I need to use <code>subprocess</code> which I've read...
<python><tkinter>
2024-11-22 23:57:12
0
402
Ryan Farber
79,216,489
2,039,866
easyocr readtext ends with illegal instruction exception
<p>I'm trying to process a very clear image with python's easyocr package.</p> <p>This is my image: <a href="https://photos.app.goo.gl/eiPTPqnZtJ3h9rXu9" rel="nofollow noreferrer">phonenum.png</a></p> <p>Here is my code:</p> <pre><code>import easyocr reader = easyocr.Reader(['en']) result = reader.readtext('images/pho...
<python><easyocr>
2024-11-22 20:31:32
0
770
Charles Knell
79,216,349
6,574,178
How can getattr() respect python class properties?
<p>I have a class that performs some useful job in my project</p> <pre><code>class Test: def __init__(self): self.__value = None def set_value(self, value): print(f&quot;set_value(): value={value}&quot;) self.__value = value def get_value(self): print(f&quot;get_value()&quo...
<python><decorator><python-decorators>
2024-11-22 19:29:00
2
905
Oleksandr Masliuchenko
79,216,296
11,870,534
How to pickle a class instance with persistent methods in Python?
<p>I want to serialize a class instance in python and keep methods persistent. I have tried with joblib and pickle and am really close with dill, but can't quite get it.</p> <p>Here is the problem. Say I want to pickle a class instance like so:</p> <pre class="lang-py prettyprint-override"><code>import dill class Test...
<python><python-3.x><pickle><dill>
2024-11-22 19:06:40
2
620
thehumaneraser
79,216,188
5,080,858
pytest-recording / VCR for S3: IncompleteReadError (but only sometimes?)
<p>Looking to use <code>pytest-recording</code> in my tests that involve connecting to and downloading data from S3.</p> <p>I import all the functions from the script I'm testing. This is using prod env vars, but only to test downloading and reading data from S3 (not uploading). In a REPL, the exact same code works fin...
<python><amazon-s3><testing><pytest><vcr>
2024-11-22 18:28:22
0
679
nikUoM
79,216,008
30,997
Python FlickrAPI throwing exception on construction: "sqlite3.OperationalError: no such table: oauthtokens"
<p>There's nothing in the installation documentation about installing sqlite3, but if it's a dependency, it will have installed as part of the pip install process. I've manually installed sqlite3 so I have a command-line client I can poke at, but had no expectation that adding it would change anything.</p> <p>I have ve...
<python><python-3.x><flickr>
2024-11-22 17:28:32
0
11,862
Sniggerfardimungus
79,215,877
392,687
Trying to automate using pyautogui and docker firefox, but can't stick to the constraints of the display
<p>I'm using an M1 MacBook Pro with docker desktop. So this is a Retina display.</p> <p>I've deployed the jlesage/firefox image in the following way:</p> <pre><code>docker run -d \ --name firefox \ -p 5800:5800 \ -p 5900:5900 \ -e DISPLAY_WIDTH=1024 \ -e DISPLAY_HEIGHT=768 \ -e DISPLAY=:0 \ ...
<python><docker><pyautogui>
2024-11-22 16:48:32
0
1,005
vwdewaal
79,215,872
6,170,340
Jupyter Notebook & Lab won't startafter anaconda's successful installation
<p>It is around one year that some of my students got issues with Anaconda Jupyter lab/notebook; they all got similar errors, as below:</p> <pre><code>[I 2024-11-22 06:01:59.231 ServerApp] Extension package aext_assistant took 0.3674s to import [I 2024-11-22 06:01:59.263 ServerApp] **** ENVIRONMENT Environment.PRODUCTI...
<python><jupyter-notebook><anaconda><jupyter-lab><anaconda3>
2024-11-22 16:47:40
0
419
B nM
79,215,796
536,262
Chrome Selenium show file downloaded but I can't find it or click the file in download panel
<p>Browser act as file is downloaded, I can see the file in the panel, but I can't open folder or click on the link in the panel, nor find the file in its designated downloadpath or anywhere else. Worked fine with chrome v121.</p> <p>test outputs: <code>20241122162434|ERROR|downloadpath:C:\dist\work\remote-eseal-fullst...
<python><selenium-webdriver><selenium-chromedriver><google-chrome-devtools>
2024-11-22 16:23:49
0
3,731
MortenB
79,215,742
2,155,362
How can I declare a string NumPy array?
<p>Below is my code:</p> <pre><code>import numpy as np row_length = 5 col_length = 3 x = np.empty([row_length,col_length],dtype=str) x[1,2]='ddd' print(x) </code></pre> <p>and the result is:</p> <pre><code>[['' '' ''] ['' '' 'd'] ['' '' ''] ['' '' ''] ['' '' '']] </code></pre> <p>why? The result I expected is:</p...
<python><numpy>
2024-11-22 16:05:57
1
1,713
user2155362
79,215,657
8,792,159
Why is joblib's Parallel delayed faster than dasks map block and compute()
<p>This question is possibly related to <a href="https://stackoverflow.com/questions/79206947/how-to-apply-a-function-to-each-2d-slice-of-a-4d-numpy-array-in-parallel-with-da?noredirect=1#comment139675265_79206947">this one</a>. I have 4D numpy array and would like to apply a function to each 2D slice across the first ...
<python><numpy><parallel-processing><dask><joblib>
2024-11-22 15:39:31
0
1,317
Johannes Wiesner
79,215,556
7,009,666
Pydantic throwing pydantic.errors.PydanticSchemaGenerationError all of a sudden
<p>I have a package (<code>llama_index</code>) in my project which uses a bunch of pydantic classes. I have been using this dependency without any issues for a couple days. Now today, all of a sudden, I try to run one of my scripts, and it throws an error when trying to import</p> <pre><code>from llama_index.core.schem...
<python><python-3.x><pydantic><llama-index>
2024-11-22 15:13:30
0
653
Steve Ahlswede
79,215,377
1,745,291
How to connect to same in-memory sqlite database instance, with both sync and async sessions with sqlalchemy?
<p>Is it possible (and if so, how ?) with sqlalchemy to have an instance of <code>AsyncEngine</code> and one of <code>Engine</code> pointing to the same <strong>in-memory</strong> sqlite database ?</p> <p>I know it is possible with file databases, and I also know the default behavior when creating such engines when wor...
<python><sqlite><sqlalchemy><in-memory>
2024-11-22 14:18:33
0
3,937
hl037_
79,214,996
1,581,090
How can I get the link/reference of a "Requirement" and "Testrail: Cases" from a Jira entry via the Python API?
<p>When using JIRA with TestRail and Confluence, you can link a Requirement to a ticket and you can link a TestRail Test Case to a Jira ticket. For example:</p> <p><a href="https://i.sstatic.net/XWgvJKsc.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/XWgvJKsc.png" alt="Enter image description here" /></...
<python><jira>
2024-11-22 12:17:17
4
45,023
Alex
79,214,906
774,575
How to solve 'cannot install both pin-1-1 and pin-1-1'?
<p>While installing <a href="https://anaconda.org/conda-forge/vispy" rel="nofollow noreferrer">VisPy</a> in a miniconda environment:</p> <pre><code>&gt; conda install vispy Channels: - conda-forge - defaults Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: \ warning libmamba P...
<python><conda><miniconda><vispy>
2024-11-22 11:55:00
1
7,768
mins
79,214,876
11,751,799
Locking `matplotlib` x-axis range and then plotting on top of it
<p>I can do the following in base <code>R</code> plotting.</p> <pre class="lang-r prettyprint-override"><code>x1 &lt;- c(3, 4) y1 &lt;- c(5, 8) x2 &lt;- c(2, 5) y2 &lt;- c(5, 7) plot(x1, y1, type = 'l') lines(x2, y2, col = 'red') </code></pre> <p><a href="https://i.sstatic.net/53OTqUiH.png" rel="nofollow noreferrer"><i...
<python><matplotlib><plot>
2024-11-22 11:47:17
2
500
Dave
79,214,751
6,356,565
unnecessary axis over all subplots numbered from 0 to 1
<p><a href="https://i.sstatic.net/yr2xv8p0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/yr2xv8p0.png" alt="enter image description here" /></a>I came up with this strange axis around all subplots I've plotted, which is numbered from 0 to 1. I tried simplifying the code e.g. removing plotting through t...
<python><matplotlib>
2024-11-22 11:08:24
0
511
Behnam
79,214,362
8,176,731
Azure Functions: Microsoft.Azure.WebJobs.Script: WorkerConfig for runtime: python not found
<p>I have Azure function app which is deployed via pipeline in Azure DevOps. Deployment completes without any issues, but when I navigate to my app in Azure portal, on Overview page I get error message <code>Microsoft.Azure.WebJobs.Script: WorkerConfig for runtime: python not found.</code> Runtime version displays Erro...
<python><azure><azure-devops><azure-functions>
2024-11-22 09:25:10
1
393
Kilipukki
79,214,347
9,400,502
I can not get an animation in jupyter notebook
<p>When I run the code below in VSC or directly run a script via the command line in linux, I get the sought animation. Since I have done most part of the work in jupyter notebook, which I am running locally (not google colab), I want to get the animation in the jupyter notebook which unfortunately is not providing the...
<python><jupyter-notebook>
2024-11-22 09:20:56
0
569
user249018
79,214,094
11,460,896
How to Optimize Preprocessing and Post-Processing in DETR-Based Object Detection?
<h3>My Question:</h3> <p>How can I reduce the time spent on preprocessing and post-processing?</p> <h3>Background Information</h3> <p>I'm implementing object detection on video frames using <a href="https://github.com/facebookresearch/detr" rel="nofollow noreferrer">DETR</a>. My system processes frames from a 30 FPS, 3...
<python><deep-learning><pytorch><computer-vision><huggingface-transformers>
2024-11-22 07:53:34
0
307
birdalugur
79,213,940
991,234
Reading data from a CSV file does not give me the correct output
<p>I am trying to read some records from a CSV file. There are some characters prepended to the first records file column data.</p> <p>Python code:</p> <pre><code>import csv with open('test.csv','r') as csvfile: spamreader = csv.reader(csvfile) for row in spamreader: print(row) </code></pre> <p>CSV file...
<python>
2024-11-22 06:55:05
0
2,295
Joshua
79,213,910
988,279
How to compare two dicts with deepdiff and modify dict in place?
<p>I've a list of two dicts and compare it with deepdiff. How can I modify/overwrite the values in the dict1 with the modified values of the dict2 &quot;in-place&quot;?</p> <pre><code>import deepdiff dict_1 = [{&quot;id&quot;: &quot;first&quot;, &quot;name&quot;: &quot;first&quot;}, {&quot;id&quot;: &quot;second&quot...
<python>
2024-11-22 06:47:23
1
522
saromba
79,213,043
876,201
Installing Intel TBB on Mac OS Big Sur
<p>Due to certain dependencies, we are restricted to Mac OS Big Sur for the moment. We are trying to install <code>Intel tbb</code> via Homebrew with <code>brew install tbb</code> but failing with the following error. Based on the error message, it appeared to us Homebrew is trying to install <code>Python 3.13.0</code>...
<python><tkinter><homebrew><tbb>
2024-11-21 21:58:31
0
350
mskb
79,212,904
850,781
Why is tz-naive Timestamp converted to integer while tz-aware is kept as Timestamp?
<p><strong>Understandable and expected</strong> (tz-aware):</p> <pre><code>import datetime import numpy as np import pandas as pd aware = pd.DatetimeIndex([&quot;2024-11-21&quot;, &quot;2024-11-21 12:00&quot;], tz=&quot;UTC&quot;) eod = datetime.datetime.combine(aware[-1].date(), datetime.time.max, aware.tz) aware, eo...
<python><pandas><numpy><datetime><timezone>
2024-11-21 20:51:27
1
60,468
sds
79,212,853
1,033,217
SWIG Hello World; ImportError: dynamic module does not define module export function
<p>This is supposed to be the absolute minimum Hello World using SWIG, C, and setuptools. But the following exception is raised when the module is imported:</p> <pre class="lang-none prettyprint-override"><code>&gt;&gt;&gt; import hello Traceback (most recent call last): File &quot;&lt;python-input-0&gt;&quot;, line ...
<python><c><setuptools><swig>
2024-11-21 20:29:34
1
795
Utkonos
79,212,852
5,056,387
Constraint to forbid NaN in postgres numeric columns using Django ORM
<p>Postgresql allows <code>NaN</code> values in numeric columns <a href="https://www.postgresql.org/docs/current/datatype-numeric.html" rel="nofollow noreferrer">according to its documentation here.</a></p> <p>When defining Postgres tables using <code>Django ORM</code>, a <code>DecimalField</code> is translated to <cod...
<python><django><postgresql><orm>
2024-11-21 20:28:55
2
722
szamani20
79,212,797
4,588,188
DRF serializer missing fields after validation
<p>I have a simple DRF serializer:</p> <pre><code>class CustomerFeatureSerializer(serializers.Serializer): &quot;&quot;&quot; Serializer for a customer feature. &quot;&quot;&quot; feature_id = serializers.CharField() feature_value = serializers.SerializerMethodField() feature_type = serializers...
<python><django><serialization><django-rest-framework>
2024-11-21 20:08:17
0
618
AJwr
79,212,751
19,318,120
Celery rabbitmq, multiple consumers consuming the same task
<p>as the title says, I have rabbitmq on a server and 6 machines connected to it with celery on them</p> <p>machine 1: [2024-11-21 19:15:12,181: INFO/MainProcess] Task tasks.task_name[ef00cc1f-1be5-44ba-8911-90c0746196ba] received</p> <p>machine 2: [2024-11-21 19:04:29,949: INFO/MainProcess] Task tasks.task_name[ef00cc...
<python><rabbitmq><celery>
2024-11-21 19:55:00
0
484
mohamed naser
79,212,641
1,306,892
"ValueError: unsupported format character 'I' (0x49) at index 34" in Python LaTeX generation
<p>I’m trying to generate a LaTeX document using Python. Here’s my code:</p> <pre class="lang-py prettyprint-override"><code>import sympy as sp import numpy as np import random import matplotlib.pyplot as plt import string latex_document = &quot;&quot; for counter in range(1, 301): # Random parameters fo...
<python>
2024-11-21 19:17:56
1
1,801
Mark
79,212,561
16,611,809
Equivalent to pandas.to_csv() without filename for polars?
<p>Is there an equivalent of casting a Polars DataFrame to a string like for a Pandas DataFrame using <code>pandasdf.to_csv()</code> without an file path (&quot;If None, the result is returned as a string.&quot;)?</p> <p>Similar to this question (<a href="https://stackoverflow.com/questions/77238309/how-can-i-cast-a-po...
<python><python-polars><py-shiny>
2024-11-21 18:46:12
1
627
gernophil
79,212,507
16,611,809
Is there an ui.update_input_file and ui.update_download_button in Shiny for Python?
<p>I have a Shiny for Python app that uses <code>ui.input_file()</code> and <code>ui.download_button()</code>. For most of the UI Inputs there exists a corresponding <code>ui.update_...()</code> with that you can activate/deactivate a button (<code>ui.update_action_button(id=&quot;some_id&quot;, disabled=False)</code> ...
<python><py-shiny>
2024-11-21 18:26:53
1
627
gernophil
79,212,385
670,338
Basemap nightshade() on Robinson Projection and lon_0=-180
<p>I'm attempting to plot day/night shading on a Robinson projection centered at -180 degrees with Basemap, and as you can see, the shading doesn't look right. I'm also getting a warning about a non-monotonically increasing x coordinate. Maybe there's some way of using shiftgrid to fix the nightshade? Any suggestions w...
<python><matplotlib><matplotlib-basemap><map-projections>
2024-11-21 17:44:04
0
914
GPSmaster
79,212,376
3,486,684
How can I change the selections presented by an Altair chart based on filtering performed by another selection?
<p>Consider the following example:</p> <pre class="lang-py prettyprint-override"><code>import sys import polars as pl import altair as alt import numpy as np # ============================================ # Creating the dummy data dataframe channels = pl.DataFrame(pl.Series(&quot;channel&quot;, [&quot;a&quot;, &quot...
<python><altair>
2024-11-21 17:41:28
0
4,654
bzm3r
79,212,366
1,435,803
Read same file from src and test in PyCharm
<p>Where do I put a resource file so that it can be accessed from both <code>src</code> and <code>test</code> in PyCharm?</p> <p>I've got a PyCharm project structured like this:</p> <pre><code>src scrabble board.py words.txt test scrabble test_board.py </code></pre> <p><code>board.py</code> contains thi...
<python><pycharm><pytest>
2024-11-21 17:39:41
2
462
Peter Drake
79,212,165
4,118,462
How does Pandas.Series.nbytes work for strings? Results don't seem to match expectations
<p>The help doc for <a href="https://pandas.pydata.org/docs/reference/api/pandas.Series.nbytes.html" rel="nofollow noreferrer">pandas.Series.nbytes</a> shows the following example:</p> <pre><code>s = pd.Series(['Ant', 'Bear', 'Cow']) s </code></pre> <p>0 Ant<br /> 1 Bear<br /> 2 Cow<br /> dtype: object</p>...
<python><pandas>
2024-11-21 16:43:40
1
395
MCornejo
79,212,123
3,241,653
Unauthorized to Delete Tweet with OAuth2.0 path on free-tier developer account
<h2>Context</h2> <ul> <li><p>I'm using a free-tier Twitter / X developer account.</p> </li> <li><p>Admittedly, the OAuth stuff confuses me. I have the following key-values in my .env (values removed), not knowing which are actually necessary and which aren't.</p> <pre><code>API_KEY= API_SECRET= ACCESS_TOKEN= ACCESS_TOK...
<python><twitter><oauth-2.0><tweepy><twitter-oauth>
2024-11-21 16:30:29
1
467
geofflittle
79,212,072
2,108,771
conflict when using multiprocessing's share memory
<p>I am using <code>multiprocessing</code>'s shared memory to share a numpy array between tasks. While each task should originally just read the array, I was curious if writing was also possible. I wrote the following example to test it in a similar situation as I actually use it. In this toy example, each process &quo...
<python><multiprocessing><python-multiprocessing><shared-memory>
2024-11-21 16:18:53
2
1,253
John Smith
79,212,063
7,713,770
How to run django-ckeditor-5 with docker container?
<p>I have a django app and I installed the module django-ckeditor. I can run the app with the command:</p> <pre><code>python manage.py runserver without any problems. </code></pre> <p>But after I build the docker container with the command:</p> <pre><code>docker-compose -f docker-compose-deploy.yml up </code></pre> <p>...
<python><django><docker>
2024-11-21 16:14:04
0
3,991
mightycode Newton
79,212,023
9,272,737
Dynamic many2one field domain in Odoo 17 based on callback function
<p>I need to create a new Many2one field in Odoo 17, extending the standard res.partner model so that the domain of the newly created <code>res_partner.settore_principale</code> field and its possible values are selected dynamically according to the value of the <code>res_partner.x_studio_macrocategoria</code> attribut...
<python><orm><odoo><odoo-16><odoo-17>
2024-11-21 16:06:34
0
303
Fed C
79,212,020
1,609,514
How to write a generic Python function that works with Python, Numpy or Pandas arguments and returns the same type
<p>What's the best way to write a python function that can be used with either float, Numpy, or Pandas data types and always returns the same data type as the arguments it was given. The catch is, the calculation includes one or more float values.</p> <p>E.g. toy example:</p> <pre class="lang-py prettyprint-override">...
<python><pandas><numpy><types>
2024-11-21 16:06:17
3
11,755
Bill
79,211,955
4,377,521
Spyne define a function that accepts array of complex types
<p>I am trying to make a SOAP function on my spyne server that follows this structure.</p> <pre><code>&lt;soap-env:Envelope xmlns:soap-env=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;&gt; &lt;soap-env:Body&gt; &lt;test_function xmlns:ns0=&quot;Test&quot;&gt; &lt;resource&gt; &lt;item&gt; ...
<python><soap><zeep><spyne>
2024-11-21 15:51:44
0
2,938
sashaaero
79,211,778
16,389,095
How to convert a pypdf reader object into a base64 string
<p>I'm trying to develop a simple app in Python Flet for displaying each page of a Pdf file. The code imports the <em>pypdf</em> library for PDF management. The UI consists of a button for loading the first page of the PDF and for skipping to the next page, and of a Flet <a href="https://flet.dev/docs/controls/containe...
<python><flutter><dart><pypdf><flet>
2024-11-21 15:07:46
1
421
eljamba
79,211,733
3,557,405
Airflow UI parameters not being passing on to DAG
<p>I am trying to run a DAG with user specified value for a parameter - using this <a href="https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/params.html" rel="nofollow noreferrer">documentation</a> as a guide.</p> <p>In the Airflow UI when I click the play button next to the DAG I see a page where my...
<python><airflow><orchestration>
2024-11-21 14:56:36
1
636
user3557405
79,211,709
2,807,964
How to mix pytest fixtures that uses request and regular values for parametrize?
<p>This is very hard for me to find in pytest documentation. That's why I'm asking here.</p> <p>I have a fixture that is loading data.</p> <pre class="lang-py prettyprint-override"><code>import pytest @pytest.fixture(scope=&quot;function&quot;) def param_data(request): with open(f'tests/fixtures/{request.param}.js...
<python><pytest><fixtures>
2024-11-21 14:49:54
1
880
jcfaracco
79,211,394
301,723
Alternative to "with" template command for loops
<p>I have a template file <code>letter.txt</code> in the format</p> <pre><code>Hello {{ first_name }} {{ last_name }}! </code></pre> <p>(In reality there are many more variables than these two, but for simplicity I'll stick with only <code>first_name</code> and <code>last_name</code>.)</p> <p>This works nicely with a c...
<python><jinja2>
2024-11-21 13:33:27
1
4,403
mawimawi
79,211,272
6,930,340
dtype changes during collect process in polars dataframe
<p>I have a <code>pl.LazyFrame</code> with a number of columns. One of the columns is called <code>signal</code> and is supposed to have <code>dtype=pl.Int8</code>. It only contains <code>0</code> and <code>1</code>.</p> <p>This will be confirmed if I do <code>collect_schema</code>.<br /> However, when I actually <code...
<python><python-polars>
2024-11-21 12:58:38
0
5,167
Andi
79,211,174
3,802,122
Environment Variables Not Loading in FastAPI App on Vercel
<p>I am trying to deploy a FastAPI application on Vercel, but I am having trouble getting environment variables to load. My setup works perfectly fine locally, where I use <code>python-dotenv</code> with <code>load_dotenv()</code> to load the <code>.env</code> file, but on Vercel, the environment variables are not bein...
<python><environment-variables><fastapi><vercel><python-dotenv>
2024-11-21 12:34:44
2
5,525
Anderson K
79,211,072
10,061,193
Docker Actions Ignore the Installed Dependencies That Are Installed During the Build Step
<p>I've created a Python GitHub action. It runs as a Docker container. One of its layers is the installation of some packages using <code>uv</code>. When I use that action from another repository, although it shows the dependencies are installed in the building step, it seems none of its dependencies are installed when...
<python><docker><github><github-actions><cicd>
2024-11-21 12:07:26
1
394
Sadra
79,210,963
3,782,128
Problems testing with pytest with mock in a subclass
<p>I'm having problems trying to mock a class called into another class. I have three modules:</p> <p>tree.py</p> <pre><code>from branch import Branch class Tree: type_of_tree = None branches = None def __init__(self, type_of_tree, branches = 0, default_leaves = 0): self.type_of_tree = type_of_tr...
<python><mocking><pytest>
2024-11-21 11:36:46
1
1,093
RubΓ©n Pozo
79,210,940
8,726,488
How to calculate Dataframe size?
<p>In Pyspark, How to find dataframe size ( Approx. row count : 300 million records) through any available methods in Pyspark.? My Production system is running on &lt; 3.0 spark version. The idea is based on dataframe size i need to calculate shuffle partition number before joining</p>
<python><apache-spark><pyspark>
2024-11-21 11:30:14
3
3,058
Learn Hadoop
79,210,615
3,494,790
Python NLTK recognizing last name as ORGANISATION if name comes first in sentence
<p>I am using Python's <strong>nltk</strong> library to extract names from a sentence. I am expecting output as <code>['Barack Obama', 'Michelle Obama']</code> but I am getting <code>['Barack', 'Michelle Obama']</code>. My example code is as follows. When I tried printing the <code>ner_tree</code>, I come to know that ...
<python><nltk>
2024-11-21 09:56:49
1
553
kishor10d
79,210,603
4,706,711
How can I update display of chat history upon page refresh?
<p>My chat UI using Gradio:</p> <pre><code>import sqlite3 import gradio as gr import time formatted_history = [] sqlite = None def loadHistoryFromDB(): global sqlite,formatted_history sql=&quot;SELECT role,message from chat_history order by created_at_unix ASC Limit 10&quot;; cur = sqlite.cursor() cu...
<python><sqlite><chat><gradio><sqlite3-python>
2024-11-21 09:52:30
1
10,444
Dimitrios Desyllas
79,210,369
3,049,419
How do I unzip a password protected zip file using Python inside ADLS
<p>Below is the code.</p> <pre><code>from zipfile import ZipFile file_name = &quot;XYZ.zip&quot; with ZipFile(file_name, 'r') as zip: zip.printdir() print('Extracting all the files now...') zip.extractall(pwd=b'123123$SADMK6%002#') print('Done!') </code></pre> <p>It is giving &quot;<code>FileNotFou...
<python><azure><zip>
2024-11-21 08:51:52
1
1,715
Govind Gupta
79,210,355
7,895,542
How to get model field types in pydantic v2?
<p>I am trying to write a generic class that takes a pydantic model type, however the model can only have string fields. So i am trying to verify this at runtime.</p> <p>I looked and found <a href="https://stackoverflow.com/a/75827637/7895542">this</a> answer, but it does not seem to work in v2 as the <code>FieldInfo</...
<python><pydantic><pydantic-v2>
2024-11-21 08:48:47
1
360
J.N.
79,210,306
17,148,835
start a program via Jenkins service
<p>I have installed Jenkins as a service on my windows 10 computer. Jenkins connects via SSH to the machine.</p> <p>The pipeline script looks like this:</p> <pre><code>timestamps { node('abc') { stage(&quot;exec&quot;) { bat &quot;&quot;&quot; echo 'script start' ...
<python><windows><jenkins><subprocess>
2024-11-21 08:38:23
0
1,045
BeanBoy