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,231,899
11,112,772
How to I install the latest versions of numpy which are available as ".whl" files in the repository of Chaquopy?
<p><strong>When did the question arise?</strong></p> <p>For a purpose, I need to install the <code>numpy</code> version at least 1.20.3. Since the default installation of <code>numpy</code> by the command <code>install &quot;numpy&quot;</code> does not satisfy the requirement, initially, I tried to install it by <code>...
<python><android><numpy><chaquopy>
2023-10-04 17:49:04
1
881
Md Sabbir Ahmed
77,231,828
1,761,521
How do I structure an AWS CDK application to be able to import from a python package in the same root directory?
<p>I have a project directory that looks like,</p> <pre><code>. β”œβ”€β”€ infrastructure β”‚ β”œβ”€β”€ app.py β”‚ β”œβ”€β”€ stacks β”‚ β”œβ”€β”€ batch β”‚ └── long_running β”‚ β”œβ”€β”€ Dockerfile β”‚ β”œβ”€β”€ app.py β”‚ └── functions β”‚ └── lambda1 β”‚ β”œβ”€β”€ Dockerfile β”‚ β”œβ”€β”€ app.py β”‚ └── requirements.t...
<python><aws-cdk>
2023-10-04 17:37:59
1
3,145
spitfiredd
77,231,648
11,278,588
Matching data two inputs
<p>I have 2 inputs as follows:</p> <pre><code>input1 = [&quot;order&quot;, &quot;name&quot;, &quot;age&quot;, &quot;soul&quot;, &quot;test&quot;, &quot;chill&quot;, &quot;thym&quot;, &quot;transport&quot;, &quot;lim&quot;] input2 = [&quot;order&quot;, &quot;age&quot;, &quot;soul&quot;, &quot;chill&quot;, &quot;thym&quo...
<python>
2023-10-04 17:09:13
1
401
Kepler452B
77,231,562
13,653,794
Difference in behaviour of identical lists
<p>When attempting <a href="https://leetcode.com/problems/n-queens/" rel="nofollow noreferrer">N-Queens</a>, the solution I was using would break when using the first way to create a list.</p> <p>I thought both of these methods created the same list, why do they behave differently?</p> <p>(Full Code Below)</p> <p>Final...
<python><list><recursion>
2023-10-04 16:56:03
1
374
Fergus Johnson
77,231,435
3,261,772
Text Embeddings from Finetuned llama2 model
<p>I have finetuned my locally loaded llama2 model and saved the adapter weights locally. To load the fine-tuned model, I first load the base model and then load my peft model like below:</p> <pre><code>model = PeftModel.from_pretrained(base_model, peft_model_id) </code></pre> <p>Now, I want to get the text embeddings...
<python><langchain><llama><peft>
2023-10-04 16:37:18
1
1,205
Hamid K
77,231,407
1,532,602
MySQL datetime not converting GMT to appropriate timezone in Python
<p>I created A MySQL table with a timestamp field which is supposed to hold GMT time:</p> <pre><code>CREATE TABLE `Notes` ( `RecordID` varchar(36) NOT NULL, `DateAdded` timestamp NOT NULL, `UserID` varchar(36) NOT NULL, `Note` text NOT NULL, PRIMARY KEY (`RecordID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ...
<python><mysql>
2023-10-04 16:32:41
1
1,665
Elcid_91
77,231,391
21,540,734
Can anyone explain to me how these constants in win32con are picked apart?
<p>What I'm trying to do is find out what is fullscreen or exclusive fullscreen. The code I have is to generate the styles of the open windows on my desktop. WS_MAXIMIZE has a different numbers then what is being printed by the code. Can someone explain to me how these numbers are being generated by windows?</p> <p>SO ...
<python><win32con>
2023-10-04 16:30:24
0
425
phpjunkie
77,231,350
7,505,228
Invoking a Google Cloud Function with non-http trigger via python
<p>I have deployed a cloud function (1st gen) with a trigger when a new object is created in a bucket</p> <pre><code>gcloud functions deploy &lt;function_name&gt; \ --source &lt;source_folder&gt; \ --trigger-bucket=&lt;trigger_bucket&gt; \ --region europe-west3 \ --runtime python38 \ ... </code></pr...
<python><google-cloud-functions>
2023-10-04 16:25:12
1
2,289
LoicM
77,231,334
15,209,268
How to zoom in and out with Moviepy
<p>I have a video in 1080P resolution and need to perform various editing tasks, including rotation, cropping, trimming, and zooming. While I've successfully applied all these edits using MoviePy, I'm encountering an issue with the zoom effect.</p> <p>Specifically, I'm looking for a way to zoom in and out by a specifie...
<python><zooming><moviepy>
2023-10-04 16:23:18
0
444
Oded
77,231,294
9,983,652
why using resample().interpolate('spine') create all nan?
<p>I have a dataframe with date gap, for example, 2023 10-02 10:00, 2023 10-02 10:10, then jump to next day of 2023 10-03 10:00,2023 10-03 10:10. Now I am using <code>resample('10min')</code> to create time series every 10min from 2021 01-01 to 2021 01-02, then using <code>interpolate(method=&quot;slinear&quot;, fill_v...
<python><pandas>
2023-10-04 16:18:37
0
4,338
roudan
77,231,187
15,189,432
Extract date, day, time in single columns out of a dataframe column
<p>How can I convert the dataframe so that I have one column with &quot;Day&quot;, one with &quot;date&quot;, one with &quot;time&quot;? I tried to slide bit can't get the correct output.</p> <pre><code>df = pd.DataFrame({'Datum': [&quot;Samstag, 12.08.2023Anstoß um 15:30 Uhr&quot;, &quot;Samstag, 19.08.2023Anstoß um...
<python><pandas>
2023-10-04 16:04:14
2
361
Theresa_S
77,231,133
7,252,531
AWS Glue Spark Job Extract Database Table Data in Parallel
<p>Suppose I have this simple AWS Glue 4.0 PySpark job:</p> <pre><code>import sys from awsglue.transforms import * from awsglue.utils import getResolvedOptions from pyspark.context import SparkContext from awsglue.context import GlueContext from awsglue.job import Job args = getResolvedOptions(sys.argv, [&quot;JOB_NAM...
<python><amazon-web-services><apache-spark><pyspark><aws-glue>
2023-10-04 15:55:39
1
1,830
gbeaven
77,230,984
1,920,827
Disable Warnings when executing python code from C# with process class
<p>I'm running a sample Python script through the command prompt:</p> <pre class="lang-py prettyprint-override"><code>import warnings print('Hello, world!') warnings.warn('Geeks 4 Geeks !') </code></pre> <p>Executing script file with warnings:</p> <pre><code>python first_script.py Hello World! </code></pre> <p>Executin...
<python><c#><.net><process>
2023-10-04 15:37:03
0
9,563
Pearl
77,230,983
18,445,352
Why does it take longer to execute a simple for loop in Python 3.12 than in Python 3.11?
<p>Python 3.12 was released two days ago with several new features and improvements. It claims that it's faster than ever, so I decided to give it a try. I ran a few of my scripts with the new version, but it was slower than before. I tried various approaches, simplifying my code each time in an attempt to identify the...
<python><performance>
2023-10-04 15:36:51
1
346
Babak
77,230,902
2,148,773
How to depend on opencv-python OR opencv-python-headless?
<p>In the setup.py file for my package I currently have the line</p> <pre><code>install_requires=['opencv-python'], </code></pre> <p>because my package uses some OpenCV functions. When installing my package, <code>opencv-python</code> is automatically installed as well.</p> <p>But I want to deploy my package sometimes ...
<python><opencv><pip><python-packaging>
2023-10-04 15:24:45
0
6,891
oliver
77,230,830
9,317,361
How to disable password manager in chrome webdriver
<p>I hope you are all having a good day.</p> <p>I have been trying to disable the password manager bubble for the last 3 days now without any luck. The reeason why I want to disable it is because its interfeering with my selenium automation even though it's not supposed to. But since I don't need password manager for m...
<python><selenium-webdriver><webdriver><password-manager>
2023-10-04 15:14:58
3
374
Speci
77,230,733
13,364,925
Python selenium can't click on a checkbox
<p>I'm writing python selenium code to automatic fill the form for testing purpose. But my code always throw exception when I try to click a checkbox. This is the HTML checkbox code:</p> <pre class="lang-html prettyprint-override"><code>&lt;div id=&quot;isManuallyEnterYourAddress&quot; &gt; &lt;div class=&quot;fiel...
<python><selenium-webdriver>
2023-10-04 15:00:05
1
554
dungreact
77,230,366
411,929
SciPy fails to build from source on Mac under CPython 3.9/PyPy on Intel & M1 Macs
<p>I have virtualenvs on both an Intel Mac running Catalina and an M1 Mac running Ventura and a friend has tried on an Intel Mac running Monterey.</p> <p>I am following the build from source instructions from the scipy docs:</p> <p><a href="https://docs.scipy.org/doc/scipy/building/index.html" rel="nofollow noreferrer"...
<python><numpy><scipy><cpython><pypy>
2023-10-04 14:14:08
0
5,041
handloomweaver
77,230,340
17,082,611
SSIM is large but the two images are not similar at all
<p>I want to use the <a href="https://scikit-image.org/docs/0.21.x/api/skimage.metrics.html#skimage.metrics.structural_similarity" rel="nofollow noreferrer">structural similarity index measure</a> for computing the mean structural similarity index between two images: the original one and the reconstructed one.</p> <p>T...
<python><numpy><image-processing><scikit-image><ssim>
2023-10-04 14:11:06
1
481
tail
77,230,239
382,912
python regex breaks with new unicode characters in Mac OS Sonoma filenames
<p>After updating to Mac OS Sonoma, a <a href="https://github.com/kortina/dotfiles/blob/master/s3screenshots/s3screenshots.py#L97" rel="nofollow noreferrer">helper script</a> I had to upload screenshots to s3 has broken.</p> <p>Specifically, this:</p> <pre class="lang-py prettyprint-override"><code>r = r&quot;(\d{4}-\d...
<python><python-3.x><regex><macos-sonoma>
2023-10-04 13:56:23
1
6,151
kortina
77,230,233
1,686,628
pytest: validating __init__ args with mock
<p>I would like to write a test confirming <code>__init__</code> values</p> <pre><code>def test_foo(mocker): mock = Mock() mocker.patch( &quot;Foo.__init__&quot;, return_value=mock ) foo = Foo('bar') mock.assert_called_with('bar') </code></pre> <p>But i get the following error <code>TypeErr...
<python><pytest><python-unittest.mock>
2023-10-04 13:55:02
1
12,532
ealeon
77,230,153
2,562,058
How to squeeze a list of numpy arrays into an existing array?
<p>Consider the following snippet:</p> <pre><code>import numpy as np pos = np.array([1, 3, 4]) arr = np.array([0, 1, 2, 3, 4, 5]) vals = np.array([[-10,10], [-20,20], [99,66]]) </code></pre> <p>I want to squeeze the elements of <code>val</code> into <code>arr</code> in the indices specified by <code>pos</code>. At the...
<python><python-3.x><numpy>
2023-10-04 13:46:43
1
1,866
Barzi2001
77,229,992
12,133,068
snakemake doesn't execute the right rules
<p>I'm using snakemake <code>7.25.0</code>. Sometimes, some of my rules are <strong>not</strong> re-executed after a parameter change. Sometimes it detects a parameter change, and sometimes it doesn't. More generally, I'm experiencing a lot of strange behavior of snakemake, and it's hard to understand when it decides t...
<python><snakemake>
2023-10-04 13:24:35
0
334
Quentin BLAMPEY
77,229,890
2,306,148
train gpt-2 modal with json data
<p>I have a dataset in JSON format that contains questions, options, categories, and correct answers. I would like to train a GPT-2 model on this dataset, but I am getting an error.</p> <p>i got following error: &quot;ImportError: cannot import name 'Dataset' from 'transformers'&quot;</p> <p>I have written the followin...
<python><training-data><gpt-3><gpt-2>
2023-10-04 13:10:46
1
596
Gautam Menariya
77,229,585
4,403,498
Azure mltable throwing ImportError when it is imported in Azure Notebooks in AutoML
<p>I am writing code in the notebooks on Azure AutoML wtih Spark Version 3.2 which means that Python version is 3.8.</p> <p>I have installed the mltable in Azure Notebooks using the command:</p> <pre><code>%pip install -U mltable azureml-dataprep[pandas] </code></pre> <p>Before installing mltable I had already installe...
<python><azure>
2023-10-04 12:32:40
1
719
Syed Shaharyaar Hussain
77,229,540
3,625,533
extract values as columns into dataframe from same dataframe json string
<p>Let have a data frame with json string like below</p> <pre><code>df = pd.DataFrame([{'sno':1, 'values':&quot;[{'a':1, 'b':2,'c':3}]&quot;}, {'sno':2, 'values':&quot;[{'a':4, 'b':5,'c':6}]&quot;}]) </code></pre> <p>Need to get the json string column as new columns in the same dataframe. Tried the b...
<python><pandas><dataframe>
2023-10-04 12:23:55
1
435
user3625533
77,229,506
7,776,781
Adding class getattr behaviour to pydantic v2 BaseModel
<p>I have a library that is essentially a type of ORM. As part of this I have a my own 'Model' class that is to be subclassed by end users of the library to create models that are to be persisted in a nosql database.</p> <p>My base model class inherits from <code>pydantic.BaseModel</code>. One of the features of this l...
<python><python-3.x><orm><pydantic>
2023-10-04 12:18:38
1
619
Fredrik Nilsson
77,229,321
619,754
The default channel for miniforge is default?
<p>Windows 10</p> <p>The installation <a href="https://github.com/conda-forge/miniforge" rel="nofollow noreferrer">instructions for miniforge on github</a> says &quot;... the only difference between Miniforge and Mambaforge was the presence of the mamba Python package. To minimize surprises, we decided to add mamba to ...
<python><conda><mamba>
2023-10-04 11:47:35
2
999
garyp
77,229,228
4,841,654
Appending and Inserting with Dask Arrays giving mismatch between chunks and shape
<p>I have a Dask array with shape <code>(1001,256,1,256)</code> (data over 1001 timesteps with len(x)=len(z)=256 and len(y)=1).</p> <p>I need to pad the x-dimension with arrays of shape <code>(1001,2,1,256)</code>, which I'm attempting with <code>dask.array.insert()</code> and <code>dask.array.append()</code>, which ar...
<python><arrays><numpy><dask>
2023-10-04 11:36:00
1
501
Dave
77,229,227
4,630,773
Python Error TypeError: 'bytes' object cannot be interpreted as an integer when concatenating bytes
<p>Here's my code:</p> <pre><code>with open(&quot;SomeFile&quot;, mode=&quot;rb&quot;) as file: byte = file.read(1) count = 0 previous = [] while byte != b&quot;&quot;: if len(previous) &gt;= 2: addr = bytearray(b'') addr.append(previous[len(previous) - 2]) a...
<python><byte><python-bytearray>
2023-10-04 11:35:55
1
703
cr001
77,229,004
13,924,886
Incorrect Byte Representation in eth_abi
<p>I am in the process of familiarizing myself with Uniswap v3, albeit with limited success thus far. I am attempting to obtain a quote by invoking the function: quoteExactInput(pathBytes, amountinUint256).call()</p> <p>For v3, it is required to specify the path in bytes, which I am doing. However, it seems like there ...
<python><ethereum><web3py>
2023-10-04 11:01:39
0
401
MaTok
77,228,915
9,363,181
Window_all throwing an error with Pyflink Kafka Connector
<p>I am trying to print the <code>datastream</code> by applying the <code>tumbling process window</code> for every <code>5</code> seconds. Since I couldn't implement the custom deserializer for now, I created the process function which returns the result as tuple, and as per this <a href="https://nightlies.apache.org/f...
<python><apache-flink><pyflink>
2023-10-04 10:49:54
1
645
RushHour
77,228,650
5,758,423
How to control Python's += operator to update dictionary values in-place?
<p>Consider the following:</p> <pre class="lang-py prettyprint-override"><code>d = dict(a=(1,2)) d['a'] += (3,4) assert d == {'a': (1, 2, 3, 4)} # and yet assert not hasattr(tuple, '__iadd__') </code></pre> <p>The way I parse this is that <code>(1, 2)</code> is first retrieved, then, since tuples are immutable, Python...
<python>
2023-10-04 10:09:16
1
2,432
thorwhalen
77,228,579
16,155,080
FastAPI Background Tasks execute tasks in LIFO order
<p>I'm using FastAPI BackgroundTasks and trying to get it to execute tasks in background in a given order.</p> <p>For example, if I request my endpoint that creates Tasks with the following order <code>request1 - request2 - request3</code>, I am expecting them to be executed in the same order. Unfortunately, the tasks ...
<python><fastapi><fifo>
2023-10-04 09:58:42
1
641
Jules Civel
77,228,433
2,893,518
Problem in converting a Python code to Delphi
<p>I need to convert a Python code to Delphi but I cant.</p> <p>The Python code is:</p> <pre><code>def crc32(data: bytes, initial): crc = initial for x in data: for k in range(8): if ((crc ^ x) &amp; 0x01) == 1: crc = crc &gt;&gt; 1 crc = crc ^ 0x04c11db7 else: cr...
<python><delphi><crc32>
2023-10-04 09:39:10
1
529
elcharlie
77,228,389
10,353,865
Broadcasting when setting on a boolean slice of a DataFrame gives weird results
<p>Consider the following code:</p> <pre><code>import numpy as np import pandas as pd df = pd.DataFrame( {&quot;AAA&quot;: [4, 5, 6, 7], &quot;BBB&quot;: [10, 20, 30, 40], &quot;CCC&quot;: [100, 50, -30, -50]} ) df[[True, False, False, True]] = np.array([2,5]).reshape(2,1) df AAA BBB CCC 0 2 2 2 1 ...
<python><pandas><array-broadcasting>
2023-10-04 09:33:56
1
702
P.Jo
77,228,378
1,307,905
dataclasses use InitVar default to set instance attribute
<p>When you provide a default for an <code>InitVar</code> typed variable in a dataclass, the attribute for that variable is set (actually, for variables that lack a default the attribute seems to be actively deleted in <code>dataclasses:_process_class()</code>).</p> <pre><code>from dataclasses import dataclass, InitVar...
<python><default-value><python-dataclasses>
2023-10-04 09:32:39
0
78,248
Anthon
77,228,256
2,173,320
python textual - run a loop besides the main loop
<p>I'm using <a href="https://github.com/Textualize/textual" rel="nofollow noreferrer">textual</a> to display a ui in my console window. I start my class extending textual's App class by myclass.run(). Since I'm analyzing a camera signal using opencv, I now want to introduce a second loop that runs as long as the app r...
<python><multithreading><textual>
2023-10-04 09:13:41
1
1,507
padmalcom
77,228,235
20,266,647
Different batch limits for Cassandra and Scylla, Err - 2200, Batch too large
<p>I used standard 'cassandra-driver' for access to Cassandra and Scylla for insert/udpate data via BatchStatement. I updated data via batch (~500 rows) and I got only for Cassandra this error (everything work fine for Scylla):</p> <pre><code>Error from server: code=2200 [Invalid query] message=&quot;Batch too large&qu...
<python><cassandra><scylla>
2023-10-04 09:10:00
2
1,390
JIST
77,227,962
2,520,186
How to incorporate `pooch` with scipy.datasets?
<p>I am trying to use the <code>ascent</code> image data from <code>scipy.datasets</code>. My code on the Jupyter Notebook:</p> <pre><code>import scipy.datasets import pooch !pip show pooch ascent = scipy.datasets.ascent() ascent.shape </code></pre> <p>When I run this, I find a version of has been successfully installe...
<python><jupyter-notebook><scipy>
2023-10-04 08:26:43
1
2,394
hbaromega
77,227,902
15,671,914
How to make LangChain's chatbot answer only from the knowledge base I provided? It shouldn't have access to OpenAI's GPT-3.5 knowledge base
<p>I have the following chatbot which answers questions about the knowledge base <code>docs</code> and retrieves the source documents it got its answers from.</p> <pre><code>import os from langchain.embeddings.openai import OpenAIEmbeddings from langchain.vectorstores import FAISS from langchain.chains import Retrieval...
<python><openai-api><langchain><py-langchain>
2023-10-04 08:16:41
2
385
Blue Cheese
77,227,897
18,769,241
How to adjust sensitivity of y-axis?
<p>I have these y-axis values that I want to plot each on a x-tick using a bar plot to show the difference (the first below value for the x-tick 1, the second value for x-tick 2 and the third for the x-tick 3)</p> <pre><code>0.9999893294851471 0.9999997569910387 1.0 </code></pre> <p>for now I am trying to get helped b...
<python><matplotlib>
2023-10-04 08:15:55
2
571
Sam
77,227,895
1,188,594
Polars SQL Context filter by date or datetime
<p>I'm trying to write a query against parquet using Polars SQL Context. It's working great if I pre-filter my arrow table by date. I cannot figure out how to use date in the SQL query.</p> <p>works:</p> <pre><code>filters = define_filters(event.get(&quot;filters&quot;, None)) table = pq.read_table( f&quot;s3://m...
<python><python-polars><rust-polars>
2023-10-04 08:15:22
2
813
Stephen Lloyd
77,227,671
8,253,860
How to create a singleton design inside a function scope in python?
<p>I have a singleton class for tracking events. The design is something like this.</p> <pre><code>class Events: def __new__(cls): # Ensure singleton if not hasattr(cls, &quot;instance&quot;): cls.instance = super(Events, cls).__new__(cls) return cls.instance def __init__(se...
<python><python-3.x>
2023-10-04 07:41:35
3
667
Ayush Chaurasia
77,227,291
1,401,472
Building a Document-based Question Answering Assistant with OpenAI's LLM - Cost-effective Strategies for Testing
<p>I'm working on a project that involves building a question-answering assistant using OpenAI's large language model (LLM). My goal is to make this assistant capable of answering questions related to a collection of informative documents.</p> <p>I have already built this assistant using python + langchain + openai and...
<python><openai-api><langchain><large-language-model>
2023-10-04 06:35:57
0
2,321
user1401472
77,227,241
3,886,675
Is there a lint rule for python that automatically detects list +operator concatenation and suggests using spread
<p>For me the following</p> <pre class="lang-py prettyprint-override"><code>extras = [&quot;extra0&quot;, &quot;extra1&quot;] func_with_list_arg([ &quot;base0&quot;, &quot;base1&quot;, ] + extras) </code></pre> <p>is nicer to read with a spread operator like the following</p> <pre class="lang-py prettyprint-ove...
<python><pylint><ruff>
2023-10-04 06:27:43
1
448
Tomi Kokkonen
77,227,153
6,018,303
Pyscript using classes in the Python source code
<p>I am trying to rewrite the <a href="https://docs.pyscript.net/2023.09.1.RC2/beginning-pyscript/" rel="nofollow noreferrer">Polyglot - Piratical PyScript</a> application using in <code>main.py</code> a <code>Pirate</code> class instead of the original <code>translate_english</code> function.</p> <p><strong><code>pysc...
<python><pyscript>
2023-10-04 06:12:10
0
509
PedroBiel
77,227,060
5,369,777
Python39 and pymysql
<p>I've just tried upgrading up to python3.9.5 from 3.7 and I'm encountering a strange behavior that I can't quite nail down. It involves pandas1.3 and pymysql1.1.0. The strange part is that the dataframes lengths' are the same, but the data is just not right in the 3.9 executed version.</p> <p>I'd really like to move ...
<python><python-3.x><pandas><python-3.7><pymysql>
2023-10-04 05:54:18
0
666
Derek_P
77,227,040
992,421
Spark job and optimization
<p>I am trying to run a spark job with code as below</p> <pre><code>def call_stripes(rdd,voc,bas): vocabulary =sc.broadcast(voc) basis=sc.broadcast(bas) def create_stripes(words): vocab=set() basis=set() basis_set = set(words).intersection(basis.value) vocab_set = set(words)....
<python><apache-spark><pyspark>
2023-10-04 05:49:50
1
850
Ram
77,226,827
1,041,958
How can I have a minimum period greater than the rolling window in a Pandas dataframe?
<p>I have multiple dataframes that have a column called <code>SIZE</code>. I need to calculate the rolling average of the size column on each Dataframe with different rolling windows; <strong>HOWEVER</strong> I want them all to require <code>x</code> number of valid (non-zero) observations to have passed before genera...
<python><pandas>
2023-10-04 04:49:00
1
955
StormsEdge
77,226,687
8,516,987
FlaskForm, JWT Extended
<p>Looking for some help, clarity and to maybe get pointed in the right direction regarding python flask wtforms and flask jwt extended.</p> <p>I have a login route that works just fine. My protected GET routes work fine as well. However, when I submit a post request, I get this error: flask_jwt_extended.exceptions.CSR...
<python><flask><flask-wtforms><flask-jwt-extended>
2023-10-04 04:08:49
1
642
itsPav
77,226,579
7,188,690
Unable to get the dictionary based on the first value of the dictionary
<p>I have a dictionary is this format. This is a spark representation :</p> <pre><code>[4401188189705 -&gt; [4.0, 1.0], 44011125835787 -&gt; [5.0, 1.0], 44011142622982 -&gt; [12.0, 1.0], 4401192401665 -&gt; [7.0, 1.0], 4401171339786 -&gt; [5.0, 1.0]] </code></pre> <p>I am trying to sort it in the descending order of th...
<python><dictionary>
2023-10-04 03:38:01
0
494
sam
77,226,549
13,238,846
Limit Memory Access on LangChain Bot
<p>I'm creating a langchain chatbot (Conversationl-ReACT-description) with zep long term memory and that bot has access to real-time data. How do I prevent use the memory when same query asked again few minutes later?</p>
<python><langchain>
2023-10-04 03:26:23
1
427
Axen_Rangs
77,226,540
3,398,536
Tensorflow Keras not fitting the model - Cannot add tensor to the batch: number of elements does not match. Shapes are: [tensor]: [13], [batch]: [5]
<p>i'm trying to use Tensorflow Keras for captcha solver per the example of the package example and using my own data set to train it.</p> <p>I try a couple of suggestions in StackOverflow do not find solution.</p> <p>The error keep showing :</p> <pre><code>Cannot add tensor to the batch: number of elements does not ma...
<python><tensorflow><keras><deep-learning>
2023-10-04 03:22:39
1
341
Iron Banker Of Braavos
77,226,390
8,387,921
How to iterate through each url form txt file and download multiple file
<p>I have a txt file that contains more than 2000 the download links of various zip files. What is the best way to read text file and iterate through each line and download all files one by one. opening 2000 tabs will probably crash the pc, so i only want to download the file after first is finished.</p> <p>The example...
<python><python-3.x><selenium-webdriver><tkinter><beautifulsoup>
2023-10-04 02:30:25
1
399
Sagar Rawal
77,226,367
861,757
What's the best way to calculate Tp,q,r = Sp,q Sp,r in NumPy?
<p>I'm trying to turn a series of m input sequences with n items each (s<sub>m,n</sub>) into a tensor where t<sub>p,q,r</sub> = s<sub>p,q</sub>s<sub>p,r</sub></p> <p>While my code does work, I feel there must be a better solution. Here's what I got.</p> <pre class="lang-py prettyprint-override"><code># nseqs is the num...
<python><numpy>
2023-10-04 02:19:40
2
728
Paulo Mendes
77,226,161
1,302,018
Airflow 2.7.1 - Two dags scheduled on same time but not both will run at same time
<p>I have 2 dags that are scheduled to run every 5 minutes. The issue i'm having is not both of them will simultaneously run. Please see below.</p> <pre><code>*/5 * * * * scheds of both dagA with task1, task2, task3 dabB with task1, task2 ex: dagA.task1 (running) dagB (not even have queues) dagA.task1 (completed) dag...
<python><airflow>
2023-10-04 00:54:21
1
669
nickanor
77,226,153
2,759,316
Custom Thread names with ThreadPoolExecutor (NOT just the prefix)?
<p>I've found a couple threads with a pre-search, but they ALL (including online tutorials) state the solution is to use the thread_name_prefix parameter, which is NOT what I want.</p> <p>I'm using the code below which works fine. As expected, all threads are named as &quot;Access Rule Deletion_XXX&quot;. What I am try...
<python><python-3.x><multithreading><threadpoolexecutor>
2023-10-04 00:49:53
0
1,241
Source Matters
77,226,084
13,142,245
Python asyncio for triggering event w/o waiting for response
<p>Suppose I have an event driven architecture and two functions, named outer and inner. Outer will call inner but outer does not require the response from inner. As soon as the request has been sent to inner, outer can terminate.</p> <p>Can this be accomplished in Python using asyncio? Is it as simple as not using the...
<python><async-await><python-asyncio>
2023-10-04 00:16:16
1
1,238
jbuddy_13
77,225,892
258,418
Typing function object property
<p>I have to implement a protocol which sends a message, and gets a response in turn. Usually, the response is instant but in some cases the message sets the device into the correct state to process other messages, and only after processing the other messages will the device respond to the initial message setting the s...
<python><python-typing><pyright>
2023-10-03 22:54:05
1
5,003
ted
77,225,888
3,387,716
SAM alignment: Extract specific region in the query sequence and its enclosing parts in the CIGAR string
<p>I need to perform the local alignment of a given region of a DNA sequence for which a global alignment was made, and update the corresponding part of the global CIGAR string.</p> <p>The steps would be as follow:</p> <p><strong>1.</strong> Extract the region of interest from the &quot;query&quot; sequence according t...
<python><bioinformatics><text-processing>
2023-10-03 22:52:39
1
17,608
Fravadona
77,225,488
2,642,356
VSCode: "fatal error: Python.h: No such file or directory" even with python-dev installed
<p>Using VSCode (which I'm quite new to) on Ubuntu 20.04, I wish to build a C-extension (actually C++ extension) to Python.</p> <p>I'm trying to build the following MWE:</p> <pre><code>#include &lt;numpy/arrayobject.h&gt; int main() {return 0;} </code></pre> <p>However the build fails on <code>#include &lt;numpy/arrayo...
<python><c++><visual-studio-code><python-extensions>
2023-10-03 21:00:08
0
1,864
EZLearner
77,225,147
12,144,448
Improving model when Coefficient of Determination (RΒ²)is inconsistent
<p>Many examples in the literature state that the value of the coefficient of determination (RΒ²) is a value between 0 and 1, but some cases in my regression model yielded negative results. While researching on the StackOverflow community and also reading the Sklearn library documentation, I found some information indic...
<python><machine-learning><statistics>
2023-10-03 19:52:36
0
531
Liam Park
77,225,146
2,865,313
Using `arcgisbinding` and `reticulate` to run R code and python within a Quarto document
<h1>Background</h1> <p>I am a long-time R user but completely new to python. I have used the <code>arcgisbinding</code> package successfully for several years and I am happy with how it is working - I am connecting to my AGOL account there and exporting file geodatabases (fGDB) without issue.</p> <p>Recently I found a ...
<python><r><quarto><reticulate>
2023-10-03 19:52:29
0
5,950
Nova
77,225,048
9,869,695
sklearn requirements installation with pip: ensure that binary wheels are used
<p>In the sklearn <a href="https://scikit-learn.org/stable/install.html#installing-the-latest-release" rel="nofollow noreferrer">installation guide</a> for the latest version (1.3.1) it mentions that you can install dependencies with pip, but says</p> <p><strong>&quot;When using pip, please ensure that binary wheels ar...
<python><pip><sklearn-pandas>
2023-10-03 19:32:51
1
1,514
Arran Duff
77,225,046
11,107,192
Handling Large Payloads in CosmosDB with Azure Durable Functions
<p>We have encountered an issue with a function responsible for writing data chunks into CosmosDB. The problem arises when one of the items within these chunks exceeds 2MB in size, resulting in the following exception:</p> <pre class="lang-bash prettyprint-override"><code>Microsoft.Azure.DocumentDB.Core: Message: {&quo...
<python><azure-cosmosdb><azure-durable-functions>
2023-10-03 19:32:45
0
717
basquiatraphaeu
77,224,942
10,430,394
Installing OpenBabel for Python isn't working
<p>I have read all the related posts and they aren't helping. Like <a href="https://stackoverflow.com/questions/65537365/how-to-install-openbabel">this</a> one is just a defunct that leads nowhere. I have installed the binary for Windows form <a href="https://github.com/openbabel/openbabel/releases" rel="nofollow noref...
<python><pip><openbabel>
2023-10-03 19:12:14
1
534
J.Doe
77,224,940
10,534,633
How to smooth Venn diagram edges
<p>I have a Venn diagram created in Python but I don't know how to smooth all (also the internal ones) the edges.</p> <p><a href="https://i.sstatic.net/UrcLw.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/UrcLw.png" alt="enter image description here" /></a></p> <p>My code:</p> <pre class="lang-py pretty...
<python><matplotlib><visualization><venn-diagram><matplotlib-venn>
2023-10-03 19:11:52
1
1,230
maciejwww
77,224,749
11,203,574
What is the difference between "mouse_event" and "SendMessage"?
<p>I have two functions that perform clicks using pywin32.</p> <p>One that uses <code>win32api.mouse_event</code>:</p> <pre><code>def click_1(hwnd, x, y): win_activate(hwnd) win32api.SetCursorPos((x, y)) time.sleep(.1) win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0) time.sleep(.1) win...
<python><winapi><pywin32><win32gui>
2023-10-03 18:36:09
0
377
Aurelien
77,224,603
2,289,030
Is there a way to check what object a decorated classmethod binds to?
<p>I want to do some runtime type checking on a property that's decorated with <code>@classmethod</code> (making sure the classmethod decorates a property and not some other thing), but I don't see a way to do this through the &quot;normal&quot; ways (inspection with <code>vars()</code> or <code>dir()</code> or <code>....
<python><reflection><python-decorators>
2023-10-03 18:07:41
1
968
ijustlovemath
77,224,564
5,256,563
Napari doesn't display full resolution
<p>I want to visualize a large tiff (65Kx35K) files using <code>Napari 4.18</code> but Napari does not display the image at full resolution. Instead at best it display a lower and pixelized image.</p> <p>See the attached image where I compare the display between Napari (left) and ImageJ (right). We can see that resolut...
<python><python-napari>
2023-10-03 18:02:04
1
5,967
FiReTiTi
77,224,505
2,205,930
Python3: c-type segfault from multithreaded C shared library
<p>I've looked at other StackOverflow related questions and answers and followed the information given. I am still having trouble.</p> <p>Running Python3 on Linux which accesses a shared C library (.so). The C library will spin up threads as needed. I am having as issue with segmentation faults when accessing a C API w...
<python><c><multithreading><segmentation-fault><shared-libraries>
2023-10-03 17:51:49
1
1,086
user2205930
77,224,498
10,098,481
Convert string to float when the exponent is also a float
<p>Converting a string to a float is easy when said string is 10E-3:</p> <pre><code>input_str = &quot;10E-3&quot; output_float = float(input_str) </code></pre> <p>However, this breaks when the exponent is a non-integer. For instance:</p> <pre><code>input_str = &quot;10E-3.5&quot; output_float = float(input_str) </code>...
<python><python-3.x>
2023-10-03 17:50:29
2
723
Wychh
77,224,476
7,563,690
Why is my Python script is not dealing with indexes properly when I am trying to reformat the data
<pre><code>import pandas as pd cleaned_df = pd.read_csv('filepath/test.csv', index_col=1, parse_dates=True) id_list = list(set(cleaned_df.loc[:, 'id'].tolist())) df_list = [] # Create an empty list to store individual dataframes for id in id_list: id_df = cleaned_df[cleaned_df['id'] == id].l...
<python><pandas>
2023-10-03 17:45:58
1
475
Luka Vlaskalic
77,224,410
22,407,544
Why is my form calling the wrong Django view?
<p>The flow of my app is as follows: A file is submitted on the transcribe.html page first which then redirects to the transcibe-complete.html page where the user can click to beginning transcription.</p> <p>Why is the 'transcribeSubmit' view being called instead of the 'initiate_transcription' view when the user clic...
<javascript><python><html><django>
2023-10-03 17:34:37
1
359
tthheemmaannii
77,224,402
20,830,264
Render the Django REST Framework uploading system with an HTML script
<p>I have developed a simple file-upload system using Django REST Framework using this tutorial <a href="https://www.section.io/engineering-education/how-to-upload-files-to-aws-s3-using-django-rest-framework/" rel="nofollow noreferrer">How to upload files to AWS S3 with Django</a>. Basically the system allows user to u...
<python><html><django><amazon-s3><django-rest-framework>
2023-10-03 17:33:40
0
315
Gregory
77,224,368
9,245,201
`__init__` called twice?
<p>Here is a simplified Python code:</p> <pre><code> class Base: __possible_types__ = {} def __new__(cls, *args, **kwargs) -&gt; type: # pop the `__type__` argument because it # should be passed to the class `__init__` type_ = kwargs.pop(&quot;__type__&quot;, None) if type_ is ...
<python>
2023-10-03 17:27:12
3
720
dsal3389
77,224,363
1,753,640
Langchain streaming output using a Flask app
<p>I have managed to stream the output successfully to the console but i'm struggling to get it to display in a webpage.</p> <p>This is the code to invoke RetrievalQA and get a response:</p> <pre><code> def get_openai_answer(query, chroma_folder, search_size): handler = StreamingStdOutCallbackHandler() ...
<python><flask><openai-api><langchain>
2023-10-03 17:26:25
1
385
user1753640
77,224,177
3,826,115
How to specify map extent in GeoViews with map tiles in the background
<p>If I have a GeoDataFrame of point geometries, I can plot it up with GeoViews and specify the longitude extent of the display like this:</p> <pre><code>import geopandas as gpd import geoviews as gv import numpy as np gv.extension('bokeh') gdf = gpd.GeoDataFrame(geometry = gpd.points_from_xy(np.linspace(-88, -82, 100...
<python><gis><holoviews><geoviews>
2023-10-03 16:53:29
0
1,533
hm8
77,223,972
6,347,469
Flask App Accessible on Localhost but Not on Private IP Address
<p>I'm making a Flask app and trying to make it accessible on my local network to test it on my phone. I run the app with the following settings to make it externally visible on my local network:</p> <pre><code>if __name__ == '__main__': app.run(host=&quot;0.0.0.0&quot;, port=5000, debug=True, threaded=False) </cod...
<python><windows><flask><network-programming><firewall>
2023-10-03 16:23:03
0
493
Paul Miller
77,223,969
1,056,563
Spark/pyspark on same version but "py4j.Py4JException: Constructor org.apache.spark.api.python.PythonFunction does not exist"
<p>I have a properly sync'ed <code>pyspark</code> client / <code>spark</code> installation: both versions are 3.3.1 [ shown below]. The full exception message is:</p> <blockquote> <p>py4j.Py4JException: Constructor org.apache.spark.api.python.PythonFunction([class [B, class java.util.HashMap, class java.util.ArrayList...
<python><apache-spark><pyspark><pycharm>
2023-10-03 16:22:41
1
63,891
WestCoastProjects
77,223,721
11,167,163
Is it possible to split HTML view and Python back-end across different servers (IIS) in Django?
<p>I have a <code>Django</code> application where I want to separate the <code>HTML</code> views and the <code>Python</code> back-end logic into two different servers for architectural and security reasons. Specifically, I want one server to handle all the <code>HTML</code> rendering and another server to handle the Py...
<python><django><iis>
2023-10-03 15:44:24
1
4,464
TourEiffel
77,223,620
10,755,032
Python requests and Graphql API: How to use variables?
<p>I am working on creating users on my wiki.js using graphql API and python's request package. I am able to create a user normally(hard coded) but I want to use variables. Here is the code I tried:</p> <pre><code># we have imported the requests module import requests # defined a URL variable that we will be # using...
<python><graphql>
2023-10-03 15:29:11
0
1,753
Karthik Bhandary
77,223,538
226,342
Can I make my dash app return static responses using curl
<p>I've defined a multi page Dash app:</p> <p>app.py:</p> <pre><code>import dash import dash_bootstrap_components as dbc from dash import html app = dash.Dash(__name__, use_pages=True, suppress_callback_exceptions=True) ... app.layout = dbc.Container( [navbar, nav, dash.page_container] ) if __name__ == &quot;__ma...
<python><curl><plotly-dash>
2023-10-03 15:15:27
1
2,005
Henrik
77,222,971
3,092,490
Extracting specific JSON property into CSV using Python
<p>I have a JSON which is in nested form. I would like to extract billingcode and rate from json and put into csv using pandas python.</p> <pre><code>{ &quot;TransactionId&quot;: &quot;1c9cc4b9-a0e1-4228-b382-b244a7674593&quot;, &quot;Number&quot;: &quot;1022&quot;, &quot;Version&quot;: 534, &quot;StartDateTime&quot;: ...
<python><json><pandas>
2023-10-03 14:00:33
2
381
user176047
77,222,906
7,757,135
How can swap columns into rows and maintain its values using Pandas?
<p>I have a problem when working with a tabular data series in Pandas. In particular, I have a DataFrame with a structure like the following:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>date</th> <th>H01</th> <th>H02</th> <th>...</th> <th>H24</th> <th>Variable</th> <th>station_code</th>...
<python><pandas><dataframe><pivot>
2023-10-03 13:52:24
1
1,760
JuMoGar
77,222,802
1,062,139
Python static typing: How to tell the static type checker that my function has checked the type?
<p>I have the following code:</p> <pre><code>ExprType: TypeAlias = int | str | datetime def check_type(value: ExprType, expected_type: type[ExprType]): if not isinstance(value, expected_type): raise TypeError(f&quot;Expected {expected_type}, but got {type(result)}.&quot;) value: ExprType = 0 # ... more p...
<python><python-typing>
2023-10-03 13:39:35
3
2,118
peter.slizik
77,222,723
2,562,058
How to use np.insert in iterations?
<p>I want to insert an array to some specific positions of another array. For example, say that you have</p> <pre><code>import numpy as np pos = np.array([1, 3, 4]) arr = np.array([0, 1, 2, 3, 4, 5]) vals = np.array([-1,-1]) </code></pre> <p>I want that <code>vals</code> is inserted to <code>arr</code> in the positio...
<python><python-3.x><numpy>
2023-10-03 13:31:08
2
1,866
Barzi2001
77,222,716
17,082,611
model.load_weights() does not load the weights I stored previously using model.save_weights()
<p>I aim to save and then load the weights of my model using <a href="https://www.tensorflow.org/tutorials/keras/save_and_load?hl=en#manually_save_weights" rel="nofollow noreferrer"><code>save_weights</code> and <code>load_weights</code> functions</a>.</p> <p>In order to show you a minimal reproducible example, these a...
<python><tensorflow><machine-learning><keras>
2023-10-03 13:30:11
1
481
tail
77,222,538
2,050,158
Need to downgrade to Werkzeug==2.3.7 from Werkzeug==3.0.0 to avoid werkzeug/http.py TypeError: cannot use a string pattern on a bytes-like object
<p>I have a docker image flask web application which is generating the error below after rebuilding the docker image and deploying the docker container from it. Before today, the containers from the images built using the docker file and requirements.txt file as this image ran without any errors. I suspect there may ha...
<python><flask><flask-session>
2023-10-03 13:06:05
3
503
Allan K
77,222,535
3,948,766
Why is the bind method not working in python kivy
<p>I am at a complete loss, why is the <code>on_packet</code> method not being called in either of the classes. I have plenty of other bindings in my app but for some reason these do not seem to work??</p> <pre class="lang-py prettyprint-override"><code>from kivy.uix.checkbox import CheckBox from kivy.uix.switch impor...
<python><kivy>
2023-10-03 13:05:28
1
356
Infinity Cliff
77,222,463
1,418,090
Is there a way to change Adam to legacy when using Mac M1/M2 in TensorFlow?
<p>I am running a Deep Learning model, but sometimes I use my work PC and sometimes my Mac. The problem is that whenever using the Mac (with an M2 chip), I get this warning message:</p> <blockquote> <p>WARNING:absl: At this time, the v2.11+ optimizer <code>tf.keras.optimizers.Adam</code> runs slowly on M1/M2 Macs, plea...
<python><macos><tensorflow><deep-learning><tensorflow2.0>
2023-10-03 12:56:31
1
438
Umberto Mignozzetti
77,222,375
2,386,113
QR decomposition results in Python (using numpy) and in C++ (using Eigen) are different?
<p><strong>Sample QR decomposition Code (Python):</strong></p> <pre><code>import numpy as np import matplotlib.pyplot as plt # Define the 2D array data = np.array([ [12, -51, 4], [6, 167, -68], [-4, 24, -41], [-1, 1, 0], [2, 0, 3] ], dtype=float) # specify data type as 'float' to match C++ double ...
<python><c++><math><eigen><qr-decomposition>
2023-10-03 12:44:01
1
5,777
skm
77,222,210
10,533,225
Assign column from one dataframe to another dataframe using pyspark
<p>I need to assign <code>item_name</code> from first daframe to second dataframe by creating a new column base on first dataframe.</p> <p>This is the sample dataframe #1</p> <p><a href="https://i.sstatic.net/kOKZc.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/kOKZc.png" alt="enter image description he...
<python><pyspark>
2023-10-03 12:20:17
2
583
Tenserflu
77,222,170
8,040,369
Remove df rows if based on some condition in column values
<p>I have a data frame which has 2 columns datetime and value as shown below.</p> <pre><code> Datetime Value ============================================== 10-03-2023 00:00:00.000 10 10-03-2023 01:00:00.000 20 10-03-2023 04:00:00.000 50 </code></pre> <p>So to impute the missing ent...
<python><pandas><dataframe><datetime>
2023-10-03 12:15:16
0
787
SM079
77,222,164
13,508,045
Data bar length isn't correct for 0% and 100%
<p>I have an excel sheet for which I want to add a <code>DataBarRule</code>. Technically it works but in excel it doesn't look correct. The type of the data bar is percent but for 0% the data bar doesn't disappear and for 100% it doesn't fill out the cell completely. For 50% it looks correct.</p> <p><a href="https://i...
<python><excel><openpyxl>
2023-10-03 12:13:59
1
1,508
codeofandrin
77,222,122
4,355,873
Run python with nodemon in docker compose run/debug configuration
<p>Is there a way to set up a <strong>python run/debug configuration</strong> with docker compose in <strong>PyCharm</strong> that uses <code>nodemon</code> to start the script? I want to use <code>nodemon</code> for the hot reload functionality in my python code. I’ve managed to set up it working with docker compose/d...
<python><docker><docker-compose><pycharm>
2023-10-03 12:06:48
1
379
GameAtrix1
77,222,090
188,331
HuggingFace Trainer is not using GPU
<p>I wrote a simple trainer code as follows:</p> <pre><code>from typing import List from tokenizers import ( decoders, models, trainers, Tokenizer, Regex, NormalizedString, PreTokenizedString ) tokenizer = Tokenizer(models.WordPiece(unk_token=&quot;[UNK]&quot;)) special_tokens = [&quot;[U...
<python><huggingface-tokenizers>
2023-10-03 12:01:44
0
54,395
Raptor
77,221,923
10,243,896
Embedding Python libraries in C# project
<p>I need to use a specific Python library (SciPy) in a C# application. Application will be deployed to machines that do not have Python installed, and it should not be a prerequisite. I am trying to use <a href="https://github.com/pythonnet/pythonnet" rel="nofollow noreferrer">Pythonnet</a> to integrate Python into my...
<python><c#><python.net>
2023-10-03 11:37:51
1
428
Justin8051
77,221,899
22,466,650
How to scatter plot the intersecting values from arrays with different shapes
<p>I have two arrays and I need to use them in a scatter plot with the consideration of their membership. For example, the first row of <code>B</code> is located at the second row of <code>A</code>, from column 2 to 3.</p> <pre class="lang-py prettyprint-override"><code>#A array([[ 0, 1, 2, 3], [ 4, 5, 6, ...
<python><numpy><matplotlib><scatter-plot><intersection>
2023-10-03 11:34:51
1
1,085
VERBOSE