QuestionId int64 74.8M 79.8M | UserId int64 56 29.4M | QuestionTitle stringlengths 15 150 | QuestionBody stringlengths 40 40.3k | Tags stringlengths 8 101 | CreationDate stringdate 2022-12-10 09:42:47 2025-11-01 19:08:18 | AnswerCount int64 0 44 | UserExpertiseLevel int64 301 888k | UserDisplayName stringlengths 3 30 ⌀ |
|---|---|---|---|---|---|---|---|---|
78,862,464 | 2,539,916 | Django complex relation with joins | <p>I have the following models:</p>
<pre class="lang-py prettyprint-override"><code>class Position(BaseModel):
name = models.CharField()
class Metric(BaseModel):
name = models.CharField()
class PositionKPI(BaseModel):
position = models.ForeignKey(Position)
metric = models.ForeignKey(Metric)
expect... | <python><django><django-models> | 2024-08-12 15:26:31 | 2 | 1,584 | Alex Tonkonozhenko |
78,862,382 | 1,627,234 | Trouble migrating to numpy 2: numpy.core.multiarray failed to import | <p>I maintain <a href="https://github.com/pavlin-policar/openTSNE" rel="nofollow noreferrer">openTSNE</a> and would like to support numpy2. The package depends on numpy and uses Cython, so the build process is a bit more involved.</p>
<p>When building the package on Azure's CI servers, I previously depended on <code>ol... | <python><numpy><numpy-2.x> | 2024-08-12 15:06:11 | 1 | 5,558 | Pavlin |
78,862,245 | 10,090,697 | Discrepancy between Python and R calculation of a robust covariance matrix | <p>I am currently developing a statistical package in Python using R code as a reference, and I've noticed different results between the two programs when calculating a robust covariance matrix in Python versus R.</p>
<p>Using the following code with equivalent input data (<code>x</code>) in Python:</p>
<pre><code># du... | <python><r><statistics> | 2024-08-12 14:36:53 | 2 | 311 | Zack Eriksen |
78,862,065 | 5,482,999 | How to serialize a ComputeRoutesResponse | <p>When using the web endpoint with python <code>requests</code> for computing Routes with Google Cloud, <code>https://routes.googleapis.com/directions/v2:computeRoutes</code>, I get the response in json.
This is how I build the request with python, it allows me to work better with data received.</p>
<pre><code>headers... | <python><google-maps><google-cloud-platform><google-routes-api> | 2024-08-12 13:59:28 | 1 | 1,924 | Guanaco Devs |
78,861,984 | 11,328,614 | Uninstall all packages from specific group | <p>In my <code>pyproject.toml</code> I have configured a "normal" and a "dev" configuration, like so:</p>
<pre class="lang-toml prettyprint-override"><code>[tool.poetry]
name = "project_name"
version = "0.2.0"
description = "Project description"
authors = ["me"... | <python><python-poetry> | 2024-08-12 13:38:51 | 0 | 1,132 | Wör Du Schnaffzig |
78,861,861 | 3,888,816 | Django annotation returns 1 for each item | <p>I have 2 almost identical models.</p>
<pre><code>class FavoriteBook(models.Model):
class Meta:
# Model for books added as favorites
verbose_name = "Favorite Book"
unique_together = ['user', 'book']
user = models.ForeignKey(User, null=False, blank=False, on_delete=models.CA... | <python><django><annotations> | 2024-08-12 13:08:58 | 1 | 982 | orhanodabasi |
78,861,658 | 10,285,705 | misplaced item on Frame and Root | <p>I am building an tkinter application with 2 frames inside my root. Here is my code and what I obtain:</p>
<pre><code>from tkinter import*
from tkinter import ttk
root = Tk()
root.geometry('880x600')
root.config(bg="blue")
root.resizable(0,0)
################ RIGHT FRAME #################################... | <python><tkinter> | 2024-08-12 12:24:03 | 1 | 481 | Camue |
78,861,619 | 51,816 | How to detect audio retakes using Python? | <p>I have a lot of audio recordings for lectures where I say the same thing multiple times, mostly it's incomplete statements like:</p>
<p>"this is the part" (and then retrying)</p>
<p>"this is the part where" (and then retrying)</p>
<p>"this is the part where we will explore the theory"</... | <python><audio><signal-processing><speech><librosa> | 2024-08-12 12:14:42 | 1 | 333,709 | Joan Venge |
78,861,589 | 2,071,807 | Is it possible to only mention arguments which change between overloads in Python? | <p>I have a function whose return type varies based on the value of one of it's arguments:</p>
<pre class="lang-py prettyprint-override"><code>class ReturnType(Enum):
NONE = 1
SCALAR = 2
VECTOR = 3
@overload
def perform_query(
sql: str, return_type: Literal[ReturnType.NONE], log_query: bool = ...
) -&... | <python><python-typing> | 2024-08-12 12:08:43 | 0 | 79,775 | LondonRob |
78,861,350 | 1,894,388 | Pandas Unable to Find NaN when 0 is divided by 0 | <p>I have dataframe like this:</p>
<pre><code>df_challenge = pd.DataFrame({'x': [1, pd.NA, 6, 9, pd.NA, 0, 9, 10, 0, 9, pd.NA, 0],
'y': [0, 7.2, pd.NA, 10, 0, 1, 9.2, 10.65, pd.NA, 9, pd.NA, 0],
'y_copy': [0, 7.2, np.nan, 10, 0, 1, 9.2, 10.65, np.nan, 9... | <python><pandas> | 2024-08-12 11:15:40 | 1 | 11,116 | PKumar |
78,861,297 | 8,726,488 | Python regex convert single row into multiple rows | <p>This is my data in single line.</p>
<pre><code>1. B 2. E 3. E 4. D 5. E 6. A 7. A 8. E 9. E 10. D
</code></pre>
<p>How to convert into multiple lines as below using python</p>
<pre><code>1. B
2. E
3. E
.
.
10. D
</code></pre>
| <python><python-3.x><regex> | 2024-08-12 10:59:18 | 3 | 3,058 | Learn Hadoop |
78,861,118 | 13,757,692 | Multiply array of matrices with array of vectors in Numpy | <p>I have an array of matrices <code>A</code> of shape <code>A.shape = (N, 3, 3)</code> and an array of vectors <code>V</code> of shape <code>V.shape = (N, 3)</code>. I want to get an (N, 3) array, where each vector is the result of multiplying the i-th matrix with the i-th vector. Such as:</p>
<pre><code>result = [A[i... | <python><arrays><numpy> | 2024-08-12 10:10:52 | 1 | 466 | Alex V. |
78,860,597 | 2,401,053 | Parse Messy Dates from an Object Column and Replace with Formatted Dates | <p>I'm currently new to R and I'm trying to make a script for cleaning messy dates. Basically, I have a linelist of deaths and it has a column called "Date of Death". This column contains dates that are not uniformly formatted so I'd like to parse and format the dates into a uniform date format however, I'm g... | <python><r><date> | 2024-08-12 08:07:06 | 1 | 1,327 | maikelsabido |
78,860,550 | 288,201 | Return an empty AsyncIterable from a function | <p>I would like to define a function returning an <em>empty</em> <code>AsyncIterable</code> of a concrete type.</p>
<p>The function will be a part of a base class; derived classes can implement it as necessary but the default behaviour is to return no items to iterate.</p>
<p>Unfortunately there is no convenient "... | <python><asynchronous> | 2024-08-12 07:57:06 | 2 | 8,287 | Koterpillar |
78,860,479 | 8,510,149 | Find tree hierachy in group and collect in a list - PySpark | <p>In the data below, for each id2, I want to collect a list of the id1 that is above them in hierarchy/level.</p>
<pre><code>from pyspark.sql import SparkSession
from pyspark.sql.types import StructType, StructField, StringType, IntegerType
schema = StructType([
StructField("group_id", StringType(), Fal... | <python><pyspark> | 2024-08-12 07:39:50 | 1 | 1,255 | Henri |
78,860,333 | 4,577,688 | A more efficient way to add values inplace at colums of a 2d matrix, using a 2d array for the colum indices | <p>I would like to do a <code>+=</code> operation at specified columns of a 2d matrix, where the column indices are in another 2D matrix.</p>
<p>Specifically, is there a more efficient way to do the operation in <code>loop_fun</code> below.</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
np.rando... | <python><arrays><numpy> | 2024-08-12 06:58:44 | 1 | 3,840 | dule arnaux |
78,860,330 | 1,942,868 | How to add the evey objects to Many-to-Many relationship model | <pre><code>class MyUserGroup(BaseModel):
my_user_types = m.ManyToManyField('MyUserType',blank=True)
</code></pre>
<p>I have this models which has the many-to-many relation ship to type.</p>
<p>Now I want to give the every MyUserType objects to this model such as</p>
<pre><code>muy = MyUserType()
muy.save()
muy.my_u... | <python><django> | 2024-08-12 06:58:25 | 1 | 12,599 | whitebear |
78,859,973 | 13,000,229 | Why does using `any` as type hints cause no error? | <h2>Question</h2>
<p>Recently I mistakenly wrote <code>any</code> where I should write <code>Any</code>. I find this does not cause any warning/error messages.<br />
Why is this not an error?</p>
<h2>Sample code</h2>
<p>Environment</p>
<ul>
<li>Python 3.12.4</li>
<li>IDE: PyCharm 2024.1.4 (Professional Edition)</li>
</... | <python><pycharm><python-typing> | 2024-08-12 04:24:10 | 0 | 1,883 | dmjy |
78,859,586 | 6,197,439 | Programmatically close a QTabWidget, so tabCloseRequested handler triggers? | <p>In the example below, which produces this GUI:</p>
<p><a href="https://i.sstatic.net/AJbhFzr8.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/AJbhFzr8.png" alt="example GUI" /></a></p>
<p>... if I click the close button on tab 2 (or tab 3), then <code>on_tab_close</code> handler fires/is triggered/run... | <python><pyqt5> | 2024-08-11 23:20:10 | 0 | 5,938 | sdbbs |
78,859,343 | 1,601,580 | How to reinitialize from scratch GPT2 XL in HuggingFace? | <p>I'm trying to confirm that my GPT-2 model is being trained from scratch, rather than using any pre-existing pre-trained weights. Here's my approach:</p>
<ol>
<li><strong>Load the pre-trained GPT-2 XL model</strong>: I load a pre-trained GPT-2 XL model using <code>AutoModelForCausalLM.from_pretrained("gpt2-xl&qu... | <python><machine-learning><huggingface-transformers><huggingface> | 2024-08-11 20:27:07 | 1 | 6,126 | Charlie Parker |
78,859,302 | 688,624 | Python MRO for operators: Chooses RHS `__rmul__` instead of LHS `__mul__` when RHS is a subclass | <p>Consider the following self-contained example:</p>
<pre class="lang-py prettyprint-override"><code>class Matrix:
def __mul__(self, other):
print("Matrix.__mul__(⋯)")
return NotImplemented
def __rmul__(self, other):
print("Matrix.__rmul__(⋯)")
return NotImpl... | <python><language-lawyer><operators><method-resolution-order> | 2024-08-11 20:04:56 | 1 | 15,517 | geometrian |
78,859,203 | 2,288,506 | Python + Sqlite3 dump, source to MariaDB: Unknown collation: 'utf8mb4_0900_ai_ci' (db noob) | <p>I'm following Head First Python (3ed). I'm at the last chapter and have a bug I can't get past.</p>
<p>I've got an sqlite3 database that I need to port to MariaDB. I've got the schema and data in separate files:</p>
<pre><code>sqlite3 CoachDB.sqlite3 .schema > schema.sql
sqlite3 CoachDB.sqlite3 '.dump swimmers ev... | <python><sql><sqlite><mariadb> | 2024-08-11 19:10:36 | 1 | 512 | CraigFoote |
78,858,791 | 558,801 | Not able to open or call the current open file with xlwings | <p>I'm not able to open or call the current active workbook using xlwings.
I'm on macOS Sonoma 14.5 and xlwings v0.31.10.</p>
<p>I keep getting this error (I'm running the .py file out of 4. Master):</p>
<pre><code>UnboundLocalError: cannot access local variable 'mount_point' where it is not associated with a value
</... | <python><excel><xlwings> | 2024-08-11 16:16:15 | 1 | 2,227 | cocos2dbeginner |
78,858,596 | 5,650,267 | minimizing a multidimentional solution over a dataset | <p>I have a rectangle within a 2d space and a set of points within the rectangle. The rectangle is moving in the following manner: the center moves a value of <code>u</code> on the x-axis, <code>v</code> on the y-axis and everything is scaled in a factor of <code>sx</code> and <code>sy</code> respectively. I only get t... | <python><scipy><mathematical-optimization> | 2024-08-11 14:42:42 | 1 | 1,247 | havakok |
78,858,582 | 17,795,398 | How to install torch with CUDA in virtual environment (Torch not compiled with CUDA enabled) | <p>I'm trying to use the <a href="https://github.com/fpgaminer/joytag" rel="nofollow noreferrer">joytag model</a> locally. This is <code>requirements.txt</code>:</p>
<pre><code>torch>=2.0.1,<3.0.0
transformers>=4.36.2
torchvision>=0.15.2
einops>=0.7.0
safetensors>=0.4.1
pillow>=9.4.0
</code></pre>
... | <python><pytorch> | 2024-08-11 14:34:08 | 1 | 472 | Abel Gutiérrez |
78,858,457 | 9,999,861 | Server Error (500) and strange symbols inside a form | <p>I set up a Raspberry Pi with Ubuntu server as OS. I followed this guide: <a href="https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-apache-and-mod_wsgi-on-ubuntu-16-04" rel="nofollow noreferrer">Guide from digitalocean</a></p>
<p>It all seemed to work good until I opened a page w... | <python><django><apache2><ubuntu-server> | 2024-08-11 13:37:02 | 1 | 507 | Blackbriar |
78,858,319 | 1,371,666 | Looking for Short and better way to create widget in Tkinter | <p>I am using Python 3.11.9 in windows 11 OS (home edition)<br>
I create text entry using three lines shown in code below:</p>
<pre><code>import tkinter as tk
class Application(tk.Tk):
def __init__(self, title:str="Bill generation", x:int=0, y:int=0, **kwargs):
tk.Tk.__init__(self)
... | <python><tkinter> | 2024-08-11 12:25:49 | 1 | 481 | user1371666 |
78,858,292 | 4,581,085 | ProcessPoolExecutor fails | <p>I have a simple setup to test parallel execution, but it fails no matter what I've tried. I'm working in a Jupyter Notebook.</p>
<p>Here is a model example:</p>
<pre><code>from concurrent.futures import ProcessPoolExecutor
def worker(i):
print(f"TASK: {i}")
result = i * i
print(f"RESULT: ... | <python><jupyter-notebook><concurrency><jupyter><concurrent.futures> | 2024-08-11 12:16:23 | 1 | 985 | Alex F |
78,858,039 | 2,840,697 | Implementing power function in two different ways. What's the big O difference between these two codes? | <ul>
<li><p>1:</p>
<pre><code>class Solution(object):
def myPow(self, x, n):
"""
:type x: float
:type n: int
:rtype: float
"""
if n < 0:
return 1.0/self.myPow(x, -n)
elif n==0:
return 1
elif n ==... | <python><big-o> | 2024-08-11 10:03:19 | 2 | 942 | user98235 |
78,857,858 | 2,749,397 | Where is Tkinter sourcing info about the screen DPI? | <p>Using X on Linux, Tkinter (Python 3.12) tells me that I have a DPI value of ~96 (wrong), while the X server tells me that my DPI value is ~185 (correct).</p>
<pre><code>In [1]: import tkinter as tk
...: root = tk.Tk()
...: print(root.winfo_fpixels('1i'))
...: root.destroy()
...:
...: xrandr_out = ! x... | <python><tkinter><xserver> | 2024-08-11 08:36:58 | 0 | 25,436 | gboffi |
78,857,955 | 2,036,464 | Python: Find and replace html tags, with an exception? | <p>I have this <code>test.html</code> and I need to find all lines that starts with <code><p class="text_obisnuit"></code> and <code><p class="text_obisnuit2"></code> , and have <code><br></code> instead ofthe close tag <code></p></code>. So, I have to remove <br> and replace... | <python><python-3.x><html> | 2024-08-11 07:57:34 | 1 | 1,065 | Just Me |
78,857,605 | 14,250,641 | Filter strings with high proportion of lowercase letters | <p>I have quite a large df (50+ million) with one of the columns containing DNA sequences (1 DNA sequence per row). Some of these sequences contain a mix of lowercase and uppercase letters. I would like to have my dataset only have sequences with 50% or more uppercase letters (take out the seqs with 50% or more lowerca... | <python><pandas><dataframe><optimization><bioinformatics> | 2024-08-11 06:00:57 | 5 | 514 | youtube |
78,857,511 | 1,838,076 | Using with block vs processing the file in one line | <p>In Python, while reading the file's content, it is recommended to use the <code>with</code> block.</p>
<p>Something like below</p>
<pre><code>with open(file, 'r', encoding='utf-8') as f:
content = f.read().splitlines()
</code></pre>
<p>However, if I am not processing much, I can do something like below in one li... | <python><file-io><with-statement> | 2024-08-11 04:39:15 | 2 | 1,622 | Krishna |
78,857,434 | 801,902 | How to filter a query in Django for week_day using a specific timezone? | <p>I am trying to filter data by the day of the week. That's easy enough with the week_day filter. The problem is, since all dates are stored as UTC, that is how it's filtered. How can I localize a query?</p>
<p>For instance, trying to count all the records that have been created on specific days, I use this:</p>
<p... | <python><django> | 2024-08-11 03:13:35 | 1 | 1,452 | PoDuck |
78,857,171 | 19,366,064 | Pylance missing imports with DevContainers | <p>I have the following folder structure</p>
<pre><code>C:.
│ docker-compose.yml
│ Dockerfile
│
├───.devcontainer
│ devcontainer.json
│
└───app
__init__.py
main.py
sub.py
</code></pre>
<p>Dockerfile</p>
<pre><code>FROM python:3.9
</code></pre>
<p>docker-compose.yml</p>
<pre><code>vers... | <python><visual-studio-code><pylance><devcontainer> | 2024-08-10 22:53:00 | 1 | 544 | Michael Xia |
78,857,126 | 2,727,167 | Extract lines from the image with text | <p>I have followde the image:</p>
<p><img src="https://i.sstatic.net/yrpSn7q0.png" alt="enter image description here" /></p>
<p>I want to extract only lines from it -- only lines without text.</p>
<p>What would be the best practice to do this?</p>
<p>I tried with the cv2 Python library and HoughLinesP with following th... | <python><opencv> | 2024-08-10 22:11:41 | 2 | 450 | user2727167 |
78,856,785 | 10,499,034 | How to properly scale cmapcolor | <p>Below is a fully-functioning example of my problem. The color that cmap assigns based on the values I give to it does not match the color that it should be on the color bar. For example, the fragment with distance=1.75 is yellow when according to the colorbar it should be light purple. How can I assign the colors... | <python><matplotlib> | 2024-08-10 18:38:18 | 1 | 792 | Jamie |
78,856,532 | 8,648,222 | How to make huggingface transformer for translation return n translation inferences? | <p>So I am trying to use this transformer from huggingface <a href="https://huggingface.co/docs/transformers/en/tasks/translation" rel="nofollow noreferrer">https://huggingface.co/docs/transformers/en/tasks/translation</a>. The issue is that I want n translations returned and not just one. How can I do that? I mean, I... | <python><huggingface-transformers><transformer-model> | 2024-08-10 16:37:03 | 1 | 825 | v_head |
78,856,511 | 3,442,683 | TimeoutError with python-chess when trying to initialize Stockfish on macOS | <p>I'm trying to use the python-chess library to interface with Stockfish on macOS, but I'm encountering a TimeoutError during the initialization process. Here's a simplified version of my code:</p>
<pre><code>import chess.engine
# Set your Stockfish path here
engine_path = '/Applications/Stockfish.app/Contents/MacOS/... | <python><macos><python-chess><uci><stockfish> | 2024-08-10 16:26:12 | 1 | 534 | klooth |
78,856,452 | 558,639 | Is [a,b][a>b] equivalent to min(b, a)? | <p>I came upon a bit of third party Python code that read:</p>
<pre><code>count = [remaining, readlen][remaining > readlen]
</code></pre>
<p>After staring at it for a bit, I have to ask: are there any cases where this construct is NOT equivalent to:</p>
<pre><code>count = min(readlen, remaining)
</code></pre>
<p>i.e... | <python> | 2024-08-10 16:02:57 | 2 | 35,607 | fearless_fool |
78,856,105 | 2,268,543 | Unable to Extract Text from Image Using Tesseract OCR - How to Preprocess Instagram Reels Frames | <p>I am working on a project where I need to extract text from frames of an Instagram Reels video. I used the <code>yt-dlp</code> to download the video, extracted frames using <code>ffmpeg</code>, and attempted to read the text from the frames using Tesseract OCR.</p>
<p>However, I'm unable to extract text from the fra... | <python><ocr><tesseract><python-tesseract><image-preprocessing> | 2024-08-10 13:13:49 | 0 | 2,519 | Rasik |
78,856,001 | 16,320,430 | How to combine two columns into `{key:value}` pairs in polars? | <p>I'm working with a <code>Polars DataFrame</code>, and I want to combine two columns into a dictionary format, where the values from one column become the keys and the values from the other column become the corresponding values.</p>
<p>Here's an example DataFrame:</p>
<pre class="lang-py prettyprint-override"><code>... | <python><dataframe><data-cleaning><python-polars> | 2024-08-10 12:24:13 | 2 | 435 | Dante |
78,855,989 | 5,893,683 | How to do inter-process communication with pathos/ppft? | <p>I'm using the <a href="https://pathos.readthedocs.io/en/latest/" rel="nofollow noreferrer"><code>pathos</code></a> framework to do tasks concurrently, in different processes. Under the hood, this is done with <a href="https://ppft.readthedocs.io/en/latest/" rel="nofollow noreferrer"><code>ppft</code></a>, which is p... | <python><ipc><dill><pathos><ppft> | 2024-08-10 12:19:20 | 1 | 572 | onetyone |
78,855,921 | 1,711,146 | How to async instantiate and close a shared aiohttp session in Azure Functions in Python? | <p>I need to use an HTTP client in my Azure Function. I can use aiohttp like this (this is a minimalistic example form the MSFT documentation).</p>
<pre><code>import aiohttp
import azure.functions as func
async def main(req: func.HttpRequest) -> func.HttpResponse:
async with aiohttp.ClientSession() as client:
... | <python><asynchronous><azure-functions><aiohttp> | 2024-08-10 11:46:52 | 2 | 2,680 | Konstantin |
78,855,919 | 1,092,084 | Accessing original object (one being serialized / validated) from validators, computed_field(), etc | <p>I use pydantic in a FastAPI project to serialize SQLAlchemy entity objects, and I need to access the original entity object in <code>@computed_field</code> methods and validators in order to access data from relationships (which are not supposed to be themselves serialized).</p>
<p>This is what I tried so far:</p>
<... | <python><pydantic><pydantic-v2> | 2024-08-10 11:45:27 | 1 | 340 | Thorn |
78,855,322 | 420,947 | Can the Python `protoc` compiler module from `grpc_tools` automatically include proto files from site-packages? | <p>In Python, the gRPC project proto files are shipped in smaller packages. For example, I want to use <code>status.proto</code>, which is the <code>grpc-status</code> package.</p>
<p>The <code>protoc</code> compiler is provided as a Python module by the <code>grpc-tools</code> package.</p>
<pre class="lang-protobuf p... | <python><grpc><grpc-python> | 2024-08-10 05:50:58 | 1 | 1,663 | Richard Michael |
78,855,271 | 10,669,327 | how to inspect locally running BLE GATT server on Ubuntu Linux using D-bus? | <p>I am using following sample code:
<a href="https://github.com/bluez/bluez/blob/master/test/example-gatt-server" rel="nofollow noreferrer">example-gatt-server</a> for testing purpose.</p>
<p>Example:</p>
<p>-> In this code we have registered Service: HeartRateService which has multiple Characteristics as: HeartRa... | <python><linux><bluetooth-lowenergy><dbus><pybluez> | 2024-08-10 05:04:15 | 0 | 701 | raj123 |
78,855,135 | 4,803,413 | sentence-transformers: combined parallelization for custom chunking function and encode_multi_process() | <p>I am working in Python 3.10, using a sentence-transformers model to encode/embed a list of text strings. I want to use sentence-transformer's <code>encode_multi_process</code> method to exploit my GPU. This is a very specific function that takes in a string, or a list of strings, and produces a numeric vector (or li... | <python><machine-learning><python-multiprocessing><transformer-model><sentence-transformers> | 2024-08-10 03:16:07 | 1 | 431 | Anshu Chen |
78,855,105 | 1,608,276 | Python3 Type Safe partial_apply | <p>I'm trying to implement a helper function which partial apply arguments to a specific function and return a new function</p>
<pre><code>from typing import Any, Callable, TypeVar
from typing_extensions import ParamSpec
P = ParamSpec('P')
R = TypeVar('R')
def partial_apply(fn: Callable[P, R], *args: subset_of[P.args... | <python><python-typing><partial-application> | 2024-08-10 02:55:16 | 0 | 3,895 | luochen1990 |
78,854,892 | 865,220 | Correct option to download from youtube with video resolution of 1080p using youtube-dl? | <p>To download youtube videos manually I typically use : <a href="https://y2meta.app/en/youtube/rU8_Fg103ZQ" rel="nofollow noreferrer">https://y2meta.app/en/youtube/rU8_Fg103ZQ</a> 's
[1080p (.mp4) full-HD] resolution.</p>
<p>Now I am looking to replicate the same via code using python's library <a href="https://github... | <python><youtube><youtube-dl> | 2024-08-10 00:03:27 | 0 | 18,382 | ishandutta2007 |
78,854,857 | 1,030,542 | Python3.11 handle HttpException raised alongwith the status code | <p>I see one of the methods in python uses <code>raise_for_status()</code>:</p>
<pre><code> def raise_for_status(self):
if 400 <= self.status_code < 500:
http_error_msg = (
f"{self.status_code} Client Error: {reason} for url: {self.url}"
... | <python><python-requests><try-except><raise> | 2024-08-09 23:32:41 | 1 | 2,453 | iDev |
78,854,702 | 229,058 | How can I get head of branch with illegal characters in it | <p>I know you can get the head of a branch directly using it's name (e.g. <code>repo.heads.main</code>). Can you get the head of a branch that has illegal variable characters (e.g. <code>feature-generate-events</code>) directly or do I have to iterate to get it? The hyphens are illegal (in a Python sense as @phd comm... | <python><git><gitpython> | 2024-08-09 21:52:49 | 2 | 2,702 | Stephen Rasku |
78,854,539 | 7,106,915 | Multiplication in an arbitrary base in Python | <p>Is there a library or efficient way to perform multiplication in an arbitrary base in Python, <strong>without</strong> going through the conversion to base 10?</p>
<p>Example of the wanted function f in base 14:</p>
<pre><code>base = 14
a = "b5"
b = "2a"
f(a,b,base) = "22b8"
</code></pr... | <python> | 2024-08-09 20:36:08 | 0 | 3,007 | Rexcirus |
78,854,509 | 5,083,516 | replacement for python3 crypt module | <p>The documentation for the python3 crypt module says.</p>
<blockquote>
<p>Deprecated since version 3.11, will be removed in version 3.13: The crypt module is deprecated (see PEP 594 for details and alternatives). The hashlib module is a potential replacement for certain use cases. The passlib package can replace all ... | <python><crypt> | 2024-08-09 20:22:28 | 1 | 10,972 | plugwash |
78,854,478 | 16,320,430 | How can I replace null values in polars with a prefix with ascending numbers? | <p>I am trying to replace null values in my dataframe column by a prefix and ascending numbers(to make each unique).ie</p>
<pre class="lang-py prettyprint-override"><code>df = pl.from_repr("""
┌──────────────┬──────────────┐
│ name ┆ asset_number │
│ --- ┆ --- │
│ str ┆... | <python><dataframe><data-science><data-cleaning><python-polars> | 2024-08-09 20:11:44 | 3 | 435 | Dante |
78,854,416 | 11,196,682 | How to Reduce Cold Start Time for AWS Lambda with Heavy Library Imports (SQLAlchemy, etc.)? | <p>I'm working with AWS Lambda in a serverless environment and I'm facing significant cold start delays due to heavy library imports before my handler. My Lambda function needs to use libraries like SQLAlchemy, which takes around 0.4 seconds just to import. Combined with other library imports, my cold start time can re... | <python><amazon-web-services><aws-lambda><import> | 2024-08-09 19:49:45 | 1 | 552 | MathAng |
78,854,255 | 1,914,781 | pandas convert continuous duration column to start and end colum | <p>I would like to convert <code>duration</code> column to <code>start</code> and <code>end</code> column. I try below code, it works as expected but it not a perfect way.</p>
<pre><code>import pandas as pd
def main():
data = [
['A',7],
['B',5],
['C',5],
['D',15],
['E',5]
... | <python><pandas> | 2024-08-09 18:55:12 | 2 | 9,011 | lucky1928 |
78,854,232 | 10,614,373 | How do I add a Multilevel dropdown to a Django template? | <p>I am trying to add a dropdown to my navbar in <code>base.html</code> that shows multiple categories from a store. Each of these categories has a sub-category associated with it. I've created a model in Django that maps this relationship like so.</p>
<p><strong>models.py</strong></p>
<pre><code>class CategoryView(mod... | <javascript><python><html><css><django> | 2024-08-09 18:47:38 | 1 | 492 | Trollsors |
78,854,169 | 5,798,365 | How to raise numerical labels on a matplotlib bar plot | <pre><code>points_1_25 = {'Completed' : grades_simple_completed, 'Failed': grades_simple_failed}
fig, ax = plt.subplots(figsize=(25, 10))
bottom = np.zeros(25)
width = 0.8
for verdict, point in points_1_25.items():
p = ax.bar(x_labels, point, width, label=verdict, bottom=bottom)
bottom += point
ax.bar_label... | <python><matplotlib> | 2024-08-09 18:24:35 | 0 | 861 | alekscooper |
78,854,061 | 3,769,033 | `KinematicTrajectoryOptimization` fails with `DurationCost` and any `AccelerationBounds` (even infinite) | <p><code>KinematicTrajectoryOptimization</code> seems to fail arbitrarily on some inputs when using a <code>DurationCost</code> and <code>AccelerationBounds</code>, even when setting the <code>AccelerationBounds</code> far outside the actual acceleration of the trajectory (or even setting them to infinity).</p>
<p>Here... | <python><drake> | 2024-08-09 17:47:19 | 1 | 1,245 | JoshuaF |
78,853,975 | 19,369,310 | KeyError: 0 # If we have a listlike key, _check_indexing_error will raise after applying a function to a pandas dataframe | <p>I have a rather complicated function <code>f(featureList)</code> that takes a list of arbitrary length as input and gives another list of the same length as output:</p>
<pre><code>import math
import random
import time
def survivalNormalcdf(x):
return (1-math.erf(x/math.sqrt(2)))/2
def normalcdf(x):
return ... | <python><pandas><dataframe><group-by><apply> | 2024-08-09 17:18:29 | 1 | 449 | Apook |
78,853,806 | 3,103,957 | Python __set__() descriptor behaviour | <p>I have the following Python code snippet.</p>
<pre><code>class LoggedAgeAccess:
def __get__(self, obj, objtype=None):
value = obj._age
return value
def __set__(self, obj, value):
obj._age = value
class Person:
age = LoggedAgeAccess() # Descriptor instance
def ... | <python><descriptor> | 2024-08-09 16:31:44 | 1 | 878 | user3103957 |
78,853,700 | 719,276 | Package and use source files with PyInstaller? | <p>My app auto-updates by:</p>
<ol>
<li>regularly checking for new versions of my app on PyPi,</li>
<li>downloading and extracting the latest one,</li>
<li>replacing the source files, and restarting.</li>
</ol>
<p>My project has the following structure:</p>
<pre><code>app.py
project/
utils.py
core.py
</code></p... | <python><package><pyinstaller> | 2024-08-09 16:01:36 | 1 | 11,833 | arthur.sw |
78,853,597 | 7,290,845 | DLT UDFs with modular code - INVALID_ARGUMENT No module named 'mymodule' | <p>I am migrating a massive codebase to Pyspark on Azure Databricks,using DLT Pipelines. It is very important that code will be modular, that is I am looking to make use of UDFs for the timebeing that use modules and classes.</p>
<p>I am receiving the following error:</p>
<pre><code>org.apache.spark.SparkRuntimeExcepti... | <python><azure><pyspark><databricks><azure-databricks> | 2024-08-09 15:32:36 | 1 | 1,689 | Zeruno |
78,853,535 | 3,265,791 | Pandas 3.0 Copy-on-Write changes, how to best assign loc and iloc selection | <p>I am preparing code for pandas3.0 and I noticed that the original syntax <code>df['b'].iloc[0]</code> causes a lot of future warnings.
Is there an alternative, more elegant way to express this instead of using <code>df.loc[df.index[0], 'b'] = 9</code>. It seems much less elegant.</p>
<pre><code>import pandas as pd
... | <python><pandas> | 2024-08-09 15:13:59 | 1 | 639 | MMCM_ |
78,853,441 | 1,914,034 | Get images back from patches | <p>I use a function to creates patches of shape <code>(i,j,c,h,w)</code> from an image <code>(c,h,w)</code> with overlap like so:</p>
<pre><code>def create_patches(image, patch_size=224, overlap=0):
_, height, width = image.shape
step = patch_size - overlap
padding_width = (step - (width - overlap) % step) ... | <python><pytorch> | 2024-08-09 14:53:34 | 0 | 7,655 | Below the Radar |
78,853,388 | 87,973 | How to re-cache global variable? | <p>I'm trying to change a global state (an <a href="https://code.larus.se/lmas/opensimplex" rel="nofollow noreferrer">opensimplex</a> random seed), which I use in a function called from an <code>@njit</code>ed function. But once compiled, Numba fixes the global value and I'm not able to change it. Like so:</p>
<pre cla... | <python><numba> | 2024-08-09 14:42:10 | 1 | 26,357 | Jonas Byström |
78,853,345 | 18,142,235 | Problem in importing electrocardiogram dataset from scipy [Error: No module named 'scipy.datasets'] | <p>I tried to follow <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html" rel="nofollow noreferrer">this</a> example of scipy in peak analysis but when I imported the electrocardiogram dataset by <code>from scipy.datasets import electrocardiogram </code>, I got mentioned error.</p... | <python><scipy><anaconda> | 2024-08-09 14:35:59 | 1 | 359 | hamflow |
78,853,293 | 2,171,348 | how to restore to previous debugpy version in vscode | <p>I've started using vscode 1.91.1 and docker on windows10 and WSL2 ubuntu 22.04 for about one week.</p>
<p>Before vscode starts showing the "there's an available update", and the workspace was single-root, I can open python project in vscode's devcontainer without problem.</p>
<p>After I added one more fold... | <python><visual-studio-code><vscode-devcontainer> | 2024-08-09 14:23:12 | 1 | 481 | H.Sheng |
78,853,188 | 1,236,694 | Most efficient way to sum-up subset of list | <pre><code>a = [-1, 17, 3, 101, -46, 51]
</code></pre>
<p>I want the sum of elements from an arbitrary start index to an arbitrary end index.</p>
<p>I can do this :</p>
<pre><code>partial = sum(a[start:end+1])
</code></pre>
<p>But Python slice creates another list which consumes memory and might be time-inefficient.</p... | <python> | 2024-08-09 14:00:48 | 1 | 9,151 | BaltoStar |
78,853,009 | 1,862,861 | How to manually set all learnable parameters in PyTorch model to a fixed value | <p>For some testing purposes, I would like to manually set all the learnable parameters of a PyTorch <a href="https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module" rel="nofollow noreferrer"><code>torch.nn.Module</code></a> model to a fixed value (I'm comparing two models that should be the sam... | <python><pytorch> | 2024-08-09 13:21:15 | 1 | 7,300 | Matt Pitkin |
78,852,650 | 12,719,086 | Efficiently processing large molecular datasets with Dask Disctributed, DataFrames and Prefect, | <p>I'm working with a large dataset of molecular structures (approximately 240,000 records) stored in a PostgreSQL database. I need to perform computations on each molecule using RDKit. I'm using Dask for distributed computing and Prefect for workflow management. My main goal is to efficiently distribute this dataset t... | <python><dask><dask-distributed><dask-dataframe><prefect> | 2024-08-09 12:02:10 | 0 | 471 | Polymood |
78,852,506 | 4,473,615 | Nested list in Python - Transpose nested list | <p>I have a below nested list:</p>
<pre><code>list = [Language:'Tamil'
Capital: 'Chennai'
Place: 'Chennai', 'Vellore', 'Trichy', 'Madurai'
]
</code></pre>
<p>I'm expecting to transpose it as:</p>
<pre><code>Language Capital Place
Tamil Chennai Chennai
Tamil Chennai Vellor... | <python><list> | 2024-08-09 11:25:00 | 3 | 5,241 | Jim Macaulay |
78,852,292 | 2,697,895 | How to implement the Preferences menu in Toga application? | <p>I tried like this, but when I access the menu, the Preferences item is not enabled :</p>
<pre><code>class Application(toga.App):
def startup(self):
# ... build UI here
self.main_window = toga.MainWindow(title=self.formal_name)
self.main_window.content = MainBox
self.main_window.show()
def ... | <python><beeware><toga> | 2024-08-09 10:33:38 | 1 | 3,182 | Marus Gradinaru |
78,852,017 | 9,879,534 | pre-commit using mypy specify venv cross-platform | <p>I'm using <a href="https://pdm-project.org/latest/" rel="nofollow noreferrer"><code>pdm</code></a>, and each project has its own <code>.venv</code>. When using <code>mypy</code>, I need to specify venv like <code>mypy --python-executable ./.venv/Scripts/python.exe .</code> on windows or <code>mypy --python-executabl... | <python><mypy><pre-commit><pre-commit.com> | 2024-08-09 09:21:21 | 1 | 365 | Chuang Men |
78,851,937 | 3,244,618 | Bacnet Bac0 issue while reading device from outside network | <p>I am using library ( and bacnet ) first time, so maybe I am doing it totally wrong but I have situation that in some local network under IP: 192.168.1.215 there is some Eclypse ECY-Tu203-96B019, and I have access to router under address 10.x.y.z, I have setup port forwarding there to be able to access 192.168.1.215.... | <python><bacnet><bac0> | 2024-08-09 09:00:29 | 0 | 2,779 | FrancMo |
78,851,764 | 1,335,606 | Conversion issues in sql - GREATEST(CEILING()) | <p>Below one working fine with the float values.</p>
<pre><code>import mysql.connector
conn = mysql.connector.connect()
cur = conn.cursor()
cur.execute('SELECT GREATEST(CEILING(Tot_Weight + 3.4),4.5) FROM TestTable order by id asc;')
print(cur.fetchall())
</code></pre>
<p>If I pass parameters to the query then facing ... | <python><sql><mysql> | 2024-08-09 08:07:17 | 2 | 503 | user1335606 |
78,851,759 | 8,077,619 | Create QML grouped properties in PyQt6 | <p>I am trying to replicate <a href="https://doc.qt.io/qtforpython-6/examples/example_qml_tutorials_extending-qml-advanced_advanced4-Grouped-properties.html" rel="nofollow noreferrer">this</a> PySide6 example to PyQt6. The example creates a grouped property ShoeDescription in Python and exposes it to Qml. Here are the ... | <python><qml><pyqt6> | 2024-08-09 08:06:14 | 1 | 303 | Anonimista |
78,851,633 | 881,712 | Equalize values of a list of list | <p><em>It's not easy for me to search for similar questions, I guess because the term "equalize" is not correct.</em></p>
<hr />
<p><strong>Scenario</strong></p>
<p>I have a couple of list of lists, not actually a matrix since each list can be of different length.<br />
Let's see an example.<br />
The first l... | <python><algorithm><optimization> | 2024-08-09 07:26:12 | 1 | 5,355 | Mark |
78,851,583 | 3,555,115 | Time difference in Seconds between two Timestamp columns in Pandas | <p>I need to compute and add the timestamp difference between two columns in seconds in the given dataframe</p>
<pre><code>df =
A B
Wed Jul 31 07:09:48 EDT 2024 Wed Jul 31 07:04:35 EDT 2024
Wed Jul 31 07:26:31 EDT 2024 Wed Jul 31 07:21:04 EDT 2024
Need to add... | <python><pandas><dataframe> | 2024-08-09 07:13:12 | 2 | 750 | user3555115 |
78,851,490 | 10,200,497 | Is it possible to not get NaN for the first value of pct_change()? | <p>My DataFrame is:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
{
'a': [20, 30, 2, 5, 10]
}
)
</code></pre>
<p>Expected output is <code>pct_change()</code> of <code>a</code>:</p>
<pre><code> a pct_change
0 20 -50.000000
1 30 50.000000
2 2 -93.333333
3 5 150.000000
4 10 100.00... | <python><pandas><dataframe> | 2024-08-09 06:47:50 | 2 | 2,679 | AmirX |
78,851,387 | 1,361,752 | Does dask bag preserve order when using sequential dask.bag.map operations | <p>It is stated that dask bags do not preserve order. However, the example given for <code>dast.bag.map</code> does something that implies that order is preserved, or at least predictable, in <a href="https://docs.dask.org/en/stable/generated/dask.bag.map.html" rel="nofollow noreferrer">https://docs.dask.org/en/stable/... | <python><dask> | 2024-08-09 06:10:18 | 1 | 4,167 | Caleb |
78,851,367 | 11,748,924 | How to Display Fixed Y-axis Range and Hide Non-Integer Values on the Y-axis in a Matplotlib Plot? | <p>Given plot like this:
<a href="https://i.sstatic.net/652NiVDB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/652NiVDB.png" alt="enter image description here" /></a></p>
<p>Here is the code:</p>
<pre><code>#@title Visualizer Function
def plot_delineation_comparison(Xt, yt, Xp, yp, start, stop=None, r... | <python><matplotlib> | 2024-08-09 06:00:50 | 0 | 1,252 | Muhammad Ikhwan Perwira |
78,851,129 | 7,722,867 | How to use Async Redis Client + Django in python? | <p>I'm trying to create a distributed semaphore using Redis to use in my Django application. This is to limit concurrent requests to an API. I'm using asyncio in redis-py. However, I want to create a connection pool to share across requests since I was getting a "Max clients reached" error. Thus, I created a ... | <python><django><redis><python-asyncio> | 2024-08-09 03:56:33 | 1 | 488 | user7722867 |
78,851,069 | 1,896,028 | Python's America/New_York time offset showing -04:56 | <p>I'm currently using Python 3.9.6 and have this simple code</p>
<pre><code>import datetime
import pytz
est = pytz.timezone('America/New_York')
myDateTime = datetime.datetime(year=2024, month=8, day=15, hour=17, minute=00, tzinfo=est)
print("America/New_York: ", myDateTime.isoformat())
print("UTC: ... | <python><datetime><timezone><pytz> | 2024-08-09 03:28:54 | 1 | 786 | Steven |
78,850,880 | 16,613,735 | Python cx_oracle concurrent fetch | <p>When using Python cx_Oracle - we set a parameter cursor.arraysize = 10000. I am assuming that this means the Python client running on the server receives data "sequentially" in batches of 10K from the Oracle database. Let's say that we are pulling 500Million records and the database can handle the load and... | <python><oracle-database><cx-oracle><python-oracledb> | 2024-08-09 01:22:28 | 1 | 335 | Dinakar Ullas |
78,850,788 | 13,984,609 | Getting "sqllite3.OperationError: Unable to open database file" sometimes, but other times it works fine (cx_Freeze'd file) | <p>I made an app which uses sqllite3 database. When I run the .py file it works just fine.</p>
<p>Here is the code for the database:</p>
<pre><code>import sqlite3
connection = sqlite3.connect("game.db")
connection.execute("PRAGMA foreign_keys = 1;")
cursor = connection.cursor()
def run(sql):
... | <python><sqlite><cx-freeze> | 2024-08-09 00:08:47 | 2 | 504 | CozyCode |
78,850,502 | 1,658,617 | Does shelve write to disk on every change? | <p>I wish to use shelve in an asyncio program and I fear that every change will cause the main event loop to stall.</p>
<p>While I don't mind the occasional slowdown of the pickling operation, the disk writes may be substantial.</p>
<p>Every how often does shelve sync to disk? Is it a blocking operation? Do I have to c... | <python><python-asyncio><shelve> | 2024-08-08 21:27:58 | 2 | 27,490 | Bharel |
78,850,462 | 325,809 | N-D rotation of numpy vector | <p>I thought this would be easy, but I can't figure it out and google is not helping. I have found straightforward ways to rotate 2D and 3D tensors, but I can't find a way to rotate N-dimensional vectors. In particular I have an N-dimensional vector (numpy array) and I would like to rotate it by <code>theta</code> radi... | <python><numpy><scipy> | 2024-08-08 21:09:19 | 0 | 6,926 | fakedrake |
78,850,381 | 1,361,752 | How to export dask HTML high level graph to disk | <p>There is a way to generate a HTML high level graph in a jupyter notebook as shown in dasks' documentation: <a href="https://docs.dask.org/en/stable/graphviz.html#high-level-graph-html-representation" rel="nofollow noreferrer">https://docs.dask.org/en/stable/graphviz.html#high-level-graph-html-representation</a></p>
... | <python><jupyter><dask> | 2024-08-08 20:41:58 | 1 | 4,167 | Caleb |
78,850,314 | 8,510,149 | Collect list inside window function with condition, pyspark | <p>I want to collect a list of all the values of id2 for each id1 that has the same or lower level within a group.</p>
<p>To achieve this I use a window function and collect_list function. However, I dont get the conditional part here. How can that be solved?</p>
<pre><code>
df = spark.createDataFrame([
("A&qu... | <python><pyspark> | 2024-08-08 20:23:53 | 1 | 1,255 | Henri |
78,849,988 | 4,470,365 | How do I attach the contents of a failed Airflow task log to the failure notification email message? | <p>I have an Airflow DAG that runs a BashOperator task. When it fails I get an email with not much detail:</p>
<pre><code>Try 1 out of 1
Exception:
Bash command failed. The command returned a non-zero exit code 1.
Log: Link
Host: 2db56ea2ab34
Mark success: Link
</code></pre>
<p>I'm interested in the details that tell ... | <python><airflow> | 2024-08-08 18:48:05 | 1 | 23,346 | Sam Firke |
78,849,671 | 8,741,781 | How should a custom django server error view be tested? | <p>In the Django documentation they provide the following example for <a href="https://docs.djangoproject.com/en/dev/topics/http/views/#testing-custom-error-views" rel="nofollow noreferrer">testing custom error views</a>.</p>
<p>Given the following example how would you go about testing a custom <code>server_error</cod... | <python><django> | 2024-08-08 17:16:00 | 1 | 6,137 | bdoubleu |
78,849,429 | 850,781 | Convert the same local time to UTC on different dates, respecting the local DST status | <p>I have several local time points:</p>
<pre><code>import datetime
from zoneinfo import ZoneInfo as zi
wmr = datetime.time(hour=12, tzinfo=zi("GMT"))
ecb = datetime.time(hour=14, minute=15, tzinfo=zi("CET"))
jpx = datetime.time(hour=14, tzinfo=zi("Japan"))
</code></pre>
<p>which I want t... | <python><datetime><timezone><localtime><zoneinfo> | 2024-08-08 16:11:15 | 2 | 60,468 | sds |
78,849,388 | 1,914,781 | rangemode tozero not work for datetime format | <p>I would like plotly plot xaxis start from 00:00:00. I try to use <code>rangemode</code> 'tozero` as below but it not work.</p>
<p>What's proper way to let the xaxis start from 00:00:00?</p>
<pre><code>import plotly.express as px
import pandas as pd
import pandas as pd
import io
import numpy as np
import datetime
de... | <python><plotly> | 2024-08-08 16:01:24 | 1 | 9,011 | lucky1928 |
78,849,387 | 1,028,270 | How can I add a blank line between list items with Ruamel? | <p>I am appending items to a list:</p>
<pre><code>from ruamel.yaml import YAML
yaml = YAML()
yaml.preserve_quotes = True
yaml.allow_duplicate_keys = True
formatted_yaml = yaml.load(Path(my_file).open().read())
for item in my_items:
# Just want a blank line here
formatted_yaml.append(None)
# Before adding... | <python><ruamel.yaml> | 2024-08-08 16:01:14 | 2 | 32,280 | red888 |
78,849,304 | 5,527,646 | Creating nested lists from a single list | <p>Suppose I have a list like this:</p>
<pre><code>my_list = ['a_norm', 'a_std', 'a_min', 'a_max', 'a_flag', 'b_norm', 'b_std', 'b_min', 'b_max', 'b_flag', 'c_norm', 'c_std', 'c_min', 'c_max', 'c_flag']
</code></pre>
<p>I want to parse this list and create nested lists within separate lists like this. It is very import... | <python><indexing><nested-lists> | 2024-08-08 15:43:47 | 3 | 1,933 | gwydion93 |
78,849,242 | 5,106,253 | How can I make mypy correctly use my type hinting files? | <p>I am using a package that does not provide its own type hints so I have built some but cannot see how to get <code>mypy</code> to use them - anyone able to help? Here's my system:</p>
<ul>
<li>Windows</li>
<li>Using poetry</li>
<li>Created type hint files <code>*.pyi</code> for external package <code>bob</code></li... | <python><python-typing><mypy> | 2024-08-08 15:28:46 | 0 | 749 | Paul D Smith |
78,849,150 | 9,363,181 | Unable to eliminate backslashes from the JSON output via Pyspark | <p>Below is my <code>output</code> dataset:</p>
<pre><code>{"_id":"","steps":[{"cacheHit":false,"completedAt":"2024-08-01T11:24:43.702Z","data":"{\"selfiePhotoUrl\":\"\"}","id":"selfie","inner&qu... | <python><json><apache-spark><pyspark><apache-spark-sql> | 2024-08-08 15:05:08 | 0 | 645 | RushHour |
78,849,149 | 1,264,304 | How to get the number of background tasks currently running in a FastAPI application? | <p>The below <code>run_tasks</code> FastAPI route handler spawns a background task on each HTTP call to the <code>/run-tasks</code> endpoint.</p>
<pre class="lang-py prettyprint-override"><code>import asyncio
import time
from fastapi import APIRouter
from starlette.background import BackgroundTasks
router = APIRoute... | <python><python-asyncio><fastapi><starlette><graceful-shutdown> | 2024-08-08 15:04:56 | 2 | 11,003 | rokpoto.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.