QuestionId
int64
74.8M
79.8M
UserId
int64
56
29.4M
QuestionTitle
stringlengths
15
150
QuestionBody
stringlengths
40
40.3k
Tags
stringlengths
8
101
CreationDate
stringdate
2022-12-10 09:42:47
2025-11-01 19:08:18
AnswerCount
int64
0
44
UserExpertiseLevel
int64
301
888k
UserDisplayName
stringlengths
3
30
⌀
77,962,144
7,647,857
Numba Function Error: Handling 1D and 2D Arrays Differently
<p>I'm encountering an error while using Numba-optimized functions to check if the extent of an n-dimensional box (<code>n &gt;= 1</code>) is larger than a minimum value along corresponding dimensions. The functions <code>get_extent</code> and <code>is_larger_than_min</code> are decorated with <code>@njit</code>.</p> <...
<python><arrays><numpy><numba>
2024-02-08 13:40:48
1
399
user7647857
77,962,045
3,994,399
How to open an excel file that is already open without getting permission denied
<p>I need to do something with data in an excel file. I therefore open the excel file with the .read_excel method of the pandas library. I only read the data, I don't need to write to the file. However I often have to adjust something in the excel file and run the code again. In order to be able to run the code again, ...
<python><excel>
2024-02-08 13:24:56
1
692
ThaNoob
77,962,011
461,499
Transformer pipeline with 'accelerate' not using gpu?
<p>My transformers pipeline does not use cuda.</p> <p>code:</p> <pre><code> from transformers import pipeline, Conversation # load_in_8bit: lower precision but saves a lot of GPU memory # device_map=auto: loads the model across multiple GPUs chatbot = pipeline(&quot;conversational&quot;, model=&quot;BramVanroy/GEITje-...
<python><pytorch><huggingface-transformers><accelerate>
2024-02-08 13:20:01
2
20,319
Rob Audenaerde
77,961,754
4,462,690
WinPython Path for Jupyter notebooks does not seems to respond to os.chdir()
<p>I am using a portable Python distribution (WinPythyon 2023-04), and downloaded a set of notebooks from a public GitHub repository (<a href="https://github.com/kenperry-public/ML_Spring_2024" rel="nofollow noreferrer">https://github.com/kenperry-public/ML_Spring_2024</a>) using GitHub Desktop on Windows 11 to C:\User...
<python><jupyter-notebook>
2024-02-08 12:42:20
0
1,131
Thomas Philips
77,961,502
16,627,522
Python equivalent for std::basic_istream. (Pybind11, how to read from file or input stream)
<p>I am using Pybind11/Nanobind to write Python bindings for my C++ libraries.</p> <p>One of my C++ functions takes in the argument of type <code>std::istream &amp;</code> e.g.:</p> <pre class="lang-cpp prettyprint-override"><code>std::string cPXGStreamReader::testReadStream(std::istream &amp;stream) { s...
<python><c++><pybind11><nanobind>
2024-02-08 12:02:46
1
634
Tommy Wolfheart
77,961,299
4,014,825
AWS CDK Lambda Layer Python Package
<p>Currently when I create a Python Lambda Layer using the following CDK code:</p> <pre><code>_lambda.LayerVersion( self, &quot;CommonPythonLambdaLayer&quot;, code=_lambda.Code.from_asset( &quot;src/common&quot;, bundling=cdk.BundlingOptions( ...
<python><amazon-web-services><aws-lambda><aws-cdk>
2024-02-08 11:29:42
1
1,029
Inthu
77,960,915
4,561,745
Nested maps in C++ with vectors of different types as values
<p>I am trying to convert the following Python code into C++:</p> <pre><code>outer_dict = {} outer_dict[0] = {} outer_dict[0][&quot;ints&quot;] = [0] outer_dict[0][&quot;floats&quot;] = [0.0] outer_dict[0][&quot;ints&quot;].append(1) outer_dict[0][&quot;floats&quot;].append(1.2) outer_dict[1] = {} outer_dict[1][&quo...
<python><c++><dictionary><nested><hashmap>
2024-02-08 10:31:19
1
775
Dr. Prasanna Date
77,960,851
7,454,177
Is it possible to create a one to many association between a table and an Enum in SQLAlchemy?
<p>In my FastAPI project I want to associate a table with multiple regions. The regions are stored in an Enum. Many-to-Many relationships in SQLAlchemy are generally possible, but I get an error message when adjusting the <a href="https://docs.sqlalchemy.org/en/20/orm/basic_relationships.html#setting-bi-directional-man...
<python><sqlalchemy><enums><fastapi>
2024-02-08 10:20:15
0
2,126
creyD
77,960,840
8,588,743
Translate R-code into Python code - Unique timestamp values differ by a lot
<p>My data frame has the columns</p> <pre><code>DOMAINNAME object CUSTOMERNUMBER int64 CREDITCHECKSOURCE object RESULTTEXT object RESULTCODE object FUNCTION object LASTMODIFIED datetime64[ns] APPROVEDAMOUNT ...
<python><r><duplicates>
2024-02-08 10:18:34
0
903
Parseval
77,960,696
13,314,132
spaCy training stopping automatically in Google Colab
<p>I am training spaCy's NER on a customed dataset.</p> <p>I have changed the dataset template as per spaCy requirements: <code>data[0]['text']</code></p> <pre><code> RECEIVED REGISTER OF DEEDS KENT COUNTY, MI 2022 MAY 02 4:26 PM GU 51 202205030036938 Total Pages: 2 05/03/2022 11:00 AM Fees: $30.00 Lisa Posthumus Lyons...
<python><spacy><named-entity-recognition>
2024-02-08 09:54:14
1
655
Daremitsu
77,960,679
2,763,895
Stellargraph GraphSAGE sample google Colab notebook model.predict error
<p>I started working on running sample of stellargraph python module to run GraphSAGE algorithm sample from this link:</p> <p><a href="https://stellargraph.readthedocs.io/en/stable/demos/node-classification/graphsage-node-classification.html" rel="nofollow noreferrer">https://stellargraph.readthedocs.io/en/stable/demos...
<python><tensorflow><graph-neural-network><stellargraph><graphsage>
2024-02-08 09:51:52
1
1,509
Reza Akraminejad
77,960,618
13,860,719
Unique identifier for ratios with tolerance
<p>I have some data that contains ratios of 5 elements <code>'a'</code>, <code>'b'</code>, <code>'c'</code>, <code>'d'</code>, <code>'e'</code>, which looks something like this:</p> <pre><code>data = [ {'a': 0.197, 'b': 0.201, 'c': 0.199, 'd': 0.202, 'e': 0.201}, {'a': 0.624, 'b': 0.628, 'c': 0.623, 'd': 0.625,...
<python><string><algorithm><hash><rounding>
2024-02-08 09:42:11
2
2,963
Shaun Han
77,960,528
13,104,490
Integrating Python Matplotlib Heatmap into a JavaScript Application
<p>I am currently working with a medical company that is transitioning from MATLAB to JavaScript for our software solutions. As part of this process, we are looking to integrate heatmap visualizations similar to what we had in MATLAB.</p> <p>like the heatmap shown in the attached image. I'm trying to figure out if ther...
<javascript><python><matplotlib><charts><webassembly>
2024-02-08 09:26:27
1
972
Dolev Dublon
77,960,499
6,652,751
ChromaDB get list of unique metadata field
<p>I'm working with a ChromaDB collection and need to efficiently extract a list of all unique values for a specific metadata field.</p> <pre><code> collection = client.get_collection(collection_name) unique_keys = collection.get(where={&quot;$distinct&quot;: &quot;metadata_key&quot;}) #not working as expected #in db ...
<python><chromadb>
2024-02-08 09:21:29
1
1,327
Akhilesh_IN
77,960,213
12,714,241
Git Bash does not recognize Python virtual environment created by Poetry
<p>I am experiencing an issue where Git Bash is not recognizing the Python virtual environment set by Poetry, and it defaults to the system's global Python installation instead. However, PowerShell correctly identifies and uses the virtual environment.</p> <p>Here are the commands and outputs in both shells:</p> <pre><...
<python><visual-studio-code><interpreter>
2024-02-08 08:29:19
2
420
scaryhamid
77,960,212
4,614,867
UDP Packets send via Scapy are not received by a plain Python script
<p>I need help with sending UDP packets via Scapy. For some reason, I cannot receive the packets that I'm sending - I see these packets in Wireshark, but not in the UDP client.</p> <p>I'm running a simplest UDP client for testing:</p> <pre class="lang-py prettyprint-override"><code>import socket UDP_IP = &quot;127.0.0...
<python><sockets><network-programming><udp><scapy>
2024-02-08 08:29:16
1
486
StragaSevera
77,960,181
4,575,197
Is there anyway to read data from Microsoft sql directly into cudf (GPU's RAM)?
<p>I searched for this through internet, but couldn't find any code. What comes to mind is to first load the data into Pandas (Ram) then load it into Cudf (GPU's ram).</p> <pre><code>import cudf from sqlalchemy import create_engine db_url = &quot;postgresql://username:password@localhost:5432/database_name&quot; engine...
<python><pandas><dataframe><bigdata><cudf>
2024-02-08 08:22:16
1
10,490
Mostafa Bouzari
77,960,180
1,538,049
Stopping gradient flow for a multiple headed Pytorch module
<p>I have a multiple headed model in Pytorch, similar to this one:</p> <pre><code>class Net(nn.Module): def __init__(self): super(Net, self).__init__() self.backbone = Backbone() self.proxyModule = ProxyModule() def forward(self, x): backbone_output = self.backbone(x) ...
<python><deep-learning><pytorch>
2024-02-08 08:22:09
1
3,679
Ufuk Can Bicici
77,960,129
15,190,069
How to use a production WSGI server for Firebase Cloud Functions in Python
<p>I implemented production ready functions in python that I want to deploy on Cloud Functions. When I do so using the following command :</p> <pre><code>firebase deploy --only functions </code></pre> <p>I get the following Warning message.</p> <pre><code>... * Serving Flask app 'serving' * Debug mode: off WARNING: Th...
<python><firebase><google-cloud-functions><wsgi>
2024-02-08 08:14:46
0
387
RominHood
77,960,057
16,933,406
Clustering for the Protein sequences (With/without MSA)
<p>I have NGS data (Unique clones only) and I want to group them based on the similarity (clustering is preferable) using Python language. Please have a look into the below sample sequences. Also to isolate the most distant clone as encircled in the image.</p> <p><strong>Note:</strong> I have already asked similar to t...
<python><python-3.x><biopython><hierarchical-clustering>
2024-02-08 08:00:41
1
617
shivam
77,959,864
10,354,066
Set x-axis values for dataframe plotting in Python when data is time series
<p>I have drawn my graph in Python using this code:</p> <pre><code>print(data_filtered['ranking_datetime']) plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y/%m/%d')) plt.gca().xaxis.set_major_locator(mdates.AutoDateLocator()) plt.plot(data_filtered['ranking_datetime'], data_filtered['ranking']) plt.gcf().au...
<python><dataframe><plot><time-series>
2024-02-08 07:17:35
1
1,548
vytaute
77,959,719
20,088,885
How can I create another Invoice Template in Odoo Community(Saas)
<p>I'm trying to create a new <code>invoice template</code> in my Odoo 17 Community (SaaS) with a customize header on it.</p> <p>So what I did first is create a <code>report</code>, It now shows in my <code>Invoice</code>.</p> <p><a href="https://i.sstatic.net/9hWwH.png" rel="nofollow noreferrer"><img src="https://i.ss...
<python><odoo><qweb>
2024-02-08 06:45:50
1
785
Stykgwar
77,959,558
4,398,166
Pandas groupby raises ValueError: len(index) != len(labels) when trying to aggregate columns
<p>I have some data whose columns are float numbers and I want to aggregate them on the integer number they are rounded to. In the MWE below, the expected output should be</p> <pre><code> 912 0 2.5 1 1.5 </code></pre> <p>because all column elements are rounded to <code>912</code>.</p> <p>MWE:</p> <pre class="lang-p...
<python><python-3.x><pandas><dataframe>
2024-02-08 06:05:00
2
1,578
Vim
77,959,461
12,427,876
Differentiate between MSYS2 & Powershell/Command Prompt
<p>I'm writing a python project which is not going to work on PowerShell or Command Prompt, but it does work on MSYS2.</p> <p>Is there any way to differentiate between MSYS2 and PowerShell/Command Prompt?</p> <p>I tried <code>os.name</code> and <code>sys.version</code>, but both return same result between these 3.</p>
<python><msys2>
2024-02-08 05:35:23
1
411
TaihouKai
77,959,410
21,192,065
Pruning nn.Linear weights inplace causes unexpected error, requires slightly weird workarounds. Need explanation
<h2>This fails</h2> <pre class="lang-py prettyprint-override"><code>import torch def test1(): layer = nn.Linear(100, 10) x = 5 - torch.sum(layer(torch.ones(100))) x.backward() layer.weight.data = layer.weight.data[:, :90] layer.weight.grad.data = layer.weight.grad.data[:, :90] x = 5 - torch.sum(layer(tor...
<python><machine-learning><pytorch><artificial-intelligence><autograd>
2024-02-08 05:17:32
1
978
arrmansa
77,959,315
287,545
mime multipart/mixed w/ pure binary + python
<p>It's unclear to me whether raw (non base64) binary is standard supported in MIME <code>multipart/mixed</code>, in particular when decoding with python:</p> <pre class="lang-py prettyprint-override"><code>msg = email.message_from_binary_file(fp, policy=email.policy.HTTP) for part in msg.walk(): if part.get_conte...
<python><multipart>
2024-02-08 04:48:53
0
2,501
Malachi
77,959,301
395,857
How can I move a button before a box that the button uses or changes in Gradio?
<p>Example: I have the following Gradio UI:</p> <pre><code>import gradio as gr def dummy(a): return 'hello', {'hell': 'o'} with gr.Blocks() as demo: txt = gr.Textbox(value=&quot;test&quot;, label=&quot;Query&quot;, lines=1) answer = gr.Textbox(value=&quot;&quot;, label=&quot;Answer&quot;) answerjson =...
<python><gradio>
2024-02-08 04:45:11
1
84,585
Franck Dernoncourt
77,959,207
10,639,382
Pytorch model results different on each run, when using strict = False when loading weights
<p>I am attempting to use an opensource pretrained model (Resnet50) from the following repository <a href="https://github.com/ViTAE-Transformer/RSP/tree/main/Scene%20Recognition" rel="nofollow noreferrer">https://github.com/ViTAE-Transformer/RSP/tree/main/Scene%20Recognition</a> for scene classification. However when I...
<python><pytorch>
2024-02-08 04:08:46
2
3,878
imantha
77,958,980
11,280,068
docker/fastapi/peewee - can connect to mysql on host, but can't in docker container
<p>Losing my mind a little with this networking stuff</p> <p>Context:</p> <ul> <li>I'm working on a remote ubuntu server</li> <li>I have a fastapi app that uses peewee to interact with the database</li> <li>I am trying to learn docker, by containerizing this app</li> <li>The MySQL service is not containerized, but runn...
<python><mysql><linux><docker><fastapi>
2024-02-08 02:39:32
1
1,194
NFeruch - FreePalestine
77,958,694
3,626,104
pylint - how do you enable all optinal checkers / extensions?
<p>From this page <a href="https://pylint.pycqa.org/en/latest/user_guide/checkers/extensions.html" rel="nofollow noreferrer">https://pylint.pycqa.org/en/latest/user_guide/checkers/extensions.html</a> pylint has a number of optional checkers. I pretty much just want all of them, how do I say to pylint &quot;give me ever...
<python><pylint>
2024-02-08 00:43:29
1
1,026
ColinKennedy
77,958,666
14,492,001
How to achieve Polars' previous `pivot()` functionality pre 0.20.7?
<p>Previous to Polars version <code>0.20.7</code>, the <code>pivot()</code> method, if given multiple values for the <code>columns</code> argument, would apply the aggregation logic against each column in <code>columns</code> <strong>individually</strong> based on the <code>index</code> column, rather than against a co...
<python><python-3.x><python-polars>
2024-02-08 00:32:18
3
1,444
Omar AlSuwaidi
77,958,621
1,340,782
How can I use pipx version of a package by default?
<p>I'm on ubuntu 20.04 and trying to get my PC to use the <code>pipx</code> version of <code>ansible</code> by default, because the version installed by my package manager is too old.</p> <p>I tried to use the instructions <a href="https://lewoudar.medium.com/install-python-applications-globally-on-your-machine-63b8a9f...
<python><pip><ansible><pipx>
2024-02-08 00:16:53
0
1,327
localhost
77,958,603
10,714,273
ftputil throwing "530 Please login with USER and PASS" error on login with blank credentials while ftplib does not
<p>Getting the following error when trying to connect to ftp host with <code>ftputil</code>:</p> <blockquote> <p>ftputil.error.PermanentError: 530 Please login with USER and PASS.</p> </blockquote> <p>However I do not get this error when connecting with <code>ftplib</code>. I would like to use <code>ftputil</code> for ...
<python><ftp><ftplib><ftputil>
2024-02-08 00:12:13
1
359
cap
77,958,373
8,217,821
f2py does not output inout as expected
<p>Why does f2py not generate a correct wrapper when dealing with inout params?</p> <p>Here is an example of my function call:</p> <pre><code>io = 7.5 io, out1, out2, out3 = fortran_file.func(5, 2.5, False, io) </code></pre> <p>Here's how that might look in Fortran (example.f):</p> <pre><code>subroutine func(inputA, in...
<python><fortran><f2py>
2024-02-07 22:57:05
1
321
Kyle Ponikiewski
77,958,311
5,837,992
Pandas - Using QCut Rankings From One Dataframe to Categorize a Second Dataframe
<p>I am looking to get quartiles from one dataframe (grouped by PriceDate) and then use the ranges to categorize the values in a second data frame with the same dates.</p> <p>So in the data set below</p> <p>For 10-1, we have the following bins (-0.001, 3.2] and (3.2, 9.3] For 10-2, we have the following bins (0.6...
<python><pandas><qcut>
2024-02-07 22:38:54
1
1,980
Stumbling Through Data Science
77,958,261
13,215,988
Pip commands in Kaggle create a lot of dependency resolver issues
<p>I have been using Kaggle for training models. I have a notebook in which I ran this command <code>!pip install -Uqq fastai</code> and it output this error:</p> <pre><code>ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the fol...
<python><tensorflow><pip>
2024-02-07 22:25:50
1
1,212
ChristianOConnor
77,958,175
1,735,215
Is there a non-memory-intensive way of importing data from MariaDB into Python?
<p><strong>Question</strong></p> <p>Is there a non-memory-intensive way for extracting large datasets from a MariaDB database and importing them directly into Python (via the python-mariadb connector)?</p> <p><strong>Edit: Solution</strong></p> <p>Following @Georg Richter's <a href="https://stackoverflow.com/a/77960704...
<python><sql><linux><memory><mariadb>
2024-02-07 22:07:12
2
2,176
0range
77,958,149
32,836
How can I more efficiently deserialize set data strings?
<p>I've written a Rust program that exposes it's JSON API in the form of JSON Schema and then using portions of that to create Python pydantic classes.</p> <p>Where I'm stuck is that I have several JSON schema types that I could receive in the Python code and I'm rather inefficiently deserializing them. A facsimile of...
<python><pydantic>
2024-02-07 22:00:09
1
7,493
Jamie
77,958,113
9,766,795
Calculate binance ATR in python with binance connector
<p>I'm using the binance connector API in python (<a href="https://binance-connector.readthedocs.io/en/latest/getting_started.html" rel="nofollow noreferrer">https://binance-connector.readthedocs.io/en/latest/getting_started.html</a>) and I want to build a function that computes the ATR of the previous candle (not the ...
<python><math><algorithmic-trading><binance>
2024-02-07 21:50:32
1
632
David
77,958,071
9,877,065
OpenCV find contours of an RGBA image not working
<p>With input image as <code>Contours_X.png</code> [Contours_X.png: PNG image data, 819 x 1154, 8-bit grayscale, non-interlaced] :</p> <p><a href="https://i.sstatic.net/iW54X.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iW54X.png" alt="enter image description here" /></a></p> <p>Stealing code from <a ...
<python><opencv><image-processing>
2024-02-07 21:40:41
2
3,346
pippo1980
77,957,959
6,800,914
lxml xpass can't find a tag below first one in xml
<p>I have an xml doc that looks something like this</p> <pre><code>&lt;MyXmlRoot&gt; &lt;App xmlns='urn:SomethingSomething1'&gt; ... &lt;/App&gt; &lt;User xmlns='urn:SomethingSomething2'&gt; ... &lt;/User&gt; &lt;Doc xmlns='urn:SomethingSomething3'&gt; &lt;level2&gt; &lt;level3&gt; &lt;l...
<python><xml><lxml>
2024-02-07 21:18:41
1
303
Vladimir Zaguzin
77,957,732
16,837,686
Why Is a migration file created (over and over) when i run makemigrations
<p>Am facing a somehow funny issue...every time i migrate,i get this description</p> <pre><code> Your models in app(s): 'organization_app' have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to app...
<python><django><django-rest-framework>
2024-02-07 20:30:01
1
354
slinger
77,957,707
381,416
Union of protocols with invariant generic type causes problems
<p>I have a protocol <code>MyExporter</code> using a generic type <code>T</code>:</p> <pre class="lang-py prettyprint-override"><code>T = TypeVar(&quot;T&quot;, bound=BaseSample) class MyExporter(Protocol[T]): def get_sample(self) -&gt; T: ... def process_sample(self, sample: T) -&gt; str: ......
<python><generics><typeerror><python-typing>
2024-02-07 20:23:05
1
940
wstr
77,957,701
746,100
Why when my Python3 .pyw file is run from Visual Studio Code on Macos it gets "No module named 'PyQt6' but runs ok at macos command line?
<p>.pyw has no problem if I run from terminal command line or by double-clicking with Finder.</p> <p>BUT in VSC if I select the .pyw and do &quot;Run &gt; Start debug&quot; or &quot;Run &gt; Run Without Debug&quot; it gets the error:</p> <pre><code>/Users/me/.zshrc:export:2: not valid in this context: /Users/me/.zshrc ...
<python><python-3.x><visual-studio-code>
2024-02-07 20:21:49
0
8,387
Doug Null
77,957,560
1,473,517
How to convert nested brackets to a list of pairs
<p>I have code that returns a tuple with nested brackets which represents alternating intervals to exclude and include. The nested tuples look like:</p> <pre><code>((None, 6), 16) </code></pre> <p>and</p> <pre><code>(((None, 1), 6), 16) </code></pre> <p>What I really want is to convert these into a list of pairs for on...
<python>
2024-02-07 19:52:44
3
21,513
Simd
77,957,518
4,408,275
How do I add a `ttk.Notebook` widget to a `tk.Frame`?
<p>I can create this GUI</p> <pre><code>┏━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━┓ ┃ @ ┃ hello world ┃ X ┃ ┣━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━┫ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ...
<python><tkinter>
2024-02-07 19:45:56
1
1,419
user69453
77,957,504
5,594,008
Django, Subquery, more than one row returned by a subquery used as an expression
<p>Here is my model structure</p> <pre><code>class ContentFlag(models.Model): user = models.ForeignKey( User, verbose_name=&quot;user&quot;, related_name=&quot;object_flags&quot;, on_delete=models.CASCADE, ) flag = models.CharField(max_length=30, db_index=True) content_ty...
<python><django>
2024-02-07 19:42:47
1
2,352
Headmaster
77,957,365
543,913
Embedding Bokeh server into Flask app while retaining plot size
<p>I found an example in the Bokeh github of a Flask app that embeds a Bokeh server <a href="https://github.com/bokeh/bokeh/blob/branch-3.4/examples/server/api/flask_embed.py" rel="nofollow noreferrer">here</a>. When I run it and open the Flask URL in Google Chrome, I see the embedded plot. When I directly open the Bok...
<python><google-chrome><flask><bokeh>
2024-02-07 19:17:11
1
2,468
dshin
77,957,324
14,170,672
Why is zoneinfo shifting DST by 2 hours instead of 1?
<p>I need to make sure that when a naive datetime is made aware the DST rules are applied correctly. What I find here is just odd to me.</p> <p>Somehow zoneinfo decides to increment the DST transition for America/New_York by 2 hours instead of one. It is even shifting the time right before DST to EDT by 2 hours.</p> <p...
<python><datetime><timezone><zoneinfo><tzdata>
2024-02-07 19:08:17
2
870
Stryder
77,957,253
2,687,317
plot a slice of 3D data with pcolormesh
<p>I have data in 2 numpy arrays: one a list of 3D positions, the other the values of a scalar AT each of those positions. The ordering of the position data is fairly 'weird' (see below).</p> <p>The 3D position data is in an array:</p> <pre><code>pos = np.array([[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,1], ...]) pos.shape...
<python><numpy><matplotlib><slice>
2024-02-07 18:51:48
1
533
earnric
77,957,242
13,611,327
how to arbitrarily sort the radial plot values in altair?
<p>I'm building a radial chart in python but can't order the values of the plot based on the 'categoria' values. I already tried to sort the df and force through domain and sort in the altair code but can't get the desired result. What I'm doing wrong?</p> <p><a href="https://i.sstatic.net/MBJQI.png" rel="nofollow nore...
<python><altair>
2024-02-07 18:49:29
1
303
Jay Ballesteros C.
77,957,153
12,704,700
how to mock s3 last_modified for unit tests to a file?
<p>I would like to test the last last_modified timestamp for the s3 file in the unit test. When i try to get the timestamp for an s3 file it always gives me the latest timestamp when i run the unit test, but i have multiple s3 files and iam planning on using the latest timestamp for these these multiple files to assert...
<python><unit-testing><amazon-s3><boto3><moto>
2024-02-07 18:32:38
1
2,505
Sundeep
77,957,092
11,515,528
Getting peaks/troughs and charting
<p>I am analysing swings in data which resembles a sine wave.</p> <p>I have got a solution but am looking for something shorter.</p> <p>Currently I find the peaks and trough building a df for each and merging with the main data. I then make a series with the diffs and draw a box plot.</p> <p>Do I need to make those two...
<python><pandas>
2024-02-07 18:19:48
0
1,865
Cam
77,957,072
16,646,078
How to Determine Final State of Sequential Entries in a Pandas DataFrame Using Vectorized Operations?
<p>I have a pandas DataFrame with columns representing various attributes of data entries, including a timestamp &quot;dh_processamento_rubrica&quot;, a unique identifier &quot;inivalid_iderubrica&quot;, and an operation type &quot;operacao&quot;. The operations include &quot;inclusao&quot; (insertion), &quot;alteracao...
<python><pandas><dataframe>
2024-02-07 18:13:40
2
7,595
e-motta
77,956,980
14,456,476
Getting ReplicaSetNoPrimary error for M0 cluster when using Django with MongoEngine
<p>I am using django with mongoengine. I am writing the following in the settings.py file:</p> <pre><code>from mongoengine import connect URI = 'mongodb+srv://myusername:mypassword@cluster0.5apjp.mongodb.net/django?retryWrites=true&amp;w=majority&amp;ssl=false' connect(host=URI) </code></pre> <p>After that, I have a mo...
<python><django><mongodb><crud><mongoengine>
2024-02-07 17:57:33
2
378
Dhritiman Tamuli Saikia
77,956,832
7,654,773
Why is Kivy UrlRequest callback blocking GUI thread?
<p>I have Kivy app with screen that has a download button that downloads and processes various tables of remote data. It all works just fine but the gui is getting blocked in the process as evidenced by a MDSpinner that freezes about halfway through until the download process is completely finished.</p> <p>The entire D...
<python><kivy><kivy-language>
2024-02-07 17:34:02
2
696
Bill
77,956,750
4,211,950
Python Project Euler #23 Incorrect Answer
<p>I have tried solving <a href="https://projecteuler.net/problem=23" rel="nofollow noreferrer">Project Euler Problem 23</a> in python but I am getting an answer that is below the correct one by 995. The wrong answer that I get is due to the fact that my final list does not include 12, 18, 20 and 945. However, these nu...
<python>
2024-02-07 17:20:43
1
347
Michael Mooney
77,956,528
960,115
OpenPyXL coordinate_to_tuple Method Fails on Absolute Addresses
<p>Fairly simple <em>OpenPyXL</em> question... how can I change the following line to return the address tuple for an absolute address cell? I could manually remove the dollar signs, but it seems like that is a dirty work-around for something that seems like a bug in <em>OpenPyXL</em>.</p> <pre><code># The following l...
<python><openpyxl>
2024-02-07 16:46:42
1
4,735
Jeff G
77,956,505
23,361,424
How to have multiple email backends in Django?
<p>I would like to have both SMTP backend and console backend, so that I can send an email via SMTP while also printing the generated email to console.</p> <p>In my settings.py I would like to have something like this:</p> <pre><code>EMAIL_BACKEND = [&quot;django.core.mail.backends.smtp.EmailBackend&quot;, &quot;django...
<python><django><smtp>
2024-02-07 16:43:23
1
518
c p
77,956,061
2,460,464
Docker Networking with Jaeger all-in-one container using Python
<p>I have three containers (C, S, and J). C is the client, S is a SQL Server container, and J is J(aeger). All three containers are on a dedicated network.</p> <p>Traffic between C and S happens without problems. From the Docker Host (in this case, it's a VirtualBox VM), I can push metrics to J without issue. From C, I...
<python><docker><network-programming><open-telemetry><jaeger>
2024-02-07 15:36:00
1
485
user2460464
77,955,992
9,536,103
Ensuring transactional writes across two delta tables in databricks
<p>I want to create/update two delta tables in databricks. However, I want them both to be created at the same time such that the following can never occur:</p> <ol> <li>A user queries table 1 and table 2 and gets the original data from table 1 and the updated data from table 2</li> <li>A user queries table 1 and table...
<python><databricks>
2024-02-07 15:25:38
1
1,151
Daniel Wyatt
77,955,809
3,124,206
Creating a sensor in airflow using a virtual python environment
<p>I have been using successfully airflow python tasks with a virtual environment thanks to the <code>@task.virtualenv(requirements=[...])</code> decorator.</p> <p>However, is it possible to also write sensors in python that make use of external environments? There is a <code>@task.sensor</code> decorator but I can't f...
<python><airflow>
2024-02-07 15:01:10
0
485
user3124206
77,955,698
18,793,790
How do I run a python script with virtual .venv from my sveltekit app?
<p>I am able to run the python script from my sveltekit app using exec using the code below. <code>const command = `python &quot;${pythonScriptPath}&quot; ${plateID} &quot;${formattedProdDate}&quot;`; is the </code> command where I run the python script. I need to run this python script in a virtual environment.</p> <p...
<python><sveltekit><python-venv>
2024-02-07 14:43:11
1
346
Avi4nFLu
77,955,612
8,599,834
Is it possible to make a module unimportable/hidden at runtime?
<p>I have different sets of dependencies that are installed in different environments (i.e. core deps installed everywhere, plus optional deps just for linting, optionals only in production etc).</p> <p>Locally, I typically have all of them installed, so my code will never accidentally happen to fail importing somethin...
<python><mocking><python-import>
2024-02-07 14:32:39
0
2,742
theberzi
77,955,472
236,247
How do you mark an entire file as deprecated in Python?
<p>I am reviewing a .py file with no classes, just a list of functions. There is a newer version of this same file which is now used instead of the old file.</p> <p>I know to mark class or function as deprecated, one can do <code>from warnings import deprecated</code> and then for the decorated function or class use <...
<python><deprecated>
2024-02-07 14:13:57
1
9,756
demongolem
77,955,428
5,761,843
Bilinear Fit on data using python
<p>I'm trying to fit a number depending on two inputs via a bilinear fit using python.</p> <p>I have random sets of data of x and y inputs and the corresponding z output.</p> <p>I need the output coefficients a, b, c, and d for</p> <pre><code>z(x,y) = a*x + b*y + c*x*y + d </code></pre> <p>The input data I have is not ...
<python><bilinear-interpolation>
2024-02-07 14:08:39
1
672
GNA
77,955,277
5,022,847
pandas adding 0 when adding =HYPERLINK to a column
<p>I want to add hyperlink to a column, but if the column is empty it adding <code>0</code> to it</p> <pre><code>def hyperlink(row): return f'=HYPERLINK(&quot;{row.link}&quot;, &quot;{row.a}&quot;)' if row.a else '' df[&quot;a&quot;] = df.apply(hyperlink, axis=1) df.drop(columns=[&quot;link&quot;], inplace=True) w...
<python><pandas><dataframe>
2024-02-07 13:48:24
2
1,430
TechSavy
77,955,273
1,744,491
How to get AWS Managed Policy using Python Pulumi
<p>I'm trying to create an AWS Glue Role run the service properly. I want to use the AWS Managed role <strong>AWSGlueServiceRole</strong> using the following code:</p> <pre><code>import json from pulumi_aws import iam from pulumi_aws.iam import Role def get_access_bucket_role(role_name: str, bucket_name: str, tags) -&...
<python><amazon-web-services><pulumi><pulumi-python>
2024-02-07 13:48:06
1
670
Guilherme Noronha
77,955,134
7,699,037
PyInstaller won't find package metadata
<p>I have created a package that uses <code>importlib.metadata</code> to obtain the package version:</p> <pre><code>def get_version() -&gt; str: &quot;&quot;&quot;Get the installed version of this pip package. Returns: str: Version of this pip package. &quot;&quot;&quot; return metadata.version...
<python><pyinstaller><pyproject.toml>
2024-02-07 13:26:52
0
2,908
Mike van Dyke
77,955,071
8,519,830
pandas dataframe resample sum daily entries only for complete months
<p>I have dataframes with daily entries that can start and end not on months' boundaries. I want to sum by month but without the first months entries if they don't start at the first day of the month and the last months entries if they don't end at the last day of the month.</p> <pre><code> gas 2022-10-18 ...
<python><pandas><dataframe>
2024-02-07 13:17:30
1
585
monok
77,954,934
7,566,673
auto-covariance matrix for 1D array
<p>I want to compute auto-covariance matrix for real valued 1D array . I have seen in a blog that auto-correlation matrix is computed as below .</p> <pre><code>import numpy as np x = np.asarray([1+1j,2+1j,3-1j]) acf = np.convolve(x,np.conj(x)[::-1]) Rxx=acf[2:]; # R_xx(0) is the center element Rx = toeplitz(Rxx,np.hst...
<python><scipy><signal-processing>
2024-02-07 12:57:37
0
1,219
Bharat Sharma
77,954,859
12,886,610
dbt: Get return of callback function
<p>I am trying out <a href="https://docs.getdbt.com/reference/programmatic-invocations" rel="nofollow noreferrer">using dbt programmatically</a>, in particular <a href="https://docs.getdbt.com/reference/programmatic-invocations#registering-callbacks" rel="nofollow noreferrer">callbacks</a>. I would like to get the data...
<python><callback><dbt>
2024-02-07 12:47:55
1
1,263
dwolfeu
77,954,808
6,151,828
ImportError: cannot import name 'ConstantInputWarning' from 'scipy.stats'
<p>Error due to <code>scikit-kbio</code>:</p> <pre><code>ImportError: cannot import name 'ConstantInputWarning' from 'scipy.stats' (/home/smith/miniconda3/lib/python3.8/site-packages/scipy/stats/__init__.py) </code></pre> <p>This is likely related to recent installations (like <code>numba</code>) which might have modif...
<python><python-3.x><numpy><scipy><skbio>
2024-02-07 12:40:55
1
803
Roger V.
77,954,753
14,444,816
get_signing_key_from_jwt throws error Unable to find a signing key that matches kid
<p>I'm seeing this error when getting the signing key:</p> <blockquote> <p>PyJWKClientError: Unable to find a signing key that matches: &quot;{kid}&quot;</p> </blockquote> <p>The signing_key is where I'm seeing the error:</p> <pre><code>import jwt jwks_uri=&quot;https://my_auth_server/oauth2/v1/keys&quot; jwks_client ...
<python><jwt><jwk>
2024-02-07 12:33:26
0
2,021
KristiLuna
77,954,656
19,500,571
Multithreading JSON parsing
<p>I need to process a large amount of JSON-files and I want to multithread this processing. However, I find that multithreading doesn't improve the processing time at all and in fact takes the same amount of time as if done in serial.</p> <p>I have narrowed the issue down to this piece of code, where the JSON files ar...
<python><json><multithreading><io>
2024-02-07 12:17:48
1
469
TylerD
77,954,638
1,942,868
Make link to foreign key object in admin screen
<p>I have class like this which has the <code>ForeignKey</code></p> <pre><code>class MyLog(SafeDeleteModel): user = models.ForeignKey(CustomUser,on_delete=models.CASCADE) </code></pre> <p>then I set <code>user</code> in the list_display of MyLog in admin page.</p> <pre><code>class MyLogAdmin(admin.ModelAdmin): ...
<python><django><admin>
2024-02-07 12:15:16
1
12,599
whitebear
77,954,618
1,879,109
Passing custom batch to the validator in Great Expectations
<pre class="lang-py prettyprint-override"><code># Import necessary libraries import great_expectations as ge import datetime # Load the Great Expectations context context = ge.data_context.DataContext(&quot;../.&quot;) # Load the JSON data into a Pandas DataFrame data_file_path = &quot;../../data/nested.json&quot; df...
<python><great-expectations>
2024-02-07 12:10:22
0
915
Kity Cartman
77,954,586
2,148,416
Odd behavior of Numpy any() when dtype=object
<p>Numpy <a href="https://numpy.org/doc/stable/reference/generated/numpy.any.html" rel="nofollow noreferrer">docs</a> on <code>any()</code> says &quot;<em>A new boolean or ndarray is returned...</em>&quot; and &quot;<em>Returns single boolean if axis is None.</em>&quot;</p> <p>Consider this:</p> <pre><code>&gt;&gt;&gt;...
<python><numpy>
2024-02-07 12:05:08
1
3,437
aerobiomat
77,954,574
3,566,606
Generic Type Alias for NotRequired and Optional
<p>In <code>typing.TypedDict</code>, there is a difference between fields being <code>NotRequired</code> and fields whose values are declared <code>Optional</code>. The first means that the key may be absent, the latter means the value on an existing key may be <code>None</code>.</p> <p>In my context (working with mong...
<python><python-typing>
2024-02-07 12:04:03
0
6,374
Jonathan Herrera
77,954,411
7,024,352
CrispyError : as_crispy_field got passed an invalid or inexistent field for email field only
<p>I can't expose Email field from User model in django, If I remove email field from register.html there is no error. Also if I use {{ form }} It does not show the email field. It shows username, password1 and password2 with no error.</p> <p><strong>models.py:</strong></p> <pre><code>from django.contrib.auth.models im...
<python><django><django-crispy-forms>
2024-02-07 11:36:30
1
319
Hesam Marshal
77,954,161
10,353,865
Apply expanding function over whole df - numba and alternatives?
<p>I want to apply an expanding window operation on the whole df - not columnwise. The method=table requires numba engine. But I always get an error when calling it (see below)</p> <p>I would also appreciate it, if anyone could point out another solution to my problem (i.e. I don't necessarily want to use numba).</p> <...
<python><pandas><numpy>
2024-02-07 10:59:37
1
702
P.Jo
77,954,150
7,745,011
How to use type annotation to support generic subtypes for third party classes in pydantic basemodels?
<p>Going from the <a href="https://docs.pydantic.dev/latest/concepts/types/#handling-third-party-types" rel="nofollow noreferrer">pydantic documentation</a> I have written the following annotation wrapper for numpy arrays in order to parse numpy arrays from jsons directly:</p> <pre class="lang-py prettyprint-override">...
<python><numpy><python-typing><pydantic>
2024-02-07 10:57:33
1
2,980
Roland Deschain
77,954,041
8,881,495
Inference of Mixtral 8x7b on multiple GPUs with pipeline
<p>I run Mixtral 8x7b on two GPUs (RTX3090 &amp; A5000) with pipeline. I can load the model in GPU memories, it works fine, but inference is very slow. When I run <code>nvidia-smi</code>, there is not a lot of load on GPUs. But the motherboard RAM is full (&gt;128Gb) and a CPU reach 100% of load. I feel that the model ...
<python><pytorch><pipeline><large-language-model>
2024-02-07 10:43:27
1
3,655
Fifi
77,954,019
5,589,640
Load word2vec model that is in .tar format
<p>I want to load a previously trained word2vec model into gensim. The trouble is the file format. It is not a .bin file format but a .tar file. It is the model / file <em>deu-ch_web-public_2019_1M.tar.gz</em> from the <a href="https://wortschatz.uni-leipzig.de/en/download/German" rel="nofollow noreferrer">University ...
<python><gensim><word2vec><tar.gz>
2024-02-07 10:41:01
3
625
Simone
77,953,711
2,062,318
How to find the best possible team lineup (in swimming)
<p>I currently have a fairly simple algorithm that tries to build the best possible team-lineup given some constrains:</p> <ol> <li>There is a finite list of events which needs to be filled with swimmers</li> </ol> <ul> <li>Event 1: 50 Free</li> <li>Event 2: 100 Free</li> <li>...</li> </ul> <ol start="2"> <li>In each e...
<python><linear-programming><pyomo><gekko><constraint-programming>
2024-02-07 09:50:36
1
16,170
Todor
77,953,700
9,172,401
custom column type for django create DB cache table command
<p>I’m currently working with a PostgreSQL database and I want to use a timestamp of type ‘timestamp(0)’. To achieve this, I’ve created a custom column type using the following code:</p> <pre><code>class DateTimeWithoutTZField(DateTimeField): def db_type(self, connection): return 'timestamp(0)' </code></pre...
<python><django><django-models><django-rest-framework>
2024-02-07 09:48:32
1
598
Marcos DaSilva
77,953,646
2,372,467
Investing.com blocking Python Selenium Script
<p>I am trying to download portfolio data from my own login from <a href="https://www.investing.com/portfolio" rel="nofollow noreferrer">https://www.investing.com/portfolio</a> by automating using Selenium webdriver for Chrome using Python.</p> <p>It was working till few days back. Suddenly it has stopped working., it ...
<javascript><python><selenium-webdriver>
2024-02-07 09:40:17
1
301
Kiran Jain
77,953,490
773,595
Can't install chs
<p>When I try to execute <code>pip3 install chs</code> I get the following error:</p> <pre><code>pip3 install chs Defaulting to user installation because normal site-packages is not writeable Collecting chs Using cached chs-3.0.0.tar.gz (13.0 MB) Preparing metadata (setup.py) ... done Requirement already satisfied:...
<python>
2024-02-07 09:17:35
1
13,497
vdegenne
77,953,302
9,030,603
How to retrieve the generated SQL query from create_sql_agent of Langchain?
<p>I have used <strong>Langchain</strong> - <strong>create_sql_agent</strong> to generate SQL queries with a database and get the output result of the generated SQL query. Here is how my code looks like, it is working pretty well.</p> <pre><code>agent = create_sql_agent( llm=llm, db=db, verbose=True, ag...
<python><sql><python-3.x><langchain><large-language-model>
2024-02-07 08:46:03
4
444
AlfiyaFaisy
77,953,145
2,473,382
Annotate a function return type with an instance, not a type
<p>I would like to type a function to an actual object, not the type of this object, and the type checker to understand this.</p> <p>Imagine this example:</p> <pre class="lang-py prettyprint-override"><code>my_marker = &quot;This is very singletony, I promise!&quot; def get_object_or_a_singleton_marker() -&gt; int|my_...
<python><python-typing>
2024-02-07 08:13:21
1
3,081
Guillaume
77,952,977
736,662
Locust and Websockets
<p>I want to make a simple Locust script for a WebSocket call preferably using aiohttp. Request URL:</p> <pre><code>wss://someurl/api/task/ws </code></pre> <p>Request Method:</p> <pre><code>GET </code></pre> <p>Staus code:</p> <pre><code>101 Switching Protocols </code></pre> <p>Using &quot;Class&quot; and &quot;task&qu...
<python><websocket><aiohttp><locust>
2024-02-07 07:41:34
1
1,003
Magnus Jensen
77,952,743
9,608,860
Get guild details from the user DM using Discord.py
<p>I have created a discord bot which can be invited to guilds and has slash commands. Everything is working fine if a user uses the command in server. But I want to get the guild if user uses that command in bot DM. How can I do that?</p> <p>I have tried using message.guild but that is always returning None.</p>
<python><discord><discord.py>
2024-02-07 06:50:59
1
405
Aarti Joshi
77,952,733
7,408,848
How to filter metadata in a Mongodb database with Python
<p>I want to do a basic filter on the metadata of all of the documents within my Mongodb database</p> <p>I generated the metadata myself using the following code</p> <pre><code>import mongoengine as moe db = &quot;games&quot; collection = &quot;characters&quot; conn = moe.connect(&quot;db&quot;, host=&quot;localhost&...
<python><mongodb>
2024-02-07 06:47:35
1
1,111
Hojo.Timberwolf
77,952,676
20,024,690
How to use debugpy in VScode to debug remote python server?
<p>I've used <code>&quot;type&quot;: &quot;python&quot;</code> to debug remote python servers. Now I'm seeing this warning in <code>launch.json</code>:</p> <blockquote> <p>This configuration will be deprecated soon. Please replace <code>python</code> with <code>debugpy</code> to use the new Python Debugger extension.</...
<python><visual-studio-code><remote-debugging>
2024-02-07 06:36:45
1
361
PeterKogan
77,952,458
2,446,702
How to search JSON for data, get vlaues from that array in Python
<p>I have the below JSON. I want to search each array, and only scrape the data from the array which has keys and values in the &quot;source&quot; block, ignoring arrays which have an empty &quot;source&quot; block. Here is the JSON:</p> <pre><code>{ &quot;L&quot;: [ { &quot;operation_no&quot;: ...
<python><arrays><json>
2024-02-07 05:47:53
2
3,255
speedyrazor
77,952,379
8,497,844
Output data in real time
<p>I have two Python scripts for Linux.</p> <p>test.py</p> <pre><code>#!/usr/bin/env python3 import subprocess print('first line') subprocess.run('./test_1.py', shell=True, encoding='utf-8') </code></pre> <p>test_1.py</p> <pre><code>#!/usr/bin/env python3 print('second line') </code></pre> <p>If I run <code>test.py<...
<python><linux>
2024-02-07 05:18:10
0
727
Pro
77,952,302
7,662,164
JAX `custom_vjp` for functions with multiple outputs
<p>In the <a href="https://jax.readthedocs.io/en/latest/notebooks/Custom_derivative_rules_for_Python_code.html" rel="nofollow noreferrer">JAX documentation</a>, custom derivatives for functions with a single output are covered. I'm wondering how to implement custom derivatives for functions with multiple outputs such a...
<python><jax><automatic-differentiation>
2024-02-07 04:52:27
1
335
Jingyang Wang
77,952,221
3,713,236
Flask cannot open at 127.0.0.1?
<p>I'm trying to run the most basic possible app on Flask:</p> <pre><code>from flask import Flask, render_template import reddit_text_to_speech # This is a script converted from my Jupyter notebook and intended to be used in def index() once this is resolved. app = Flask(__name__) @app.route('/') def index(): re...
<python><flask><localhost>
2024-02-07 04:25:24
1
9,075
Katsu
77,951,887
4,979,733
How to stream write a large list of objects in chunks to JSON format in Python?
<p>I want to know how to stream a large list of objects into JSON format in chunks. I have something like this:</p> <pre><code>from pydantic import BaseModel class MyObj(BaseModel): .... data = [] with open('file_to_process', 'rt') as fin: for x in fin: ... data.append(MyObj(....)) with open('foo.json...
<python>
2024-02-07 02:16:37
0
3,491
user4979733
77,951,588
13,142,245
How to compute percentiles with numpy?
<p>SciPy.stats has a function called percentileofscore. To keep my package dependencies down, I want to source the most similar function possible from numpy, instead.</p> <pre><code>import numpy as np a = np.array([3, 2, 1]) np.percentile(a, a) &gt;&gt;&gt; array([1.06, 1.04, 1.02]) percentileofscore(a,a) &gt;&gt;&gt...
<python><numpy><scipy><scipy.stats>
2024-02-07 00:25:16
2
1,238
jbuddy_13