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
78,330,264
14,501,369
How do I extract a list of conditional formatting rules from excel using the xml?
<p>I need to extract a list of all cells that have conditional formatting, where they might be highlighted yellow as a result of conditional formatting. I have tried using openxpyxl to do this, but it will only give me a list of all cells that have a conditional formatting rules, regardless of whether the rule might re...
<python><excel><xml><openpyxl>
2024-04-15 18:00:12
1
997
Hooded 0ne
78,330,155
14,501,369
How do I extract the color of an excel shape using the xml?
<p>I have the below code which works beautifully to extract the text from all shapes in an excel file. For a simple xlsx with 2 sheets and 1 shape per sheet it will return the following:</p> <p>['Text box 2'] ['Sheet2 ellipse text 3']</p> <p>However, I am needing it to also return the color of the shape. I cannot use x...
<python><excel><xml>
2024-04-15 17:38:30
1
997
Hooded 0ne
78,330,095
4,398,966
dictionary of lists of dictionaries not filtering
<p>I tried the following:</p> <pre><code>positions = { 'IBM': [ {'ticker': 'IBM', 'start_date': '20240415', 'end_date': 99999999}, {'ticker': 'IBM', 'start_date': '20240416', 'end_date': 00000000}, {'ticker': 'IBM', 'start_date': '20240417', 'end_date': 99999999}], 'MRK': [ {'tic...
<python><list><dictionary><conditional-statements>
2024-04-15 17:26:25
1
15,782
DCR
78,330,035
23,626,926
Python `regex` module - get unfuzzied match from fuzzy match
<p>I an writing a simple command interpreter for a project to allow the user to interact with a virtual world. In the commands the user can refer to objects by any number of different names, and the objects can appear and disappear. Also, to be nice to the user I am allowing some typos.</p> <p>To figure out which objec...
<python><regex><fuzzy-search><python-regex>
2024-04-15 17:12:22
0
360
dragoncoder047
78,329,987
5,312,606
numba dispatch on type
<p>I would like to dispatch on the type of the second argument in a function in numba and fail in doing so.</p> <p>If it is an integer then a vector should be returned, if it is itself an array of integers, then a matrix should be returned.</p> <p>The first code does not work</p> <pre class="lang-py prettyprint-overrid...
<python><types><numba>
2024-04-15 17:03:41
1
1,897
mcocdawc
78,329,750
12,800,206
dockerized python application takes a long time to trim a video with ffmpeg
<p>The project trims YouTube videos.</p> <p>When I ran the ffmpeg command on the terminal, it didn't take too long to respond. The code below returns the trimmed video to the front end but it takes too long to respond. A 10 mins trim length takes about 5mins to respond. I am missing something, but I can't pinpoint the ...
<python><docker><flask><ffmpeg><yt-dlp>
2024-04-15 16:12:17
0
748
Ukpa Uchechi
78,329,714
2,687,317
Pandas - groupby string field and select by time-of-day range
<p>I have a dataset like this</p> <pre><code>index Date_Time Pass_ID El 0 3/30/23 05:12:36.36 A 1 1 3/30/23 05:12:38.38 A 2 1 3/30/23 05:12:40.40 A 3 1 3/30/23 05:12:42.42 A 4 1 3/30/23 05:12:44.44 A 4 1 3/30/23 12:12:50.50 B 3 1 3/30/23 12:12:52.52 B 4 1 3/30/23 12:12:54.54 B 5 1 ...
<python><pandas><group-by>
2024-04-15 16:05:19
2
533
earnric
78,329,495
4,909,242
what is the equivalent of numpy accumulate ufunc in pytorch
<p>In numpy, I can do the following:</p> <pre><code>&gt;&gt;&gt; x = np.array([[False, True, False], [True, False, True]]) &gt;&gt;&gt; z0 = np.logical_and.accumulate(x, axis=0) &gt;&gt;&gt; z1 = np.logical_and.accumulate(x, axis=1) </code></pre> <p>This returns the following:</p> <pre><code>&gt;&gt;&gt; z0 array([[Fal...
<python><numpy><pytorch><numpy-ufunc>
2024-04-15 15:26:35
2
709
Wei Li
78,329,445
15,452,168
How to Efficiently Process 6000 Requests in Python with Limited Time Constraints?
<p>I have a Python script that sends requests to an API to generate responses based on input prompts. Each request typically takes around 10 seconds to process. I have a CSV file containing 6000 rows, and I want to send the values from the 'text' column as input prompts to the API. Additionally, I aim to append the gen...
<python><python-3.x><multithreading><multiprocessing><python-multiprocessing>
2024-04-15 15:20:45
0
570
sdave
78,329,319
13,174,189
How to lattitude, longtitude and full address based on address?
<p>I have a dataframe with column address_1:</p> <pre><code>address_1 apple fifth avenue new york burj khalifa dubai microsoft office san francisco </code></pre> <p>I want to get longtitude, lattitude and full address based on address_1. How to di it? I tried geopandas library:</p> <pre><code>geolocator = Nominatim(use...
<python><python-3.x><google-maps><geolocation><geopandas>
2024-04-15 15:02:27
1
1,199
french_fries
78,329,226
447,426
PySpark where to find logs and how to log properly
<p>I have set up a local (docker) spark cluster as provided by <a href="https://github.com/bitnami/containers/blob/main/bitnami/spark/docker-compose.yml" rel="nofollow noreferrer">bitnami</a>. Everything is running fine. I can submit simple spark jobs and run them and i can interact with pyspark.</p> <p>Now i try to se...
<python><docker><logging><pyspark>
2024-04-15 14:46:17
1
13,125
dermoritz
78,329,019
4,469,336
Django: Adding unique together errors to one of the involved fields
<p>Note: I asked this question on the <a href="https://forum.djangoproject.com/t/adding-unique-together-errors-to-one-of-the-involved-fields/30017/1" rel="nofollow noreferrer">Django forum</a>, but since I did not receive any answers there, I'm asking here, too.</p> <p>I’m building an application with multi-tenancy, me...
<python><django><validation><unique-constraint>
2024-04-15 14:14:58
0
2,985
Timitry
78,328,963
3,042,018
PyCharm warns "Expected type 'int', got 'float'" for random.randint, but code still runs sometimes
<p>PyCharm (Python version 3.11.3 on Windows) is flagging <code>Expected type 'int', got 'float' instead</code> where I use <code>random.randint(x/y, 10)</code> (where x/y will be, say, 5.0), which makes sense. However the code still runs.</p> <p>Someone else using a different IDE tried to run the code and <code>TypeEr...
<python><typeerror>
2024-04-15 14:04:42
1
3,842
Robin Andrews
78,328,935
547,231
Computing the Jacobian of an image: How to reshape the numpy array properly?
<p>I have a batch <code>x</code> of images of the shape <code>[k, width, height, channel_count]</code>. This batch is transformed by a function <code>f</code>. The result has the same shape and I need to compute the divergence (i.e. trace of the Jacobian) of this transformation. (To emphasize this: The transform is wor...
<python><numpy><neural-network><jax><automatic-differentiation>
2024-04-15 13:58:44
1
18,343
0xbadf00d
78,328,798
3,324,415
Robot Framework Database Library calling Oracle stored procedure fails with character to number conversion error
<p>I have an <code>Oracle PL/SQL</code> procedure that I can directly call as follows without problem:</p> <pre><code>BEGIN example_package_name.example_procedure(p_item_no =&gt; 123456, p_send_now =&gt; true); END; </code></pre> <p>(Note: <code>p_item_no</code> expects a <code>NUMBER</code> and <code>p_send_now<...
<python><oracle-database><plsql><robotframework>
2024-04-15 13:36:10
1
766
BernardV
78,328,713
2,401,856
Sqlite3 getting outdated value when selecting straight after inserting
<p>I'm having a very wiered behavior with sqlite3 in python.<br> I have a small flask service which has 2 endpoints <code>addTask</code> and <code>deleteTask</code>, and in my database I have <code>tasks_order</code> column which holds array that represents the tasks ordering. this order is changeable by the user.<br> ...
<python><sqlite><flask>
2024-04-15 13:23:39
1
620
user2401856
78,328,663
5,089,311
Python: swap position of vars expansion
<p>My function receives object <code>myenum</code> which can be either <code>set</code> or <code>dict</code>.<br /> <code>{'a', 'b', 'c'}</code><br /> or<br /> <code>{'a': 5, 'b' : 2, 'c' : 8}</code></p> <p>It represents enum like in C/C++.</p> <p>In case of <code>dict</code> I need enumerate over <code>.items()</code>...
<python>
2024-04-15 13:15:31
4
408
Noob
78,328,539
13,819,714
Huggingface pipeline available models
<p>I'm working with Huggingface in Python to make inference with specific LLM text generation models. So far I used pipelines like this to initialize the model, and then insert input from a user and retrieve the response:</p> <pre><code>import torch from transformers import pipeline print(torch.cuda.is_available()) ge...
<python><python-3.x><machine-learning><pytorch><large-language-model>
2024-04-15 12:54:43
2
5,253
Cardstdani
78,328,474
12,094,039
FastAPI Error: HTTPBasic.__call__() missing 1 required positional argument: 'request'
<p>I am trying to create a simple WebSocket app with authentication using FastAPI, but after adding the authentication I face issues,</p> <p>The <code>/{id}</code> request passes, but the WebSocket connection <code>/ws/{client_id}</code> gets failed due to the following error</p> <pre><code>ERROR: Exception in ASGI ...
<python><python-3.x><fastapi><fastapi-middleware>
2024-04-15 12:42:43
1
411
Aravindan vaithialingam
78,328,203
3,603,546
How to get python out of the "raw" terminal mode?
<p>(In Linux context) Entering terminal raw mode (to read mouse, Function keys etc) in python is easy:</p> <pre><code>import sys, tty, termios fd=sys.stdin.fileno() #tty.setraw(fd) tty.setcbreak(fd) </code></pre> <p>But then I want to get back and use <code>input()</code> again. Unfortunately, there is no <code>tty.set...
<python><terminal><stty>
2024-04-15 11:56:27
1
316
user3603546
78,327,891
4,046,235
Use enum fields to define higher level aggregate
<p>In the project I am working on, it's a common pattern to have a function like <code>MachineType.get_external</code> to group the fields:</p> <pre><code>from enum import IntEnum class MachineType(IntEnum): Cloud = 1 OnPrem = 2 Saas = 3 @classmethod def get_external(cls): return [ ...
<python><python-3.x><enums>
2024-04-15 10:59:31
1
3,201
Yuriy Vasylenko
78,327,887
17,530,552
How can I integrate values of a color channel with the image dimensions using cv2?
<p>Using <code>cv2</code>, one can load an image into Python and directly transfer the image into a grayscale version, as shown below.</p> <pre><code>import cv2 image = cv2.imread(&quot;/path-to-image&quot;, cv2.IMREAD_GRAYSCALE) </code></pre> <p>Then, the image is a <em>two dimensional</em> numpy array. Hence, the int...
<python><arrays><numpy><opencv>
2024-04-15 10:58:24
0
415
Philipp
78,327,822
7,132,482
Python API JAMA: Put attachment to item
<p>I'm facing issues with API Jama to attach an attachment to an item.</p> <p>I need to automatise my jobs and use python to create items and attach zipfile to them. With the console I can create my attachment with my zip file and attach to it to my item.</p> <p>But with the API Jama I don't know how I can create my at...
<python><rest><jama>
2024-04-15 10:46:33
1
335
Laurent Cesaro
78,327,635
1,791,983
In Python, want to find all the placemarks in a kml file, but the list is returning empty
<p>Trying to find all the placemarks in a kml file, so I can alter them. But findall doesnt find any.</p> <pre><code>def scan (filename): from lxml import etree tree = etree.parse(open(filename,encoding='utf-8')) root = tree.getroot() namespaces = {'kml': 'http://www.opengis.net/kml/2.2'} placema...
<python><kml>
2024-04-15 10:13:04
1
381
user1791983
78,327,547
6,197,439
pyqt5 change QMessageBox when using multiprocessing (Cannot set parent, new parent is in a different thread)?
<p>Here is an example, based on the example here <a href="https://stackoverflow.com/questions/48262966/terminate-a-long-running-python-command-within-a-pyqt-application/78325636#78325636">Terminate a long-running Python command within a PyQt application</a> - but with QMessageBox:</p> <pre class="lang-python prettyprin...
<python><pyqt5><python-multiprocessing>
2024-04-15 09:56:38
1
5,938
sdbbs
78,327,535
23,461,455
scikit-learn 1.1.3. import cannot import name 'METRIC_MAPPING64' in python
<p>I am trying to <code>import linear_model</code> from scikit-learn into my python code in vscode and get an unexpected error message.</p> <pre><code>import sklearn from sklearn import linear_model </code></pre> <p>the error:</p> <pre><code>cannot import name 'METRIC_MAPPING64' from 'sklearn.metrics._dist_metrics' </c...
<python><machine-learning><scikit-learn><linear-regression><scikits>
2024-04-15 09:54:33
1
1,284
Bending Rodriguez
78,327,520
188,331
Parameter 'function' of the transform datasets.arrow_dataset.Dataset._map_single couldn't be hashed properly, a random hash was used instead
<p>I have a function to pre-process the dataset before tokenization. Here is the code:</p> <pre><code>source_lang = &quot;en&quot; target_lang = &quot;fr&quot; def preprocess_dataset(examples): inputs = [example[source_lang] for example in examples[&quot;translation&quot;]] targets = [example[target_lang] for e...
<python><huggingface-tokenizers>
2024-04-15 09:51:30
0
54,395
Raptor
78,327,471
6,775,670
How to convert pydantic model to python dataclass?
<p>There the opposite is very popular question. Why not to convert a ready pydantic model into a standard python library dataclass?</p>
<python><pydantic><python-dataclasses>
2024-04-15 09:43:59
1
1,312
Nikolay Prokopyev
78,327,423
10,357,604
Naming of file while saving with extension
<p>How can I save a file with the name as: oldname+&quot;_new&quot;+extension in an elegant way?</p> <p>I currently do:</p> <pre><code>ext = os.path.splitext(file)[1] output_file = (root+'/'+ os.path.splitext(file)[0]+&quot;_new&quot;+ext) #or output_file = (os.path.join(root, os.path.splitext(file)[0])+'_new'+ext) wi...
<python><file><os.path><code-readability>
2024-04-15 09:35:21
1
1,355
thestruggleisreal
78,327,204
18,380,493
Changing the input layout of an ONNX model from NCHW to NHWC
<p>I have an ONNX model with an input shape of <code>(1, 1, 28, 28)</code>, which is in an <code>NCHW</code> layout. Is there any way that I can convert the model to take input data in the <code>NHWC</code> layout, i.e., as <code>(1, 28, 28, 1)</code>?</p> <p>The model is loaded from a file using the following code: <c...
<python><deep-learning><onnx><onnxruntime>
2024-04-15 08:56:06
1
326
moriaz
78,327,110
13,942,929
Install GMP library on Mac OS and PyCharm
<p>I'm trying to run my Cython project. And one of the header is <code>gmpxx.h</code>.</p> <p>Even though I already installed the gmp library using <code>brew install gmp</code>. I could not run my cython file with <code> python3 setup.py build_ext --inplace</code>.</p> <pre><code>fatal error: 'gmpxx.h' file not found ...
<python><c++><pycharm><cython><gmp>
2024-04-15 08:39:57
2
3,779
Punreach Rany
78,327,057
9,381,746
Euler's identity in python
<p>I am trying to calculate the Euler's in python with the following code:</p> <pre><code>import numpy as np import cmath x = 0 y = 1 z=complex(x,y) out=complex(np.e**(np.pi*z.imag)) print(out) </code></pre> <p>But what I am getting is the following (and I should get -1 or something close to it with floating point er...
<python><math><complex-numbers>
2024-04-15 08:31:11
1
5,557
ecjb
78,327,045
3,042,018
Appending to Path to Access Parent Directory in PyCharm vs Terminal
<p>Why is it that</p> <pre><code>import sys sys.path.append(&quot;..&quot;) from file_in_parent_dir import a_function </code></pre> <p>works in PyCharm, but not in when I run the file from CMD or PowerShell?</p> <p>(Windows 10, Python 11.3.3)</p> <p><code>ModuleNotFoundError: No module named 'file_in_parent_dir'</code>...
<python><path><pycharm>
2024-04-15 08:29:01
2
3,842
Robin Andrews
78,326,981
447,738
Pandas to find a streak of sales but with a tolerance for streak interruption
<p>I am trying to use Panda's to filter out a DataFrame to find a streak of sales that shall be of variant length. I am looking to identify periods of consecutive sales, but also allow for some days with no sale in between. In the df below, I am looking to select rows 12 to 19.</p> <pre><code>data = [['2023-11-16', 1],...
<python><pandas>
2024-04-15 08:16:51
1
2,357
cksrc
78,326,962
5,043,301
Using UserCreationForm
<p>I am learning Django. I would like to understand below code.</p> <pre><code>class RegisterPage(FormView): template_name = 'base/register.html' form_class = UserCreationForm redirect_authenticated_user = True success_url = reverse_lazy('tasks') def form_valid( self, form ): user = form.sa...
<python><django>
2024-04-15 08:12:54
1
7,102
abu abu
78,326,924
4,429,265
Qdrant takes 25 second to retrieve 1000 single products
<p>We have a single-product API that is causing us problems when called in large numbers (not even very large; 1000 requests take 25 seconds to finish).</p> <h2>What Are We Using</h2> <p>So, we are using Qdrant for our product database because of the semantic vector search capabilities. But also, we want to use it for ...
<python><database><qdrant>
2024-04-15 08:07:03
1
417
Vahid
78,326,802
18,730,707
"DevTools listening on ws://127.0.0.1" message does not go away in python selenium
<p>I know this question is a duplicate. However, no matter how much I write, the following phrase will not disappear.</p> <blockquote> <p>DevTools listening on ws://127.0.0.1:62784/devtools/browser/9f06f86e-f98b-4896-9f35-8c5c73317c7a</p> </blockquote> <p>There is a reason why the above phrase should be deleted. You ne...
<python><google-chrome><selenium-webdriver>
2024-04-15 07:41:25
0
878
na_sacc
78,326,717
2,695,082
ImportError: tools/python/lib/python3.9/lib-dynload/math.so: undefined symbol: PyFloat_Type
<p>I am using Python 3.9 on Linux. The python installation structure looks like:</p> <pre><code>/tools/python/bin - containing python executable /tools/python/lib/libpython3.9.so /tools/python/lib/python3.9/lib-dynload/* </code></pre> <p>I am linking a x.so with libpython.so and trying to run it. And when I run a simp...
<python><linux><python-3.9>
2024-04-15 07:26:37
0
329
user2695082
78,326,712
3,405,291
No module named pip
<h1>Conda environment</h1> <p>I'm creating the following conda environment by <code>conda env create -f environment.yml</code>.</p> <p>The <code>environment.yml</code> file content is:</p> <pre class="lang-yaml prettyprint-override"><code>name: deep3d_pytorch channels: - pytorch - conda-forge - defaults dependenc...
<python><pip><anaconda><conda><google-colaboratory>
2024-04-15 07:25:35
1
8,185
Megidd
78,326,697
10,722,752
Trend and Residue plots in seasonal decompose not spanning entire duration of data
<p>I am performing SARIMAX forecasting and visualizing the seasonal decompose plots. I have monthly data running from Jan 1, 2022 to March 1, 2024. When I plot my data I am getting a &quot;partial&quot; trend and residue plots.</p> <p>Sample Data:</p> <pre><code>from statsmodels.tsa.seasonal import seasonal_decompose f...
<python><pandas><statsmodels><sarimax>
2024-04-15 07:22:39
1
11,560
Karthik S
78,326,633
11,503,237
Issue with generating poisson arrivals in a system
<p>I am simulating the poisson arrivals of requests in the system. I am using numpy poisson for this purpose. The code is given below:</p> <pre><code>no_of_req=500 timesteps =500 rate = no_of_req / timesteps id=1 poisson=[] idx=[] for time_step in range(1, timesteps + 1): number_of_new_agents = np.random.poisson...
<python><numpy><poisson>
2024-04-15 07:11:32
1
483
Hamsa
78,326,625
13,687,718
Handle continuous parallel requests without blocking in Asyncio
<p>I am new to python asyncio and have a slightly convoluted requirement. I have been going through the documentation for asyncio but have not found the right solution yet as I am unable to understand some aspects.</p> <p>I have a script <strong>KafkaScript.py</strong> that reads from a kafka topic (streaming) and call...
<python><multithreading><python-asyncio>
2024-04-15 07:09:50
1
832
mang4521
78,326,591
11,770,390
pd.date_range with enddate included
<p>Using pandas 2.2.2 and python 3.11, why doesn't this give me the daterange containing the end date:</p> <pre><code>import pandas as pd start_date = pd.to_datetime('2023-04-05T04:01:40Z') end_date = pd.to_datetime('2024-04-15T00:00:00Z') full_date_range = pd.date_range(start=start_date, end=end_date, freq='1M', incl...
<python><pandas><dataframe><timestamp>
2024-04-15 07:03:30
3
5,344
glades
78,326,573
2,508,672
Convert any format of date string to datetime
<p>I am reading csv file and in date column it has different format some rows using m/d/yyyy some using d-m-yyyy and others</p> <p>I am using below code to convert</p> <pre><code>if(datetime.strptime(row['Date'],&quot;%m/%d/%Y&quot;).astimezone() &lt;= datetime.strptime(&quot;2024-03-03&quot;,&quot;%Y-%m-%d&quot;).asti...
<python>
2024-04-15 06:59:07
2
4,608
Md. Parvez Alam
78,326,265
2,739,700
Azure alerting Creation using Python SDK
<p>We are creating Azure alert using python SDK for Custom KQL query and below is the code which we are trying</p> <pre><code>from azure.mgmt.monitor import MonitorManagementClient from azure.identity import DefaultAzureCredential credentials = DefaultAzureCredential() sub_id= &quot;xxxx&quot; resource_group = &quot;r...
<python><azure><azure-monitoring><azure-alerts>
2024-04-15 05:41:23
1
404
GoneCase123
78,325,944
7,584,138
How to consolidate slowing changing dimension tables using sql, python or r?
<p>I have below input table:</p> <div class="s-table-container"><table class="s-table"> <thead> <tr> <th>id</th> <th>type</th> <th>value</th> <th>date_from</th> <th>date_to</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>department</td> <td>finance</td> <td>2020-01-01</td> <td>9999-12-31</td> </tr> <tr> <td>1</td> <td>...
<python><sql><pandas><dplyr><tidyverse>
2024-04-15 03:24:01
1
1,688
Frank Zhang
78,325,675
1,202,417
Serving a webpage content by running a php/python script
<p>I'm trying to set up a RSS for my site. So I would like to make a link that takes in a keyword and produces a RSS feed.</p> <p>I have a python script (<code>script.py</code>) to generate this xml, but I don't know how to run it and serve the text to the user when my page is called.</p> <p>Essentially I would like to...
<javascript><python><rss>
2024-04-15 00:55:23
0
411
Ben Fishbein
78,325,531
11,930,602
What is the standard way to insert out-of-order elements in a list of a possibly smaller size?
<p>What I have:</p> <pre class="lang-py prettyprint-override"><code>msg: list = [] </code></pre> <p>expected behaviour:</p> <pre class="lang-py prettyprint-override"><code>msg.insert(2,&quot;two&quot;) # msg = [None, None, &quot;two&quot;] msg.insert(10,&quot;ten&quot;) # msg = [None, None, &quot;two&quot;, None, No...
<python><list><insert>
2024-04-14 23:21:46
2
2,322
kesarling
78,325,356
6,197,439
How to setup an instance method monkeypatch in this PyQt5 code?
<p>Yes, I have seen:</p> <ul> <li><a href="https://stackoverflow.com/questions/28127874/monkey-patching-python-an-instance-method">monkey-patching python an instance method</a></li> <li><a href="https://stackoverflow.com/questions/8726238/how-to-call-the-original-method-when-it-is-monkey-patched">How to call the origin...
<python><python-3.x><pyqt5><monkeypatching>
2024-04-14 21:57:33
1
5,938
sdbbs
78,325,210
777,304
maping of memory into structure using ctypes in python
<p>I am trying to map memory into structure but unable to get desired results. My memory is list of 32 bit values i.e.</p> <pre><code>[0x7E008000, 0x1234AAAA, 0xBBBBFFFF] </code></pre> <p>and I am trying to get this output.</p> <pre><code>ns: 0x7d008000 us: 0x1234 zs: 0xaaaabbbb crc: 0xffff </code></pre> <p>with follow...
<python><ctypes>
2024-04-14 20:45:17
2
455
user777304
78,324,897
1,493,192
Python ConnectionRefusedError using a Docker compose with jupyter notebook and spring boot
<p>I wrote a local application using spring boot in which I have three containers: mongodb, mongo-express and jupyter noteboot. Using a python script I can access the data without errors</p> <pre><code>import requests import json url = &quot;http://localhost:8080/api/v1/metadata/sites&quot; response = requests.get(ur...
<python><spring-boot><docker-compose><jupyter-notebook>
2024-04-14 18:44:19
0
8,048
Gianni Spear
78,324,819
7,199,629
Optimizing Lat/Lon Extraction from Astropy's GeocentricTrueEcliptic SkyCoord
<p>I am facing a challenge that should be straightforward but has proven to be quite complex with the Astropy library. Specifically, I need to frequently compute the longitude and latitude from a <code>SkyCoord</code> object that has been transformed to the <code>GeocentricTrueEcliptic</code> frame. Here is the relevan...
<python><numpy><numba><jit><astropy>
2024-04-14 18:16:23
1
361
ysBach
78,324,721
1,182,299
BERT MLM model fine-tune on small data bad results
<p>I want to fine tune a BERT MLM model from Hugging Face. I have only a small amount of data (train.csv) like this:</p> <pre><code>text בראשית ברא אלהים את השמים ואת הארץ והארץ היתה תהו ובהו וחשך על פני תהום ורוח אלהים מרחפת על פני המים ויאמר אלהים יהי אור ויהי אור וירא אלהים את האור כי טוב ויבדל אלהים בין האור ובין ה...
<python><huggingface-transformers><bert-language-model>
2024-04-14 17:44:46
1
1,791
bsteo
78,324,619
1,802,483
Problem installing `apache-flink:1.19.0` using python docker 3.9 - 3.12
<p>I am having trouble installing <code>PyFlink</code>/<code>apache-flink 1.19.0</code> using python docker 3.9 - 3.12 following <a href="https://nightlies.apache.org/flink/flink-docs-master/docs/dev/python/installation/" rel="nofollow noreferrer">the official tutorial</a>.</p> <p>It seems that the error is about a pat...
<python><docker><apache-flink>
2024-04-14 17:07:58
2
705
Ellery Leung
78,324,332
1,848,244
How to instantiate a large number of NotRequired arguments in a TypedDict?
<p>Consider this contrived example:</p> <pre class="lang-py prettyprint-override"><code>from typing import Mapping, Union, MutableMapping from typing_extensions import TypedDict, NotRequired class Pet(TypedDict): softness: NotRequired[int] name: NotRequired[str] # **IMPORTANT**: Assume these are only known ...
<python><mypy><python-typing>
2024-04-14 15:41:39
1
437
user1848244
78,324,285
10,200,497
How can I find the first row that meets conditions of a mask for each group?
<p>This is my DataFrame:</p> <pre><code>import pandas as pd df = pd.DataFrame( { 'a': ['x', 'x', 'x', 'x', 'x', 'y', 'y', 'y', 'y', 'y', 'y', 'y'], 'b': [1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2], 'c': [9, 8, 11, 13, 14, 3, 104, 106, 11, 100, 70, 7] } ) </code></pre> <p>Expected output: Creati...
<python><pandas><dataframe><group-by>
2024-04-14 15:24:24
3
2,679
AmirX
78,323,995
7,633,739
`BaseSettings` has been moved to the `pydantic-settings` package
<p>I am struggling with this error from long now, tried other solutions but no luck, here is my overview about the issue.</p> <p>Firstly i am not at all using this package anywhere in my project, seems like python is executing this internally, but still i am facing this issue, here are my python configurations</p> <pre...
<python><langchain>
2024-04-14 13:48:48
0
320
Pradeep Yenkuwale
78,323,943
5,257,430
Statistic values of Fleiss Kappa using statsmodels.stats.inter_rater
<p>I use statsmodels.stats.inter_rater.fleiss_kappa to calculate my inter-rater reliability. I only get the kappa value. What if I need the z-value, p-value, and range?</p>
<python><pandas><statsmodels>
2024-04-14 13:31:15
1
621
pill45
78,323,859
9,111,293
Broadcast pytorch array across channels based on another array
<p>I have two arrays, <code>x</code> and <code>y</code>, with the same shape (<code>B 1 N</code>).</p> <p><code>x</code> represents data and <code>y</code> represents which class (from <code>1</code> to <code>C</code>) each datapoint in <code>x</code> belongs to.</p> <p>I want to create a new tensor <code>z</code> (wit...
<python><pytorch><tensor>
2024-04-14 12:59:45
1
579
Vivek
78,323,749
6,915,206
AWS EC2 Server not serving some pages and static files propperly
<p>I just Deployed a <a href="http://3.17.142.65/" rel="nofollow noreferrer">website</a> on AWS EC2 from github clone. When i visit to <a href="http://3.17.142.65/influencers/" rel="nofollow noreferrer">Influencer Marketing</a> &amp; <a href="http://3.17.142.65/career/" rel="nofollow noreferrer">Career</a> pages the se...
<python><django><amazon-web-services><amazon-s3><django-staticfiles>
2024-04-14 12:13:05
2
563
Rahul Verma
78,323,737
1,440,299
Python+Selenium. Page wan't load in headless mode
<p>I'm trying load page with that code</p> <pre><code> from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import...
<python><selenium-webdriver><selenium-chromedriver><google-chrome-headless>
2024-04-14 12:09:41
1
355
Ishayahu
78,323,703
2,913,106
What sparse object should be used for indexing via coordinates and efficient summing across dimensions?
<p>I'd like to find some container object to contain scalar values (doesn't really matter whether integral or fractional or floating point types). The following snippet roughly outlines the usecases and the criteria it needs to fulfill. In this snipped I'm using a numpy array, but I'd like to avoid that as it needs a l...
<python><arrays><numpy><data-structures><probability-distribution>
2024-04-14 11:55:38
1
11,728
flawr
78,323,611
1,725,836
OpenCV play video without waitKey
<p>I'm trying to play a video with OpenCV in Python. For that I use this code:</p> <pre class="lang-py prettyprint-override"><code>i = 0 while True: frame = frames[i] cv2.imshow(&quot;video&quot;, frame) cv2.waitKey(int(1000 / frame_rate)) i += 1 </code></pre> <p>But once the user uses his keyboard, the...
<python><opencv><user-interface>
2024-04-14 11:24:06
1
9,887
nrofis
78,323,579
6,709,460
FastAPI TrustedHostMiddleware refuses my host
<p>When I was developing the application on my local machine and I tried to reach <code>/docs</code> I had to set up up <code>127.0.0.1</code> as my trusted host. This worked fine. But now I have put the app on the server and when I try to reach <code>/docs</code> with the IP of my computer, I am denied access.</p> <p>...
<python><fastapi><middleware><starlette>
2024-04-14 11:14:46
1
741
Testing man
78,323,390
10,480,181
How to install wheel file dependency with extras on Databricks?
<p>One of my workflows has a python wheel file dependency. However that wheel file also has extra dependencies that need to be installed. How can I do that on databricks?</p> <p>I tried using a init script but it doesn't work. I want to do something analogous to:</p> <pre><code>pip install &quot;path/to/wheel/file/mywh...
<python><azure-databricks><python-packaging><python-wheel>
2024-04-14 10:04:10
0
883
Vandit Goel
78,323,238
7,611,838
Timeout before the position for partition could be determined in one topic in apache beam ReadFromKafka
<p>I'm having a Google dataflow job, I'm using apache beam <code>ReadFromKafka</code> to consume topic messages. I'm consuming 4 topics. The pipeline used to work fine, after we added a new broker to our kafka cluster and triggered a rebalancing, the consumer started failing on one specific topic but successfully kept ...
<python><java><apache-kafka><google-cloud-dataflow><apache-beam>
2024-04-14 08:56:13
1
974
Idhem
78,323,213
13,443,114
Environment variable set as password is appearing as empty string in Python Environ library
<p>I just noticed that when I set an environment variable as <code>PASSWORD</code> for my script in Python, I am using the <a href="https://pypi.org/project/python-environ/" rel="nofollow noreferrer">python-environ</a> library to read and access environment variables, the value for the environment variable set to passw...
<python><python-3.x><environment-variables>
2024-04-14 08:43:38
2
428
Brian Obot
78,323,033
12,454,639
Im not sure I understand why Django wont let me do asynchronous database transactions
<p>I am trying to create a function that will get_or_create a user record for my discord bot in my django User model as soon as someone runs the <code>!home</code> command - but I am encountering an issue that (as far as I understand) is a normal part of django's existing model wherein it disallows asynchronous databas...
<python><django><python-asyncio>
2024-04-14 07:17:46
1
314
Syllogism
78,322,897
3,224,483
Why does this code use more and more memory over time?
<p>Python: 3.11 Saxonche: 12.4.2</p> <p>My website keeps consuming more and more memory until the server runs out of memory and crashes. I isolated the problematic code to the following script:</p> <pre class="lang-python prettyprint-override"><code>import gc from time import sleep from saxonche import PySaxonProcesso...
<python><saxon><saxon-c>
2024-04-14 06:14:07
3
3,659
Rainbolt
78,322,641
13,142,245
SqlModel - specify index type (B-Tree, Hash, etc.)
<p>I'm looking at documentation for SQLModel. The python library is written by the author of FastAPI, so I'm eager to leverage the seamless db integration via SqlModel.</p> <p>In the <a href="https://sqlmodel.tiangolo.com/tutorial/indexes/" rel="nofollow noreferrer">docs</a>, he illustrates what an index is and how it ...
<python><sqlalchemy><orm><sqlmodel>
2024-04-14 03:38:53
1
1,238
jbuddy_13
78,322,538
4,117,496
ModuleNotFoundError: No module named 'torch' on AWS Batch GPU instance
<p>I have a job that runs on AWS Batch on a GPU instance, my application uses torch, i.e.</p> <pre><code>import torch </code></pre> <p>The Compute Environment has only one GPU instance, I was able to confirm that <code>torch</code> is available there by connecting to the instance via AWS Console and ran:</p> <pre><code...
<python><amazon-web-services><tensorflow><pytorch><aws-batch>
2024-04-14 02:31:57
1
3,648
Fisher Coder
78,322,530
25,891
How to use OpenCV estimateAffinePartial2D
<p>I need to align two (actually hundreds of) images and I'm at a loss on how to do that in Python with OpenCV (which I have never heard of before). It looks like I should first estimate the transformation to apply as follows, and then apply it to one of the image (rinse and repeat hundreds of times). However even the ...
<python><opencv>
2024-04-14 02:29:49
1
17,904
Davide
78,322,515
5,264,310
Is there a way to make a long for loop to run faster?
<p>Im making a simple montecarlo simulator that takes in a 3*4 matrix of probabilities, and the number of iterations you want to simulate for. And the output is a table with all the results. Each row of the table is a list that contains: [iter no, random no, result1, result2] The logic is simple, just generate a random...
<python><list><numpy><loops>
2024-04-14 02:23:11
1
1,147
Xcecution
78,322,507
10,483,893
sqlalchemy session "Cannot use autocommit mode with future=True."
<p>Since which version sqlalchemy session <em>&quot;Cannot use autocommit mode with future=True.&quot;</em>? <a href="https://rattailproject.org/docs/wuttjamaican/_modules/sqlalchemy/orm/session.html" rel="nofollow noreferrer">https://rattailproject.org/docs/wuttjamaican/_modules/sqlalchemy/orm/session.html</a></p> <pr...
<python><sqlalchemy>
2024-04-14 02:20:47
1
1,404
user3761555
78,322,464
10,061,193
Including `.jinja` template files inside the Python distribution using `pyproject.toml`
<p>I'm working on a package. It has a console command that enables users to generate a template from the <code>.jinja</code> files within the distribution.</p> <p>My issue is that I can't include them (template files) in my distribution. Here is a tree-look of my package and where my templates are located. (<code>templ...
<python><templates><jinja2><packaging><python-packaging>
2024-04-14 01:40:26
0
394
Sadra
78,322,364
1,802,225
Ethereum: how to call Smart Contract functions directly with JSON-RPC method?
<p>I need to execute and call http JSON-RPC ethereum node to get results without web3py or web3js. How to do that? I have read there is <code>eth_call</code> method, but I didn't find any examples with ABI how to use. Below is example with <code>eth_getTransactionByHash</code>.</p> <pre class="lang-py prettyprint-overr...
<python><ethereum><smartcontracts><web3py>
2024-04-14 00:30:41
0
1,770
sirjay
78,322,358
219,153
Does eval() have performance advantage in Mojo vs. Python?
<p>I would like to use <code>eval()</code> for validation of short function synthesis. The search space may be fairly large, e.g. more than a million different functions. Functions will be synthesized as a string containing their source code and executed with <code>eval()</code>.</p> <p>Will Mojo have a performance adv...
<python><eval><mojolang>
2024-04-14 00:29:05
1
8,585
Paul Jurczak
78,322,249
17,517,315
Correct inheritance of methods from dataclass in Python
<p>I'm quite new to dataclasses and OOP in Python and I have been trying to figure out how to inheritance works. Before anything, I am really sorry if my question has been asked in one way or another, I really tried to look for similar questions but there is nothing out there that answered me. So apologies beforehand i...
<python><oop><python-dataclasses>
2024-04-13 23:04:00
0
391
matt.aurelio
78,322,169
1,498,178
How to merge Django model query results?
<p>I have to modify a legacy Django web application where there are 2 tables to store the same information using the same database structure, and the only difference is the names of the tables (and the corresponding Django models):</p> <ul> <li><code>ProgramAAssignments</code> model for <code>program_a_assignments</cod...
<python><django-models>
2024-04-13 22:10:12
1
8,705
toraritte
78,322,167
2,030,532
Why tab completion in PyCharm python console is much slower than a terminal?
<p>I am running my python script in python console of PyCharm and the tab completion of a custom object attributes is pretty slow (unusable). However when I run the same code is a terminal using IPython the tab completion is fast. I tried increasing the memory limits of PyCharm with no avail. Is this a limitation of Py...
<python><pycharm>
2024-04-13 22:09:29
0
3,874
motam79
78,321,952
8,713,442
Python Code failing : dedupe library error
<p>I am trying to learn about dedupe library . I am trying to match name which are more than 80% match.</p> <p>Sharing code and error . Please help</p> <pre><code>import dedupe from Levenshtein import distance def test(): # Sample data (replace with your actual library data) data = [ {'name': 'Alice ...
<python><python-3.x><python-dedupe>
2024-04-13 20:36:13
1
464
pbh
78,321,701
8,713,442
pip install dedupe not working for python 3.11
<p>While doing pip install dedupe getting following error .</p> <p>Python installed is 3.11 . Please help I am trying collect cluster id using dedupe . Running it from pycharm .</p> <blockquote> <pre><code> Building wheels for collected packages: affinegap, doublemetaphone Building wheel for affinegap (pyproject...
<python><python-dedupe>
2024-04-13 18:56:47
1
464
pbh
78,321,696
15,474,507
GetMessagesReactionsRequest - distinguish reactions between 2 users
<p>Is there a system to distinguish the reaction of one user from another? <br>I'm testing with two my personal telegram accounts, but the terminal always gives me the same username, but in reality they are 2 users that makes reaction, not the same one.</p> <p><a href="https://i.sstatic.net/5EqYt.png" rel="nofollow nor...
<python><telegram><telethon>
2024-04-13 18:55:11
0
307
Alex Doc
78,321,650
13,392,257
Keycloak: requests.exceptions.MissingSchema: Invalid URL 'None': No scheme supplied
<p>I am trying to run KeyCloak server and FastAPI application locally. I am following this tutorial <a href="https://fastapi-keycloak.code-specialist.com/quick_start/" rel="nofollow noreferrer">https://fastapi-keycloak.code-specialist.com/quick_start/</a></p> <p>My actions:</p> <p>1 Created docker-compose.yaml</p> <pre...
<python><keycloak><fastapi>
2024-04-13 18:37:28
0
1,708
mascai
78,321,309
13,174,189
How to group rows in dataframe based on timestamps ranges and mean group size maximization?
<p>I have a data frame:</p> <pre><code>prod_id timestamp1 timestamp2 1 2023-12-02 2023-12-01 2 2023-12-05 2023-12-01 3 2023-12-06 2023-12-01 4 ...
<python><python-3.x><algorithm><function><genetic-algorithm>
2024-04-13 16:39:34
1
1,199
french_fries
78,321,225
12,560,241
Find if a set of lists of 2 values are the result of the possible combination of a n-value list
<p>I have used itertools to find all possible 2-element combination (without repetition) from a set of 10 elements to which I have applied some filtering to reduce the 2-element combination based on given condition</p> <p>For simplicity suppose the code below: the 10 elements are the number 1 to 10. The code I have use...
<python><combinations><python-itertools><combinatorics><more-itertools>
2024-04-13 16:12:56
1
317
Marco_sbt
78,321,161
8,641,778
How to csat WinID handle to capsule in pyside6
<p>In pyqt, one can access wid as <code>sip.voidptr</code>, using <code>widget.winId()</code>, and then turn it to capsule object using <code>wid.ascapsule()</code></p> <p>In pyside6, when using <code>widget.winId()</code>, I can only get an int number.</p> <p>How can I get winId() as ptr like pyqt when using pyside6?<...
<python><qt><pyqt><pyside>
2024-04-13 15:53:29
1
323
C-Entropy
78,321,095
4,398,966
Spyder stdout not being flushed
<p>Updated with complete example. I'm running this in Spyder but it's been noted in comments that this works as expected from a windows command prompt.</p> <p>I have the following:</p> <pre><code>import sys import os class Portfolio: @classmethod def menu(cls): print(&quot;Main Menu&quot;) ...
<python><python-3.x><buffer><screen>
2024-04-13 15:33:45
0
15,782
DCR
78,321,036
2,649,312
Python how to pull data from dictionary
<p>Using the <code>weerlive.nl</code> API to pull weather data from the Dutch meteriological institute (KNMI), I get a dictionary with one key <code>'liveweer'</code> with a long set of tuples:</p> <pre><code>dict_values([[{'plaats': 'Tilburg', 'timestamp': '1713019987', 'time': '13-04-2024 16:53', 'temp': '23.3', 'gte...
<python><dictionary>
2024-04-13 15:15:19
2
811
jdelange
78,321,025
3,437,012
Why is this trivial numba function with a List input so slow
<pre><code>import numba from typing import List @numba.njit def test(a: List[int]) -&gt; int: return 1 test([i for i in range(2_000_000)]) </code></pre> <p>takes 2s and scales linearly with the size of the list. Wrapping the input argument with <code>numba.typed.List</code> takes even longer. (all the time is spe...
<python><numpy><numba>
2024-04-13 15:12:13
1
2,370
Bananach
78,320,873
19,576,917
How to achieve concurrency with python telegram bot module
<p>I am using python telegram bot module to create a bot that takes an image in Braille as an input, translates it then returns the English translation. The method responsible for the translation is defined as follows,</p> <pre><code>async def start_translation(update: Update, context: CallbackContext): # translati...
<python><parallel-processing><python-telegram-bot>
2024-04-13 14:22:00
0
488
Chandler Bong
78,320,840
16,569,183
Piping pip freeze and pip uninstall
<p>I can clean my current python environment in two steps</p> <pre class="lang-bash prettyprint-override"><code>pip freeze &gt; requirements.txt pip uninstall -r requirements.txt -y </code></pre> <p>I was wondering if it's possible to pipe these two commands to avoid creating the temporary file (and why or why not). Th...
<python><pip>
2024-04-13 14:11:27
1
313
alfonsoSR
78,320,789
2,494,795
Register a Pandas Dataframe to Azure Machine Learning: NOT_SUPPORTED_API_USE_ATTEMPT
<p>I have been using the following code to register Pandas dataframes to Azure ML:</p> <pre><code>workspace = Workspace(&lt;subscription_id&gt;, &lt;resource_group&gt;, &lt;workspace_name&gt;) from azureml.core import Dataset datastore = workspace.get_default_datastore() ds = Dataset.Tabular.register_pandas_dataframe(d...
<python><pandas><azure><azure-machine-learning-service>
2024-04-13 13:58:03
1
1,636
Irina
78,320,581
1,089,412
Pydantic - change data in nested model before validation
<p>I have this small example of nested object with pydantic.</p> <pre class="lang-py prettyprint-override"><code>from typing import Dict from pydantic import BaseModel, Field, ValidationError class UserType(BaseModel): name: str = Field(min_length=1) type: str = Field(min_length=1) class AppConfig(BaseModel):...
<python><validation><pydantic>
2024-04-13 12:30:53
1
3,306
piotrekkr
78,320,551
5,473,482
Find intersection point between line and ellipse in Python
<p>I am trying to find the point which intersects with the line and the ellipse. I can find the point manually as seen in the code but how can I find it automatically. Also when the red point is inside the ellipse the green point should also be projected on to the ellipse when extending the line. How can I solve this? ...
<python><math><geometry><ellipse>
2024-04-13 12:17:38
2
1,047
Blind0ne
78,320,404
3,047,069
Facing problems saving JSON data to postgres using Python FastAPI
<p>I am using python and Fastapi to build a project. I am fairly new to both the technologies, and now getting stuck at a task of uploading a JSON file to an endpoint and then saving its contents to postgresSQL.</p> <p>Here are some details:</p> <p><strong>vehicles.json: It can have list of 500-600 entries in the forma...
<python><json><postgresql><fastapi><psycopg2>
2024-04-13 11:21:27
0
821
Radheya
78,320,399
5,378,816
Type hint for a function returning the same type not working
<p>What is wrong in this example? Isn't the <code>str -&gt; str</code> case included in <code>T -&gt; T</code> ?</p> <pre><code>from typing import TypeVar T = TypeVar(&quot;T&quot;) def unch(arg:T) -&gt; T: if isinstance(arg, str): return arg return arg </code></pre> <p><code>mypy</code> checking resu...
<python><mypy><python-typing>
2024-04-13 11:19:05
0
17,998
VPfB
78,320,329
6,303,377
Can't run inference SDK on AWS Lambda due to error with multiprocessing
<p>I am running this code on AWS Lambda</p> <pre><code>import os from inference_sdk import InferenceHTTPClient def handler(event, context): client = InferenceHTTPClient(api_url=&quot;https://detect.roboflow.com&quot;, api_key=os.environ[&quot;ROBOFLOW_API_KEY&quot;]) img_path ...
<python><python-3.x><amazon-web-services><aws-lambda>
2024-04-13 10:50:15
0
1,789
Dominique Paul
78,320,199
1,920,003
How to improve Nginx/Uvicorn upload speed in FastAPI application?
<p>I have an Ubuntu server, running a Nginx reverse proxy for a FastAPI application using Uvicorn. The server is an AWS EC2 g4n.xlarge in Virginia. On the frontend I'm using HTMX My personal home upload speed is close to 1GBPs, fiber optics, I'm connected via the ethernet cable.</p> <p>The application uploads the file ...
<python><nginx><fastapi><uvicorn>
2024-04-13 09:55:03
1
5,375
Lynob
78,320,086
710,955
How get the value of a 'charset' meta element with Xpath?
<p>With Selenium webdriver, I'm trying to parse a <code>charset</code> meta element from a page.</p> <pre class="lang-html prettyprint-override"><code>&lt;meta charset=&quot;UTF-8&quot;&gt; </code></pre> <p>This is what I have so far</p> <pre class="lang-py prettyprint-override"><code>from selenium.webdriver.common.by...
<python><selenium-webdriver><xpath><html-meta>
2024-04-13 09:03:57
2
5,809
LeMoussel