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
75,585,578
223,837
How to configure 'TLS1.2 only' in OpenSSL 1.0.2 config file?
<p>I would like to update the configuration of OpenSSL 1.0.2 (specifically 1.0.2k-fips as found on AWS's Amazon Linux 2 AMIs), so that any client using OpenSSL refuses TLSv1.1, TLSv1, or anything lower that is not TLSv1.2.</p> <p>I have learned that for OpenSSL 1.1+ the OpenSSL config file (e.g., /etc/pki/tls/openssl.c...
<python><openssl><tls1.2><configuration-files>
2023-02-27 21:07:21
4
9,789
MarnixKlooster ReinstateMonica
75,585,475
2,908,017
How to make a Python FMX GUI Form jump to the front?
<p>I have a window <code>Form</code> that is created with the <a href="https://github.com/Embarcadero/DelphiFMX4Python" rel="nofollow noreferrer">DelphiFMX GUI library for Python</a>.</p> <p>I want to know if there is a specific method that I can call to send the Form to the top above all other forms and/or windows fro...
<python><windows><user-interface><window><firemonkey>
2023-02-27 20:54:38
1
4,263
Shaun Roselt
75,585,462
12,734,492
Pyspark: List subfolders names in AWS S3 folder
<p>Main folder: s3_path = &quot;s3a://prices/xml_inputs/stores/&quot;</p> <p>My try:</p> <pre><code>from pyspark.sql import SparkSession from pyspark import SparkContext import os from dotenv import load_dotenv # Load environment variables from the .env file load_dotenv() AWS_ACCESS_KEY_ID = os.getenv(&quot;AWS_ACCES...
<python><amazon-web-services><apache-spark><amazon-s3><pyspark>
2023-02-27 20:53:05
0
487
Galat
75,585,244
733,583
Handling data skewness in pyspark rangeBetween
<p>I am trying to calculate count, mean and average over rolling window using rangeBetween in pyspark. Some of the mid in my data are heavily skewed because of which its taking too long to compute.</p> <p>I am first grouping the data on epoch level and then using the window function. This reduces the compute time but s...
<python><apache-spark><pyspark><window-functions>
2023-02-27 20:27:40
0
2,002
Kundan Kumar
75,584,975
13,578,682
Generating combinations in order of their sum
<p>Itertools combinations seem to come out in lexicographic order:</p> <pre><code>&gt;&gt;&gt; for c in combinations([9,8,7,2,2,1], 2): ... print(c, sum(c)) ... (9, 8) 17 (9, 7) 16 (9, 2) 11 (9, 2) 11 (9, 1) 10 (8, 7) 15 (8, 2) 10 (8, 2) 10 (8, 1) 9 (7, 2) 9 (7, 2) 9 (7, 1) 8 (2, 2) 4 (2, 1) 3 (2, 1) 3 </code></pr...
<python><combinations><python-itertools><combinatorics>
2023-02-27 19:52:47
1
665
no step on snek
75,584,842
9,531,146
Python Lambda Function returning KeyError
<p>Currently trying to create a (simple) Lambda function in AWS using Python 3.8:</p> <pre><code>import json import urllib3 def lambda_handler(event, context): status_code = 200 array_of_rows_to_return = [ ] http = urllib3.PoolManager() try: event_body = event[&quot;body&quot;] payload...
<python><amazon-web-services><aws-lambda>
2023-02-27 19:37:39
1
765
John Wick
75,584,813
13,342,062
What does the sequence #' mean in Python source code
<p>In <code>os.py</code> there is a strange marker <code>#'</code> under the docstring and just before the imports</p> <pre><code>&gt;&gt;&gt; import os &gt;&gt;&gt; os?? File: /usr/local/lib/python3.11/os.py Source: r&quot;&quot;&quot;OS routines for NT or Posix depending on what system we're on. This exp...
<python>
2023-02-27 19:34:46
1
323
COVFEFE-19
75,584,773
303,704
Call native .NET interfaces from Python in a client-server architecture
<p>There is a game called Kerbal Space Program (KSP), written using the Unity game engine in C#. It has rich modding scene. Some mods add new features and game object types with new APIs.</p> <p>There is one mod, called <a href="https://github.com/krpc/krpc" rel="nofollow noreferrer">kRPC</a>, which allows for remote p...
<python><c#><.net><unity-game-engine><client-server>
2023-02-27 19:29:18
1
870
Dalibor Frivaldsky
75,584,636
2,627,487
Fortran-like negative indexing in numpy for physics and math equations
<p>In contrast to most languages that use zero-based indexing, Fortran allows to specify a particular indexing:</p> <pre><code>! array with 10 elements double precision arr(-8:1) arr(-8) = 0 ! 1st element arr( 0) = 1 ! second to last element arr( 1) = -1 ! last element </code></pre> <p>The same can be done in the C l...
<python><arrays><numpy><performance><indexing>
2023-02-27 19:10:38
0
1,290
MrPisarik
75,584,567
16,053,370
How to search and delete specific lines from a parquet file in pyspark? (data purge)
<p>I'm starting a project to adjust the data lake for the specific purge of data, to comply with data privacy legislation.</p> <p>Basically the owner of the data opens a call requesting the deletion of records for a specific user, and I need to sweep all AWS S3 bucktes by checking all parquet files and delete this spec...
<python><amazon-web-services><pyspark><parquet>
2023-02-27 19:03:07
2
373
Carlos Eduardo Bilar Rodrigues
75,583,940
5,356,096
Python skips __next__ directive and returns a generator object
<p>I'm trying to implement an iterable class, which I have done several times before, but I'm experiencing some unexpected behavior this time around, and I can't figure out why.</p> <p>My class contains the usual <code>__iter__(self)</code> method that returns <code>self</code>, and <code>__next__(self)</code> method t...
<python><iterator><python-3.8>
2023-02-27 17:53:42
1
1,665
Jack Avante
75,583,912
19,694,624
Can't run Chromedriver in headless mode using Selenium
<p>running my selenium script I ran into an error that I don't know how to pass. I've googled and tried various solutions but they didn't work. Here is my code:</p> <pre><code>from selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_driver_binary = '/home/user/Projects/myproject/chro...
<python><python-3.x><google-chrome><selenium-webdriver><google-chrome-headless>
2023-02-27 17:50:35
1
303
syrok
75,583,768
5,446,749
Tell pip package to install build dependency for its own install and all install_requires installs
<p>I am installing a package whose dependency needs to import <code>numpy</code> inside its <code>setup.py</code>. It also needs <code>Cython</code> to correctly build this dependency. This dependency is <code>scikit-learn==0.21.2</code>. Here is the <code>setup.py</code> of my own package called <code>mypkgname</code>...
<python><pip><cython><setup.py><pyproject.toml>
2023-02-27 17:35:25
2
32,794
vvvvv
75,583,746
161,816
How do I PDF-export one or more Confluence Datacenter/Server spaces?
<p>How do I export one or more Confluence spaces to PDF based on a search of all available spaces? Information is scarce, so I am making this a Q&amp;A to help others.</p> <p>I have read through a maze of API deprecations, replacements, and problem reports, and I understand that Confluence still does not allow PDF expo...
<python><python-3.x><soap><confluence><export-to-pdf>
2023-02-27 17:32:55
1
10,682
Charles Burns
75,583,649
13,231,896
How to check if two polygons have internal points in common, with geodjango and postgis
<p>I am am using geodjango with postgis backend. Giving two polygons I want to check if they overlap. I mean, they have interior points in common. If we check</p> <pre><code>A.function(B) </code></pre> <p>In the following picture &quot;Example 1&quot; would be False, &quot;Example 2&quot;, would be False (cause they on...
<python><django><gis><postgis><geodjango>
2023-02-27 17:23:29
1
830
Ernesto Ruiz
75,583,269
12,932,447
Update a specific array element if it fulfils at least one of several conditions
<p>I am trying to understand (and fix) a code that is not mine, which uses PyMongo.</p> <p>We want to look for the document with <code>_id==_id</code> that has, inside its list <code>comments</code>, a comment with <code>id==comment_id</code> or <code>id==PyObjectId(comment_id)</code>. To that comment we want to add an...
<python><mongodb><pymongo>
2023-02-27 16:45:57
1
875
ychiucco
75,583,141
2,615,160
Conda-build fails on test with missing dependency
<p>For a reason I can not build a conda package. My package is posted on PyPi and accessible by</p> <p><code>pip install molcomplib</code></p> <p>To build a conda package I do:</p> <ol> <li>I run grayskull <code>grayskull pypi molcomplib</code></li> <li>I run <code>conda build -c conda-forge molcomplib</code></li> </o...
<python><anaconda><conda><conda-build>
2023-02-27 16:34:27
0
1,434
Sergey Sosnin
75,583,115
469,476
Parsing / reformatting a tokenized list in python
<p>I have lists of tokens of the form &quot;(a OR b) AND c OR d AND c&quot; or &quot;(a OR b) AND c OR (d AND c)&quot;</p> <p>I want to reformat these tokens into a string of the form: Expressions are of arbitrary form like (a or b) and c or (d and c).</p> <p>Write python to reformat the expressions as: {{or {and {or a...
<python><parsing><boolean><expression><reformatting>
2023-02-27 16:32:01
1
1,994
elbillaf
75,583,072
2,784,828
Use file input(stdin) in VS Code debug argument
<p>I have a script that accepts multiple arguments and takes a file input(stdin) as one of the last argument. Tried debugging the script in VS Code debugger. But the file input arg is not working. The script doesn't understand the fourth argument in the launch.json. here's what I have in my launch.json file:</p> <pre><...
<python><visual-studio-code><debugging>
2023-02-27 16:27:39
1
1,025
saz
75,582,995
912,757
Python AES256-CBC, decryption with Rust OpenSSL
<p>I'm using this OpenSSL call to encrypt (symmetric) a file</p> <pre><code>key = secrets.token_bytes(32) iv = secrets.token_bytes(16) encrypted_file = file_path + &quot;.enc&quot; subprocess.run( [ &quot;openssl&quot;, &quot;enc&quot;, &quot;-aes-256-cbc&quot;, &quot;-K&quot;, key.hex(), &...
<python><rust><cryptography>
2023-02-27 16:21:24
1
2,397
Nil
75,582,975
5,491,623
Netmiko to login into 1000+ cisco router to check clock
<p>I am using python + netmiko for network automation , We have 1000's of device to manage. I am using threading to perform the task faster but I always receive read timeout exceptions if thread reaches 250+ devices.</p>
<python><automation><netmiko>
2023-02-27 16:19:25
0
643
Shashi Dhar
75,582,969
1,506,850
How does matplotlib deal with overplotting in time series?
<p>I am plotting a huge timeseries, having &gt; 1M (10^6) datapoints.</p> <p>I am plotting it using</p> <pre><code>import matplotlib.pyplot as plt plt.plot(timeseries) </code></pre> <p>Since my screen resolution is &lt;2k px, some overplotting is clearly taking place. How does matplotlib deal with number of points &gt;...
<python><matplotlib><plot>
2023-02-27 16:18:53
1
5,397
00__00__00
75,582,899
3,215,940
How to set and pass default values of kwargs from one function to another
<p>I have a few functions that call each other with a bunch of parameters. Because my use case contains several parameters, I wanted to check that they are being passed correctly whenever I modify them (will wrap this in a verbose mode afterwards, but it's mainly for debug purposes now). Here's a toy example below:</p>...
<python><python-decorators><keyword-argument>
2023-02-27 16:12:11
0
4,270
Matias Andina
75,582,704
11,397,243
lambda binding upon call is causing issue in my generated code
<p>As the author of <a href="https://github.com/snoopyjc/pythonizer" rel="nofollow noreferrer">Pythonizer</a>, I'm translating some perl code to python that defines a function FETCH in 2 different packages in the same source file, like:</p> <pre><code>package Env; sub FETCH {...} package Env::Array; sub FETCH {...} </c...
<python><lambda><expression-evaluation>
2023-02-27 15:55:36
1
633
snoopyjc
75,582,686
2,908,017
How to change GroupBox background color in Python VCL GUI app
<p>I'm using the <a href="https://github.com/Embarcadero/DelphiVCL4Python" rel="nofollow noreferrer">DelphiVCL GUI library for Python</a> and trying to change the background color on a <code>GroupBox</code> component, but it's not working</p> <p>I have the following code to create the <code>Form</code> and the <code>Gr...
<python><user-interface><vcl>
2023-02-27 15:54:11
1
4,263
Shaun Roselt
75,582,590
1,232,087
pyspark - concatenating columns and surround by two strings
<p><strong>Question</strong>: How can we concatenate the columns in the following <code>df</code> and surround each column with two strings (as shown in the <code>desired</code> output)?</p> <pre><code>from pyspark.sql.functions import concat_ws from pyspark.sql import functions as F df = spark.createDataFrame([[&quot...
<python><apache-spark><pyspark><apache-spark-sql><databricks>
2023-02-27 15:45:26
2
24,239
nam
75,582,587
13,742,058
getpath in lxml etree is showing different output for absolute xpath
<p>I am trying to get the absolute XPath of an element but it is giving different output. I am trying to get the full XPath of <kbd>search button</kbd> in Google. Here's the code I have tried:</p> <pre><code>import time import random from selenium import webdriver from selenium.webdriver.chrome.service import Service f...
<python><selenium-webdriver><web-scraping><lxml>
2023-02-27 15:44:59
1
308
fardV
75,582,565
1,317,018
How to use tqdm with while loop if counter is conditionally updated
<p>In below code, I want <code>tqdm</code> to show progress bar for counter variable <code>i</code>. Note that <code>i</code> is conditionally updated and the condition or decision to increment itself involves randomness.</p> <pre><code>import random totalItr = 100 i = 0 actualItr = 0 while i &lt; totalItr: actual...
<python><tqdm>
2023-02-27 15:42:58
0
25,281
Mahesha999
75,582,446
6,216,161
descartes, python package, error in polygonpatch
<p>I have installed the latest Descartes package using pip3. But I cannot seem to run the example code provided in the <a href="https://pypi.org/project/descartes/" rel="nofollow noreferrer">website</a>.</p> <pre><code>` IndexError Traceback (most recent call last) /tmp/ipykernel_500...
<python><polygon><descartes>
2023-02-27 15:31:42
1
327
user252935
75,582,394
5,452,378
(Dataflow) Apache Beam Python requirements.txt file not installing on workers
<p>I'm trying to run an Apache Beam pipeline on Google Dataflow. This pipeline reads data from Google BigQuery, adds a schema, converts it to a Dataframe, and performs a transformation on that dataframe using a third-party library (<code>scrubadub</code>).</p> <p>From the Google Code CLI on GCP, I run:</p> <pre><code>/...
<python><dependencies><python-import><google-cloud-dataflow><apache-beam>
2023-02-27 15:26:54
1
409
snark17
75,582,335
11,092,636
cmprsk python package example notebook doesn't work
<p>I'm using <code>Python 3.11.1</code>. I've installed <a href="https://github.com/OmriTreidel/cmprsk" rel="nofollow noreferrer">https://github.com/OmriTreidel/cmprsk</a> (<code>1.0.0</code>, the latest version) on a new virtual environment, I've installed <code>rpy2 3.4.5</code> like the documentation suggested, I'm ...
<python><r><statistics>
2023-02-27 15:21:17
1
720
FluidMechanics Potential Flows
75,582,323
5,181,219
Check that class was called in a with statement
<p>I am building a class that people are supposed to use with a context manager:</p> <pre class="lang-py prettyprint-override"><code>with MyClass(params) as mc: mc.do_things() ... </code></pre> <p>I was wondering whether it was possible to make sure that people called it this way, and that code looking like thi...
<python><contextmanager>
2023-02-27 15:19:58
1
1,092
Ted
75,582,319
5,058,116
Masking data frame with multidimensional key
<p>I have a data frame containing <code>value_1</code> and <code>value_2</code></p> <pre><code>df_1 = pd.DataFrame( { &quot;id_1&quot;: [101, 202], &quot;id_2&quot;: [101, 202], &quot;value_1&quot;: [5.0, 10.0], &quot;value_2&quot;: [10.0, 4.0], } ) df_1 = df_1.set_index([&quot;i...
<python><pandas>
2023-02-27 15:19:47
1
3,058
ajrlewis
75,582,201
16,578,438
pyspark fill missing dates in dataframe and fill other column with minimum of the two adjacent values
<p>looking to fill the pyspark dataframe and load the missing values. Existing Pyspark DataFrame -</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: center;">ID</th> <th style="text-align: center;">Date</th> <th style="text-align: center;">Qty</th> </tr> </thead> <tbody> <t...
<python><dataframe><apache-spark><pyspark>
2023-02-27 15:10:20
2
428
NNM
75,582,190
4,451,315
Why does timestamp() show an extra microsecond compared with subtracting 1970-01-01?
<p>The following differ by 1 microsecond :</p> <pre class="lang-py prettyprint-override"><code>In [37]: datetime(2514, 5, 30, 1, 53, 4, 986754, tzinfo=dt.timezone.utc) - datetime(1970,1,1, tzinfo=dt.timezone.utc) Out[37]: datetime.timedelta(days=198841, seconds=6784, microseconds=986754) In [38]: datetime(2514, 5, 30,...
<python><datetime><floating-point><timestamp>
2023-02-27 15:09:26
3
11,062
ignoring_gravity
75,582,153
3,894,818
-SOLVED- How to upload a photo to WordPress Media Library via WordPress REST API with Python?
<p>Unable to upload a photo to WordPress Media Library via WordPress REST API for the second day. <em>WordPress version 6.1.1</em> I am well aware that this and similar questions have been raised on StackOverflow many times, I have read probably all of them. I tried to use some of the suggested solutions, but unfortuna...
<python><python-3.x><wordpress><rest><request>
2023-02-27 15:06:56
1
811
Quanti Monati
75,582,039
1,473,517
How to optimize a function involving max
<p>I am having problems minimizing a simple if slightly idiosyncratic function. I have scipy.optimize.minimize but I can't get consistent results. Here is the full code:</p> <pre><code>from math import log, exp, sqrt from bisect import bisect_left from scipy.optimize import minimize from scipy.optimize import Bounds i...
<python><scipy><mathematical-optimization>
2023-02-27 14:56:49
3
21,513
Simd
75,581,946
3,672,883
Why this asyncio code doesn't run concurrent?
<p>Hello I am trying to write a script to process pdf files with asyncio concurrent in order to do this I have the following code:</p> <pre><code>import click import asyncio from pdf2image import convert_from_path from functools import wraps def coro(f): @wraps(f) def wrapper(*args, **kwargs): return a...
<python><python-asyncio><python-click>
2023-02-27 14:46:39
1
5,342
Tlaloc-ES
75,581,932
1,290,170
How do I input values from a 2-index-level dataframe into a 3-index-level dataframe?
<p>I have an empty dataframe <code>df1</code>:</p> <pre><code> column1 column2 A B C </code></pre> <p>I have a 2 dimensional dataframe <code>df2</code> with same column, but only B and C as indexes:</p> <pre><code> column1 column2 B C foo bar 123 1...
<python><pandas>
2023-02-27 14:45:10
1
1,567
alexx0186
75,581,793
51,816
How to resume download using MediaIoBaseDownload with Google Drive and Python?
<p>With large files I get various errors that stops the download, so I want to resume from where it stopped by appending to the file on disk properly.</p> <p>I saw that the FileIO has to be using 'ab' mode:</p> <pre><code>fh = io.FileIO(fname, mode='ab') </code></pre> <p>but I couldn't find how to specify where to cont...
<python><download><google-drive-api>
2023-02-27 14:31:42
2
333,709
Joan Venge
75,581,695
13,219,123
Missing Python executable 'python3'
<p>I am running pyspark locally and had some issues due to something with the paths to python (when running python3 in command prompt I got an error, but when running python I would not. I have python 3 installed) I would get an java.io.IOException error when trying to run a pyspark job.</p> <p>Now I have added</p> <pr...
<python><pyspark>
2023-02-27 14:24:55
2
353
andKaae
75,581,571
13,596,037
in numpy, what is the difference between calling MA.masked_where and MA.masked_array?
<p>Calling <code>masked_array</code> (the class constructor) and the <code>masked_where</code> function both seem to do exactly the same thing, in terms of being able to construct a numpy masked array given the data and mask values. When would you use one or the other?</p> <pre><code>&gt;&gt;&gt; import numpy as np &gt...
<python><numpy><masked-array>
2023-02-27 14:12:07
2
13,169
alani
75,581,476
8,388,965
2D to 3D projection opencv gives high error
<p>The purpose of my project is to convert some 2D/Image points into 3D/World coordinates.</p> <p>In order to determine the image coordinates, I have mapped the exact location of the image in meters/cms in the real world. Please see the image below,</p> <p><img src="https://i.sstatic.net/LfAlw.png" alt="Undistorted ima...
<python><opencv><computer-vision><camera-calibration><robotics>
2023-02-27 14:04:39
0
1,224
Farshid Rayhan
75,581,470
536,262
comparing pathlib.Paths finding if one is a subdir of the other
<p>How can I find out if a pathlib.Path() is a subdir of another?</p> <p>I can take the string of pathlib.PurePath(), but it only works if I have the whole path.</p> <pre><code>with zipfile.ZipFile(fname, 'w') as zip: for f in files: myrelroot = relroot # relative root for this zipfile if f&quot;{pathlib.Pure...
<python><pathlib>
2023-02-27 14:04:00
2
3,731
MortenB
75,581,337
8,293,726
OSError: [Errno 24] Too many open files: '/home/ec2-user/car/1016780737.jpg'
<p>I am doing predictions on 100K images using following yolov8 code:</p> <pre><code>model = YOLO(self.weightpath) src_dir = self.src_Dir src_dir = src_dir+ '*' img_list = glob.glob(src_dir) results = model(img_list, max_det = 1) </code></pre> <p>I am getting following error:</p> <pre><code>Traceback (most rece...
<python><amazon-ec2><pytorch><yolo>
2023-02-27 13:49:54
1
1,333
Hitesh
75,581,224
339,652
Google Cloud Vision OCR - Language hints seem to be ignored
<p>I am using the Python framework of Google Cloud Vision to OCR passports. I want to support Ukrainian now, but the system has trouble recognizing handwritten parts.</p> <p>I tried to improve the results by giving language hints to the system, but it seems like those are entirely ignored.</p> <p>No matter what I set t...
<python><google-cloud-vision>
2023-02-27 13:39:58
1
843
Plankalkül
75,581,204
2,908,017
How to change Panel background color in Python VCL GUI app
<p>I'm using the <a href="https://github.com/Embarcadero/DelphiVCL4Python" rel="nofollow noreferrer">DelphiVCL GUI library for Python</a> and trying to change the background color on a <code>Panel</code> component, but it's not working</p> <p>I have the following code to create the <code>Form</code> and the <code>Panel...
<python><user-interface><vcl>
2023-02-27 13:38:30
1
4,263
Shaun Roselt
75,581,199
14,640,406
Pcap data to .ts file script
<p>I want to get the UDP stream of a pcap file, get the raw data and save to a .ts file. I now i can do that in Wireshark doing: <code>analyze-&gt;follow-&gt;UDP stream-&gt;show and save data as raw-&gt;save as-&gt;video.ts</code>.</p> <p>How can i make a script in Python for doing the same thing?</p>
<python><wireshark><scapy><pcap>
2023-02-27 13:37:35
1
309
carraro
75,581,192
4,502,325
Production flask app running in parallel with main program on a Raspberry pi
<p>I have built a system around a Raspberry pi that continuously takes images, runs some computer vision analyses on the images, and reads some variables from a sensor.</p> <p>Image files are saved on board as are analysis results and sensor data (in sqlite databases).</p> <p>Now, I need to present collected data (imag...
<python><flask>
2023-02-27 13:36:55
1
396
Hjalte
75,581,175
4,393,334
How calculate percentile for each value in PySpark data frame?
<p>Let say I have PySpark data frame with column &quot;data&quot;.</p> <p>I would like to assign for each value in this column &quot;Percentile&quot; value with bin = 5.</p> <p>Here is a sketch of Python code and desired result</p> <pre><code>import numpy as np # Array of data data = [5,6,9,87,2,3,5,7,2,6,5,2,3,4,69,4...
<python><percentile>
2023-02-27 13:35:00
1
3,113
Andrii
75,581,172
3,910,269
Event grid does not trigger Azure Function when out binding is specified
<p>When I upload a file to a storage account container I have an <strong>Event Grid System Topic</strong> to detect this. I have an Event Subscription associated to it, to trigger an <strong>Azure Function</strong> with a binding <strong>in</strong>. At this point everything is working.</p> <p>However when I add a bind...
<python><azure><azure-functions><azure-cosmosdb>
2023-02-27 13:34:50
1
4,913
fandro
75,581,040
7,890,561
Check if string could be a filename
<p>I am looking for a way to check if an input string given by a user could be a valid file name for an output file, lets say a gif.</p> <p>The user may provide different kinds of input, e.g., they may provide a full path like <code>a/b/c.gif</code> or just a directory <code>a/b</code> or <code>a/b/</code>. I can check...
<python>
2023-02-27 13:22:16
0
886
Nyps
75,581,024
4,393,951
getting edges / lines of vertical lines in an image
<h1>Original Post</h1> <p>I have a batch of similar images which I need to analyze.</p> <p>After</p> <ul> <li>thresholding</li> <li>hole filling using <code>skimage.morphology.reconstruction</code> (example of usage <a href="https://scikit-image.org/docs/dev/auto_examples/features_detection/plot_holes_and_peaks.html" r...
<python><opencv><image-processing><contour><edge-detection>
2023-02-27 13:20:25
2
499
Yair M
75,580,952
14,269,252
Filter data frames based on a list of data frames and keep column which is stored in a dictionary
<p>I wrote the code as follows to read data from ParquetDataset and save the result into a list.</p> <p><em>1- I want to do some filtration based on different dataset in list (see example 1).</em></p> <p><em>2- I want to iterate over the dictionary for each data frame, keep the columns that is defined in dictionary and...
<python><pandas>
2023-02-27 13:14:41
1
450
user14269252
75,580,901
2,908,017
How to change Panel margins in Python VCL GUI app
<p>I'm using the <a href="https://github.com/Embarcadero/DelphiVCL4Python" rel="nofollow noreferrer">DelphiVCL GUI library for Python</a> and trying to change the margins on a <code>Panel</code> component, but it's not working</p> <p>I have the following code to create the <code>Form</code> and the <code>Panel</code> o...
<python><user-interface><vcl>
2023-02-27 13:09:45
1
4,263
Shaun Roselt
75,580,886
3,616,977
Open CV ImportError: /lib/x86_64-linux-gnu/libwayland-client.so.0: undefined symbol: ffi_type_uint32, version LIBFFI_BASE_7.0
<p>I have installed OpenCV and when trying to import cv2 in python, I get the following error. The import was working fine until I installed/un-installed and re-installed tensor flow.</p> <p>OpenCV has been installed in a conda environment using cmake. Any idea how to fix this?</p> <pre><code>Python 3.10.9 (main, Jan 1...
<python><opencv><conda><undefined-symbol><libffi>
2023-02-27 13:07:53
2
557
user3616977
75,580,847
10,271,487
Issues with FuncAnimation in Matplotlib
<p>I have a set of scatter data that I am trying to animate with FuncAnimation but am not getting any output. I don't use matplotlib often and have never tried to animate anything before except in matlab.</p> <p>That being said, I have dataframes with x,y data but cannot get the plot to work. The cv,of,ol,nf,nl_data ar...
<python><matplotlib>
2023-02-27 13:03:27
1
309
evan
75,580,833
3,214,538
Can I get an extended class object as a result of an SQLAlchemy relationship?
<p>I have the following structure for my Python project:</p> <pre><code>app/ ├─ classes/ │ ├─ person │ ├─ address ├─ database.py ├─ main.py ├─ models.py </code></pre> <p>database.py contains the connection details and creates the engine and session to be used:</p> <pre><code># database.py from sqlalchemy import creat...
<python><inheritance><sqlalchemy><relationship>
2023-02-27 13:02:14
0
443
Midnight
75,580,780
15,915,737
Run flow on prefect cloud without running local agent locally?
<p>I'm trying to deploy my flow but I'don't know what I should do to completely deploy it (serverless).</p> <p>I'm using the free tier of Prefect Cloud and I have create a storage and process block.</p> <p>The step I have done :</p> <ul> <li>Build deployment</li> </ul> <pre><code>$ prefect deployment build -n reporting...
<python><deployment><prefect>
2023-02-27 12:56:30
2
418
user15915737
75,580,592
3,053,450
Why is tqdm output directed to sys.stderr and not to sys.stdout?
<p>Accordingo to the python <a href="https://docs.python.org/3/library/sys.html" rel="nofollow noreferrer">python documentation concerning <code>sys.stdout</code> and <code>sys.stderr</code></a>:</p> <blockquote> <p>stdout is used for the output of print() and expression statements and for the prompts of input();</p> <...
<python><stdout><stderr><sys><tqdm>
2023-02-27 12:39:16
1
11,221
Heberto Mayorquin
75,580,522
14,751,525
Why do edge detection results look different for uint8 and float32?
<p>I use OpenCV's Sobel filter for edge detection. I was wondering why the output looks different when I run the 2 following lines.</p> <pre><code># uint8 output img_uint8 = cv2.Sobel(img_gray, cv2.CV_8U, dx=1, dy=0, ksize=5) # float32 output img_float32 = cv2.Sobel(img_gray, cv2.CV_32F, dx=1, dy=0, ksize=5) </code></...
<python><opencv><matplotlib><image-processing>
2023-02-27 12:30:52
1
694
Abdulwahab Almestekawy
75,580,508
13,320,076
YOLOv8 does not take torch tensor as input in python script
<p>I have a custom neural network where I want to use the output of a YOLO model run on the same input as part of my target. (E.g. number of objects in the image.) For that I build my own class as follows:</p> <pre><code>class yolo_mask_model(pl.LightningModule): def __init__(self, weight_path = '/mypath/weights/be...
<python><pytorch><neural-network><object-detection><yolo>
2023-02-27 12:29:30
1
631
Tom S
75,580,486
11,665,178
Firebase app check in python AWS lambda not working because of cryptography compilation
<p>I am trying to validate App Check tokens from my AWS lambda in python under the x86_64 architecture.</p> <p>When i execute my AWS lambda, i got the following error :</p> <pre><code>[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': /var/task/cryptography/hazmat/bindings/_rust.abi3.so: inva...
<python><amazon-web-services><aws-lambda><firebase-admin><firebase-app-check>
2023-02-27 12:26:58
1
2,975
Tom3652
75,580,410
3,668,129
How to convert string of time to milliseconds?
<p>I have a string which contains time (Hour-Minute-Second-Millisecond):</p> <pre><code>&quot;00:00:12.750000&quot; </code></pre> <p>I tried to convert it to milliseconds number without any success:</p> <pre><code>dt_obj = datetime.strptime(&quot; 00:00:12.750000&quot;,'%H:%M:%S') millisec = dt_obj.timestamp() * 1000 <...
<python><python-3.x>
2023-02-27 12:19:01
1
4,880
user3668129
75,580,363
5,710,684
Apply varying function for pandas dataframe depending on column arguments being passed
<p>I would like to apply a function to each row of a pandas dataframe. Instead of the argument being variable across rows, it's the function itself that is different for each row depending on the values in its columns. Let's be more concrete:</p> <pre><code>import pandas as pd from scipy.interpolate import interp1d d...
<python><pandas><apply>
2023-02-27 12:13:12
1
609
HannesZ
75,580,338
8,406,122
Converting a string to a list separated by spaces
<p>Say I have a string like this</p> <pre><code>s=&quot;a b c de fgh&quot; </code></pre> <p>Now I want to convert it to a list like this</p> <p><code>list1=['a','b','c','de','fgh']</code></p> <p>That is I will separate the characters when there's a space and make them a string of its own and store them in a list. Is th...
<python>
2023-02-27 12:10:35
1
377
Turing101
75,580,337
9,274,940
pandas group by and aggregate in a list based on condition
<p>This code groups <em>X</em> columns and aggregates <em>Y</em> column in one list when the other values are the same. I want to do the same, aggregate into a list but <strong>based in a condition</strong>:</p> <p>As you can see in the example, from 4 rows I obtain 2 rows, since it's aggregating the <em>age</em> colum...
<python><pandas><dataframe>
2023-02-27 12:10:30
1
551
Tonino Fernandez
75,580,288
1,878,788
How to preserve category dtype in pandas multiindex when concatenating data frames?
<p>I'm handling data (in my real use case, chromosome names, but here I used dummy names) for which I want to be able to control the sort order, and that will be part of a <code>MultiIndex</code> (also containing positions within chromosomes: I want to sort my data by chromosome, then position).</p> <p>To ensure the de...
<python><pandas><bioinformatics><multi-index><categorical-data>
2023-02-27 12:05:10
1
8,294
bli
75,580,278
6,013,016
How to reorder telegram posts already sent (python)
<p>Is it possible to change the order of sent posts on telegram channel. If so how to do that? Let's say I have these posts sent in my telegram channel:</p> <p><a href="https://i.sstatic.net/tw04d.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/tw04d.png" alt="enter image description here" /></a></p> <p>...
<python><telegram><telegram-bot>
2023-02-27 12:04:48
1
5,926
Scott
75,580,189
4,113,031
filter None value from python list returns: TypeError: boolean value of NA is ambiguous
<p>I used to filter out None values from a python (3.9.5) list using the &quot;filter&quot; method. Currently while upgrading several dependencies (pandas 1.3.1, numpy 1.23.5, etc.) I get the following:</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd x = pd.array(['This is', 'some text', None, '...
<python><python-3.x><pandas>
2023-02-27 11:57:47
3
1,178
Niv Cohen
75,580,118
5,931,672
Replace column value based on columns matches with another dataframe
<p>I have this two dataframes</p> <p>DataFrame A</p> <pre><code> column1 column2 column3 column4 1 a 2 True 23 2 b 2 False cdsg 3 c 3 False asdf 4 a 2 False sdac 5 b 1 False asdcd </code></pre> <p>Dataframe B is a single-row dataframe ...
<python><pandas>
2023-02-27 11:51:30
2
4,192
J Agustin Barrachina
75,580,048
6,224,975
poetry does not install the package when run in Docker, but all the dependencies is installed
<p>I have a docker-image in which I want to install my own package, <code>mypackage</code>, using the <code>.toml</code> and <code>.lock</code> file from <code>poetry</code> - inspired by <a href="https://stackoverflow.com/questions/53835198/integrating-python-poetry-with-docker">this</a> SO answer.</p> <p>It seems to ...
<python><docker><python-poetry>
2023-02-27 11:44:35
0
5,544
CutePoison
75,579,904
10,545,426
MkDocs with auto generated References
<p>I am building a TensorFlow model and have a ton of functions and modules that have proper docstrings.</p> <p>I installed mkdocs due to popular demand and the documentation does appear to be very easy to write.</p> <p>Nevertheless, I don't want to manually write up the entire API reference of all my modules inside th...
<python><mkdocs>
2023-02-27 11:30:51
1
399
Stalin Thomas
75,579,822
8,406,122
Removing space from a list of strings taken from a dataframe
<p>I have a data frame like this</p> <p><a href="https://i.sstatic.net/c72X9.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/c72X9.png" alt="enter image description here" /></a></p> <p>What I want to do that is take these as different strings in a list. For that I have written the following line</p> <pre...
<python><dataframe>
2023-02-27 11:22:42
3
377
Turing101
75,579,814
1,432,980
static resource within package are not found after wheel module installation
<p>I have <code>pyproject.toml</code> that looks like this</p> <pre><code>[tool.poetry] name = &quot;cmd-tool&quot; version = &quot;0.1.0&quot; description = &quot;&quot; authors = [] readme = &quot;README.md&quot; repository = &quot;&quot; documentation = &quot;&quot; packages = [ { include = &quot;src&quot; } ] ...
<python><python-packaging><python-poetry><python-wheel>
2023-02-27 11:22:08
0
13,485
lapots
75,579,680
110,963
Fine grained logging configuration for pytest
<p>When running my <a href="https://docs.pytest.org/en/7.2.x/" rel="nofollow noreferrer">Pytest</a> based tests, I want to enable debug logging for my own code, but not for 3rd party libraries. For example boto3 gets very noisy if you enable debug logging. According to <a href="https://docs.pytest.org/en/7.1.x/how-to/l...
<python><pytest>
2023-02-27 11:07:49
2
15,684
Achim
75,579,081
10,012,856
PoetryException failed to install gssapi-1.8.2.tar.gz
<p>I need to use ArcGIS API, so I've created a poetry environment and I've tried to install the API: <code>poetry add arcgis</code>. Unfortunately I see the error message below:</p> <pre><code> • Installing gssapi (1.8.2): Failed CalledProcessError Command '['/home/max/.cache/pypoetry/virtualenvs/arcgis-api-UPBhV...
<python><linux><arcgis><python-poetry>
2023-02-27 10:06:44
1
1,310
MaxDragonheart
75,578,852
5,056,347
Django sitemap for dynamic static pages
<p>I have the following in my <strong>views.py</strong>:</p> <pre><code>ACCEPTED = [&quot;x&quot;, &quot;y&quot;, &quot;z&quot;, ...] def index(request, param): if not (param in ACCEPTED): raise Http404 return render(request, &quot;index.html&quot;, {&quot;param&quot;: param}) </code></pre> <p>Url is s...
<python><django><django-urls><django-sitemaps>
2023-02-27 09:43:53
1
8,874
darkhorse
75,578,804
10,633,596
Getting # collapsed multi-line command error in GitLab CI config file scripts
<p>I'm trying to put a multi-line shell script command in the GitLab CI YAML file as shown below:-</p> <pre><code>test: stage: promote-test-reports image: &quot;937583223412.dkr.ecr.us-east-1.amazonaws.com/core-infra/linux:centos7&quot; before_script: - &quot;yum install unzip -y&quot; variables: GITLA...
<python><bash><shell><gitlab-ci><gitlab-ci-runner>
2023-02-27 09:39:13
1
1,574
vinod827
75,578,764
5,090,059
How to create a cumulative list of values, by group, in a Pandas dataframe?
<p>I'm trying to add a new column to the DataFrame, that consists of a cumulative list (by group) of another column.</p> <p>For example:</p> <pre><code>df = pd.DataFrame(data={'group1': [1, 1, 2, 2, 2], 'value': [1, 2, 3, 4, 5]}) </code></pre> <p>Expected output:</p> <pre><code> group1 value cumsum_column 0 1 ...
<python><pandas><group-by><cumsum>
2023-02-27 09:35:19
3
429
Nils Mackay
75,578,679
139,150
How to optimize this numpy code to make it faster?
<p>This code is working as expected and calculates cosign distance between two embeddings. But it takes a lot of time. I have tens of thousands of records to check and I am looking for a way to make it quicker.</p> <pre><code>import pandas as pd import numpy as np from numpy import dot from numpy.linalg import norm im...
<python><pandas><numpy>
2023-02-27 09:25:42
2
32,554
shantanuo
75,578,556
5,024,631
pandas: add a grouping variable to clusters of rows that meet a criteria
<p>I have this dataframe:</p> <pre><code>df = pd.DataFrame({'forms_a_cluster': [False, False, True, True, True, False, False, False, True, True, False, True, True, True, False], 'cluster_number':[False, False, 1, 1, 1, False, False, False, 2, 2, False, 3, 3, 3, False]}) </code></pre> <p>The idea is that I...
<python><pandas><dataframe><group-by>
2023-02-27 09:12:35
2
2,783
pd441
75,578,448
6,761,328
How to set the directory where the script is in in to working directory?
<p>I want to import multiple files which will always be in the same directory as the script itself. But the script might be copied and pasted to somewhere else. I know how to set and change the working directory but I don't know how to set the working directory dynamically/automatically to where the <code>.py</code> fi...
<python>
2023-02-27 08:58:31
0
1,562
Ben
75,578,379
4,464,596
Can't update Tkinter label from Thread
<p>I'm trying to update the text of a label from a Thread but it doesn't work. Here is a sample of the code</p> <pre><code>def search_callback(): class Holder(object): done = False holder = Holder() t = threading.Thread(target=animate, args=(holder,)) t.start() #long process here holder...
<python><multithreading><tkinter>
2023-02-27 08:51:27
1
1,234
simon
75,578,232
4,847,250
What is the input dimension for a LSTM in Keras?
<p>I'm trying to use deeplearning with LSTM in keras . I use a number of signal as input (<code>nb_sig</code>) that may vary during the training with a fixed number of samples (<code>nb_sample</code>) I would like to make parameter identification, so my output layer is the size of my parameter number (<code>nb_param</c...
<python><keras><lstm>
2023-02-27 08:28:49
3
5,207
ymmx
75,578,098
7,800,760
SQLAlchemy: proper way to specify connection URL in python
<p>Using SQLAlchemy (version <strong>2.0.4</strong>)to connect to a remote MySQL server from python via the pymysql driver.</p> <p>If I declare my connection URL in the &quot;simple&quot; way, it works:</p> <pre><code>import sqlalchemy as db engine = db.create_engine(&quot;mysql+pymysql://dbuser:verysecret@myhost.com:9...
<python><mysql><sqlalchemy>
2023-02-27 08:14:33
1
1,231
Robert Alexander
75,578,069
9,727,704
swapping list variables in nested loop unexpected result (single array?)
<p>If i have a multidimensional array that is a square like this:</p> <pre><code>[[1, 2, 3], [4, 5, 6], [7, 8, 9]] </code></pre> <p>And I want to turn it 90 degrees clockwise like this:</p> <pre><code>[[7, 4, 1], [8, 5, 2], [9, 6, 3]] </code></pre> <p>I can print out the changed square like this:</p> <pre><code>for...
<python><list><algorithm>
2023-02-27 08:10:34
2
765
Lucky
75,578,039
21,295,456
How to resolve 'ModuleNotFoundError: No module named 'termios' Error
<p>for the following code:</p> <p><code>from google.colab.patches import cv2_imshow </code> I get</p> <blockquote> <p>`ModuleNotFoundError: No module named 'termios'</p> </blockquote> <p>I saw in the other similar questions that there is no <code>termios</code> module in Windows.</p> <p>If so, is there any substitute f...
<python><jupyter-notebook><anaconda><google-colaboratory>
2023-02-27 08:07:29
0
339
akashKP
75,577,983
14,958,374
How to explicitly set the amount of visible memory from inside the docker container
<p>I am using complex multi-container setup via docker compose. I wish to limit each container's max amount of memory. I set max amount via <code>deploy.resources.limits.memory</code> section in docker compose:</p> <pre><code> deploy: resources: limits: memory: 3gb </code></pre> <p>After depl...
<python><docker><docker-compose><fastapi>
2023-02-27 07:59:47
1
331
Nick Zorander
75,577,553
5,056,347
How to print HTML content from a Django template in a view?
<p>Let's say I have a template called <code>index.html</code> with a bunch of block tags and variables and URLs. I can display it from my view using the <code>render()</code> function like so:</p> <pre><code>def index(request): return render(request, &quot;index.html&quot;, {...}) </code></pre> <p>I would like to p...
<python><django><django-views><django-templates>
2023-02-27 07:04:16
1
8,874
darkhorse
75,577,478
1,539,757
Execute javascript code in nodejs using spawn
<p>I wrote below code in node js to execute python code and print logs and return output using spawn,</p> <pre><code>const { spawn } = require('node:child_process'); const ls = spawn('node', ['-c', &quot;python code content will come here&quot;]); ls.stdout.on('data', (data) =&gt; { console.log(`stdout: ${data}`); })...
<javascript><python><node.js>
2023-02-27 06:54:07
1
2,936
pbhle
75,577,468
3,323,526
Why didn't Python multi-processing reduce processing time to 1/4 on a 4-cores CPU
<p>Multi-threading in CPython cannot use more than one CPU in parallel because the existence of GIL. To break this limitation, we can use multiprocessing. I'm writing Python code to demonstrate that. Here is my code:</p> <pre><code>from math import sqrt from time import time from threading import Thread from multiproce...
<python><linux><windows><multiprocessing><cpu-architecture>
2023-02-27 06:52:32
2
3,990
Vespene Gas
75,577,379
1,852,526
Python Popen writing command prompt output to logfile
<p>Firstly I am running this Python script on Windows.</p> <p>I am trying to open a new command prompt window every time and want to execute a .exe with some arguments. After I execute, I want to copy the command prompt output to a log file. I created a log file at the location say &quot;log.log&quot;. When I run the s...
<python><logging><popen><python-logging>
2023-02-27 06:35:09
1
1,774
nikhil
75,577,350
9,236,039
How to fetch data and store into multiple files based on condition
<p>test.csv</p> <pre><code>name,age,n1,n2,n3 a,21,1,2,3 b,22,4,9,0 c,25,4,5,6 d,25,41,5,6 e,25,4,66,6 f,25,4,5,66 g,25,4,55,6 h,25,4,5,56 i,25,41,5,61 j,25,4,51,60 k,20,40,50,60 l,21,40,51,60 </code></pre> <p>My code till reading and storing into dict</p> <pre><code>import pandas as pd input_file = pd.read_csv(&quot;...
<python><pandas><dataframe><csv>
2023-02-27 06:30:44
1
357
Dhananjaya D N
75,577,330
2,975,438
FastAPI in docker container: how to get automatic detection of changes in python file?
<p>I was looking to this similar <a href="https://stackoverflow.com/questions/63038345/how-to-make-fastapi-pickup-changes-in-an-api-routing-file-automatically-while-ru">question</a> but for some reason it does not work for me.</p> <p>I have the following folder structure:</p> <pre><code>api.service - app -- main.py - D...
<python><docker><fastapi>
2023-02-27 06:26:47
0
1,298
illuminato
75,577,207
1,668,622
With argparse it it possible to process arguments only up to the last non-positional argument?
<p>I'm writing a tool which passes arguments to another command provided with the arguments like this:</p> <pre><code>foo --arg1 -b -c bar -v --number=42 </code></pre> <p>In this example <code>foo</code> is my tool and <code>--arg1 -b -c</code> should be the arguments parsed by <code>foo</code>, while <code>-v --number...
<python><command-line-arguments><argparse><positional-argument>
2023-02-27 06:04:32
1
9,958
frans
75,576,623
13,162,807
Docker python app can't find `PATH_INFO` env variable
<p>I'm trying to run python backend using Docker, however app can't find <code>PATH_INFO</code> environment variable. Though on another machine it works well, difference is OS version: previous is <code>ubuntu 21.04</code> and current is <code>ubuntu 22.04</code></p> <p>The error is caused by this piece of code:</p> <p...
<python><docker><nginx>
2023-02-27 03:49:59
1
305
Alexander P
75,576,409
12,596,824
Duplicating rows and and creating ID column and repeating column in Python
<p>I have the following input dataframe:</p> <p><strong>Input Dataframe:</strong></p> <pre><code>c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 56 1 2 4 1.0 1 4.0 1.0 2 2 18000.0 52 2 2 5 3.0 1 4.0 1.0 1 1 0.0 82 2 2 5 4.0 2 4.0 1.0 1 1 0.0 26 1 2 4 2.0 1 4.0 1.0 2 2 ...
<python><pandas>
2023-02-27 02:54:55
2
1,937
Eisen
75,576,273
5,366,075
Generate PDF containing multiple SVG barcodes
<p>I am trying to generate a PDF containing all the barcodes in SVG format. Here is the code I've written so far.</p> <pre><code>from code128 import Code128 import csv from reportlab.graphics.shapes import Group, Drawing from reportlab.graphics import renderPDF from reportlab.lib.pagesizes import letter # Scale of SVG...
<python><svg><python-barcode>
2023-02-27 02:14:44
1
1,863
usert4jju7
75,576,166
18,758,062
How to run matplotlib FuncAnimation using multiprocessing?
<p>It takes a long time (20 secs) to render 500 frames of this matplotlib animation using the code below.</p> <p>Is it possible to produce the same animation <code>anim</code> but make use of more CPU cores, such as with the use of <code>multiprocessing</code> to create more processes that runs <code>FuncAnimation</cod...
<python><matplotlib><multiprocessing><jupyter>
2023-02-27 01:46:21
0
1,623
gameveloster