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,582,244
6,175,092
Using python in Blender how to extrude and rotate?
<p>I need to extrude a mesh successively and rotate the mesh at every step. This can be done in the user interface as shown below.</p> <p><a href="https://i.sstatic.net/FLOTe.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/FLOTe.png" alt="enter image description here" /></a></p> <p>I have accomplished t...
<python><blender><mesh>
2023-11-30 23:33:28
1
585
doby
77,581,957
3,438,239
Seaborn's histplot doesn't match Matplotlib's hist when using log_scale=True
<p>I'm probably making a stupid mistake, but here's how to reproduce:</p> <ol> <li>Generate random variables based on log-normal distribution</li> <li>Fit a log-normal distribution to the synthetic data</li> <li>Compute the probability distribution function using the fitted parameters</li> <li>Plot histogram of synthet...
<python><scipy><distribution><scipy.stats>
2023-11-30 22:02:58
1
336
Blademaster
77,581,891
12,708,740
Identify text with span elements using Python BeautifulSoup
<p>I have html text that I am trying to clean up using &quot;soup&quot;. However, I need to not only identify which text segments are contained by certain span elements of the class='highlight', but also maintain their order in the text.</p> <p>For example, here example code:</p> <pre><code>from bs4 import BeautifulSou...
<python><html><pandas><beautifulsoup>
2023-11-30 21:45:04
1
675
psychcoder
77,581,779
820,011
running django makemigrations twice generates two migrations, one to add a field and one to alter that same field … to itself
<p>One would expect that running <code>makemigrations</code> twice in a row would be a no-op for the second one, but in fact I get two migrations, and the second one can't be applied (an exception is thrown trying to access <code>None.startswith</code>). Output somewhat sanitized:</p> <pre><code>% ./manage.py makemigra...
<python><django>
2023-11-30 21:20:17
1
2,535
ben w
77,581,696
19,808,508
Google Cloud Error Reporting showing extraneous errors
<p>I have a fastapi application hosted on google cloud run. When exceptions are thrown, google cloud logs and error reporting show multiple different errors in packages like uvicorn, anyio (EndOfStream), and starlette. These errors aren't very useful to me, because they aren't the actual error thrown from my code. Thes...
<python><fastapi><google-cloud-error-reporting>
2023-11-30 21:05:41
1
451
Jasper Madrone
77,581,497
1,471,980
how do perform aggregate functions to pandas data frame
<p>I have this data frame:</p> <pre><code>df Device int In Out Bw_in Bw_out Usa123 Eth1 1000 500 100 75 Usa123 Eth0 10000 700 200 80 Emea01 Wan1 1000 500 150 90 Emea01 Eth3 2000 1000 200 70 </code></pre> <p>I want to summarize the Bandwidth usage data in terms of % usage per device, re...
<python><pandas>
2023-11-30 20:28:50
4
10,714
user1471980
77,581,284
5,137,526
Setting up mitmproxy and wireguard using mitmproxy's python API
<p>I'm trying to configure a mitmproxy instance to use wireguard to route through a remote server, where the data is processed with an Addon(). Essentially I would like to run the following command with custom keys through python:</p> <pre><code>mitmdump -s addon.py --mode wireguard </code></pre> <p>But to use my own k...
<python><mitmproxy><wireguard>
2023-11-30 19:45:59
1
331
thansen0
77,581,214
12,162,229
Produce this list [0, 2, 6, 12, 20, 30, 42, 56, 72, 90] using list comprehension syntax
<p>I can produce the list <code>[0, 2, 6, 12, 20, 30, 42, 56, 72, 90]</code> using the following code:</p> <pre><code>x = [] y = 0 for i in range(2,21,2): x.append(y) y += i </code></pre> <p>However I'm not sure how to convert this into list comprehension syntax of the form</p> <p>[expression for value in itera...
<python><list-comprehension><sequence>
2023-11-30 19:31:41
5
317
AColoredReptile
77,581,033
3,861,775
Parallelize inference of ensemble
<p>I used the <a href="https://jax.readthedocs.io/en/latest/notebooks/neural_network_with_tfds_data.html" rel="nofollow noreferrer">this</a> tutorial from JAX to create an ensemble of networks. Currently I compute the loss of each network in a for-loop which I would like to avoid:</p> <pre><code>for params in ensemble_...
<python><jax>
2023-11-30 18:57:01
1
3,656
Gilfoyle
77,580,911
13,135,901
Fast way to check values of one dataframe against another dataframe in pandas
<p>I have two dataframes. df1:</p> <pre><code> Date High Mid Low 1 2023-08-03 00:00:00 29249.8 29136.6 29152.3 4 2023-08-03 12:00:00 29395.8 29228.1 29105.0 10 2023-08-04 12:00:00 29305.2 29250.1 29137.1 13 2023-08-05 00:00:00 29099.9 29045.3 29073.0 18 2023-08-05 20:0...
<python><pandas>
2023-11-30 18:33:03
1
491
Viktor
77,580,901
4,169,571
Draw all 12 axes when using ax.scatter for a 3D scatter plot
<p>I want to draw all 12 axes when using <code>ax.scatter</code> for a 3D scatter plot</p> <p>Here is my code. As you see my axes lines are not matching the range of <code>ax.scatter</code>. How can I achieve that?</p> <p><code>ax.get_xlim(</code>) etc. does not retrieve the exact limits that <code>ax.scatter</code> ha...
<python><matplotlib><axis>
2023-11-30 18:31:37
0
817
len
77,580,785
2,755,648
How much overhead does `python -X importtime` add?
<p>Does anyone know how much slower running <code>python -X importtime [module or file]</code> is vs. <code>python [module or file]</code>?</p> <p>I'm wondering if it's a bad idea to run <code>python -X importtime</code> for production code. The goal is to monitor how slow the imports are in production code, to identif...
<python><cpython>
2023-11-30 18:10:43
1
1,149
sid-kap
77,580,627
6,439,229
Why does assigning a default to a dataclass field, make it into a class attribute?
<p>When you add a field to a python dataclass, it will become a required argument for <code>__init__</code> and it will be an instance attribute. But when you add a default value to a field it becomes a class attribute.</p> <pre><code>from dataclasses import dataclass @dataclass class A: foo: int bar: int = 0 ...
<python><python-dataclasses>
2023-11-30 17:41:17
1
1,016
mahkitah
77,580,556
1,505,259
Importing data from two XML parent nodes to a Pandas DataFrame using read_xml
<p>I am having trouble in importing an XML file to Pandas where I need to grab data from two parent nodes. One parent node (<code>AgentID</code>) has data directly in it, and the other (<code>Sales</code>) has child nodes (<code>Location</code>, <code>Size</code>, <code>Status</code>) that contain data, as given below....
<python><pandas><xml><dataframe><file-io>
2023-11-30 17:33:15
3
11,270
marillion
77,580,402
4,913,108
Quickly create a list of sequential and non-sequential numbers in Python
<p>In R, I can quickly create a list of sequential and non-sequential numbers like so:</p> <pre class="lang-r prettyprint-override"><code>numbers &lt;- c(1:5, 8, 12, 15:19) numbers [1] 1 2 3 4 5 8 12 15 16 17 18 19 </code></pre> <p>Is there a similar method in Python? Everything I've seen seems to require a loop ...
<python>
2023-11-30 17:12:48
1
5,750
Gaurav Bansal
77,580,266
5,159,284
Ray tranformation with column dtype list<element: double not null>
<p>My dataset schema is the following in ray:</p> <pre><code>Column Type ------ ---- x_1 list&lt;element: double not null&gt; x_2 list&lt;element: double not null&gt; y int32 </code></pre> <p>Right now if I try to convert this to a tensorflow object, I get the following dtypes:</p> <pre><code>data.to_tf...
<python><tensorflow><ray>
2023-11-30 16:54:33
1
2,635
Prabhjot Singh Rai
77,580,216
867,124
Starred unpacking in subscription index
<p>Consider the following code:</p> <pre><code>class A: def __getitem__(self, key): print(key) a = A() a[*(1,2,3)] </code></pre> <p>With python 3.10.6, I get a <code>SyntaxError : invalid syntax</code> at the starred unpacking on the last line. On python 3.11.0, however, the code works fine and prints <code...
<python>
2023-11-30 16:48:43
2
1,037
TonioElGringo
77,580,168
3,429,916
pybind11 - Convert type B to const A* in C++ but not in python
<p>I have a polymorphic base class A and a polymorphic class B derived from A. The virtual inheritance must be and I expose both classes to python, so I will have automatic down-casting on the python side. But I explicitly do not specify that A is the parent class of B (as shown in <a href="https://pybind11.readthedocs...
<python><c++><pybind11>
2023-11-30 16:43:27
0
597
huzzm
77,580,143
5,865,393
Reading Excel file with merged cells Pandas
<p>I have the following Excel file:</p> <p><a href="https://i.sstatic.net/gWuym.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/gWuym.png" alt="enter image description here" /></a></p> <p>And the dataframe is</p> <pre class="lang-bash prettyprint-override"><code> Name Selector Range Policy 0 Name...
<python><pandas><excel><dataframe><openpyxl>
2023-11-30 16:39:35
2
2,284
Tes3awy
77,580,116
10,404,663
I am getting this error in Fast API FileResponse "UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte"
<p>I am trying to send a file in response to an API. I have file in my &quot;data&quot; folder on server and I am trying to sent that file. I've checked path of file and it is fine. I am getting this error on file send:</p> <blockquote> <p>&quot;UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: in...
<python><fastapi><fileresponse>
2023-11-30 16:35:33
0
641
FAHAD SIDDIQUI
77,580,088
705,373
Cannot convert string variable to raw
<p>I have seen few examples on how to convert string variable to raw one using interpolation, but it doesn't work for me:</p> <pre><code>import json j = '{&quot;value&quot;: &quot;{\&quot;foo\&quot;: \&quot;bar\&quot;}&quot;}' print(j) print(fr&quot;{j}&quot;) print(r'{&quot;value&quot;: &quot;{\&quot;foo\&quot;: \&...
<python><python-3.x><string>
2023-11-30 16:32:16
3
11,810
Roman Newaza
77,580,068
7,519,069
Optimize this Python function - apply a linear transformation based on parity of index
<p>I have this simple Python function:</p> <pre class="lang-py prettyprint-override"><code>import numpy as np def fast_transform(img, offset, factor): rep = (img.shape[0]//2, img.shape[1]//2) out = (img.astype(np.float32) - np.tile(offset, rep)) * np.tile(factor, rep) return out </code></pre> <p>The functi...
<python><numpy><optimization><numba>
2023-11-30 16:29:37
2
351
RyArazi
77,579,964
804,184
Python: Import class from args parser
<p>I want to know if it is possible to import a class from the input arguments of argsparser. What I am doing now is something like this:</p> <pre><code>parser = argparse.ArgumentParser() parser.add_argument('-p', dest=&quot;process&quot;, default=&quot;process1&quot;) args = parser.parse_args() if 'process1' in args....
<python><python-import><argparse>
2023-11-30 16:13:53
0
5,276
Alejandro
77,579,932
276,193
Workaround for stop required by python slice()
<p>The python documentation for <a href="https://docs.python.org/3/library/functions.html#slice" rel="nofollow noreferrer">slice</a> notes that a stop parameter is always required.</p> <p>This is good for digging around in data where instead of <code>x[100000:200000]</code>, I can instead do something like...</p> <pre>...
<python><slice>
2023-11-30 16:09:29
2
16,283
learnvst
77,579,920
7,995,293
Which is more efficient in python (and in general): iterate over short list and searching in the longer one, or vice versa?
<p>I have two lists, both contain integers represented as strings. <code>large_list</code> is large, up to low 10s of thousands of elements. <code>small_list</code> is smaller, up to hundreds of elements. I am filtering the larger one by the smaller one. I'm curious to know which is more efficient:</p> <p>(a)</p> <pre>...
<python><list><performance><set>
2023-11-30 16:07:24
4
399
skytwosea
77,579,895
861,757
PyTorch CNN Returns Only One Result After Training
<p>I'm training a CNN image classifier. The network classifies 255 x 255 RGB images into five categories numbered <code>0</code> to <code>4</code>.</p> <p>But the network is behaving strangely during training. Although the loss function drops smoothly, the model returns identical answers for all the samples in the batc...
<python><pytorch><conv-neural-network><backpropagation>
2023-11-30 16:03:18
1
728
Paulo Mendes
77,579,884
1,914,781
convert CST time string to datetime object
<p>How can I covert a time string which contains CST to datetime object?</p> <pre><code>ts = &quot;Wed Dec 31 18:00:00 CST 1969&quot; </code></pre>
<python><pandas>
2023-11-30 16:01:44
1
9,011
lucky1928
77,579,876
5,896,319
How to fix empty table of content in Pylatex?
<p>I'm trying to generate a pdf file using pylatex and pdf latex. I have sections and subsection in my document and I want to create a table of contents like this:</p> <pre><code>doc.append(NewPage()) doc.append(Command('tableofcontents')) doc.append(NoEscape(r'\clearpage')) </code></pre> <p>but after I compile it it g...
<python><flask><latex><pylatex>
2023-11-30 16:00:20
1
680
edche
77,579,830
18,904,265
operational error when testing my CLI app with a SQLite DB
<p>So I wanted to add tests to my CLI app, but I am struggling to replace my db with a temporary one. So far I have used SQLModel for database access, but for the app testing I want to assert the db values using raw SQL statements. However, I get a connection error when trying to access my temporary DB.</p> <pre><code>...
<python><sqlite><pytest><typer>
2023-11-30 15:52:58
1
465
Jan
77,579,813
14,634,210
Implementing discord bot joining logic via oauth: looking for solution on how to join my bot onto a guild
<p>I am trying to add the logic onto my discord bot to add it to a guild however I can't figure out how to do this.</p> <p>The first thing I tried was to create an algorithm to join a discord server with an oauth.</p> <pre class="lang-py prettyprint-override"><code># an redrected url look like this https://www.example....
<python><discord>
2023-11-30 15:50:19
2
669
The epic face 007
77,579,674
4,738,644
"roll axis" using inner and outer values in Dictorionaries in python
<p>Hello I'm kind of new for dictionaries in python and have the following dictionary structure (I prefer to show it as simple as possible, trying to omit every key and value):</p> <pre><code>data_group_test = {Example: {model: {: epoch{: dataset {np.array}}}} </code></pre> <p>but I would like it to be</p> <pre><code>d...
<python><dictionary>
2023-11-30 15:30:27
1
421
Diego Alejandro Gómez Pardo
77,579,658
7,054,001
Pretrained model with stride doesn’t predict long text
<p>My objective is to annotate long documents with bioformer-8L. I have been said to use stride and truncation so I don’t have to split my documents in chunks of 512 tokens.</p> <p>In the training phase, I called the tokenizer like this:</p> <pre><code>tokenizer = AutoTokenizer.from_pretrained(model_checkpoint, stride ...
<python><nlp><huggingface-transformers>
2023-11-30 15:28:13
1
626
Despe1990
77,579,554
5,692,673
SyntaxError: future feature annotations is not defined using python 3.9
<p>I am using python 3.9 in a virtual environment. The only solution I can find just says to use python 3.7 or higher and try using a virtual environment to ensure it is. I am doing both and as you can see from the backtrace, it is indeed using 3.9.</p> <p>edit: we just found in this stack trace, two lines where it ...
<python><django><numpy>
2023-11-30 15:11:59
0
1,001
general
77,579,530
9,983,652
How to move the legend of each trace inside each subplot when subplot has more than 1 column
<p>When subplot has 2 columns and 2 rows. Typically the legends are grouped together and places on the same location like below on the right hand side. I am wondering if I can place legend of each trace inside each of subplot, for example, legend of Trace 1 inside subplot row=1 and col=1, legend of trace 2 inside subpl...
<python><plotly>
2023-11-30 15:06:40
1
4,338
roudan
77,579,451
1,740,254
Gunicorn Timeout - How to increase timeout?
<p>I have python fastapi deployed using gunicorn. Request gets timed out exactly after 1min.</p> <pre><code>504 Gateway Time-out </code></pre> <p>I want to increase the timeout of api due to long backend processing. Tried to pass time out as below but it does not work at all.</p> <pre><code>gunicorn main:app --keep-ali...
<python><docker><fastapi><gunicorn>
2023-11-30 14:55:07
1
451
CoronaVirus
77,579,346
7,454,638
Pylance has wrong type hint (Any) for class method with additional params
<p>Perhaps best way to explain the issue is with an example:</p> <pre class="lang-py prettyprint-override"><code>class Bar: pass class Foo: @classmethod def class_foobar(cls) -&gt; Bar: return Bar() @classmethod def class_foobar_param(cls, param: str) -&gt; Bar: return Bar() bar =...
<python><intellisense><pylance>
2023-11-30 14:38:33
0
1,886
leoschet
77,579,324
418,413
How to Register Multiple Pluggy Plugins with Setuptools
<h2>Problem</h2> <p>I can successfully register a single plugin in pluggy using <a href="https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluginManager.load_setuptools_entrypoints" rel="nofollow noreferrer"><code>load_setuptools_entrypoints</code></a>, but I can only register one. If two different plug...
<python><plugins><pluggy>
2023-11-30 14:34:41
2
77,713
kojiro
77,579,302
13,836,083
Python Assignment statement
<p>I was going through the python assignment statement <a href="https://docs.python.org/3/reference/simple_stmts.html#assignment-statements" rel="nofollow noreferrer">docs</a> .</p> <p>Here python uses below <a href="https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form" rel="nofollow noreferrer">Backus–Naur form</a> ...
<python><bnf>
2023-11-30 14:33:03
1
540
novice
77,579,157
3,070,181
How to call an async function from a tkinter button
<p>I want to call an asynchronous function from a tkinter button</p> <pre><code>import asyncio import time import tkinter as tk async def gui(): root = tk.Tk() timer = tk.Button(root, text='Timer', command=lambda: asyncio.run(wait())) # timer = tk.Button(root, text='Timer', command=wait()) timer.pack()...
<python><tkinter><asynchronous>
2023-11-30 14:13:41
1
3,841
Psionman
77,579,104
12,415,855
Selenium using proxy when creating driver?
<p>for a long time i used the following code to create a selenium-driver for chrome:</p> <pre><code>from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.proxy import Proxy, ProxyType from selenium.common...
<python><selenium-webdriver><proxy>
2023-11-30 14:06:24
1
1,515
Rapid1898
77,578,921
6,292,430
Divide data into clusters by a linear function
<p>I have a number of rows, which form three noticeable lines on a graph.</p> <p><a href="https://i.sstatic.net/jhSrj.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jhSrj.png" alt="enter image description here" /></a></p> <p>Sample data</p> <pre><code>line_position,queue_number,real_seq 0,2280,41171 55,...
<python><pandas><scikit-learn><cluster-analysis>
2023-11-30 13:40:55
2
873
Pavel Botsman
77,578,898
3,745,149
My Pytorch multi-GPU prediction code freezes at `spawn()`
<p>The following small code does multi-GPU prediction using Pytorch.</p> <p>I launch multiple <code>task</code>s using <code>torch.multiprocessing.spawn()</code>.</p> <p>Inside <code>task</code>, I put no real prediction code. Just putting something into a common <code>Queue</code> to collect prediction results.</p> <p...
<python><pytorch><concurrency><multi-gpu>
2023-11-30 13:37:56
0
770
landings
77,578,843
11,426,624
iterate over all elements of a list of tuples with lists
<p>I have a list of tuples (that again consists of lists) and would like to to check how many of the elements of the first list in the tuple is in the second list of the tuple.</p> <pre><code>names =[ ([''],['aa']), (['aa', 'bb'],['aa']), (['cc'],['cc', 'dd', 'yy']), (['xx', 'ss'],['xx', 'ss']), ] </code></pre> <p...
<python><list><loops><list-comprehension>
2023-11-30 13:28:28
2
734
corianne1234
77,578,724
6,681,932
Conformal prediction intervals insample data nixtla
<p>Given the documentation of <code>nixtla</code> y dont find any way to compute the prediction intervals for insample prediction (training data) but just for future predicitons.</p> <p>I put an example of what I can achieve but just to predict (future).</p> <pre><code>from statsforecast.models import SeasonalExponenti...
<python><intervals><prediction><forecasting>
2023-11-30 13:12:44
2
478
PeCaDe
77,578,626
1,574,054
Can sympy arrays be properly sliced after numerical substitutions?
<p>Consider this example for sympy:</p> <pre><code>import numpy from sympy import Array, IndexedBase, symbols k = symbols('k', positive=True) M = IndexedBase('M') M_vals = numpy.array(( (0, 1, 2), (3, 4, 5), (6, 7, 8) )) M[k, 0].subs(M, Array(M_vals)).doit() </code></pre> <p>which prints</p> <pre><code>[...
<python><numpy><sympy><symbolic-math>
2023-11-30 12:59:15
0
4,589
HerpDerpington
77,578,604
264,136
difference between 2 string holding Cisco device's config
<p>I have 2 variables, config1 and config2 holding the running config of a Cisco device at 2 different points in time.</p> <p>Sample running config:</p> <pre><code>version 12.3 no service pad service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname retail ! b...
<python><cisco><cisco-ios>
2023-11-30 12:56:04
1
5,538
Akshay J
77,578,454
3,416,774
TypeError: write() argument must be str, not Tag
<p>Here is my code:</p> <pre class="lang-py prettyprint-override"><code>html = open(&quot;meetup.html&quot;, &quot;r&quot;) from bs4 import BeautifulSoup soup = BeautifulSoup(html, 'html.parser') file = open('myfile.txt', 'w') for elem in soup.find_all(attrs={&quot;type&quot;: &quot;application/ld+json&quot;}): ...
<python><beautifulsoup>
2023-11-30 12:31:55
2
3,394
Ooker
77,578,360
11,748,924
getElementById between two cells google colaboratory
<p>I have this cell:</p> <h1>Cell 1</h1> <pre><code>from IPython import display, HTML display(HTML( ''' &lt;img src=&quot;value_to_replace&quot; id=&quot;yeah&quot;&gt; ''' )) </code></pre> <p>And this</p> <h1>Cell 2</h1> <pre><code>%%javascript const yeahElem = document.getElementById(&quot;yea...
<javascript><python><jupyter-notebook><google-colaboratory>
2023-11-30 12:17:41
0
1,252
Muhammad Ikhwan Perwira
77,578,241
2,890,129
How to get Anscombe data wide format from long format
<p>I have the follwing anscombe data in long format</p> <pre><code>import seaborn as sns # Load the example dataset for Anscombe's quartet anscombe_long = sns.load_dataset(&quot;anscombe&quot;) </code></pre> <p>anscombe_long</p> <pre><code> dataset x y 0 I 10.0 8.04 1 I 8.0 6.95 2 I 13.0 7.58 3 ...
<python><pandas>
2023-11-30 11:56:44
1
439
Ramakrishna S
77,578,121
7,766,158
Successful requests but no messages in Azure Service Bus
<p>I have an Azure function that sends messages to a Azure Service Bus queue with the following code :</p> <pre><code>class ServiceBusSenderClient: def __init__(self, fully_qualified_namespace, queue_name): credentials = DefaultAzureCredential() servicebus_client = ServiceBusClient(fully_qualified_n...
<python><azure><azure-functions><azureservicebus>
2023-11-30 11:36:18
1
1,931
Nakeuh
77,578,029
11,426,624
check if string contains another column value
<p>I have a dataframe and would like to check if a column value contains another column value.</p> <pre><code> name1 name2 0 aa aab 1 xyz x </code></pre> <p>the below doesn't work</p> <pre><code>df = df.assign(name1_contains_name2=df.name1.str.contains(df.name2), name2_contains_name1=df.na...
<python><pandas><string><dataframe><contains>
2023-11-30 11:24:09
3
734
corianne1234
77,577,962
2,101,808
Python multiprcessing on Windows with dynamic types
<pre><code>import multiprocessing class Handler: pass handler = type('HandlerClass', (int, Handler),{&quot;const&quot;: [123]}) def stream_process(H): h=H() print(h.const) processes = [ multiprocessing.Process(target=stream_process, args=( handler,), name=f&quot;server #{i}&quot;) for i in range(4) ] for...
<python><python-3.x><windows><multiprocessing>
2023-11-30 11:14:20
1
3,614
eri
77,577,929
10,178,508
How to handle cloudflare turnstile on form recaptcha with selenium / seleniumbase?
<p>I'm trying to login to this website: <a href="https://visa.vfsglobal.com/are/en/fra/login" rel="nofollow noreferrer">https://visa.vfsglobal.com/are/en/fra/login</a> with <code>selenium</code>, but I cannot bypass the Cloudflare Turnstile CAPTCHA.</p> <p>My script uses <a href="https://github.com/seleniumbase/Seleniu...
<python><selenium-webdriver><undetected-chromedriver><seleniumbase>
2023-11-30 11:09:21
1
598
Ismayil Ibrahimov
77,577,897
1,383,029
Dropbox API (Python) - How to get access to Team and User files
<p>I have a dropox business user which is member of the team. I would like to see the filesystem with the API like when I just login to dropbox.com: Member and team files and folder.</p> <p>So I'm creating a dropbox authentication code with:</p> <pre><code>dropbox.DropboxOAuth2FlowNoRedirect( settings.DROPBOX_APP_K...
<python><dropbox><dropbox-api>
2023-11-30 11:03:23
1
2,155
user1383029
77,577,864
2,641,038
Issue with Hierarchical Lucas-Kanade method on Optical Flow
<p>Issue with Hierarchical Lucas-Kanade method on optical flow</p> <p>I am implementing the hierarchical Lucas-Kanade method in Python based on <a href="http://robots.stanford.edu/cs223b04/algo_tracking.pdf" rel="nofollow noreferrer">this tutorial</a>. However, when applying the method to a rotating sphere, I am encoun...
<python><opencv><matplotlib><opticalflow>
2023-11-30 10:57:49
1
2,025
Der Fänger im Roggen
77,577,820
19,932,351
"Unknown Configuration Setting" in VSCode. Where to find current VSCode Python configurations for settings.json?
<p>Similar issues have been posted like <a href="https://stackoverflow.com/questions/62470439/vscode-python-jedienabled-false-showing-as-unknown-configuration-setting">vscode &quot;python.jediEnabled&quot;: false, showing as Unknown Configuration Setting</a></p> <p>I was really struggling now setting up my flake8 setti...
<python><visual-studio-code>
2023-11-30 10:51:15
1
662
Leon
77,577,521
13,184,263
Shifted column when reading csv file in pyspark
<p>I have a csv file stored in gcs, when reading this file some values are being shifted by 2 columns and I don't know why. One example is the following row:</p> <pre><code>202100000264277,01212022,*******2752,00000411042,15314.15,27021421334,D,00000000396,JONES HEALTHCARE GROUP,08036296542,8036296542,,02560,15314.15,4...
<python><dataframe><csv><pyspark>
2023-11-30 10:05:11
0
415
Jenny
77,577,497
7,204,691
Visualize iteratively t-SNE in Dash for large sample dataset
<p>I'm building a Dash app. In this dashboard, there is the possibility for the user to perform a dimension reduction of the dataset and visualize the result on a 2d or 3d plot.</p> <p>The computation is really slow as the dataset contains lots of samples (~ 30000) and the algorithm (T-SNE) is not the fastest one.</p> ...
<python><dataset><visualization><plotly-dash>
2023-11-30 10:01:52
0
307
Mathieu Rousseau
77,577,477
2,793,602
Show lines that differ between pandas dataframes
<p>I have two dataframes, one with the current estimate and one with the previous estimate. I want to create a new dataframe that shows the lines that have differences. Both have about 600 lines. This code:</p> <pre><code>merged_df = pd.merge(df_current_est, df_previous_est, how='outer', indicator=True) changed_df = me...
<python><pandas><dataframe>
2023-11-30 09:59:40
2
457
opperman.eric
77,577,292
903,011
How to precisely describe a dict type?
<p>I am back to Python (after some infidelities with Go and Typescript) and in the meantime the <code>type</code> parameter <a href="https://docs.python.org/3.12/reference/simple_stmts.html#the-type-statement" rel="nofollow noreferrer">landed in</a>.</p> <p>I tried to understand how to use it to <strong>precisely</stro...
<python><python-typing>
2023-11-30 09:30:20
1
30,596
WoJ
77,577,229
1,657,666
Why the ZipFile python library does not enforce passwords if ZipCrypto encryption is set?
<p>I am trying to create a zip file using DEFLATED compression and ZipCrypto encoding. The test is only trying to uncompress the zip file created using the Win11 Extractor tool. I used the code below to generate the zip file, which was created with success, but when I try to extract it, no password is being asked by an...
<python><python-zipfile><system.io.compression.zipfile>
2023-11-30 09:20:41
0
451
user1657666
77,577,205
10,722,752
Getting AttributeError when running optuna study
<p>I am trying to run optimization using <code>optuna</code>:</p> <pre><code>study = optuna.create_study(direction='minimize', sampler=optuna.samplers.GridSampler(search_space)) study.optimize(objective, n_trials=20) </code></pre> <p>For which I am getting below error:</p> <p><code>AttributeError: module optuna.sampler...
<python><python-3.x><optuna>
2023-11-30 09:16:29
1
11,560
Karthik S
77,577,121
6,364,117
Pandas read_table never fails
<p>Trying to learn a bit of python and test that the incoming binary data ( which is a file ) is tab-delimited. Whatever kind of string I turn into binary does not break the pandas <code>read_table</code> parser. I am not sure what is going here and am at the end of the rope.</p> <p>Seems pretty standard that I should ...
<python><pandas><flask><pytest><flask-sqlalchemy>
2023-11-30 09:02:20
0
1,422
godhar
77,577,080
7,078,356
xhost and Pyautogui to click the buttons on a linux Application, cannot see mouse click action
<p>I have a Linux application, which automatically runs and loads on system startup, filling the entire display. Currently, I want to write a Python script to simulate mouse clicks on buttons within the application. Here is the issue I am facing: I connect to my Linux machine using SSH and use the PyAutoGUI library to ...
<python><linux><display><pyautogui>
2023-11-30 08:56:40
0
1,327
Ringo
77,577,009
6,273,503
Pandas handling of daylight saving time (double hour) excel / csv compatible
<p>I am reading / writing quarter-hourly data into a csv file. The csv file format is given, since it is processed by Excel.</p> <p>CSV looks like this:</p> <pre><code>from;Price ... 30.10.2022 01:00;120,41 30.10.2022 01:15;104,2 30.10.2022 01:30;89,93 30.10.2022 01:45;71,21 30.10.2022 02:00;101,54 30.10.2022 02:15;92,...
<python><pandas>
2023-11-30 08:44:17
0
1,273
Harper
77,576,973
10,687,907
Blurred map when I move in Folium
<p>So I'm trying to display an interactive map using streamlit and folium but every time I move the map it becomes blurry.</p> <p>I suppose it is a performance problem where things are getting processed over and over again but I can't seem to bypass it, even though I've tried using cache to only process things once but...
<python><streamlit><folium>
2023-11-30 08:37:10
0
807
Achille G
77,576,912
15,222,211
How to resolve mypy errors when changing values with a Literal type?
<p>I need to change the value of an attribute that has a <code>Literal</code> type. In a real case, I have a long list of values in ValidChar and I need to convert it to <code>List[str]</code> for checking. <code>mypy</code> shows an error for the following example. How can I solve it?</p> <pre class="lang-py prettypri...
<python><mypy><python-typing>
2023-11-30 08:25:54
2
814
pyjedy
77,576,778
2,194,036
ansible playbook not able to find the inventory file
<p>I am running an ansible playbook, in the playbook only I am calling a python script which actually generates the inventory file which needs to be used by this playbook.. <br> For the very first execution, although the playbook runs fine but it does not perform any listed operation on those target servers as it does ...
<python><ansible><ansible-inventory>
2023-11-30 08:02:12
0
459
Sandy
77,576,739
11,276,356
Project point cloud into depth image in python
<p>I have a point cloud which is in the same coordinate system as the cameras used for capturing the image.</p> <p><em>I have a set of points (1000000, 3)</em></p> <p><em>The camera extrinsic matrix Rt</em></p> <p><em>The camera intrinsic matrix K</em></p> <p><em>And my image (480, 640, 3)</em></p> <p><em>near=0.05 and...
<python><numpy><point-clouds><open3d><camera-projection>
2023-11-30 07:54:04
0
4,122
Hannah Stark
77,576,528
12,100,211
llama model to get answers of the questions which are in the context of pdf
<p>model name = llama-2-7b-chat.ggmlv3.q2_K.bin<br> pdf-name = fastfacts-what-is-climate-change.pdf<br> pdf-data = size of pdf is 2 to 3 pages, having info about climate change. <br></p> <p>dependencies:</p> <pre><code>from langchain.document_loaders import PyPDFLoader from langchain.text_splitter import RecursiveChar...
<python><machine-learning><pdf><artificial-intelligence><llama>
2023-11-30 07:14:31
0
303
Kanha Tomar
77,576,488
15,222,211
How to solve mypy error for @property with pydantic @computed_field?
<p>I need to decorate <code>@property</code> with the <code>@computed_field</code> from pydantic (to automatically generate key-value pairs and include them in a FastAPI JSON Response). In the following example, mypy displays an error. If there is an error, how can I fix it? If everything is correct, how do I disable t...
<python><mypy><pydantic>
2023-11-30 07:05:48
3
814
pyjedy
77,576,384
298,847
Structuring a multi-package Python project with editable installs in Visual Studio Code?
<p>At our company we've split up our Python code base into multiple packages. To allow for a decent development workflow, we use editable installs.</p> <p><strong>Setup</strong></p> <ul> <li><p>We have three packages, structure like so:</p> <pre><code>. ├── api │ └── pyproject.toml ├── db │ └── pyproject.toml └── c...
<python><visual-studio-code><virtualenv><python-poetry>
2023-11-30 06:42:17
0
9,059
tibbe
77,576,380
15,513,073
how to do Image reprojection by setting some control points on a picture in any language
<h3>description:</h3> <ul> <li>How to correct a picture all points coordination by setting 2 point coordination? or which lib I need to use?</li> <li>I prefer <code>python</code> lib solution but any language solution are accepted.</li> <li>It is better if I can set the coordinate system in parameter.</li> <li>I want t...
<python><algorithm><image><tiff><gdal>
2023-11-30 06:41:28
1
2,546
leaf_soba
77,576,347
2,289,710
Beautifulsoup: find the location of a string in the soup
<p>I am trying to scrap data from a web page generated by a search engine. For this purpose, I study the data structure of the document using a sample query and the output result. The output contains a string &quot;blah-blah-blah&quot; being a value of the field that I need to scrap. I have this simple code:</p> <pre><...
<python><web-scraping><beautifulsoup>
2023-11-30 06:33:26
1
3,894
freude
77,576,314
65,889
How to read a CSV in Python which is 99% UTF-8 encoded
<p>I have large CSV files (&gt;100.000 rows, 50 columns) which are &quot;mainly&quot; UTF-8 encoded.</p> <p>On one of them, let's call it <code>file.csv</code> I run</p> <pre class="lang-none prettyprint-override"><code>$ chardetect file.csv file.csv: utf-8 with confidence 0.99 </code></pre> <p>However when I read the ...
<python><csv><unicode><character-encoding><decoding>
2023-11-30 06:25:03
0
10,804
halloleo
77,576,244
9,516,820
dropdown select showing up in views.py but not in the clean method in forms.py
<p>I have a django template as follows</p> <pre><code>&lt;div class=&quot;container-fluid lineitem_form_container&quot;&gt; &lt;div class=&quot;inner_holder&quot;&gt; &lt;h2&gt;Add Line Item&lt;/h2&gt; &lt;form method=&quot;post&quot; action=&quot;{% url 'Dashboard:lineitems' %}&quot; class=&quot;co...
<python><django><django-models><django-views><django-forms>
2023-11-30 06:09:27
0
972
Sashaank
77,576,160
990,207
GStreamer Python dynamic pipeline construction not working
<p>I have a gstreamer pipeline that currently works if I invoke <code>Gst.parse_launch</code>:</p> <pre><code>rtspsrc tcp-timeout=&lt;timeout&gt; location=&lt;location&gt; is-live=true protocols=tcp name=mysrc &quot; ! rtph264depay wait-for-keyframe=true request-keyframe=true &quot; ! mpegtsmux name=mpegtsmux &quot; ! ...
<python><gstreamer>
2023-11-30 05:44:12
1
1,597
Niru
77,575,954
5,558,021
How to improve speed of copy files in Python?
<p>I need to copy ~ 100,000 files; copying one file is too slow compared to the Unix terminal cp -r recursive copy of all files in the directory. Is there a way to copy all files instead of copying each file via Shutil? copy() in the loop?</p>
<python>
2023-11-30 04:45:06
2
1,383
Dmitry Sokolov
77,575,913
8,384,910
Use case for np.log2 vs math.log2
<p>Sometimes, authors use <a href="https://numpy.org/doc/stable/reference/generated/numpy.log2.html" rel="nofollow noreferrer"><code>np.log2</code></a> instead of <a href="https://docs.python.org/3/library/math.html#math.log2" rel="nofollow noreferrer"><code>math.log2</code></a>. For example, in <a href="https://github...
<python><numpy><pytorch><conventions>
2023-11-30 04:32:41
1
9,414
Richie Bendall
77,575,842
1,188,943
Unable to install google-re2 on macos 14.1.1
<p>I want to install Apache Airflow and in the installation process, it needs google-re2. The error is:</p> <pre><code> Building wheel for google-re2 (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─&gt; [149 lines of output] ...
<python><airflow><re2>
2023-11-30 04:12:18
1
1,035
Mahdi
77,575,542
10,200,497
keep the first row and change the rest of values to NaN in multiple columns
<p>This is my dataframe:</p> <pre><code>import pandas as pd df = pd.DataFrame( { 'a': [ 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'b', 'b', 'b', 'b', 'b', ], 'b': [ -20, 20, 20, 20,-70, -70,-11, -100, -1, -1, -100, 100 ], 'c': [ 'f', 'f', 'f', 'f...
<python><pandas>
2023-11-30 02:32:31
2
2,679
AmirX
77,575,330
4,862,402
Dropping the key column of right data frame after merging
<p>I'm looking for a simple way to get rid of the key column of the right table after merging it with another data frame:</p> <pre><code>import pandas as pd users = pd.DataFrame({&quot;id&quot;: [1,2,3], &quot;name&quot;: [&quot;Mark&quot;, &quot;Elon&quot;, &quot;Jeff&quot;]}) orders = pd.DataFrame({&quot;id&quot;: [...
<python><pandas><merge>
2023-11-30 01:06:01
3
1,161
Victor Mayrink
77,575,271
359,219
Why is a Python module not being found?
<p>The source in hypothesis_test.py, I have:</p> <pre><code>from utils import collapse_contiguous_ranges, check_number_in_range @given(st.lists(st.integers())) def test_collapse_contiguous_ranges(range: list[int]): collapsed = collapse_contiguous_ranges(range) for i in range: assert check_number_in_rang...
<python>
2023-11-30 00:46:50
0
11,040
pitosalas
77,575,238
14,256,643
python subprocess getting error when trying to install requirements.txt
<p>I am trying to develop an automate python scripts using python subprocess. I am using fastapi uvicorn server for build automatically djago project but got internal 500 server error fast api while installing requirements.txt for django project. I am using python 3.11 my code</p> <pre><code>@app.post(&quot;/webhook&qu...
<python><python-3.x><django><subprocess><fastapi>
2023-11-30 00:31:27
0
1,647
boyenec
77,575,141
646,549
Is there a good algorithm to reconstruct a global ranked list from several partially ranked lists?
<p>I have a list of objects which are being reviewed by a team of judges. Each judge only sees a subset of the objects, and each judge ranks the objects from best to worst. Each object is ranked by at least two judges, and there is possibility of the judges to disagree (i.e., this is a noisy judging process). No judge ...
<python><list><ranking>
2023-11-29 23:58:01
2
309
tomr_stargazer
77,574,967
4,980,705
create multiple columns with df.apply that uses multi return function
<p>I am creating a new column with df.apply and a function and would like to use the same function to create another column in the dataframe. The function returns several values from which I'm selecting one successfully. To avoid new calculation I would like to get two return outputs and create two columns in the dataf...
<python><pandas><pandas-apply>
2023-11-29 23:07:57
0
717
peetman
77,574,962
4,399,016
Converting Byte Literal to Pandas
<p>I have a data that looks like this:</p> <p>In bytes literal form</p> <pre><code>data b'[{&quot;Name&quot;:&quot;USA Stocks&quot;,&quot;Code&quot;:&quot;US&quot;,&quot;OperatingMIC&quot;:&quot;XNAS, XNYS&quot;,&quot;Country&quot;:&quot;USA&quot;,&quot;Currency&quot;:&quot;USD&quot;,&quot;CountryISO2&quot;:&quot;US&q...
<python><pandas>
2023-11-29 23:06:46
1
680
prashanth manohar
77,574,902
192,221
Uninstall package with pip and uninstall the wheels built
<p>If I <code>pip uninstall</code> a package, in this case llama-cpp-python, the whl file that it built upon installation is not removed. I doesn't make sense to me why that would be left hanging around. Why is this not done by default, and why is there no option to tell pip to remove wheels? It would make sense to ...
<python><python-3.x><pip><python-wheel>
2023-11-29 22:49:25
0
6,017
kristianp
77,574,896
10,621,555
py -m ensurepip doesn't install the latest version of pip (instead of 23.3, it installed 21.1)
<p>I am stuck here as I have python 3.9 installed but it came with 21.1.3 pip. I would like to upgrade my pip but it keeps saying 21.1.3 version is the latest which is not true. I uninstalled my pip and then reinstalled it using py -m ensurepip but still, it installed pip-21.1.3 for me but not 23.3 the latest.</p> <p>A...
<python><pip><version><ensurepip>
2023-11-29 22:47:50
0
707
Hao Xu
77,574,863
4,038,747
Can these sorts of if/else statements be boiled down with a walrus operator?
<p>I have read up blogs and tutorials around the <code>:=</code> operator but I am still trying to wrap my head around how to know <em>when</em> to use it. I understand its purpose is to improvement maintainability, avoiding potential code duplication, and assignments in comprehensions but I am wondering if it can be u...
<python><python-assignment-expression>
2023-11-29 22:38:59
1
1,175
lollerskates
77,574,748
3,083,138
What is the correct technique for incorporating access to large machine learning data sets in a Ray Tune Tuner() object?
<p>I'm attempting to use Ray Tune 2.8.0 to optimize the hyperparameters of a pytorch neural network model--a fairly standard use case as far as I can understand. Pytorch is distributed with several standard prepackaged data sets that can be loaded to facilitate user practice and learning exercises. In the pytorch pro...
<python><pytorch><distributed-computing><ray><pytorch-dataloader>
2023-11-29 22:06:42
0
4,613
stachyra
77,574,637
1,580,469
Find number with least number of signifcant bits in an interval
<p>Given a lower and upper bound, what is the number within these boundaries with the minimal number of significant bits? The number of significant bits is the difference of the position of most and least significant bit (MSB - LSB).</p> <p>Examples:</p> <pre><code>def sig_bits(x: int) -&gt; int: &quot;&quot;&quot;...
<python><bit-manipulation><intervals>
2023-11-29 21:40:39
2
396
Christian
77,574,533
10,620,003
delete the units from an order from customers based on another table
<p>I have three dfs related to the order from customers, and some steps for preprocessing of that. So, in one df I define some units in the <strong>gramaz df</strong>. which if we have that in the order, we should delete them. Like, if we have the pepper in the order, we should change that to:</p> <pre><code>pepper kg-...
<python><pandas><dataframe>
2023-11-29 21:14:03
1
730
Sadcow
77,574,466
159,072
Why is this AutoKeras NAS failing?
<p>I am using</p> <ol> <li>nVidia GeForce GTX 780 (Kepler)</li> <li>Driver Version: 470.223.02</li> <li>CUDA Toolkit v11.4.0</li> <li>cuDNN v8.2.4</li> <li>TensorFlow and Keras v2.8.0</li> <li>AutoKeras v1.0.17</li> <li>Ubuntu 20.04</li> </ol> <p>=======================</p> <p>I have two directories, <code>train_data_n...
<python><tensorflow><keras><deep-learning><auto-keras>
2023-11-29 21:00:04
1
17,446
user366312
77,574,386
3,517,025
Merging Cluster Lists from Multiple Algorithms: Identifying Methods and SQL Implementation
<p>I'm facing a challenge in merging lists of clusters generated by different algorithms using the same set of data items, identifiable by their IDs. Each algorithm clusters these IDs based on varying attributes (which I'll omit for irrelevance here), with the largest ID in each cluster being the cluster key (using max...
<python><sql><algorithm><pyspark><cluster-analysis>
2023-11-29 20:44:29
1
5,409
Joey Baruch
77,574,287
6,234,139
How to select a single value from a GeoDataFrame column?
<p>I am trying to join a polygon of Belgium with the multipoygon of France making use of what is posted here: <a href="https://stackoverflow.com/questions/40385782/make-a-union-of-polygons-in-geopandas-or-shapely-into-a-single-geometry">Make a union of polygons in GeoPandas, or Shapely (into a single geometry)</a>. Un...
<python><geopandas>
2023-11-29 20:23:43
1
701
koteletje
77,574,099
12,959,994
Why building a new scorer outputs an empty string for deepspeech 0.9.3
<p>I am trying to create a limited corpus and train a language model to use for a deepspeech scorer.</p> <p>I have followed the information provided in <a href="https://deepspeech.readthedocs.io/en/r0.9/Scorer.html" rel="nofollow noreferrer">the docs here</a></p> <p>I read a helpful guide posted for an older version of...
<python><node.js><nlp><mozilla-deepspeech>
2023-11-29 19:46:17
0
652
jbflow
77,574,026
4,438,012
How to transpose tabular organizational hierarchy data in python?
<p><strong>I have a csv dataset that is similar in structure to the following table in tabular form:</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Employee</th> <th>Manager</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>B</td> </tr> <tr> <td>B</td> <td>E</td> </tr> <tr> <td>C</t...
<python>
2023-11-29 19:30:01
2
439
harcot
77,574,022
19,588,737
Cleanly stop processes and exit when a Tkinter widget is closed
<p>I have a Python 3.11.5 program that uses a Tkinter GUI to receive user input, and runs a number of processes in the background. I'm wondering what the preferred method is for handling when the user wants to cancel a background process while it's still running. I've tried to make cancel buttons, to use separate threa...
<python><tkinter>
2023-11-29 19:28:37
1
307
bt3
77,573,998
17,896,651
PYTHON DROPBOX API process been hang since CLOSE_WAIT socket is not closed
<p>So I have my application running on windows for 5 years now. I have around 800 processes running in 5 different Machines. 5 / day lately are hanging on this: <a href="https://i.sstatic.net/oa3VC.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/oa3VC.png" alt="enter image description here" /></a></p> <p...
<python><multithreading><sockets><tcp><dropbox>
2023-11-29 19:24:05
0
356
Si si