QuestionId int64 74.8M 79.8M | UserId int64 56 29.4M | QuestionTitle stringlengths 15 150 | QuestionBody stringlengths 40 40.3k | Tags stringlengths 8 101 | CreationDate stringdate 2022-12-10 09:42:47 2025-11-01 19:08:18 | AnswerCount int64 0 44 | UserExpertiseLevel int64 301 888k | UserDisplayName stringlengths 3 30 ⌀ |
|---|---|---|---|---|---|---|---|---|
77,381,226 | 9,137,547 | Python multiprocessing on ipykernel | <p>I want to make some parallel CPU-bound computations in Python, I was writing my code on a notebook running on my machine with ipykernel.</p>
<p>I reduced my problem to the following simple replicable code:</p>
<pre><code>from multiprocessing import Pool
from pprint import pprint
def square(num):
return num ** 2... | <python><jupyter-notebook><multiprocessing> | 2023-10-28 21:04:31 | 1 | 659 | Umberto Fontanazza |
77,381,192 | 2,854,555 | In VS Code, how can I change the problem level of a certain error/violation from the Flake8 extension? | <p>I'm using VS Code with Flake8 configured to check some obvious issues for my Python code. However, some of its errors are not really errors in my current development phase, e.g. <code>E501</code> (line too long) and <code>F401</code> (unused import).</p>
<p>The annoying thing is that the relevant lines are marked in... | <python><visual-studio-code><flake8> | 2023-10-28 20:52:16 | 2 | 691 | renyuneyun |
77,381,158 | 1,084,174 | ValueError: Shapes (None,) and (None, 100, 6) are incompatible | <p>I am trying to solve a classification problem using LSTM Sequential machine learning. My DataFrame structure is here:</p>
<blockquote>
<p>feature1, feature2, feature3, category</p>
</blockquote>
<p><a href="https://i.sstatic.net/FGcHT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/FGcHT.png" alt="ent... | <python><pandas><machine-learning><keras><lstm> | 2023-10-28 20:41:04 | 0 | 40,671 | Sazzad Hissain Khan |
77,380,915 | 5,947,365 | You cannot call this from an async context - use a thread or sync_to_async. Django ORM | <p>I wrote the following code:</p>
<pre><code>class BookmakerA:
def __init__(self) -> None:
self.bookmaker = None
async def _init(self):
self.bookmaker, _ = await Bookmaker.objects.aget_or_create(name="BookmakerA", defaults={"name": "BookmakerA"})
</cod... | <python><django><asynchronous><python-asyncio> | 2023-10-28 19:26:38 | 0 | 607 | Sander Bakker |
77,380,817 | 3,188,278 | Declare Instance variables in django-formtools SessionWizardView | <p>Using SessionWizardView, I want to declare Instance variables, that persist between steps. However, they are not persistent, when using:</p>
<p><code>def __init__(self): self.variable = {}</code></p>
| <python><django><django-formtools> | 2023-10-28 18:55:00 | 1 | 499 | T_Torture |
77,380,448 | 5,246,226 | Python class missing attribute that was initialized? | <p>I am trying to create a class that enables counting based off of the <code>multiprocessing</code> Queue:</p>
<pre><code>import multiprocessing
from multiprocessing import Value
from multiprocessing.queues import Queue
class SharedCounter(object):
""" A synchronized shared counter.
The lockin... | <python><multiprocessing> | 2023-10-28 17:13:14 | 1 | 759 | Victor M |
77,380,240 | 9,511,223 | How to access message field inside iframe on protonmail.com? | <p>I am trying to send an email with Python Selenium on Protonmail server. Everything works fine until until I get to the email message.</p>
<p>To get to the email message field I use the following xpath: <code>"//div[@id='rooster-editor']/div[1]"</code>. It gives a unique element when searching manually thro... | <python><selenium-webdriver><nosuchelementexception> | 2023-10-28 16:11:51 | 1 | 315 | achille |
77,380,239 | 3,760,986 | How is a multiprocessing.Event passed to a child process under the hood? | <p>According to <a href="https://stackoverflow.com/questions/56912846/why-is-pickle-and-multiprocessing-picklability-so-different-in-python/56916787#56916787">this SO answer</a>, when a <code>multiprocessing.Queue</code> is passed to a child process, what is actually sent is a file descriptor (or handle) obtained from ... | <python><events><multiprocessing><pickle> | 2023-10-28 16:11:48 | 1 | 964 | Joerg |
77,380,210 | 12,343,115 | rapids cannot import cudf: Error at driver init: Call to cuInit results in CUDA_ERROR_NO_DEVICE (100) | <p>To install RAPIDS, i have already installed WSL2.</p>
<p>But i still got the following error when import cudf:</p>
<pre><code>/home/zy-wsl/miniconda3/envs/rapids-23.12/lib/python3.10/site-packages/cudf/utils/_ptxcompiler.py:61: UserWarning: Error getting driver and runtime versions:
stdout:
stderr:
Traceback (m... | <python><machine-learning><cuda><rapids> | 2023-10-28 16:02:14 | 2 | 811 | ZKK |
77,380,206 | 1,778,043 | monitor grandchild processes spawned by Python's Popen subprocess | <p>I can successfully process the STDOUT of a process I spawn with:</p>
<pre class="lang-python prettyprint-override"><code>print("launching child")
child=subprocess.Popen(params,stdout=subprocess.PIPE)
for line in child.stdout:
#do processing
print("processed:"+line.decode())
print("ch... | <python><windows><subprocess> | 2023-10-28 16:00:35 | 0 | 1,336 | Eph |
77,380,134 | 10,118,502 | Image Bicubic Interpolation does not match OpenCV and Scikit-image implementations | <p>I am trying to implement bicubic convolution interpolation for images from the paper "Cubic Convolution Interpolation for Digital Image Processing" in Python. However, my implementation which looks like a proper scale still differs from reference implementations and I do not understand why. This is especia... | <python><image-processing><interpolation><bicubic> | 2023-10-28 15:39:42 | 1 | 324 | tzv |
77,380,110 | 5,246,226 | Errors in Python daemon process aren't propagated to Terminal? | <p>I have a daemon process in Python that I create using the following code:</p>
<pre><code>process = mp.Process(name="test", target=run, args=(chunk_queue, res_queues))
process.daemon = True
process.start()
</code></pre>
<p>I can confirm that this daemon can print to Terminal. However, it seems like unless I... | <python><python-multiprocessing> | 2023-10-28 15:33:42 | 1 | 759 | Victor M |
77,380,003 | 593,487 | How to rotate numpy 3D array around its center given a rotation matrix? | <p>I have a <strong>3D</strong> numpy array with <code>shape=(50, 50, 50)</code> which I would like to rotate around center, <strong>using a rotation matrix R</strong>.</p>
<p>I am trying to do this by using <code>scipy.ndimage.affine_transform</code>, but I'm open to better suggestions.</p>
<p>This is the code that sh... | <python><numpy><scipy.ndimage> | 2023-10-28 14:53:43 | 2 | 18,451 | johndodo |
77,379,908 | 395,882 | Backtrader Strategy with multiple time frames | <p>I am using a strategy which is using 2 time frames (Daily and Weekly) and supposed to generate a buy/sell order on daily time frame whenever condition using daily time frame and weekly time frames are met. I saw that my code executes next() in strategy twice and execute order twice one for daily and one for weekly t... | <python><algorithmic-trading><backtrader> | 2023-10-28 14:32:27 | 1 | 665 | user395882 |
77,379,874 | 1,658,617 | Closing resources with dependency injection | <p>I have the following pseudocode:</p>
<pre><code>class Resource:
"""E.g. Session, connection, file, etc."""
async def open(self):
pass
async def close(self):
pass
class ResourceUser:
def __init__(self, resource: Resource):
self.resource = resource... | <python><resources><resource-management> | 2023-10-28 14:23:28 | 1 | 27,490 | Bharel |
77,379,782 | 17,267,064 | Solve Forbidden 403 error during response testing | <p>I am trying to get response of website <a href="https://clutch.co/sitemap.xml" rel="nofollow noreferrer">https://clutch.co/sitemap.xml</a></p>
<p>I tested in Python as well in Postman, it shows a forbidden 403 status code. I copied all of its headers still it doesn't get successful response.</p>
<p>Below is a piece ... | <python><web-scraping><python-requests><scrapy><postman> | 2023-10-28 13:58:31 | 1 | 346 | Mohit Aswani |
77,379,774 | 5,859,885 | Keras model_from_json() returning a string? | <p>I am trying to use the Keras <code>model_from_json()</code> function to load the structure of my model. I thought the return of this function was an instance of a Keras model, but it is returning a string for me?</p>
<p>My .json config file looks like this:</p>
<pre><code>{"class_name": "MyModel"... | <python><json><tensorflow><keras> | 2023-10-28 13:55:33 | 1 | 1,461 | the man |
77,379,703 | 8,229,029 | Python Spyder start up error No Qt application plug could be initialized | <p>I just installed anaconda, along with a bunch of extra packages outside the ones that come with the installation. Now, Spyder won't start, and I get the error "The application failed to start because no Qt platform plugin could be intitialized. Reinstalling the application may fix this problem."</p>
<p>W... | <python><pyqt5><spyder> | 2023-10-28 13:38:04 | 0 | 1,214 | user8229029 |
77,379,637 | 1,445,660 | How to update db from json patch | <p>I get a complex json every few hours. Part of it is a <code>Game</code> object with a list of <code>Player</code> objects that each <code>Player</code> has a list of <code>Training</code> object (each object has also other fields - ints, strings, list of strings etc.).
If the <code>Game</code> object doesn't exist i... | <python><json><postgresql><json-patch> | 2023-10-28 13:21:01 | 1 | 1,396 | Rony Tesler |
77,379,346 | 4,094,231 | How to scrape Japanese content using Python? | <p>I have a code in Python requests and also tried in Python Scrapy.</p>
<p>It returns correct HTML but the content inside HTML tags is strange characters like <code>Á¶¼±°úÇбâ¼úÃÑ·Ã¸Í Áß¾ÓÀ§¿øÈ¸ Á¶¼±ÀÚµ¿ÈÇÐȸ¿Í Á¶¼±ÀÚ¿¬¿¡³</code> etc.</p>
<pre><code>headers = {
'Accept': 'text/html,application/xhtml+xml,applicati... | <python><python-requests><scrapy> | 2023-10-28 12:04:06 | 1 | 21,655 | Umair Ayub |
77,379,334 | 15,129,164 | form.validate_on_submit() never runs for my form | <p><a href="https://i.sstatic.net/rTXrt.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/rTXrt.png" alt="[](https://i.sstatic.net/eDyv7.png)" /></a></p>
<p>Python code</p>
<p><a href="https://i.sstatic.net/BPP53.png" rel="nofollow noreferrer"... | <python><html><flask><bootstrap-5><flask-wtforms> | 2023-10-28 11:58:58 | 0 | 325 | Hridaya Agrawal |
77,379,301 | 8,365,731 | Pandas SettingWithCopyWarning: How does panda konw DataFrame was created as a slice from another DataFrame | <p>How does python pandas know a DataFrame is a slice from another DataFrame? example 1 gives SettingWithCopyWarning:</p>
<pre><code>a=pd.DataFrame([list(range(4)) for i in range(7)])
b=a[[1,2]]
b.loc[0,1]=7
</code></pre>
<p>:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame</... | <python><pandas> | 2023-10-28 11:50:28 | 1 | 563 | Jacek Błocki |
77,379,143 | 8,030,794 | Update values in table many times in minute | <p>I need to call Update many times in minute. Is it the correct way to do this? I think not, cuz sometimes i get Exception - <code>cursor already closed</code>. I call this func from many threads, may be need to lock this part?</p>
<pre><code>conn = psycopg2.connect(dbname='MyDB', user='...', password='...', host='127... | <python><psycopg2> | 2023-10-28 11:05:21 | 2 | 465 | Fresto |
77,379,133 | 3,611,164 | Aggregate string column close in time in pandas | <p>I'm trying to group messages, which have been sent shortly after another. A parameter defines the maximum duration between messages for them to be considered part of a block. If a message is added to the block, the time window is extended for more messages to be considered part of the block.</p>
<p><strong>Example I... | <python><pandas><string><time-series> | 2023-10-28 11:01:34 | 1 | 366 | Fabitosh |
77,379,119 | 2,284,240 | calling elastic search query from frontend with multiple query params | <h1>API Usage:</h1>
<p>I am using a public API to display artworks on frontend. The public API url: <a href="https://api.artic.edu/api/v1/artworks/search" rel="nofollow noreferrer">https://api.artic.edu/api/v1/artworks/search</a></p>
<h1>Scenarios that works individually</h1>
<p>To filter artworks that has <code>place_... | <javascript><python><elasticsearch> | 2023-10-28 10:57:02 | 1 | 6,428 | Vishal |
77,379,065 | 11,331,463 | Plot with matplotlib in WSL2 | <p>I have tried several post recommendations and follow several guides to use matplotlib in wsl2 in my windows machine. None of the tutorials worked. For instance, I have installed x11 apps follwing this tutorial: <a href="https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps" rel="nofollow noreferrer">http... | <python><matplotlib><windows-subsystem-for-linux> | 2023-10-28 10:43:11 | 1 | 312 | GGChe |
77,379,047 | 7,195,666 | Is there a way to create a TypedDict from django ninja Schema or vice versa? | <p>For this piece of code</p>
<pre><code>from typing import TypedDict
from ninja import Schema
class MyDict(TypedDict):
a: str
class MySchema(Schema):
a: str
</code></pre>
<p>is there a way no to repeat the keys (<code>a</code> in the example)?</p>
<p>I tried</p>
<pre><code>class MyDict(TypedDict):
a: str
clas... | <python><metaprogramming><typing><django-ninja> | 2023-10-28 10:37:23 | 0 | 2,271 | Vulwsztyn |
77,379,001 | 17,214,759 | Efficient computation of the set of surjective functions | <p>A function <code>f : X -> Y</code> is surjective when every element of <code>Y</code> has at least one preimage in <code>X</code>. When <code>X = {0,...,m-1}</code> and <code>Y = {0,...,n-1}</code> are two finite sets, then <code>f</code> corresponds to an <code>m</code>-tuple of numbers <code>< n</code>, and ... | <python><algorithm><performance><tuples><combinatorics> | 2023-10-28 10:23:40 | 2 | 432 | Script Raccoon |
77,378,731 | 2,661,703 | Switch to another subdomain in django on a click of a button | <p>I am actually having issues with template link of a button to point to my subdomain which actually if I enter it manually on a browser, it works just fine. I need something like this</p>
<pre><code>{% load hosts %}
<a href="{% host_url 'homepage' host 'www' %}">Home</a>
</code></pre>
<p>But it ... | <python><django><django-templates><django-hosts> | 2023-10-28 08:57:03 | 0 | 3,770 | Transformer |
77,378,634 | 2,100,606 | Ticker.info throws error in jupyter but not Google Colab | <p>The following code used worked fine in jupyter but stopped working last week,</p>
<pre><code>import yfinance as yf
ltam = 'AAPL'
ticker = yf.Ticker(ltam)
ticker.info
</code></pre>
<p>The error thrown is,</p>
<pre><code>HTTPError: 404 Client Error: Not Found for url: https://query2.finance.yahoo.com/v6/finance/quoteS... | <python><yfinance> | 2023-10-28 08:19:14 | 0 | 325 | insomniac |
77,378,515 | 1,285,061 | How can I append to an array in NumPy without flattening the arrays? | <p>How can I append two arrays in NumPy without flattening?</p>
<p>I tried changing axis.</p>
<pre class="lang-none prettyprint-override"><code>>>> h = np.array([])
>>> g = np.array([2,4])
>>> i = np.array([6,9])
>>> np.append(h,g)
array([2., 4.])
>>> h = np.append(h,g)
>... | <python><numpy> | 2023-10-28 07:46:18 | 1 | 3,201 | Majoris |
77,378,391 | 3,899,975 | how to add text to a box plot by matching and extracting the data from two dataframes | <p>I have two df (df1 and df2) as below:</p>
<pre><code>import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
np.random.seed(12)
# Generate first df
col_a1 = [i for i in range(18)] * 15
col_b1 = np.random.randint(1, 100, len(col_a))
configs = ['c1', 'c2', 'c3', 'c4']
col_c1... | <python><pandas><matplotlib><seaborn><plot-annotations> | 2023-10-28 07:05:54 | 1 | 1,021 | A.E |
77,378,068 | 511,436 | python3 regex: how to remove u[0-9]{4} from string? | <p>python 3.9</p>
<pre><code>s = "aaau0004bbbbu0001"
s.replace(r"u[0-9]{4}", "")
'aaau0004bbbbu0001'
</code></pre>
<p>How to get the result 'aaabbbb'?</p>
| <python><python-3.x><regex> | 2023-10-28 04:43:27 | 1 | 1,844 | Davy |
77,378,036 | 2,077,386 | jinja NativeEnvironment casts an int string to a literal int | <p>This surprised me:</p>
<pre><code>import jinja2.nativetypes
env = jinja2.nativetypes.NativeEnvironment()
result = env.from_string('{{ x }}')
value = result.render(x='2')
print(type(value))
</code></pre>
<p>Output:</p>
<pre><code><class 'int'>
</code></pre>
<p>Looking over the native parser code it seems like ... | <python><jinja2> | 2023-10-28 04:30:04 | 0 | 7,133 | rrauenza |
77,377,886 | 652,528 | Does mypy check Never type at all? | <p>I was playing with <code>Never</code> type in mypy. If I have a function <code>foo(x: int)</code> I expected that when called with a value of type <code>Never</code> mypy would complain, but it silently typechecks the call:</p>
<pre class="lang-py prettyprint-override"><code>from typing import Never
def foo(x: int... | <python><mypy><python-typing> | 2023-10-28 03:12:30 | 1 | 6,449 | geckos |
77,377,732 | 6,202,092 | Django redirect error unexpected keyword while returning to previous view | <p>I have searched and have not found any answers related to my specific problem.</p>
<p>When I submit a form from my <code>index</code> view to an <code>up_load</code> view and try to have the <code>up_load</code> view redirect back to the <code>index</code> view while including the <code>page</code> number as an argu... | <python><django><django-views> | 2023-10-28 01:43:16 | 1 | 503 | Enrique Bruzual |
77,377,731 | 3,129,604 | How to find the width of the red area using opencv or any other python library? | <p><a href="https://i.sstatic.net/hvgQP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/hvgQP.png" alt="enter image description here" /></a></p>
<p>The red image above is the health meter for enemy units in a game. I got a python application that takes a screenshot and it must be able to determine the pe... | <python><opencv><image-processing><computer-vision><game-automation> | 2023-10-28 01:42:35 | 1 | 2,753 | Matteus Barbosa |
77,377,687 | 316,737 | Consume C++ COM class from Python | <p>I have a COM dll which is created using ATL COM with C++. I am creating an Python application which can reuse the existing business logic written in COM C++.</p>
<p>I am looking for a way to consume the COM class object methods from the COM DLL from python. Please suggest ways to achieve this.</p>
| <python><c++><com><atl> | 2023-10-28 01:14:07 | 1 | 905 | srajeshnkl |
77,377,645 | 219,153 | Is there a pure NumPy way to create an array of ND indicies and values? | <p>This script creates an array <code>b</code> of indices and values of given array <code>a</code>, which is useful for example in conversion of 2.5D height map to a point cloud:</p>
<pre><code>import numpy as np
a = np.arange(12).reshape(3, 4)
b = np.array([[*i, val] for i, val in np.ndenumerate(a)])
print(b)
</code>... | <python><arrays><numpy><numpy-ndarray> | 2023-10-28 00:48:22 | 2 | 8,585 | Paul Jurczak |
77,377,614 | 3,417,592 | Openai python api and Firestore emulator not playing well together | <p>wondering if anyone else has seen this bizarre behavior.</p>
<p>The python script below is a simplified version of something that I'm deploying to Cloud Run. The emulator stuff is replaced by <code>client = firestore.Client()</code> in the deployed app, and that works fine. The problem only pertains to using the fir... | <python><firebase><google-cloud-platform><google-cloud-firestore><openai-api> | 2023-10-28 00:30:31 | 0 | 1,951 | Nathan Lloyd |
77,377,439 | 19,123,103 | How to change label font size in streamlit | <p>I want to change the fontsize of the label above an input widget in my streamlit app.</p>
<p>What I have so far:</p>
<pre class="lang-py prettyprint-override"><code>import streamlit as st
label = "Enter text here"
st.text_input(label)
</code></pre>
<p>This renders the following:
<a href="https://i.sstatic.... | <javascript><python><html><css><streamlit> | 2023-10-27 23:07:24 | 1 | 25,331 | cottontail |
77,377,438 | 6,379,197 | Why fit_round received failures in flwr framework? | <p>I am using flwr framework to send a random array from client to server and then server will merge the array and sends back to each of the clients.</p>
<pre><code>import numpy as np
import flwr as fl
from flwr.server.strategy import Strategy
from typing import List
class MergeArraysStrategy(fl.server.strategy.FedAv... | <python><pytorch><federated-learning> | 2023-10-27 23:07:11 | 1 | 2,230 | Sultan Ahmed |
77,377,413 | 14,735,451 | How to query arxiv daily based on keywords and write the results in a Google doc? | <p>I want to find papers that are published in the <a href="https://arxiv.org/list/cs/recent" rel="nofollow noreferrer">computer science section of arxiv</a> <strong>every day</strong> based on a list of keywords and write their <strong>titles</strong> and <strong>arxiv link</strong> to my Google doc (i.e., append to t... | <python><web-scraping><google-docs> | 2023-10-27 22:58:43 | 2 | 2,641 | Penguin |
77,377,348 | 13,383,986 | Is there a way to modify the frequency of upload_file Callback? | <p>I'm using boto3 (Python). Here's a sample call:</p>
<p><code>s3.upload_file(file_name, s3_bucket, s3_bucket_key, Callback=update_progress, Config=config)</code></p>
<p>The issue is that no matter what, the Callback is called 4 times per Mb. So, basically every 256k it's called. That's annoying for most progress t... | <python><amazon-web-services><amazon-s3><boto3> | 2023-10-27 22:35:21 | 0 | 676 | GoForth |
77,377,292 | 5,536,733 | AttributeError: 'GlueContext' object has no attribute 'create_sample_dynamic_frame' | <p>This <a href="https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-crawler-pyspark-extensions-glue-context.html#aws-glue-api-crawler-pyspark-extensions-glue-context-create-sample-dynamic-frame-from-catalog" rel="nofollow noreferrer">official doc</a> suggests there is a function to read sample data from Glue Catal... | <python><amazon-web-services><pyspark><aws-glue> | 2023-10-27 22:18:45 | 1 | 1,787 | Aakash Basu |
77,377,228 | 10,426,490 | How to debug python Azure Functions, that use .venv, inside Visual Studio Code? | <p>I created a new Azure Function locally, via the VS Code terminal, using <a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=windows%2Cisolated-process%2Cnode-v4%2Cpython-v2%2Chttp-trigger%2Ccontainer-apps&pivots=programming-language-python#install-the-azure-functions-core-to... | <python><azure><azure-functions><vscode-debugger> | 2023-10-27 21:56:38 | 1 | 2,046 | ericOnline |
77,377,189 | 2,541,276 | pyodbc.OperationalError: ('08001', '[08001] [Microsoft][ODBC Driver 18 for SQL Server]SSL Provider: [SSL routines::certificate verify failed') | <p>I've created sql server docker container using the below command.</p>
<pre class="lang-bash prettyprint-override"><code>sudo docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=Password123#" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2022-latest
</code></pre>
<p>The docker container with sql... | <python><sql-server><ssl><pyodbc> | 2023-10-27 21:45:35 | 0 | 10,555 | user51 |
77,377,165 | 19,299,757 | Download chrome driver 117 | <p>I need to download chrome version 117.0.5846.0 from <a href="https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json" rel="nofollow noreferrer">https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json</a></p>
<p>I know I can use "curl&qu... | <python><google-chrome><selenium-webdriver><curl><selenium-chromedriver> | 2023-10-27 21:37:23 | 3 | 433 | Ram |
77,377,032 | 5,960,363 | Computed fields in Pydantic V2 - can I add aliases for validation and serialization? | <h2>Context</h2>
<p>Within a Pydantic model, I want to set the values of two fields based on the values contained by a third. BUT I'd also like to set some nuanced aliases.</p>
<p>So if we have:</p>
<pre class="lang-py prettyprint-override"><code>class FooModel(BaseModel):
data_holder: list = Field(..., exclude=Tru... | <python><class><validation><inheritance><pydantic> | 2023-10-27 21:02:21 | 1 | 852 | FlightPlan |
77,376,961 | 2,058,333 | BioPython SeqIO fails with Invalid Alphabet found | <p>I am trying to store a GenBank file that could be read by Geneious later.
I found an example how to create the GenBank file <a href="https://stackoverflow.com/questions/65216225/writing-and-saving-genbank-files-with-biobython-seqio-module">here</a></p>
<p>But now I run into <code>Alphabet</code> issues.
I tried all ... | <python><bioinformatics><biopython><genbank> | 2023-10-27 20:46:23 | 1 | 5,698 | El Dude |
77,376,856 | 1,806,124 | How to properly run python-telegram-bot together with fastapi? | <p>I built a Python framework to easily build Telegram bots based on the python-telegram-bot module. Then I added fastapi to it so that framework plugins could easily provide web interfaces.</p>
<p>But in order to get both working I needed to use the nest_asyncio module, which I don't like. I'd like to do it "prop... | <python><bots><telegram><fastapi><python-telegram-bot> | 2023-10-27 20:19:57 | 0 | 661 | Endogen |
77,376,805 | 3,129,604 | How to use pytesseract to read text from this image with simple numbers? | <p><a href="https://i.sstatic.net/jiyYb.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jiyYb.jpg" alt="enter image description here" /></a></p>
<p><code>image_processed</code> variable is the attached image.</p>
<pre><code> custom_config = r'--oem 3 --psm 7 -c tessedit_char_whitelist= 0123456789/'
... | <python><ocr><python-tesseract> | 2023-10-27 20:07:03 | 1 | 2,753 | Matteus Barbosa |
77,376,745 | 51,167 | Create an airtable OAuth token in python | <p>I have code from Google that successfully uses the <code>google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file</code> API to open a browser and create a Google API Oauth2 token which is stored in a file and used in API calls:</p>
<pre><code>from google_auth_oauthlib.flow import InstalledAppFlow
def get... | <python><oauth-2.0><oauth><airtable> | 2023-10-27 19:53:43 | 2 | 30,023 | vy32 |
77,376,715 | 11,716,727 | Why do I have a problem when I visualising the testing set results? | <p>As a beginner, I am working on the Titanic Survival dataset <a href="https://github.com/datasciencedojo/datasets/blob/master/titanic.csv" rel="nofollow noreferrer">The data is here</a> and applying LOGISTIC REGRESSION to them. After cleaning my data as shown below:</p>
<p><a href="https://i.sstatic.net/ysF7a.png" re... | <python><matplotlib><plot><seaborn><logistic-regression> | 2023-10-27 19:46:08 | 0 | 709 | SH_IQ |
77,376,677 | 10,466,809 | why does `datetime` module behave this way with timezones? | <p>I am trying to work with time and timezones. I am in the <code>US/Mountain</code> time zone and my computer (Windows) is configured to that time zone.</p>
<pre><code>import datetime
import zoneinfo
utc = zoneinfo.ZoneInfo('UTC')
mt = zoneinfo.ZoneInfo('US/Mountain')
print(datetime.datetime.now())
print(datetime.da... | <python><datetime><timezone> | 2023-10-27 19:35:01 | 2 | 1,125 | Jagerber48 |
77,376,634 | 7,195,376 | Python `ShareableList` is removed when "reading" process closes | <p>I have a "main" process (write-only) in Python that generates a list of IDs which I would like to share with other <em>independently created</em> Python processes (read-only) on the same machine. I want the list to persist regardless if any of the "read" processes exit. I have been exploring <cod... | <python><multiprocessing><shared-memory> | 2023-10-27 19:25:30 | 1 | 544 | Mason McGough |
77,376,586 | 3,842,845 | How to extract certain blocks of data from a csv file using values in the first column | <p>I am trying to extract only data in the two sections ("Admissions" and "Readmissions") starting from 3rd line & 2nd column from a <strong>key word</strong> in the 1st column.</p>
<p>Please see bottom for sample of dataset in a csv file.</p>
<pre><code>Admissions
Not Started:12 Sent:3 ... | <python><pandas><regex> | 2023-10-27 19:16:27 | 1 | 1,324 | Java |
77,376,483 | 3,462,509 | Deep Learning: Choice of architecture in the IMDB Classification toy example. Embeddings underperform simple baseline | <p>I am comparing the performance of two different network architectures to solve the binary classification problem of <a href="https://keras.io/api/datasets/imdb/" rel="nofollow noreferrer">IMBD movie reviews</a>, presented in Chapter 3 of "Deep Learning With Python".</p>
<p><strong>Loading the data:</strong... | <python><keras><deep-learning><pytorch> | 2023-10-27 18:56:17 | 0 | 2,792 | Solaxun |
77,376,429 | 219,153 | Assign consecutive numbers to numpy array locations satisfying certain condition | <p>This Python script:</p>
<pre><code>import numpy as np
a = np.random.rand(8, 8)
b = np.full_like(a, -1)
n = 0
for i, val in np.ndenumerate(a):
if val < 0.666:
b[i] = n
n += 1
</code></pre>
<p>creates array <code>b</code> with consecutive natural numbers in locations where <code>a < 0.666</code> (pla... | <python><numpy><numpy-ndarray> | 2023-10-27 18:41:30 | 1 | 8,585 | Paul Jurczak |
77,376,311 | 7,055,769 | Unable to log user in | <p>This is my code:</p>
<pre><code>from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework import status
from django.contrib.auth import authenticate, login
@api_view(["POST"])
def user_login_api_view(request):
username = request.data.get("user... | <python><django><django-rest-framework> | 2023-10-27 18:16:34 | 2 | 5,089 | Alex Ironside |
77,376,207 | 10,918,680 | When is asyncio.Lock() needed? | <p>Here is the code I have so far that uses the bleak package to connect to multiple Bluetooth devices and get data/notifications from them. The devices are scales are they automatically shut off after awhile if there are no weights on them. Upon placing weight on them, they turn on and starts notifying. The code conti... | <python><asynchronous><async-await><python-asyncio><coroutine> | 2023-10-27 17:57:27 | 1 | 425 | user173729 |
77,376,190 | 9,105,621 | chatbot that will generate a document draft with python, langchain, and openai | <p>I'm attempted to pass draft documents and have my chatbot generate a template using a prompt <code>create a non disclosure agreement draft for California between mike llc and fantasty world.</code> with my code below the response i'm getting is:
<code>"I'm sorry, but I cannot generate a non-disclosure agreement... | <python><openai-api><langchain><llama-index> | 2023-10-27 17:53:49 | 1 | 556 | Mike Mann |
77,376,095 | 20,181,052 | How to show one legend for multiple same label | <p>Below is plotting a time series graph in which colour categories the age group and label categories the location.</p>
<pre class="lang-py prettyprint-override"><code>import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.use('TkAgg') # !IMPORTANT
fig, ax = plt.subplots()
ax.plot([93497, 137558, 158293, 1804... | <python><matplotlib> | 2023-10-27 17:37:52 | 2 | 553 | TungTung |
77,376,049 | 5,304,058 | the JSON object must be str, bytes or bytearray, not float | <p>df_json:</p>
<pre><code>filedate code errorID rawrecord errortype
20230811 8003 100 {"Action":"NEW","ID":"30811-195552-952","E... | <python><pandas> | 2023-10-27 17:30:20 | 2 | 578 | unicorn |
77,375,953 | 11,153,160 | Directory not found from Makefile | <p>I'm trying to setup a few scripts in a Makefile for a Python project. My current Makefile looks like this:</p>
<pre><code>install:
pip install -r requirements.txt
activate:
source env/bin/activate
deactivate:
deactivate
jupyter:
jupyter lab
</code></pre>
<p>This file is in the project's root folder. ... | <python><makefile> | 2023-10-27 17:11:26 | 0 | 990 | strblr |
77,375,881 | 263,061 | How to type a Python function the same way as another function? | <p>For writing a wrapper around an existing function, I want to that wrapper to have the same, or very similar, type.</p>
<p>For example:</p>
<pre class="lang-py prettyprint-override"><code>import os
def my_open(*args, **kwargs):
return os.open(*args, **kwargs)
</code></pre>
<p>Tye type signature for <code>os.open... | <python><mypy><python-typing><pyright> | 2023-10-27 16:55:31 | 1 | 25,947 | nh2 |
77,375,728 | 3,568 | How to add "AND EXISTS (SELECT ...)" to a Python/SqlAlchemy query? | <p>I have an SqlAlchemy query that looks like this.</p>
<pre><code>results = (
session.query(MyFirstTable)
# various .join() and .filter() removed for brevity.
.all()
)
</code></pre>
<p>I want to add another <code>.filter</code>, but if I were writing SQL, it would look like:</p>
<pre><code>SELECT * MyFirst... | <python><sqlalchemy> | 2023-10-27 16:23:44 | 1 | 3,313 | billpg |
77,375,679 | 7,672,005 | Jupyter notebook opening a console to fill sudo password | <p>I've opened a jupyter notebook through my terminal on ubuntu, and am trying to run part of the notebook that has a <code>sudo -S pip install -e .</code> command.
It will hang on prompting for a password due to the sudo.
I'm not sure how to circumvent this, I've tried the following:</p>
<ol>
<li><code>%qtconsole</cod... | <python><linux><bash><jupyter-notebook><jupyter> | 2023-10-27 16:16:13 | 0 | 534 | Zyzyx |
77,375,518 | 8,260,569 | Pandas groupby slicing, but in numpy | <p>I have a dataframe with float dtypes only, and an id column. I want to restrict the dataframe to just the top 10 rows for each id value. The immediate way to do that is just <code>df.groupby('id').apply(lambda minidf: minidf.iloc[:k])</code>, but it seems a bit slow and I'm wondering if there are much faster ways of... | <python><numpy><group-by> | 2023-10-27 15:53:28 | 1 | 304 | Shirish |
77,375,425 | 159,633 | Large memory usage when calculating std dev over rolling window | <p>I have a 2D array, and I want to calculate the mean and standard deviation over a spatial window of <code>win_size</code> pixels (~50 pixels or more). I only need to extract this for a subset of pixels whose coordinates I have stored in two arrays.</p>
<p>My code looks like this:</p>
<pre><code># Set up rolling wind... | <python><dask><python-xarray> | 2023-10-27 15:35:54 | 0 | 2,149 | Jose |
77,375,031 | 1,867,328 | Print nothing in Python | <p>I have below code</p>
<pre><code>choose = 4
print(choose if choose == 4 else None)
## this print 4
</code></pre>
<p>But,</p>
<pre><code>choose = 5
print(choose if choose == 4 else None)
</code></pre>
<p>But this print <code>None</code> in the screen. Is there any way to print <code>NOTHING</code>?</p>
| <python> | 2023-10-27 14:34:44 | 2 | 3,832 | Bogaso |
77,374,878 | 15,341,457 | Python Scrapy - brotli.brotli.Error: Decompression error: incomplete compressed stream | <p>I'm scraping restaurant reviews from Yelp and I'm accessing the restaurant's APIs to do so. I'm currently scraping 4 star reviews, for example this <a href="https://www.yelp.it/biz/tonnarello-roma?osq=tonnarello&rr=4" rel="nofollow noreferrer">restaurant page</a> has this corresponding <a href="https://www.yelp.... | <python><web-scraping><scrapy><compression><brotli> | 2023-10-27 14:15:16 | 1 | 332 | Rodolfo |
77,374,683 | 4,726,173 | quiver plot does not adjust to arrow extent | <p>As visible for example here: <a href="https://stackoverflow.com/questions/53484900/how-to-turn-off-matplotlib-quiver-scaling">How to turn off matplotlib quiver scaling?</a></p>
<p>when using matplotlib.pyplots's quiver to draw arrows, the arrows often point out of the image. It seems like the plot adjusts only to th... | <python><matplotlib><arrows> | 2023-10-27 13:48:05 | 1 | 627 | dasWesen |
77,374,491 | 2,130,515 | Ray-tune log results in two folders | <p>I using ray-tune to fine-tune parameter.</p>
<p>Based on the docs, ray-tune log the results of each trial to a sub-folder under a specified local dir, which defaults to <code>~/ray_results</code>.</p>
<p>To change <em>ray_results</em> to a <em>custom folder</em>, I used the following:</p>
<pre><code>timestamp = date... | <python><logging><hyperparameters><ray> | 2023-10-27 13:20:43 | 0 | 1,790 | LearnToGrow |
77,374,339 | 4,399,016 | Using PyQuery and Gadget selector to extract URLs from a Website | <p>I have code that only works partially:</p>
<pre><code>from pyquery import PyQuery as pq
import requests
url = SAMPLE_URL.com
content = requests.get(url).content
doc = pq(content)
Latest_Report = doc(".head+ .post .heading")
Latest_Report.text()
</code></pre>
<p>I am able to get the Text element with th... | <python><python-requests><pyquery> | 2023-10-27 12:57:48 | 1 | 680 | prashanth manohar |
77,374,321 | 468,455 | Python authorizing into Google - getting referenced before assignment error | <p>This code has been working for a while and suddenly this morning it started throwing a 'reference before assignment' error but I am not sure why that is being thrown. The error is happening at this line <code>creds.refresh(Request())</code> on the <code>creds</code> var:</p>
<pre><code>def getAuth(self):
try:
... | <python><google-drive-api> | 2023-10-27 12:53:47 | 1 | 6,396 | PruitIgoe |
77,374,277 | 16,027,663 | Vectorising Iterrows/Itertuples on Time Series Dataframe | <p>I have a series of dataframes containing OHLC data from Yahoo Finance, sorted by ascending dates. I want to test some things for my economics class so built a simple script using <code>iterrows</code>. It was painfully slow but it is what I knew.</p>
<p>To speed it up I tried using <code>itertuples</code>. This did ... | <python><pandas><numpy> | 2023-10-27 12:47:24 | 1 | 541 | Andy |
77,374,217 | 5,437,090 | numpy unique with customized sorting of unique elements of an array | <p>Given:</p>
<pre><code>R=["ip1", "ip7", "ip12", "ip5", "ip2", "ip22", "ip7", "ip1", "ip17", "ip22"]
</code></pre>
<p>I would like to get unique values of my list <code>R</code> with their corresponding indices.</p>
<p>... | <python><numpy><sorting> | 2023-10-27 12:38:37 | 2 | 1,621 | farid |
77,373,979 | 17,973,966 | Install pandera[pyspark]-compatible version of pydantic on Databricks cluster | <p>I have an issue with installing pandera[pyspark] and pydantic on my Databricks cluster.</p>
<h2>Background</h2>
<p>I have a data pipeline in Databricks notebooks. It is completely written in PySpark, so for my data validation I want to use <a href="https://pandera.readthedocs.io/en/stable/pyspark_sql.html" rel="nofo... | <python><pyspark><databricks><pydantic><pandera> | 2023-10-27 12:00:00 | 0 | 472 | Neele22 |
77,373,902 | 12,297,666 | Inconsistent number of samples in Sklearn with XGBoost | <p>I am trying to train a <code>XGBRegressor</code> using this code:</p>
<pre><code>import xgboost as xgb
from sklearn.metrics import mean_squared_error
def xgboost():
model = xgb.XGBRegressor(n_estimators=200,
max_depth=4,
subsample=1,
... | <python><scikit-learn><xgboost> | 2023-10-27 11:46:06 | 1 | 679 | Murilo |
77,373,823 | 4,424,484 | Training neural networks on very large sparse matrices in pytorch | <p>I have a dataset with about 74 million observations. Each of these observations is represented by ~1,000 features and labelled with up to ~3,200 binary classes. Most individual observations are labelled with no more than ~10 classes, so the labels are very sparse. Currently, the label and feature matrices are stored... | <python><pytorch><sparse-matrix><large-data> | 2023-10-27 11:33:17 | 1 | 321 | dentist_inedible |
77,373,685 | 2,922,325 | Facing IndexError: tuple index out of range in vanilla example for Petals by bigscience-workshop | <p>To get bootstrapped, I tried to use the example from Readme</p>
<pre><code>from transformers import AutoTokenizer
from petals import AutoDistributedModelForCausalLM
import torch
# Choose any model available at https://health.petals.dev
model_name = "petals-team/StableBeluga2" # This one is fine-tuned Ll... | <python><huggingface-transformers> | 2023-10-27 11:11:04 | 0 | 509 | jazz |
77,373,538 | 14,534,480 | List with the names of points in a given radius for all rows of the dataframe | <p>I have a dataframe like:</p>
<pre><code>projectName latitude longitude
a 56.864229 60.609576
b 55.810413 37.701168
c 55.924912 37.966033
d 56.804987 60.590667
e 55.806000 37.569863
</code></pre>
<p>I want to get a list of points in a given radius for eac... | <python><pandas><geo> | 2023-10-27 10:46:47 | 2 | 377 | Kirill Kondratenko |
77,373,522 | 5,786,649 | How does an instance of pytorch's `nn.Linear()` process a tuple of tensors? | <p>In the <a href="http://nlp.seas.harvard.edu/annotated-transformer/" rel="nofollow noreferrer">annotated transformer's implementation of multi-head attention</a>, three tensors (query, key, value) are all passed to a <code>nn.Linear(d_model, d_model)</code>:</p>
<pre><code># some class definition ...
self.linears = c... | <python><machine-learning><pytorch><nlp><transformer-model> | 2023-10-27 10:43:27 | 1 | 543 | Lukas |
77,372,990 | 11,092,636 | Pandas SettingWithCopyWarning when chaining dataframe operations and displaying in Notebook | <p>MRE:</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
# Sample data for demonstration
data = {
"a": ["a", "b", "b", "a", "b", "b", "a", "a"],
"date": ["01/01/2021", "02/0... | <python><pandas><dataframe><jupyter-notebook> | 2023-10-27 09:24:26 | 0 | 720 | FluidMechanics Potential Flows |
77,372,866 | 2,254,210 | PyArrow Flight: Empty Strings in pa.Table Converting to NULLs When Reading/Writing to Exasol | <p>I'm reading and writing a table on Exasol using PyArrow Flight. I noticed an issue, where empty strings get converted to NULLs in the flight process. When I write a pa.Table containing a column of ""s to Exasol, the resulting table contains NULLs rather than "". I confirmed the same issue the oth... | <python><pyarrow><exasol><apache-arrow-flight> | 2023-10-27 09:07:28 | 1 | 1,444 | altabq |
77,372,760 | 6,224,975 | Google vertex endpoint is unavilable when deploying new model | <p>Every night we train a new model, and deploy it (in Flaks) to an existing endpoint. The Flask code is (simplified) as:</p>
<pre class="lang-py prettyprint-override"><code>from flask import Flask, request
def load_models()
"""
Load new model from google cloud storage
"""
.
... | <python><google-cloud-platform><google-cloud-vertex-ai> | 2023-10-27 08:54:44 | 0 | 5,544 | CutePoison |
77,372,689 | 1,608,765 | secondary_xaxis with global variable in subplot | <p>I'm trying to make a figure that is showing some Doppler velocities of different spectra, but the script does not seem to like the fact that i am changing a global variable. Is there a way around this? Basically, it only plots the seondary axis for the latest value of the global variable, see figure below where the ... | <python><matplotlib><global-variables><subplot><twiny> | 2023-10-27 08:42:58 | 1 | 2,723 | Coolcrab |
77,372,596 | 12,415,855 | Add items to product cart using selenium? | <p>i would like to add a product to a product cart using the following code:</p>
<pre><code>import time
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.support.ui import WebDriverWait
from seleni... | <python><selenium-webdriver> | 2023-10-27 08:28:43 | 1 | 1,515 | Rapid1898 |
77,372,592 | 12,436,050 | Streamlit: Series.count() takes 1 positional argument but 2 were given | <p>I am new to streamlit and building an application using data from a csv file. I am trying to apply a function on a dataframe column which gives me an error: <code>TypeError: Series.count() takes 1 positional argument but 2 were given.</code></p>
<p>Below is the code:</p>
<pre><code>@st.cache_data
def load_data(file)... | <python><streamlit> | 2023-10-27 08:28:08 | 0 | 1,495 | rshar |
77,372,572 | 1,598,626 | Delta Live Table ignoring the defined schema | <p>Using autoloader, I am reading some continues data from storage to Databricks Delta Live table. The declaration of data pipeline is as follows.</p>
<pre><code>import dlt
from pyspark.sql.functions import *
from pyspark.sql.types import *
sch = "StructType([StructField('Date', StringType(), True), StructFie... | <python><azure><pyspark><azure-databricks><delta-live-tables> | 2023-10-27 08:25:04 | 2 | 381 | abhijit nag |
77,372,530 | 10,200,497 | groupby streak of numbers and one row after it | <p>This is my dataframe:</p>
<pre><code>import pandas as pd
df = pd.DataFrame({'a': [1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0]})
</code></pre>
<p>And my desired outcome which is about grouping them is:</p>
<pre><code> a
0 1
1 1
2 1
3 0
4 1
5 0
6 1
7 1
8 0
10 1
11 1
12 0
</code></pre>
<p>Basic... | <python><pandas> | 2023-10-27 08:17:52 | 1 | 2,679 | AmirX |
77,372,484 | 4,529,168 | Count tuples in array that are equal to same value | <p>I have a NumPy array of shape <code>(100,100,3)</code> (an RGB image). I want to compare all 3-eleemnt tuples contained in the array for equality to produce array of booleans of shape <code>(100,100)</code>.</p>
<p>Expected usage:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
arr = np.array... | <python><arrays><numpy><image-processing><python-imageio> | 2023-10-27 08:11:06 | 1 | 3,767 | jiwopene |
77,372,469 | 2,869,143 | SQL execution error: OAuth2 Access token request failed | <p>I'm working in Snowflake with the new functionality <a href="https://docs.snowflake.com/en/developer-guide/external-network-access/external-network-access-examples" rel="nofollow noreferrer">External Network Access</a> that allows a function to connect to an external domain and make HTTP requests, in this use case I... | <python><oauth-2.0><snowflake-cloud-data-platform> | 2023-10-27 08:09:17 | 1 | 537 | frammnm |
77,372,355 | 7,580,944 | How to get Lebedev and Gaussian spherical grid | <p>I am being reading some works on HRTF interpolation and spherical harmonics.
In such works regular spherical grids are often used, e.g., in <a href="https://www.frontiersin.org/articles/10.3389/frsip.2022.884541/full" rel="nofollow noreferrer">this work</a>, but I am missing how to compute them:<br />
Hence, how to ... | <python><numpy><mesh><spherical-coordinate> | 2023-10-27 07:48:56 | 1 | 359 | Chutlhu |
77,372,162 | 9,363,181 | Unable to publish data to Kafka Topic using pyflink 1.17.1 | <p>I am trying to publish the data which was originally a <code>list</code> but I converted it to the <code>string</code> and then tried to push it to the <code>Kafka</code> topic as per this <a href="https://nightlies.apache.org/flink/flink-docs-release-1.17/docs/connectors/datastream/kafka/#kafka-sink" rel="nofollow ... | <python><apache-kafka><apache-flink><pyflink> | 2023-10-27 07:17:38 | 1 | 645 | RushHour |
77,372,135 | 8,040,369 | Selenium: Clicking on img button open the url in new tab but not returning the url in python | <p>I have an <strong>img</strong> for the linked in link as below</p>
<pre><code><span class="MuiTypography-root MuiTypography-body1 css-lkp0s4">
<img alt="linkedin icon" srcset="https://d3ml3b6vywsj0z.cloudfront.net/website/v2/icons_v2/linkedin_icon_blue_fill.svg 1x, https://d3ml3b6vy... | <python><selenium-webdriver><selenium-chromedriver> | 2023-10-27 07:13:26 | 1 | 787 | SM079 |
77,372,055 | 4,435,175 | Replacing emptry strings with a value adds this value at the start of every string | <p>I have a df through reading in an Excel file (<code>pl.read_excel()</code>). For some reasons empty cells are <code>""</code> instead of <code>None</code>/<code>null</code>. Replacing those empty strings with another value does not work as expected.</p>
<p>MVE:</p>
<pre><code>import polars as pl
df = pl.D... | <python><python-polars> | 2023-10-27 06:58:47 | 1 | 2,980 | Vega |
77,371,777 | 5,835,780 | Is there an efficient way to find the maximum so far in a pandas group? | <p>I have a value 'risk' that (should) increase within each group. Each group is identified by 'id' and nested 'sub_id' values. I want to calculate the maximum value <em>so far</em> within a group's sequence - from 0-8 in this example. I'm using pandas <code>rolling</code> windowing operations, which has a fixed window... | <python><pandas><group-by> | 2023-10-27 05:53:56 | 1 | 960 | eknumbat |
77,371,521 | 6,660,373 | Making function single threaded and running in background | <p>I am trying to implement <strong>in-memory queue like Kafka using Python</strong> using concepts like <strong>re-entrant locks and threads.</strong> I am new to Python threading.</p>
<p>I have a <em>consumer</em> which will <em>subscribe to the topic</em> and <em>read a message</em> from it. So far it's working fine... | <python> | 2023-10-27 04:33:08 | 1 | 13,379 | Pygirl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.