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,686,818
5,924,264
How to do a cartesian join of a numpy array and a pandas series?
<p>I have a numpy array <code>ids</code> (unique) and a pandas series <code>dates</code>.</p> <p>I want to create a pandas dataframe that is a cartesian product of <code>ids</code> and <code>dates</code> with columns <code>id</code> and <code>date</code> grouped by date.</p> <p>e.g., <code>ids = [1, 2]</code> and <code...
<python><pandas><cartesian-product>
2023-12-19 16:59:35
3
2,502
roulette01
77,686,715
1,574,054
How can I get the x coordinate of a ylabel in matplotlib?
<p>I have this example:</p> <pre><code>from numpy import linspace, sin from matplotlib.pyplot import plot, ylabel, gcf, text x = linspace(0, 1) y = x ** 2 plot(x, y) ylabel(&quot;test&quot;) </code></pre> <p>I now want to place some text <em>approximately</em> like &quot;abc&quot; in this figure:</p> <p><a href="https...
<python><matplotlib>
2023-12-19 16:42:28
1
4,589
HerpDerpington
77,686,694
15,893,581
SVD Decomposition for linear equation solving
<p>I'm looking for <a href="https://www.ltu.se/cms_fs/1.51590!/svd-fitting.pdf" rel="nofollow noreferrer">Algo here</a> &amp; trying to implement <a href="https://sthalles.github.io/svd-for-regression/" rel="nofollow noreferrer">this code</a>, I'm getting different <code>l2-norms</code> for resulting vectors of params ...
<python><scipy><svd>
2023-12-19 16:38:43
1
645
JeeyCi
77,686,665
2,711,059
Understanding Exception Handling on the context of Inheritance in Python
<p>On the context of Inheritance of the Exception handling class</p> <p><a href="https://i.sstatic.net/uYRCM.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uYRCM.jpg" alt="enter image description here" /></a></p> <p>Exception is inherited from BaseException, so all the implementation of the BaseExceptio...
<python><inheritance>
2023-12-19 16:34:08
2
5,268
Lijin Durairaj
77,686,557
1,838,726
For a given node, how to find small cycles of which that node is a member?
<p>I'm using python and <a href="https://graph-tool.skewed.de/" rel="nofollow noreferrer">graph-tool</a> to do graph analysis. In a graph <code>g</code>, I want to find all cycles up to a specific length <code>max_length</code> of which a given node <code>node</code> is a member.</p> <p>Related question:<br /> <a href=...
<python><graph-theory><graph-tool><cycle-detection>
2023-12-19 16:17:26
0
6,700
Daniel S.
77,686,480
8,938,220
python dbf query with multiple conditions
<p>I am using <a href="https://pypi.org/project/dbf/" rel="nofollow noreferrer">dbf</a> strong text module in my projects.</p> <p>my dbf file condtains 5 fields. (ACKNO is primary key field)</p> <p>ACKNO INVNO INVDT CTYPE DTYPE</p> <p>Read DBF is working file and querying single field (using .index_search)is work...
<python><pandas><dataframe><dbf>
2023-12-19 16:02:32
1
343
Ravi Kannan
77,686,416
9,173,710
How to use different colorpalette for each subplot in seaborn catplot
<p>I am plotting categorical data with seaborn catplot. I want to make 2 plots from my data, they just differ in that the x, hue and col parameters are swapped around.</p> <p><a href="https://i.sstatic.net/r9ebtm.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/r9ebtm.png" alt="enter image description her...
<python><matplotlib><plot><seaborn>
2023-12-19 15:52:13
1
1,215
Raphael
77,686,189
1,838,726
How to iterate simple cycles in ascending cycle length order?
<p>I want to find all nodes of a graph, which are in simple cycles of length up to some given maximum cycle length <code>max_length</code>. Along with this I want to make a histogram of the number of cycles (per cycle length) that each node is contained in. I'm trying to figure out what the best way is to get this task...
<python><graph-theory><graph-tool><cycle-detection>
2023-12-19 15:12:48
2
6,700
Daniel S.
77,686,182
1,874,170
Override or augment setuptools build_ext error messages
<p>I'm trying to build on a fresh Linux installation a CFFI-based package I'm maintaining.</p> <p>However, out of the box, the errors it gives about the dependencies pip couldn't fetch (attached at the end of this post) are useless and inscrutable.</p> <p>I want to <strong>catch, override, or somehow augment</strong> t...
<python><error-handling><setuptools><python-packaging><code-documentation>
2023-12-19 15:11:28
0
1,117
JamesTheAwesomeDude
77,686,120
15,991,297
Get Lowest Elementwise Values from Multiple Numpy Arrays Which May be Different Lengths
<p>I can get the lowest values from multiple arrays by using the following:</p> <pre><code>first_arr = np.array([0,1,2]) second_arr = np.array([1,0,3]) third_arr = np.array([3,0,4]) fourth_arr = np.array([1,1,9]) print(np.minimum.reduce([first_arr, second_arr, third_arr, fourth_arr])) </code></pre> <p>Result = [0 0 2]...
<python><numpy>
2023-12-19 15:00:49
3
500
James
77,686,078
7,766,158
Django : Update object in database using UpdateAPIView
<p>I have a Django project with the the following <code>models.py</code></p> <pre><code>from django.db import models class RawUser(models.Model): id = models.CharField(max_length=256, primary_key=True) field1 = models.IntegerField(null=True) field2 = models.CharField(max_length=256) </code></pre> <p>And th...
<python><django>
2023-12-19 14:55:12
0
1,931
Nakeuh
77,686,072
6,067,741
Issues with azure.identity when using federated credentials
<p>I'm running a GH actions pipeline which is configured to login Azure cli using federated credentials (and this works fine):</p> <pre><code>env: ARM_USE_OIDC: true steps: - name: az login uses: azure/login@v1 with: client-id: ${{ env.ARM_CLIENT_ID }} tenant-id: ${{ env.ARM_TENANT_ID }} subscription...
<python><azure><authentication><github><pytest>
2023-12-19 14:54:14
1
71,429
4c74356b41
77,686,055
2,414,957
lmdb/cpython.c:26:10: fatal error: Python.h: No such file or directory
<p>[Disclaimer] I need to use same exact version Blender as well as the bundled Python that comes with it for <a href="https://github.com/zju3dv/pvnet-rendering/" rel="nofollow noreferrer">PVNET-Rendering git repo</a>. Steps to reproduce the error:</p> <p>1.</p> <pre><code>root@fae597dbdb79:/home# wget https://bootstra...
<python><ubuntu><pip><blender><lmdb>
2023-12-19 14:52:42
1
38,867
Mona Jalal
77,686,033
10,145,953
OpenCV boundingRect to detect rectangle?
<p>I am new to OpenCV and I'm having some trouble figuring out how to crop a rectangle in an image. I have a PDF of a form (which I've converted to an image) which looks similar to this <a href="https://img.yumpu.com/16772683/1/500x640/dd-form-2585-repatriation-processing-center-processing-sheet-.jpg" rel="nofollow nor...
<python><opencv>
2023-12-19 14:49:17
1
883
carousallie
77,686,020
9,973,879
How to align the axes of a figure in matplotlib?
<p>I have a figure with a <code>2x2</code> grid of <code>plt.Axes</code> (one of which is actually removed). Axes of the same row (resp. col) share the same y-axis (resp. x-axis) range. For example,</p> <pre class="lang-py prettyprint-override"><code>import matplotlib.pyplot as plt import numpy as np fig, axs = plt.su...
<python><matplotlib>
2023-12-19 14:47:47
2
1,967
user209974
77,685,970
3,445,378
How to use the python-flask server generated by swagger-codegen?
<p>I have a simple open-api-definition that can used by swagger-codegen to generate a client and server application. While using the client is not a problem, I find no information how to use the server.</p> <p>So far I can see, that the server is based on connextion. There is also a setup.py from setup-tools.</p> <p>Th...
<python><swagger-codegen>
2023-12-19 14:37:53
0
1,280
testo
77,685,924
1,933,185
Uncaught ReferenceError: IPython is not defined
<p>I try to pass a javascript variable to python in a jupyter notebook, as described in <a href="https://stackoverflow.com/q/37172978/1933185">How to pass variables from javascript to python in Jupyter?</a></p> <p>Somehow the <code>IPython.notebook.kernel.execute(&quot;foo=97&quot;)</code> seems not to work, but IPytho...
<python><jupyter-notebook><ipython>
2023-12-19 14:30:12
0
5,797
jerik
77,685,797
8,510,149
Create a dynamic case when statement based on pyspark dataframe
<p>I have a dataframe called <code>df</code> with <code>features, col1, col2, col3</code>. Their values should be combined and produce a result. What result each combination will produce is defined in <code>mapping_table</code>.</p> <p>However, mapping_table sometimes has the value '*'. This mean that this feature can ...
<python><pyspark>
2023-12-19 14:10:24
1
1,255
Henri
77,685,544
8,030,746
Selenium: Chrome suddenly stopped working
<p>I have a scraping script that worked perfectly, but then out of the blue suddenly stopped. This is the error I'm getting:</p> <pre><code>Traceback (most recent call last): File &quot;/home/user/myproject/scraping_all.py&quot;, line 29, in &lt;module&gt; driver = webdriver.Chrome(options=options) ^...
<python><google-chrome><selenium-webdriver>
2023-12-19 13:27:57
0
851
hemoglobin
77,685,213
13,518,907
How to Speed up RetrievalQA Chain?
<p>I have created a RetrievalQA chain and now want to speed up the process. At the moment, the generation of the text takes too long (1-2minutes) with the qunatized Mixtral 8x7B-Instruct model from &quot;TheBloke&quot;.</p> <p>I am running the chain locally on a Macbook Pro (Apple M2 Max) with 64GB RAM, and 12 cores.</...
<python><artificial-intelligence><langchain>
2023-12-19 12:33:01
0
565
Maxl Gemeinderat
77,685,135
12,704,700
How do i write to dynamo from pyspark without the attributevalues?
<p>I have a dynamicframe which has following schema</p> <pre><code>root |-- data1: string (nullable = false) |-- data2: string (nullable = false) |-- data3: array (nullable = false) | |-- element: string (containsNull = true) </code></pre> <p>Now when i write this to dynamodb using the</p> <pre><code>glue_contex...
<python><pyspark><amazon-dynamodb>
2023-12-19 12:19:09
1
2,505
Sundeep
77,684,851
7,566,673
Cluster list elements into sublists if an element is greater than threshold
<p>I have a list which has <code>str</code>, <code>int</code>, and <code>float</code> elements.</p> <p>I want to create sublists (cluster elements) in such a way that if any numeric element is greater than threshold (here threshold is 3), a cluster will be created containing the previous elements. Code and expected ou...
<python><python-3.x><list>
2023-12-19 11:30:31
1
1,219
Bharat Sharma
77,684,767
10,595,871
Azure speech to text gives "The recordings URI contains invalid data"
<p>I am trying to transcribe the text from an audio, I'm using the code provided by azure: <a href="https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/samples/batch/python/python-client/main.py" rel="nofollow noreferrer">https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/...
<python><azure><speech-to-text>
2023-12-19 11:17:09
1
691
Federicofkt
77,684,764
883,164
Getting this message on langchain: The FileType.UNK file type is not supported in partition. Has anyone figured this out?
<p>Getting this message on langchain: The FileType.UNK file type is not supported in partition.</p> <p>I haven't found much info on the web. The folder only contains PDF documents, nothing else.</p> <p>This is what I'm running:</p> <pre><code>from langchain.embeddings import OpenAIEmbeddings from langchain.vectorstores...
<python>
2023-12-19 11:16:43
1
570
biogeek
77,684,593
2,813,085
Is there a way to retain keys in Polars left join
<p>Is there a way to retain both the left and right join keys when performing a left join using the Python Polars library? Currently it seems that only the left join key is retained but the right join key gets dropped.</p> <p>Please see example code below:</p> <pre><code>import polars as pl df = pl.DataFrame( { ...
<python><dataframe><left-join><python-polars>
2023-12-19 10:45:01
2
644
jeremyh
77,684,402
7,766,158
Django : Serializer validation prevents my code from updating an existing object
<p>I have a Django project that get some user data and store them in a database. I want my function to handle both <code>Create</code> and <code>Update</code> with the same method, so I created a view that inherit from <code>UpdateAPIView</code></p> <pre><code>class UserList(generics.UpdateAPIView): queryset = RawU...
<python><django>
2023-12-19 10:12:17
1
1,931
Nakeuh
77,684,346
219,976
Type checking in pycharm for class-decorated property
<p>I'm using PyCharm 2023.2.3 (Community Edition) for developing. There's a script:</p> <pre><code>from functools import cached_property from collections.abc import Callable from typing import TypeVar, Generic, Any, overload, Union T = TypeVar(&quot;T&quot;) class result_property(cached_property, Generic[T]): ...
<python><pycharm><python-decorators><python-typing>
2023-12-19 10:04:03
1
6,657
StuffHappens
77,684,053
10,468,528
"Module does not explicitly reexport attribute" Mypy implicit-reexport
<p>I have a python library of the following structure:</p> <pre><code>module &gt; module_namespace __init__.py MyClass.py &gt; asyncio __init__.py MyClass.py </code></pre> <p>In the <strong>ini</strong>.py files I have explicitly exported the classes like:</p> <pre><code># __init__.py from .MyC...
<python><mypy><python-module><python-typing>
2023-12-19 09:15:17
0
395
Miguel Wang
77,684,046
955,885
How to access rest point from Python that requires a google sign on?
<p>I am trying to do a:</p> <pre><code>response = requests.post(url, json=payload) </code></pre> <p>call in Python to a site, but get &quot;unauthorized&quot; response. If I use a browser, I get redirected first to &quot;https://accounts.google.com/v3/signin/identifier/...&quot; to authenticate (which I do) before allo...
<python><python-3.x><rest><oauth-2.0><google-api-python-client>
2023-12-19 09:13:24
1
727
Nicko Po
77,684,036
7,566,673
summing up elements between two strings in list
<p>I have a list of <code>str</code> and <code>int</code> elements as given below</p> <pre><code>L = [1, &quot;a&quot;, &quot;b&quot;, 1, 2, 1, &quot;d&quot;, 1, &quot;e&quot;, 4, 5, &quot;f&quot;, &quot;g&quot;, 2] </code></pre> <p>I want to sum up numbers found between two string elements so resultant output is excp...
<python>
2023-12-19 09:12:22
2
1,219
Bharat Sharma
77,683,855
2,803,777
Can I use a more pythonic way for my conditional array operations?
<p>In Python using <code>numpy</code> I have to do some iterations over a <code>numpy</code> 2D array. I boiled down the original problem to its essentials:</p> <pre><code>f = np.array([[0, 0, 0, 0, 0, 0, 0], [0, 10, 22, 30, 40, 50, 0], [0, 11, 22, 33, 44, 55, 0], [0, 0, 0, 0, 0, 0, 0]]) u = np.array([[1, 1, 1, 1, 1, 1...
<python><numpy>
2023-12-19 08:42:16
2
1,502
MichaelW
77,683,810
21,049,944
fastest way to use cmaps in Polars
<p>I would like to create a column of color lists of type [r,g,b,a] from another float column using a matplotlib cmap.</p> <p>Is there a faster way then:</p> <pre><code>data.with_columns( pl.col(&quot;floatCol&quot;)/100) .map_elements(cmap1) ) </code></pre> <p>Minimal working example:</p> <pre><code>im...
<python><python-polars>
2023-12-19 08:33:22
1
388
Galedon
77,683,734
3,336,423
Prevent Ctrl+C sent to child process being received by parent process too
<p>Consider this very simple Python program:</p> <pre><code>import subprocess import time import signal import sys if __name__ == '__main__': process = subprocess.Popen( [&quot;timeout&quot;,&quot;5&quot;] ) time.sleep(1) print(&quot;PID is &quot; + str(process.pid)) process.send_signal( signa...
<python>
2023-12-19 08:16:47
0
21,904
jpo38
77,683,731
23,106,915
Smoother Tkinter GUI
<p>So instead of tkinter, I am using customtkinter for my python GUIs. So what I am trying to do is whenever a user clicks a button in my project the frame changes to another frame</p> <p><strong>Example:</strong></p> <pre><code>def analytics_win(): if frame_main_win.winfo_ismapped(): frame_main_win.pack_fo...
<python><user-interface><tkinter>
2023-12-19 08:16:00
1
546
AshhadDevLab
77,683,712
5,594,008
Refactoring multiple ifs
<p>My current code is this</p> <pre><code>class CounterFilters(TextChoices): publications_total = &quot;publications-total&quot; publications_free = &quot;publications-free&quot; publications_paid = &quot;publications-paid&quot; comments_total = &quot;comments-total&quot; votes_total = &quot;voted-t...
<python><django>
2023-12-19 08:12:13
2
2,352
Headmaster
77,683,522
1,799,528
Retrieve all documents related to a long text file from FAISS Vectorstore
<p>Sorry if this question is too basic. But is it possible to retrieve all documents in a vectorstore which are chunks of a larger text file before embedding? Are the documents in vectorstore related to each other according to their metadata or something like that or is it only the similarity between the vectors that r...
<python><embedding><langchain><large-language-model><faiss>
2023-12-19 07:34:42
0
1,376
gabi
77,683,462
988,279
Python SQLAlchemy upgrade from 1.X to 2.X...add_entity is no more working
<p>Here is my models.py</p> <pre><code>Base = declarative_base() class Service(Base): __tablename__ = 'Service' id = Column('ID', primary_key=True) f_Service_type_id = Column('f_ServiceTypeID', Integer) sType = relationship('ServiceType', primaryjoin=&quot;Service.f_Service_...
<python><python-3.x><sqlalchemy>
2023-12-19 07:21:22
2
522
saromba
77,683,384
15,222,211
Python prometheus_client, how to get counter from the registry?
<p>How can I obtain a Counter object from the registry? In the example below, I am currently using the private argument to achieve this. Perhaps someone knows a more elegant way to accomplish this using only public methods?</p> <pre class="lang-py prettyprint-override"><code>from prometheus_client import CollectorRegis...
<python><prometheus>
2023-12-19 07:04:33
1
814
pyjedy
77,683,316
1,106,951
How to extract every 6th columns of a horizontally wide dataframe and append as rows into new cleaner dataframe
<p>I have a horizontally large CSV file with 606 columns. I have imported the csv into Pandas dataframe as</p> <pre><code>df = pd.read_csv(&quot;groups.csv&quot;) </code></pre> <p>but I need to change this weird horizontal length to a more readable vertically table. How can I extract every 6 columns in a loop from <co...
<python><pandas>
2023-12-19 06:45:28
1
6,336
Behseini
77,682,954
2,360,477
Connecting to SQL Server in PySpark
<p>Currently, I've got my PySpark python script in a Docker container, which is using the jupyter/pyspark-notebook image.</p> <p>I've downloaded the Microsoft JDBC driver (<a href="https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver16" rel="nofollow noref...
<python><docker><pyspark>
2023-12-19 04:43:58
0
1,075
user172839
77,682,908
1,502,898
Python: patch sqlite3.Cursor to accept kwargs
<p>I'm trying to patch <code>sqlite3.Cursor</code> to accept any random kwargs and ignore them.</p> <p>My attempt is below. Essentially this is trying to patch <code>sqlite3.Cursor</code> with <code>TestCursor</code> which accepts <code>**kwargs</code>, and ignores them.</p> <pre class="lang-py prettyprint-override"><c...
<python><sqlite><pytest>
2023-12-19 04:23:44
1
1,607
jprockbelly
77,682,444
7,796,211
PyGame: Use SDL2 to render a pixel
<p>I want to render a singular green pixel in PyGame with SDL2. This is my current code:</p> <pre class="lang-py prettyprint-override"><code>import pygame import pygame._sdl2 SCREEN_W = 800 SCREEN_H = 800 pygame.init() pygame_screen = pygame.display.set_mode((SCREEN_W, SCREEN_H), vsync=0, flags=pygame.SCALED) window...
<python><pygame>
2023-12-19 00:56:49
1
418
Thegerdfather
77,682,374
5,942,100
transform and replace values in existing column IF multiple matching values exist using pandas
<p>I have two datasets: A and B.</p> <p>If dataset A's <code>year</code>, <code>ID</code>, <code>delivery</code>, <code>type</code>, and <code>vendor</code> columns all match with dataset B's <code>Tags</code>, <code>ID</code>, <code>qtr</code>, <code>TYPE</code>, and <code>msc</code> columns, then I want to replace th...
<python><pandas>
2023-12-19 00:24:09
2
4,428
Lynn
77,682,075
189,270
splitlines() of lldb SBValue.GetSummary() result doesn't work?
<p>I have a program that supplies context dependent information that I'd like to display in lldb. For illustration purposes, imagine that program is as simple as:</p> <pre><code>#include &lt;stdio.h&gt; const char * get_perform_stack() { return &quot;CARP-AND-RETURN-IF-VSAM-ERROR\nMAIN\n&quot;; } int main() { ...
<python><lldb>
2023-12-18 22:30:27
1
8,350
Peeter Joot
77,682,050
2,749,393
Is there an API call to find out the random seed used for the Python `hash()` function?
<p>I know that if the <code>PYTHONHASHSEED</code> environment variable is not set or set to <code>&quot;random&quot;</code> then the hash function (used for <code>set</code>, <code>frozenset</code>, and <code>dict</code>) is salted with a random number.</p> <p>So I want to know if it is possible to find out what value ...
<python>
2023-12-18 22:22:40
1
930
daveraja
77,681,935
1,473,517
Can this simpler case of the 2d maximum submatrix problem be solved more quickly?
<p>Given an n by m matrix of integers, there is a well known problem of finding the submatrix with maximum sum. This can be solved with a 2d version of <a href="https://en.wikipedia.org/wiki/Maximum_subarray_problem" rel="nofollow noreferrer">Kadane's algorithm</a>. An explanation of an O(nm^2) time algorithm for the 2...
<python><algorithm>
2023-12-18 21:51:49
2
21,513
Simd
77,681,902
1,423,938
MySQLdb call procedure with long name
<p>In the <a href="https://mysqlclient.readthedocs.io/user_guide.html#cursor-objects" rel="nofollow noreferrer">documentation for callproc</a>, it uses the procedure name prepended by an underscore and appended with an underscore and the parameter's position. When calling a stored procedure with a long name, this cause...
<python><mysql><stored-procedures><database-cursor>
2023-12-18 21:44:53
1
2,433
Dewey Vozel
77,681,797
1,185,254
How to mock a constant value
<p>I have a structure like so:</p> <pre><code>mod1 ├── mod2 │ ├── __init__.py │ └── utils.py └── tests └── test_utils.py </code></pre> <p>where</p> <ul> <li><code>__init__.py</code>:</li> </ul> <pre><code>CONST = -1 </code></pre> <ul> <li><code>utils.py</code>:</li> </ul> <pre><code>from mod1.mod2 import CONST ...
<python><pytest><python-mock><pytest-mock>
2023-12-18 21:22:37
1
11,449
alex
77,681,786
1,804,173
Is it possible to statically wrap/derive a parameter from another paramerter in pytorch?
<p>I often run into situations where I want to train a parameter, but that parameter only gets used by the model in a transformed form. For example, think of a simple scalar parameter defined on <code>(-∞, +∞)</code>, but the model only wants to use that parameter wrapped in a sigmoid, to constrain it to <code>(0, 1)</...
<python><pytorch>
2023-12-18 21:19:11
1
27,316
bluenote10
77,681,757
643,920
determine availability (and price?) of 50k domains
<p>I have a list of 50k possible domain names. I'd like to find out which ones are available and if possible how much they cost. the list looks like this</p> <pre><code>presumptuous.ly principaliti.es procrastinat.es productivene.ss professional.ly profession.ally professorshi.ps prognosticat.es prohibitioni.st </code...
<python><linux><dns><whois>
2023-12-18 21:09:50
1
2,879
gnarbarian
77,681,622
1,181,452
OpenCV - motion detection in large video files
<p>I have large video files (over a few GB each) that I am trying detect motion on. I am using fairly basic OpenCV code in python with ROI to detect motion in a certain area of the video only. This works absolutely fine but takes absolutely ages to process large files. Is there any way to speed things up? I am simply j...
<python><opencv><ffmpeg><video-processing>
2023-12-18 20:35:40
0
3,296
M9A
77,681,610
6,168,639
Make a Django application pip-installable with pyproject.toml?
<p>I've got a couple Django projects that use the same 'shared application', which we will call <code>shared-django-app</code>. The shared application has it's own git repository.</p> <p>Recently, instead of having to run <code>git clone</code> after setting up the project to bring in the <code>shared-django-app</code>...
<python><django><git><pip><python-packaging>
2023-12-18 20:33:16
0
722
Hanny
77,681,471
9,357,484
Unable to tag the POS of the text file
<p>I want to tag the parts of speech of a sentence. For this task I am using <a href="https://huggingface.co/flair/pos-english-fast" rel="nofollow noreferrer">pos-english-fast</a> model. If there was one sentence the model identified the tags for the pos. I created a data file where I kept all my sentences. The name of...
<python><nlp><tagging><huggingface><flair>
2023-12-18 20:02:17
1
3,446
Encipher
77,681,420
7,487,335
Python Playwright - How can I check that an element does not have an href?
<p>As part of my automated testing I'm trying to validate that an href is correctly removed from an element on the page.</p> <pre class="lang-py prettyprint-override"><code>from playwright.sync_api import Page, expect def test_reset_button(page: Page): page.goto(&quot;https://www.example.com&quot;) page.locato...
<python><playwright-python>
2023-12-18 19:48:23
2
4,400
Josh Correia
77,681,288
3,583,669
Getting dependency error installing chatterbot
<p>I am trying to create a chatbot using Python. When I run &quot;pip3 install chatterbot&quot; I get the error</p> <blockquote> <p>ERROR: Some build dependencies for preshed&lt;2.1.0,&gt;=2.0.1 from <a href="https://files.pythonhosted.org/packages/0b/14/c9aa735cb9c131545fc9e23031baccb87041ac9215b3d75f99e3cf18f6a3/pres...
<python><python-3.x><chatbot><chatterbot>
2023-12-18 19:17:45
2
313
Obi
77,681,239
9,983,652
How to find matching date index in multiple dataframes FASTER without using a loop?
<p>I am trying to find matching index for each date inside a multiple dataframes. if a date is found inside a dataframe, then move to next matching date. I am using a loop and it is very slow when dataframe is big. I am looking for a way to make it faster. Thanks for your help.</p> <p>Here is the way I am doing. It wil...
<python><pandas>
2023-12-18 19:07:01
2
4,338
roudan
77,681,216
6,109,394
How to draw a tick in the mid of a line segment for Manim animation?
<h2>Problem</h2> <p>I want to mark two line segments as of equal length using ticks, like it is commonly done in geometry. <a href="https://i.sstatic.net/mo3xX.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/mo3xX.png" alt="enter image description here" /></a>.</p> <p>Despite my search effort, I failed t...
<python><geometry><manim>
2023-12-18 19:02:58
0
621
pch
77,681,163
388,038
Python type hint name of enum
<p>In Python how can I type hint a variable to restrict it to the names in an Enum?</p> <pre class="lang-py prettyprint-override"><code>class DataFormatOptions(Enum): calibrate = &quot;Calibrate&quot; lrs = &quot;LRS&quot; custom = &quot;Custom&quot; _E = TypeVar(&quot;_E&quot;, bound=DataFormatOptions) ...
<python><mypy><python-typing>
2023-12-18 18:50:50
1
3,182
André Ricardo
77,681,060
519,422
How to get JSON-formatted data from a website into a dataframe? I.e., extract values following identifiers?
<p>I asked <a href="https://stackoverflow.com/questions/77616133/python-pandas-how-to-get-data-from-a-website-into-a-dataframe-by-searching-for">this</a> question about how to extract data from a website into a Pandas (Python) dataframe. There was a very helpful answer that worked for a snippet of the data I posted di...
<python><json><python-3.x><pandas><file-io>
2023-12-18 18:27:46
1
897
Ant
77,680,833
5,815,127
Load Mongo `Binary.createfrombase64` field in Python
<p>I have a Mongo collection with this kind of documents:</p> <pre class="lang-json prettyprint-override"><code> { _id: ObjectId('656f001650078dc1d50872ed'), created_at: ISODate('2023-12-05T10:48:54.641Z'), user_id: Binary.createFromBase64('MjkyMmZkYmUtOTM1Yi0xMWVlLTlkMjEtN2U2NjQwYmEyNGEw', 4), } </code...
<python><mongodb><pymongo>
2023-12-18 17:38:43
1
4,603
Till
77,680,831
16,205,113
SignalR communication between python and aspnet
<p>I COMMUNICATE BETWEEN ASP NET C# AND PYTHON using a websocket, or more specifically, I use a signalR library in both cases. I'm trying to get my server to respond in some way when a Python client sends a message. nothing helps for now. anyone had this problem?</p> <p>it is enough that after the client sends the mess...
<python><websocket><asp.net-core-signalr>
2023-12-18 17:38:23
2
385
Majkelele
77,680,667
16,578,438
transforming a 7 digit integer number to unique alphanumeric value and vice versa
<p>I am trying to convert a 7 digit integer to 6 character alphanumeric value (ALL CAPS a). I don't want to translate the integer value, is there any other way I can do it ? encode it and decode with output value back to the function and get in input back again -</p> <div class="s-table-container"> <table class="s-tabl...
<python><pyspark>
2023-12-18 17:06:03
2
428
NNM
77,680,557
4,111,341
Python, using UDP ports to transfer data from common pool makes threads crawl to a halt
<p>I'm quite stuck with while implementing a proxy tunnel. Based on pysoxy, I basically split it in half, a local &quot;half&quot; that deals with connecting to the client, and a remote &quot;half&quot; that does the proxying to the destination. The two parts communicate with each other via UDP.</p> <p>The problem is, ...
<python><multithreading><sockets><udp>
2023-12-18 16:46:08
0
323
Marco Carandente
77,680,539
2,556,795
How to get QoQ, MoM values from previous years
<p>I have a dataframe with quarterly values for various items and I need to create a column showing quarter values from previous year of each item (Ex: 2021_Q1 value of item A to be compared with 2020_Q1 and so on for other items) similarly for MoM.</p> <p>Below is my reproducible dataframe.</p> <pre><code>df = pd.Data...
<python><pandas>
2023-12-18 16:42:14
3
1,370
mockash
77,680,307
509,977
Check the status of a running async ansible playbook using Python Flask API
<p>In a Flask API I have an endpoint able to run an ansible playbook on remote host using:</p> <pre><code>ansible_runner.run_async </code></pre> <p>The playbook is running for long time and I would like to allow my users to check playbook status using another endpoint.</p> <p>How is this possible if the only data I hav...
<python><ansible>
2023-12-18 16:03:14
1
8,679
Pitto
77,680,284
2,363,318
python fabric set ssh_path via config yaml file
<p>What is the proper way to store and use a custom ssh path for fabric to run</p> <p>This does not seem to be working:</p> <p>fabric.yaml:</p> <pre><code>set_runtime_ssh_path: 'my/ssh/path' </code></pre> <p>main.py:</p> <pre><code>with open('fabric.yaml') as config_file: config = yaml.safe_load(config_file) with Conne...
<python><python-3.x><fabric>
2023-12-18 16:00:48
1
1,067
user2363318
77,680,237
20,233,502
Deploying Python Function Application with DevOps is moving files but not actually deploying application
<p>This is a repost of this question, <a href="https://learn.microsoft.com/en-us/answers/questions/1462841/deploying-python-function-application-with-devops" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/answers/questions/1462841/deploying-python-function-application-with-devops</a> adding to SO to get mo...
<python><azure-devops><azure-functions><azure-pipelines><azure-pipelines-release-pipeline>
2023-12-18 15:53:11
4
320
Mike
77,680,161
1,862,861
Get final values from a specific dimension/axis of an arbitrarily dimensioned PyTorch Tensor
<p>Suppose I had a PyTorch tensor such as:</p> <pre><code>import torch x = torch.randn([3, 4, 5]) </code></pre> <p>and I wanted to get a new tensor, with the same number of dimensions, containing everything from the final value of dimension 1. I could just do:</p> <pre><code>x[:, -1:, :] </code></pre> <p>However, if <...
<python><pytorch><tensor>
2023-12-18 15:41:52
2
7,300
Matt Pitkin
77,679,978
20,771,478
Memory overflow when reading excel with pandas
<p>I am loading excel files into pandas dataframes to do work with their data.</p> <p>The script works on my machine with 16GB RAM but not on the machine where it is supposed to run with 8GB of RAM.</p> <p>With the function <code>df.info(memory_usage=’deep’)</code> I have checked the size of the dataframes coming out o...
<python><pandas><excel><dataframe><memory-optimization>
2023-12-18 15:05:47
0
458
Merlin Nestler
77,679,964
3,795,597
Set document title with custom sphinx parser
<p>I am looking into using sphinx to generate documentation for a non-python (SKILL, though not relevant here) project. Most of the functions have docstrings, so as a first approach I settled on creating a custom parser to document <em>procedures</em> from files, using the provided docstrings.</p> <p>The following is m...
<python><python-sphinx><docutils>
2023-12-18 15:03:25
1
2,089
MayeulC
77,679,855
10,595,871
Jupyter Notebook can't hold type string if string is too long
<p>I'm working with python and Jupyter Notebook, I've a dictionary in which values are lists with strings in them.</p> <p>The thing is that the code is giving me an error, I printed the dictionary and everything seems fine, but when I tried to copy and paste it in a cell, I noticed that from a certain point, the string...
<python><dictionary><jupyter-notebook>
2023-12-18 14:45:17
0
691
Federicofkt
77,679,808
219,976
mypy for derived class of cached_property
<p>When I run mypy check for the following code:</p> <pre><code>from functools import cached_property def func(s: str) -&gt; None: print(s) class Foo: @cached_property def prop(self) -&gt; int: return 1 foo = Foo() func(foo.prop) </code></pre> <p>I got error: <code>error: Argument 1 to &quot;func...
<python><properties><decorator><python-decorators><mypy>
2023-12-18 14:37:06
1
6,657
StuffHappens
77,679,764
3,511,695
Reliably clean/convert all unicode/emojis for JSON parsing
<p>I'm seeking the correct sequence of Python <code>decode()</code> and <code>encode()</code> functions required to result in completely clean and parse-able JSON, no matter which combinations of unusual ASCII/unicode/emoji characters present.</p> <p>In Javascript, I'm trying to <code>JSON.parse()</code> some API data ...
<python><json><jsonparser>
2023-12-18 14:29:33
0
1,000
velkoon
77,679,562
18,904,265
Docker build failed with Gitlab CI, service didn't start properly
<p>So I wanted to move my build step of my docker image to Gitlab CI. Since this is my first time using Gitlab CI to build a Docker Image, I'm guessing that I have an error in my configuration somewhere.</p> <p>The Error I get is: <code>ERROR: error during connect: Get &quot;http://docker:2375/_ping&quot;: dial tcp: lo...
<python><docker><gitlab-ci>
2023-12-18 13:56:43
1
465
Jan
77,679,260
9,766,795
Calculated EMA is lagging compared to Trading View EMA
<p>I'm using the binance connector API in python (<a href="https://binance-connector.readthedocs.io/en/latest/" rel="nofollow noreferrer">https://binance-connector.readthedocs.io/en/latest/</a>) to calculate short, medium and long term EMA on the 1 minute chart. I have access to real time data from binance and so does ...
<python><algorithmic-trading><binance><binance-api-client>
2023-12-18 13:00:55
0
632
David
77,679,151
241,515
Pandas groupby: use data in other columns to create groups (genomic intervals)
<p>As part of a larger data set, I have a <code>DataFrame</code> organized as such:</p> <pre><code>Chromosome arm Start End ratio_median 5 5.5 96100001 96150000 -0.582 5 5.5 96150001 96200000 -0.582 5 5.5 96200001 96250000 -0.582 5 5.5 96250001 96300000 -0.582...
<python><pandas><bioinformatics><pyranges>
2023-12-18 12:40:41
2
4,973
Einar
77,678,958
12,131,616
How to change an array using advanced indexing and boolean array indexing without loops in numpy?
<p><strong>Problem:</strong></p> <p><code>A</code> is a multidimensional array of two dimensions <code>(i,j)</code> and <code>B</code> is a boolean array of the same shape that I want to define according to the values of <code>A</code>.</p> <p>I want to define <code>B</code> through two broadcasting indices:</p> <ul> <...
<python><numpy><vectorization><numpy-ndarray><array-broadcasting>
2023-12-18 12:04:52
1
663
Puco4
77,678,899
11,748,924
Extracting X_train and y_train from tabular data where a column is target and another columns are features with its corresponding ID
<p>I have this DataFrame:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>timestep</th> <th>ID</th> <th>x1</th> <th>x2</th> <th>y</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>2</td> <td>3</td> <td>0</td> </tr> <tr> <td>2</td> <td>1</td> <td>4</td> <td>5</td> <td>0</td> </tr> <...
<python><pandas><dataframe><numpy><tabular>
2023-12-18 11:53:29
1
1,252
Muhammad Ikhwan Perwira
77,678,782
4,505,998
Interweave groups in Pandas
<p>I have a DataFrame that I want &quot;intereaved&quot; row-wise by groups.</p> <p>For example, this DataFrame:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Group</th> <th>Score</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>10</td> </tr> <tr> <td>A</td> <td>9</td> </tr> <tr> <td>A</td...
<python><pandas><dataframe>
2023-12-18 11:30:43
2
813
David Davó
77,678,640
7,801,777
How can I use variables as part of my bucket path with s3 boto client?
<p>At the moment Im trying to upload to a bucket with the variables as the path name using the boto s3 client and here are the variables I have defined:</p> <pre><code>var1 = A var2 = B var3 = C </code></pre> <p>I am uploading to the bucket like this:</p> <pre><code>client.upload_file('myfile.jpeg', 'bucket', 'director...
<python><amazon-web-services><aws-lambda><boto3>
2023-12-18 11:03:31
1
355
i'i'i'i'i'i'i'i'i'i
77,678,603
11,159,734
Create multiple functions in one Azure Function App
<p>I want to create multiple python Azure Functions within one Azure Functions App using the azure cli/core tools. One http triggered function and one blob triggered function.</p> <p>I have the following folder structure:</p> <pre><code>├── azure-functions │ ├── az-func-blob │ │ ├── .python_packages │ │ ├── ....
<python><azure><azure-functions>
2023-12-18 10:57:35
1
1,025
Daniel
77,678,525
6,498,649
python pandas double aggregation function with nth(0)
<p>The following pandas aggregation:</p> <pre><code>df = pd.DataFrame({ 'a' : [1,1,1,1], 'b' : [1,2,3,4], 'c' : [np.nan,6,7,8], }) r = df.groupby('a').agg({ 'b' : 'mean', 'c' : 'nth(0)', }) </code></pre> <p>obviously gives:</p> <pre><code>AttributeError: 'SeriesGroupBy' object has no attrib...
<python><pandas><group-by>
2023-12-18 10:42:06
1
403
Dario Colombotto
77,678,414
4,537,160
Reverting pre-processing step on image returned by Pytorch Dataloader leads to unexpected results
<p>I created a Dataset in Pytorch to load images and feed them to a CNN. In the dataset <code>__getitem__</code> method, images are processed using a transform function (normalization on Imagenet avg values) before being returned.</p> <p>I noticed that, if I revert the transformed image inside the dataloader itself, I ...
<python><pytorch><pytorch-dataloader>
2023-12-18 10:20:37
1
1,630
Carlo
77,678,244
1,394,786
how to discover a class's instance level fields given a class name
<p>Given the following class <strong>Mock</strong>, I want to write a function <strong>get_members</strong> that returns a and b when the input is the class Mock. This task is easy if you are allowed to use an object of Mock as the input of this function to be written ( you can use &quot;_ <em>dict</em>_&quot; or vars ...
<python><member><inspect>
2023-12-18 09:54:20
1
480
Peaceful
77,678,147
1,889,750
Cannot install Python module 'arcgis'
<p>I try to install the module arcgis from the cheese shop and it fails. Here the cli...</p> <pre><code>(base) PS C:\Python311\Scripts&gt; .\pip3.11.exe install arcgis Could not find platform independent libraries &lt;prefix&gt; Python path configuration: PYTHONHOME = (not set) PYTHONPATH = (not set) program name...
<python><pip><arcgis>
2023-12-18 09:34:40
1
1,355
TomGeo
77,677,960
3,099,733
Is that anyway to update c++ packages when the project is install with `pip install -e .`?
<p>I am working on a Python project that have some C++ packages in it. To make it easier to test, I used to install under developed Python packages with <code>pip install -e .</code>. It works well with pure python packages. But for the project with C++ packages in it this method won't work when the C++ code get update...
<python><c++><pip><python-wheel>
2023-12-18 08:56:13
0
1,959
link89
77,677,826
2,529,125
logger.info throws result = f(record) # assume callable - will raise if not TypeError: 'bool' object is not callable
<p>A basic logger setup can be created using the following python code:</p> <pre><code>import logging # create and configure main logger logger = logging.getLogger(__name__) # create console handler with a higher log level handler = logging.StreamHandler() handler.setLevel(logging.DEBUG) # create formatter and add it ...
<python><conda>
2023-12-18 08:27:42
0
511
Sade
77,677,714
6,446,146
gunicorn post_request vs flask.after_request
<p>I'm trying to understand the difference between <a href="https://docs.gunicorn.org/en/stable/settings.html#post-request" rel="nofollow noreferrer">gunicorn</a> <code>post_request()</code> callback and <a href="https://flask.palletsprojects.com/en/3.0.x/api/#flask.Flask.after_request" rel="nofollow noreferrer">flask<...
<python><flask><gunicorn>
2023-12-18 08:03:21
0
417
yeger
77,677,570
1,190,316
Get the Max value of a row and get its' column name along with an additional column in the output
<p>I have the following data frame:</p> <p><a href="https://i.sstatic.net/I3EAW.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/I3EAW.png" alt="enter image description here" /></a></p> <p>I want to get the highest value from each row in the data frame and get it's corresponding column name along with the...
<python><pandas><dataframe><max>
2023-12-18 07:32:08
1
1,465
Sindu_
77,677,428
11,141,816
Sympy Dummy symbol in the derivative could not be replaced
<p>I have a very long expression where, after the derivative, the term with the dummy variable <code>_xi_1</code> appeared,</p> <pre><code>Subs(Derivative(eta(_xi_1), _xi_1), _xi_1, 0) type(exp_list[0].args[2].args[2].args[1][0]) sympy.core.symbol.Dummy </code></pre> <p>I tried to replace the dummy variable with the n...
<python><sympy>
2023-12-18 07:05:46
1
593
ShoutOutAndCalculate
77,677,227
7,601,346
Passing str as parameter to class definition? Defining a separate class for key for sorted?
<p>I'm learning and Python and am trying to understand the code below</p> <pre><code>class LargerNumKey(str): def __lt__(x, y): return x+y &gt; y+x class Solution: def largestNumber(self, nums): largest_num = ''.join(sorted(map(str, nums), key=LargerNumKey)) return '0' if larges...
<python>
2023-12-18 06:04:48
1
1,200
Shisui
77,677,226
16,312,980
jupyterlab not detecting installed module: textract and doc2text
<p>I did this in a jupyter lab cell:</p> <pre><code>!pip install textract </code></pre> <p>and i managed to installed it successfully.</p> <p>I also installed textract and doc2text in command line too in my conda environment.</p> <p>But when I tried to import in a jupyter lab cell:</p> <pre><code>import textract </code...
<python><pip><conda><jupyter-lab><development-environment>
2023-12-18 06:04:22
1
426
Ryan
77,677,185
6,027,759
How can I reference an environment variable for python path in vscode launch configuration?
<p>I am using vscode on my desktop and laptop and each machine would generate a random folder name with a hash for the virtual environment path when creating the virtual environment using poetry. In order to use the same launch.json file in my project for both computers, I'd like to reference an environment variable in...
<python><visual-studio-code><vscode-debugger>
2023-12-18 05:50:30
1
1,729
bayman
77,677,098
5,005,808
keras_nlp.models.from_preset gets Segmentation fault (core dumped)
<p>I'm using <code>keras_nlp</code> and I get <code>Segmentation fault (core dumped)</code> in the following code:</p> <pre><code>import os os.environ[&quot;KERAS_BACKEND&quot;] = &quot;torch&quot; # &quot;jax&quot; or &quot;tensorflow&quot; or &quot;torch&quot; import keras_nlp import keras_core as keras import ke...
<python><keras><large-language-model>
2023-12-18 05:26:14
0
1,930
pfc
77,676,828
15,845,509
Understand weight in PyTorch convolution layer 1D
<p>I am trying to understand the work of convolution layer 1D in PyTorch. I use Conv1D(750,14,1) with input channels equal to 750, output channels are 14 with kernel size 1. As I understand, the weight in convolution layer is the kernel/filter so in this case, the weight dimension is 14x1. but when I print the weight, ...
<python><pytorch><conv-neural-network><convolution>
2023-12-18 03:37:50
2
369
ryan chandra
77,676,757
1,174,378
Run a full Flask server under pytest to handle HTTP requests on a given port
<p>Normally, when testing an endpoint, the <a href="https://flask.palletsprojects.com/en/2.3.x/testing/" rel="nofollow noreferrer">Flask docs</a> recommend doing something like this:</p> <pre class="lang-py prettyprint-override"><code>import pytest from my_project import create_app @pytest.fixture() def app(): app...
<python><flask><pytest><werkzeug>
2023-12-18 03:09:14
1
8,364
Mihai Todor
77,676,747
9,357,484
Google Colab unable to Hugging Face model
<p>I like to tag parts of speech using the BERT model. I used the <a href="https://huggingface.co/AdapterHub/bert-base-uncased-pf-ud_pos" rel="nofollow noreferrer">Hugging face</a> library for this purpose.</p> <p>When I run the model on Hugging face API I got the output <a href="https://i.sstatic.net/RjeUj.png" rel="n...
<python><nlp><google-colaboratory><huggingface-transformers><bert-language-model>
2023-12-18 03:07:35
2
3,446
Encipher
77,676,735
15,587,184
Resolving Selenium Driver issue on AWS EC2 Linux RedHat
<p>I have a peculiar issue while trying to set up Selenium WebDriver on an AWS EC2 instance running Red Hat. I'm using Google Chrome version 120.0.6099.109 on this instance.</p> <p>I have been trying to install the appropriate ChromeDriver for this Chrome version, but I've encountered an intermittent problem. My Seleni...
<python><selenium-webdriver><amazon-ec2><selenium-chromedriver>
2023-12-18 03:03:40
1
809
R_Student
77,676,693
6,396,569
How can I add tabs to this Tk application in Python 3.12.0?
<p>I have an app where there is a <code>main</code> function that looks like this:</p> <pre><code>root = Tk() root.title(&quot;MyApp&quot;) #Set the initial size of the window and make it resizeable root.geometry(&quot;1024x768&quot;) root.resizable(True,True) app = AudioPlayer(master=root) app.pack(fill=&quot;both&q...
<python><tkinter>
2023-12-18 02:45:29
1
2,567
the_endian
77,676,622
5,058,488
What's wrong with this coin change python implementation?
<p>I'm reading through <a href="https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/index.html" rel="nofollow noreferrer">Structure and Interpretation of Computer Programs</a>, and on section 1.2.2 there's a brute force implementation of the coin change problem given:</p> <pre><code>(d...
<python><scheme><racket>
2023-12-18 02:05:22
2
647
Alejandro