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,981,007
6,394,722
How to add namespace when add node to XML with xml.etree.ElementTree?
<p>I have next code to parse one XML string, and then add a new node to the XML. But you can see my code can only add <code>&lt;category term=&quot;Platform Version&quot; value=&quot;Linux_6.6&quot; /&gt;</code> without namespace. I need the <code>ns0</code> before <code>category</code>.</p> <p><code>test_xml.py</code>...
<python><xml><elementtree>
2024-09-13 06:55:16
2
32,101
atline
78,980,993
13,494,917
When comparing two dataframes in an azure function app, I receive this error- valueerror: the truth value of a series is ambiguous
<p>I have some logic here that I'm using to iterate through dataframes. My goal is to iterate through all of the rows in one dataframe and compare that row against every row found in another dataframe. So, where &quot;code&quot; matches in the two dataframes I want to</p> <ol> <li>Transform df2's code to equal df's&qu...
<python><sql><pandas><dataframe><azure-functions>
2024-09-13 06:52:33
1
687
BlakeB9
78,980,960
12,466,687
How to get consistent results in tabular PDF parsing with llama-parse?
<p>I was parsing some PDF files using llama in Python with below code:</p> <pre><code>import os import pandas as pd import nest_asyncio nest_asyncio.apply() os.environ[&quot;LLMA_CLOUD_API_KEY&quot;] = &quot;some_key_id&quot; key_input = &quot;some_key_id&quot; from llama_parse import LlamaParse # running llama pa...
<python><pdf><pdf-parsing><llama-parse>
2024-09-13 06:44:26
2
2,357
ViSa
78,980,819
311,786
Using specific Django LTS version with cookiecutter-django
<p>Currently, the Cookiecutter Django template uses Django 5.0, which is not a long-term support (LTS) release.</p> <p>I couldn't find clear instructions in their documentation on how to specify a different Django version during installation.</p> <p>I'd like to use Django 4.2 with <a href="https://github.com/cookiecutt...
<python><django><cookiecutter-django>
2024-09-13 06:02:06
1
1,846
Manish
78,980,609
520,558
Weirdest behaviour (pycharm, python, virtual environment, loading error)
<p>Long story short: python &quot;sees&quot; some files but not others. <a href="https://i.sstatic.net/A2YbqY98.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/A2YbqY98.png" alt="the console inside pycharm" /></a></p> <p><a href="https://i.sstatic.net/4D0b6aLj.png" rel="nofollow noreferrer"><img src="htt...
<python><pycharm><python-venv>
2024-09-13 04:19:27
1
2,171
Attilio
78,980,496
2,985,331
Moving a class into a module and loading an instance from joblib
<p>I have a class called DiseaseTree defined in a file called diseaseTree.py. I have been using this class for a while. In a different workflow I have generated an instance of this class, and written to file using joblib.</p> <p>I am now attempting to construct a module, with this code in it. My directory structure loo...
<python><joblib>
2024-09-13 03:21:21
1
451
Ben
78,980,254
3,311,276
Why adding custom_openapi scema to FastAPI is causing the authorisation not to work?
<p>I have this FastAPI app working in the <code>main.py</code>:</p> <pre><code>app = FastAPI() app.add_middleware( CORSMiddleware, allow_origins=[&quot;*&quot;], allow_credentials=True, allow_methods=[&quot;*&quot;], allow_headers=[&quot;*&quot;], ) sub_app1 = FastAPI() sub_app1.include_router(aut...
<python><fastapi>
2024-09-13 00:28:15
1
8,357
Ciasto piekarz
78,980,144
17,275,378
Select Multiple Columns Efficiently in SQLModel
<p>I'm using <a href="https://github.com/fastapi/sqlmodel" rel="nofollow noreferrer">SQLModel</a>, which is a wrapper around SQLAlchemy.</p> <p>The data model includes:</p> <pre><code>class Line(SQLModel, table = True): id: int | None = Field(default = None, primary_key = True) name: str class Product(SQLModel...
<python><sqlmodel>
2024-09-12 22:59:12
1
326
eldrly
78,980,136
44,375
Face recognition test failing with correct image
<p>I'm beginning to explore face recognition but even my simple &quot;hello world&quot; is blowing up on my face.</p> <p>Here's the code:</p> <pre class="lang-python prettyprint-override"><code>import face_recognition from PIL import Image import numpy as np import base64 from io import BytesIO def test_face_recogniti...
<python><face-recognition>
2024-09-12 22:54:08
1
11,730
Paulo Santos
78,980,100
1,444,564
Python/Oct2Py/Octave Setup Woes
<p>In Windows 10 or 11, I am trying to set up a Python/Oct2Py/Octave environment so that I can write Python scripts that can invoke Octave functionality. I set this up on my own machine, and got it working about a year ago. Now I am trying to replicate this setup, but my notes must be somewhat deficient, as I run into ...
<python><octave><oct2py>
2024-09-12 22:28:08
1
723
Bob
78,979,833
8,086,892
Monkeypatch Extract step in ETL data pipeline for functional testing
<p>Consider an ETL pipelines repo build like that:</p> <pre><code>etl_repo β”œβ”€β”€ app β”œβ”€β”€ extract β”œβ”€β”€ extr_a.py β”œβ”€β”€ extr_b.py β”œβ”€β”€ transform β”œβ”€β”€ trans_a.py β”œβ”€β”€ trans_b.py β”œβ”€β”€ load β”œβ”€β”€ load_a.py β”œβ”€β”€ load_b.py β”œβ”€β”€ config.py ...
<python><pytest><monkeypatching>
2024-09-12 20:22:59
2
347
mouch
78,979,548
6,930,340
Create list column out of column names
<p>I have a simple <code>pl.DataFrame</code> with a number of columns that only contain boolean values.</p> <pre><code>import polars as pl df = pl.DataFrame( {&quot;s1&quot;: [True, True, False], &quot;s2&quot;: [False, True, True], &quot;s3&quot;: [False, False, False]} ) shape: (3, 3) β”Œβ”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β” ...
<python><python-polars>
2024-09-12 18:45:17
3
5,167
Andi
78,979,442
7,700,802
Get subset of dataframe following a condition from a dictionary
<p>I am trying to find instances of where three columns may exceed some number that is stored in a dictionary. I know this code works, but I think there is a better more pythonic way of doing this.</p> <pre><code>l = [] for index, row in df_usage.iterrows(): item_id = row['item_id'] try: if ( ...
<python><pandas>
2024-09-12 18:01:00
1
480
Wolfy
78,979,400
9,064,615
How to set width/height of widgets within a Paned Window widget in Tkinter after initialization?
<p>I'm trying to create a save/restore functionality in my Tkinter GUI, but I'm having trouble restoring the width/height of Widgets within a Paned Window. I've tried .place() and .config, but the resizable window around each of the widgets disappears and I can no longer resize each widget.</p> <p>Example code:</p> <pr...
<python><python-3.x><tkinter>
2024-09-12 17:50:53
3
608
explodingfilms101
78,979,258
163,679
Configure python argparse to accept an optional argument multiple times, like `grep --exclude`
<p>How do I configure a python <code>argparse</code> object to accept an optional argument multiple times, similar to how I can pass <code>--exclude</code> to <code>grep</code> mutliple times?</p> <pre><code># Command line example python main.py --exclude=foo.js --exclude=bar.java # args.exclude should be ['foo.js', '...
<python><argparse>
2024-09-12 17:07:27
1
2,673
bigh_29
78,979,081
2,928,970
Python exception stack trace not full when function is wrapped
<p>I have two files <code>t.py</code>:</p> <pre><code>import functools import traceback def wrapper(func): @functools.wraps(func) def wrapped(*args, **kwargs): try: return func(*args, **kwargs) except Exception as e: traceback.print_exception(e) return wrapped @w...
<python><exception><wrapper><python-decorators>
2024-09-12 16:15:06
2
1,395
hovnatan
78,978,944
4,817,370
TimescaleDB not accepting intervales less than one day
<p>I have a timescaleDB but I cannot seem to be able to use the time_bucket method with less than one day intervals.</p> <p>The code attempting to access it is running inside of a fast API and is as follows :</p> <pre class="lang-py prettyprint-override"><code> async def get_candlestick_data(self, db: AsyncSession,...
<python><sqlalchemy><fastapi><timescaledb>
2024-09-12 15:38:49
2
2,559
Matthieu Raynaud de Fitte
78,978,937
1,818,713
In a python stubs file, how to have a type without importing an external package?
<p>Suppose I want to annotate pyarrow's <code>pq.ParquetFile</code> which takes a filesystem parameter. A valid input to that parameter is pyarrow's own FileSystem implementation. That is easy enough to just have <code>filesystem: FileSystem | None</code> but what I really want is <code>filesystem: FileSystem | fsspec....
<python><python-typing>
2024-09-12 15:36:59
0
19,938
Dean MacGregor
78,978,810
12,466,687
How to use st.file_uploader() returned object to parse pdf through LlamaParse() in python streamlit?
<p>I am trying to upload a PDF using <code>st.file_uploader()</code> from <code>streamlit</code> and then parse it using <code>LlamaParse()</code> currently running on <code>localhost</code>.</p> <p>Issue is I am getting <code>[]</code> in output which is probably happening because of directly using returned <code>uplo...
<python><pdf><file-upload><streamlit><llama>
2024-09-12 15:02:57
1
2,357
ViSa
78,978,783
607,846
Iterate over batch size for each batch
<p>Its there a more pythonic way, or built in function in python to do the following:</p> <pre><code>def batch(number, batch_size): number_left = number while number_left: if number_left &gt;= batch_size: yield batch_size number_left -= batch_size else: yield ...
<python>
2024-09-12 14:58:30
3
13,283
Baz
78,978,757
13,158,157
How to prevent Calamine from auto-guessing data types when reading Excel files
<p>I’m working with an Excel file and need to read its contents into a DataFrame. When I use pandas (with default engine), I can specify the data type of the columns to be strings, which works perfectly:</p> <pre><code>import pandas as pd df = pd.read_excel(fp, dtype=str, nrows=10) print(df[col]) </code></pre> <p>This...
<python><excel><pandas><calamine>
2024-09-12 14:54:40
1
525
euh
78,978,753
8,297,745
How to manage concurrent API token updates in a Python script using a ini file for multiple clients?
<p>I’m working on a Low-Level Discovery (LLD) script for Zabbix, which is set up as an &quot;External&quot; item. The script interacts with Aruba’s API to generate hosts for different clients based on their specific sites and devices.</p> <p>The Aruba API requires authentication via access tokens, which expire after a ...
<python><zabbix>
2024-09-12 14:54:12
0
849
Raul Chiarella
78,978,581
247,542
Playwright test failing in headless mode due to Paypal button
<p>I have a Playwright test that confirms an e-commerce site's checkout process works, which terminates in clicking a Paypal button, logging into Paypal, and clicking submit payment.</p> <p>In headed mode, it can interact with the Paypal popup just fine, but in headless mode, the Paypal widget doesn't render at all, an...
<python><paypal><playwright><playwright-python>
2024-09-12 14:15:34
0
65,489
Cerin
78,978,563
24,191,255
Colouring a surface using go.Surface in plotly
<p>I aim to colour a surface in a 3d plot, created using <code>plotly.graph_objects</code>.</p> <p>I've been working on an approach incorporating <code>Mesh3d</code>, the code runs, but the wanted surface is not coloured. How can this be solved in <code>plotly</code>?</p> <p>The final outcome should look similar to thi...
<python><arrays><plot><plotly><surface>
2024-09-12 14:10:56
1
606
MΓ‘rton HorvΓ‘th
78,978,557
1,424,395
Plotting each row in a pandas DataFrame as a bar with seaborn
<p>Given such a dataframe,</p> <pre><code>data = pd.DataFrame({'a':[1,2],'b':[2,3],'c':[3,4],'d':[1,2],'code':[1,2]}) a b c d code 0 1 2 3 1 1 1 2 3 4 2 2 </code></pre> <p>I want to have a barplot with a 2 bars for each column (one for each row...)</p> <p>this one</p> <pre><code>sns.barplot...
<python><pandas><seaborn>
2024-09-12 14:09:33
1
1,827
myradio
78,978,475
17,082,611
Unable to import module 'main': No module named 'pydantic_core._pydantic_core when deploying a FastAPI app to AWS Lambda
<p>I am working on my MacOS machine following <a href="https://www.youtube.com/watch?v=7-CvGFJNE_o" rel="nofollow noreferrer">this tutorial</a>.</p> <p>I am trying to deploy my FastAPI app to AWS Lambda.</p> <p>I launched <code>pip install fastapi uvicorn mangum</code></p> <p>and these are the dependencies I get:</p> <...
<python><amazon-web-services><aws-lambda><fastapi><python-3.12>
2024-09-12 13:47:45
1
481
tail
78,978,265
2,171,348
python 3.9 multiprocessing.RLock on windows 10
<p>Here is my code:</p> <pre><code>from multiprocessing import Process, RLock import os LOCK = RLock() def acquire_lock(): r = LOCK.acquire() print(os.getpid(), &quot;lock acquired:&quot;, r) if __name__ == &quot;__main__&quot;: acquire_lock() process1 = Process(target=acquire_lock) process1.sta...
<python><multiprocessing><locking>
2024-09-12 12:55:39
0
481
H.Sheng
78,978,045
562,769
Is it possible to switch to a through model in one release?
<p>Assume I have those Django models:</p> <pre><code>class Book(models.Model): title = models.CharField(max_length=100) class Author(models.Model): name = models.CharField(max_length=100) books = models.ManyToManyField(Book) </code></pre> <p>I already have a production system with several objects and sever...
<python><django><django-orm>
2024-09-12 11:59:52
1
138,373
Martin Thoma
78,978,016
1,606,657
Add default text to curses Textbox object
<p>I'm using the curses python library in an application and have implemented a <code>Textbox</code> as well <a href="https://docs.python.org/3/library/curses.html#textbox-objects" rel="nofollow noreferrer">https://docs.python.org/3/library/curses.html#textbox-objects</a>.</p> <p>Is there a way to add a default text wh...
<python><textbox><python-curses>
2024-09-12 11:53:35
1
6,352
wasp256
78,977,945
1,473,517
What is the fastest way to read in a large yaml file containing lists of lists?
<p>I have a number of yaml files I need to read in which contain lists of list. Here is a way to make some example data:</p> <pre><code>from time import time import random import yaml # First make a list of lists N = 2**17 lol = [] for _ in range(N): lol.append([random.uniform(0, 2) for _ in range(10)]) # Write t...
<python><performance>
2024-09-12 11:32:12
1
21,513
Simd
78,977,827
1,469,980
Cannot close a dialog PyQt5
<p>I have the following 2 classes. From <code>UI_mainwindow</code> I open a dialog as seen below. I want that dialog to close when I click on one of those 2 buttons (<code>createProject_btn</code>, <code>openProject_btn</code>). Though nothing seems to be working.</p> <p>I know this kind of questions have been asked mi...
<python><pyqt5><qdialog>
2024-09-12 11:03:02
0
7,390
Tolga Evcimen
78,977,494
9,525,238
Combine 2 numpy 1d arrays taking elements from each consecutively
<p>I have 2 arrays</p> <pre><code>xs1 = [ x0, x1, x2, x3, x4, x5, x6, x7, x8] xs2 = [x00, x01, x02, x03, x04, x05, x06, x07, x08] </code></pre> <p>I want to combine them taking an element from each at a time.</p> <pre><code>xs = [x0, x00, x1, x01, x2, x02, x3, x03, x4, x04, x5, x05, x6, x06, x7, x07, x8, x08] <...
<python><numpy>
2024-09-12 09:39:31
2
413
Andrei M.
78,977,364
188,331
Simple import codes in transformers cause errors
<p>Here are my simple import codes:</p> <pre><code>from transformers import trainer_seq2seq </code></pre> <p>It shows:</p> <pre><code>2024-09-12 16:47:25.651645: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:485] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has ...
<python><tensorflow><huggingface-transformers>
2024-09-12 09:09:30
1
54,395
Raptor
78,977,145
179,014
Derived python dataclass cannot override default value?
<p>In the following code snippet the dataclass <code>Derived</code> is derived from dataclass <code>Base</code>. The <code>Derived</code> dataclass is setting new default values for <code>field1</code> and <code>field2</code>.</p> <pre><code>from dataclasses import dataclass @dataclass class Base: field1: str ...
<python><inheritance><python-dataclasses>
2024-09-12 08:11:52
1
11,858
asmaier
78,977,133
8,946,188
Why does drop_duplicates in_place = True not work in this case?
<p>Sample data:</p> <pre><code>data = [[1, 'john@example.com'], [2, 'bob@example.com'], [3, 'john@example.com']] person = pd.DataFrame(data, columns=['id', 'email']).astype({'id':'int64', 'email':'object'}) </code></pre> <p>Reproducible code:</p> <pre><code>(person.sort_values(by = ['email', 'id'], ascending = [True, T...
<python><pandas><dataframe><in-place><drop-duplicates>
2024-09-12 08:09:59
1
462
Amazonian
78,977,057
7,519,700
elasticsearch-py add delay between retries
<p>I'm instantiating a python elasticsearch client as follows</p> <pre><code>es = Elasticsearch( hosts=ELASTICSEARCH_URL, timeout=5, ignore_unavailable=True, # connection_retries=Retry( # total=5, # backoff_factor=1.1, # status_forcelist=[429, 502, 503...
<python><delay><elasticsearch-py>
2024-09-12 07:49:05
1
1,033
room13
78,976,844
2,573,075
ODOO 17 Obtain sorted query result for a customized report
<p>In a crm.lead model I have 2 more attributes (columns) let's call col1 and col2.</p> <p>How do I obtain 2 recordsets for each user like &quot;select * from crm_records col1 desc limit 5&quot; and the second &quot;select * from crm_records col1 desc limit 5&quot; in the same?</p> <p>In the beginning, I was trying to ...
<python><sql><odoo><odoo-17>
2024-09-12 06:58:42
1
633
Claudiu
78,976,722
1,922,589
PyYAML - error: subprocess-exited-with-error
<p>I got this error when trying to install PyYAML</p> <pre><code>Collecting PyYAML==5.4.1 (from -r /xxx/src/requirements_2.txt (line 21)) Using cached PyYAML-5.4.1.tar.gz (175 kB) Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error Γ— Gett...
<python><pyyaml>
2024-09-12 06:26:09
1
24,027
Nurdin
78,976,441
2,717,373
centering the bottom row of subplots in a matplotlib grid
<p>If I have 5 plots I want to present, is it possible to have them in 2 rows, with the top row having 3 plots, the bottom row having 2 plots, but the bottom row centred?</p> <p>I can plot them with 3 on the top and 2 on the bottom, but I can't work out how to centre the bottom row.</p> <p>for example:</p> <pre><code>i...
<python><matplotlib><plot><layout>
2024-09-12 04:06:53
2
1,373
guskenny83
78,976,156
11,934,499
i am using cookiecutter-django with docker and it keeps reloading in the local env
<p>I am starting to use cookiecutter-django 2024.07.26 with docker and after a few updates it keeps reloading</p> <p><a href="https://i.sstatic.net/CU67taqr.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CU67taqr.gif" alt="screen recorder" /></a></p> <pre><code>aqua_loui_local_django | * Detected ch...
<python><django><docker><local><cookiecutter-django>
2024-09-12 01:39:28
1
1,423
Ahmed Abo 6
78,976,148
6,929,343
Get PythonTkinter width of string in pixels using given font
<p>Given a string such as &quot;this is a string&quot; or &quot;THIS IS A STRING&quot; and knowing the font family and size, how can the pixel width be calculated?</p> <p>This is required to align columns for an eyesome GUI.</p>
<python><string><user-interface><tkinter><width>
2024-09-12 01:36:17
1
2,005
WinEunuuchs2Unix
78,975,956
1,380,285
python list comprehension -- two loops with three results?
<p>I can ask my question best by just giving an example. Let's say I want to use a list comprehension to generate a set of 3-element tuples from two loops, something like this:</p> <pre><code>[ (y+z,y,z) for y in range(10) if y%2==0 for z in range(20) if z%3==0 ] </code></pre> <p>This works, giving me</p> <pre><code>[...
<python><list-comprehension>
2024-09-11 23:08:29
3
6,713
bob.sacamento
78,975,869
2,687,317
pandas- merge to datasets with diff col names adding values from the second into the first
<p>I have a couple of dataframes:</p> <pre><code>DTime A B C 2023-02-21 00:00:01 0 0 0 2023-02-21 00:00:02 0 1 0 2023-02-21 00:00:03 0 0 2 2023-02-21 00:00:04 4 2 0 DTime AAA BBB CC DDD EE 2023-02-21 00:00:01 0 0 0 1 0 2023-02-21 00:00:02 0 1 0 0 0 2023-02-21 00:00:03 0 0 2 0 1 2023-02-2...
<python><pandas><merge>
2024-09-11 22:21:07
3
533
earnric
78,975,859
19,366,064
Pycharm: How to display project name instead of path
<p><a href="https://i.sstatic.net/BaHL3ozu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/BaHL3ozu.png" alt="enter image description here" /></a></p> <p>Pycharm: How to display project name instead of path</p> <p>The screen shot above shows the project tool window. Under Project Files view, it display t...
<python><pycharm>
2024-09-11 22:18:49
1
544
Michael Xia
78,975,828
2,171,348
how to share hash() function output with multiprocessing.Array in python 3?
<p>I need to share some 64-bit integers in a python 3 multiprocessing runtime.</p> <p>I tried to use multiprocessing.Array, and it works on linux, but fails on Windows.</p> <p>The long type for multiprocessing.Array is 64-bit on linux, but on Windows (10) it's only 32-bit! Cannot use the same code on both OSes.</p> <p>...
<python><python-multiprocessing><long-integer>
2024-09-11 22:01:58
0
481
H.Sheng
78,975,818
1,125,062
How to use parallel torch cuda streams without causing oom? (example included)
<p>I'm storing a large amount of tensors data in a cpu memory, and the intended workflow is to process them using the GPU. And while one chunk is being processed, <em>simultaneously</em> transfer the previous chunk's result back into cpu. And <em>simultaneously</em> transfer the next chunk into gpu so it's ready to pro...
<python><python-3.x><machine-learning><pytorch><cuda-streams>
2024-09-11 21:55:42
0
4,641
Anonymous
78,975,805
3,825,948
Convert wav to mulaw in Python
<p>I'm opening a wav file and attempting to convert it into mulaw unsuccessfully. The mulaw is then sent to Twilio to play. The code is as follows:</p> <pre><code> with wave.open('audio/test.wav', 'rb') as wav: raw_wav= wav.readframes(wav.getnframes()) raw_ulaw = audioop.lin2ulaw(raw_wav, wav.getsampwidth()) </...
<python><twilio><wav><file-conversion><mu-law>
2024-09-11 21:49:01
0
937
Foobar
78,975,594
22,407,544
Should I use Django's `FloatField()` or `DecimalField(`) for audio length?
<p>I use:</p> <pre class="lang-py prettyprint-override"><code>duration = float(ffmpeg.probe(audio_path)[&quot;format&quot;][&quot;duration&quot;]) </code></pre> <p>I collect an audio/video's length and want to store it using my models. Should I use <code>models.DecimalField()</code> or <code>models.FloatField()</code>?...
<python><django>
2024-09-11 20:24:07
2
359
tthheemmaannii
78,975,581
2,262,854
Split pdf pages workflow with celery
<p>I have the following use case using Celery and Flask.</p> <p>A user uploads a PDF file. I want a worker to count the number of pages, n workers to split each page in a separate PDF file in parallel and then one worker to generate a report.</p> <pre><code> +----------------+ ...
<python><flask><celery>
2024-09-11 20:17:43
0
2,366
maxime
78,975,570
8,510,149
Rank on a subset of a partition - PySpark
<p>The code snippet below creates the column 'rank' with a condition. I want to perform the rank based on a subset of the partition, hence I use a when clause and set category=='Y' and then execute the rank. However, I did not expect the result below. Where I expected rank=1 it is in fact rank=2.</p> <p>How can I achie...
<python><pyspark>
2024-09-11 20:13:37
1
1,255
Henri
78,975,435
23,260,297
float values not displaying decimal places when using pandas to_sql()
<p>I am inserted values into a table using <code>df.to_sql()</code> function, but the values are not being displayed properly in SQL Server.</p> <p>At the top of my script I use:</p> <pre><code>pd.options.display.float_format = '{:,.4f}'.format </code></pre> <p>and when I print my dataframes all is well:</p> <pre><code...
<python><sql-server><pandas><sqlalchemy>
2024-09-11 19:25:43
1
2,185
iBeMeltin
78,975,421
1,924,830
How do I filter across multiple model relationships?
<p>My models:</p> <pre><code>class Order (models.Model): customer = models.ForeignKey(&quot;Customer&quot;, on_delete=models.RESTRICT) request_date = models.DateField() price = models.DecimalField(max_digits=10, decimal_places=2) @property def agent_name(self): assignment = Assignment.objec...
<python><django><sqlite><django-models><django-views>
2024-09-11 19:22:04
5
303
grover999
78,975,219
4,749,639
Maintaining order in polars data frame after `partition_by`
<p>Does <code>polars.DataFrame.partition_by</code> preserves the order of rows <strong>within</strong> each group?</p> <p>I understand that <code>group_by</code> does, even when <code>maintain_order=False</code>. From <a href="https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.group_by.html...
<python><python-polars>
2024-09-11 18:17:34
1
307
jcsun
78,974,811
16,155,080
Resource exhaustion and SSLTransport errors with FastAPI websocket shared between multiples threads
<p>I am developing a back-end FastAPI server that is a game.</p> <p>All players connect and interact with the game via a Websocket in the main thread.</p> <p>The game has multiples categories that are all running in a separate thread with the websocket as a common parameter. Input messages are received in the main thre...
<python><multithreading><websocket><fastapi>
2024-09-11 16:22:21
0
641
Jules Civel
78,974,795
2,386,113
Caching in python is working slower than without caching
<p>In a Python program, I have to load a couple of thousands of files. I want to maintain their cache. I am able to create the cache using <code>joblib</code>. But for me, the program loads the data faster if I disable the caching.</p> <p><strong>Step to run MWE:</strong></p> <ul> <li>For my MWE, <a href="https://githu...
<python><python-3.x><caching><joblib>
2024-09-11 16:18:51
0
5,777
skm
78,974,468
865,220
scipy smoothening issue with zero values in window
<p>I have a pandas dataframe like this:</p> <pre><code>1960-09-01 24027064 4503904.333 1960-10-01 18020298 3377928.25 1960-11-01 12013532 2251952.167 1960-12-01 6006766 1125976.083 1961-01-01 0 0 1961-02-01 0 0 1961-03-01 0 0 1961-04-01 0 0 1961-05-01 0 0 1961-06-01 0 0 1961-07-01 0 ...
<python><pandas><scipy>
2024-09-11 14:55:17
1
18,382
ishandutta2007
78,974,451
9,177,877
How to map scores from one table to another when the cell contains operators
<p>I performed OLS regression on a dataset and I have the predicted <code>Diagnostic_Score</code> but the mapping table (<code>norms</code>) can have two operators - e.g. <code>&gt;=</code> and <code>&lt;=</code>. Is there a way to map the predicted score to the percentile?</p> <p>My first thought was to map the scores...
<python><pandas>
2024-09-11 14:52:32
2
14,163
It_is_Chris
78,974,386
5,269,892
Pandas avoid element-wise NaN check for lists
<p>I have a dataframe with columns containing both single NaNs, as well as lists which may contain NaN elements. Example:</p> <pre><code>df = pd.DataFrame({'A': [[1, 2, 3], np.nan, [7, np.nan, np.nan], [4, 5, 6]]}) </code></pre> <p>I want to check whether the cell values are single NaNs. The expected result of <code>[F...
<python><pandas><nan>
2024-09-11 14:40:44
1
1,314
silence_of_the_lambdas
78,974,328
9,401,990
How to install latest Python patch on older versions?
<p>I've had a look online and can't figure out how to install the latest patch on an older version of Python.</p> <p>I'm on Windows, with no admin rights. I want to upgrade 3.10.1 to 3.10.15, without losing any of my installed libraries (like pandas). I don't want to upgrade to the latest minor version (3.12.x).</p> <p...
<python><windows>
2024-09-11 14:26:03
0
1,408
Theo F
78,974,282
13,570,788
Why is sys.stdout adjustment needed to print Unicode in Python?
<p>I scraped some data from the web using: <br></p> <pre><code>import requests from bs4 import BeautifulSoup def get_lines_from_url(url): response = requests.get(url) if response.status_code == 200: soup = BeautifulSoup(response.text, 'html.parser') lines = soup.get_text(&quot;\n&quot;).strip...
<python><web-scraping><beautifulsoup><unicode><codec>
2024-09-11 14:15:13
0
485
Kun.tito
78,974,186
11,092,636
Sphere Online Judge (SPOJ) Python input handling broken?
<p>I'm fairly familiar with input handling in Competitive Programming settings, but I can't make it work in Python for this problem (<a href="https://www.spoj.com/problems/MINDIST/" rel="nofollow noreferrer">https://www.spoj.com/problems/MINDIST/</a>) (my solution works in C++ so the problem in itself is not broken). W...
<python><stdin>
2024-09-11 13:53:37
1
720
FluidMechanics Potential Flows
78,974,149
10,425,150
Alternative to fillna(method='pad', inplace=True) to avoid FutureWarning
<p>I would like to fill NA/NaN values with the last valid option.</p> <p><strong>My code:</strong></p> <pre><code>import pandas as pd import numpy as np df = pd.DataFrame({&quot;Col1&quot;:[&quot;A&quot;, np.nan, 1, np.nan], &quot;Col2&quot;:[&quot;B&quot;, np.nan, &quot;C&quot;, np.nan]}) df.fillna...
<python><pandas><dataframe><fillna>
2024-09-11 13:45:30
1
1,051
GΠΎΠΎd_MΠ°n
78,974,111
534,238
What windowing constraints are needed when combining two streams in Apache Beam [Dataflow]?
<p>I have an ETL flow where I need to combine two Pub/Sub messages on a key and write these into BigQuery. One of the message types is the parent; I am working on payment processing, and this is an order or a payment, for example. The other is the child; this is an update to the payment (&quot;Authorized&quot;, &quot;P...
<python><google-cloud-dataflow><apache-beam>
2024-09-11 13:36:27
1
3,558
Mike Williamson
78,974,009
2,287,458
Polars pl.col(field).name.map_fields applies to all struct columns (not the one specified)
<p>I have this code:</p> <pre class="lang-py prettyprint-override"><code>import polars as pl cols = ['Delta', 'Qty'] metrics = {'CHECK.US': {'Delta': {'ABC': 1, 'DEF': 2}, 'Qty': {'GHIJ': 3, 'TT': 4}}, 'CHECK.NA': {}, 'CHECK.FR': {'Delta': {'QQQ': 7, 'ABC': 6}, 'Qty': {'SS': 9, 'TT': 5}} ...
<python><dataframe><python-polars>
2024-09-11 13:17:40
1
3,591
Phil-ZXX
78,973,872
536,262
plotly scatterplot on top of annotation
<p>Any way to get an annotation below/under a scatter plot, so that the scatter-points show on top of the annotation text/link?</p> <p>I tried with <code>zorder=100</code> in <code>scatter</code>, but there is no <code>zorder</code> in <code>add_annotation()</code></p> <p>Below are the annotation and the scatter settin...
<python><plotly>
2024-09-11 12:49:54
1
3,731
MortenB
78,973,639
3,879,857
Python pydantic validation of subclasses
<p>I'm trying to use <code>pydantic</code> together with <code>ABC</code>. I created a base class <code>Datasource</code> and four subclasses:</p> <pre><code>from pydantic import BaseModel from typing import Literal, Union, TypeVar from devtools import debug from abc import ABC, abstractmethod class Datasource(ABC, B...
<python><subclass><pydantic><type-variables>
2024-09-11 11:51:09
0
887
MaPo
78,973,619
9,448,637
How can I stop pandas from plotting weekend dates for 5T frequency data when there is no weekend data?
<p>I have the following 5-minute frequency time series data for weekdays only:</p> <pre><code>start_date = '2024-09-06 00:00:00' end_date = '2024-09-10 00:00:00' dt_index = pd.date_range(start=start_date, end=end_date, freq='5T') dt_index = dt_index[dt_index.weekday &lt; 5] # remove weekend days data = np.random.randn...
<python><pandas><matplotlib><datetime>
2024-09-11 11:46:10
1
641
footfalcon
78,973,374
1,348,691
transfomers runtimeError `No module named 'keras.__internal__`
<p>I have these installed:</p> <pre><code>keras 3.5.0 tensorflow 2.17.0 tensorflow-intel 2.17.0 tensorflow-io-gcs-filesystem 0.31.0 torch 2.2.2 </code></pre> <p>And transformers results an error:</p> <pre><code>from transformers import pip...
<python><pytorch><tf.keras>
2024-09-11 10:43:03
0
4,869
Tiina
78,973,371
1,103,752
How to prevent `pip install` resulting in duplicate code?
<p>I am working on a library with some others. Our git repo (called <code>modulename</code>) looks like this</p> <pre><code>modulename/ src_file_1.py src_file_2.py tests/ ... .../ </code></pre> <p>The instructions are to clone this somewhere in home, so I now have</p> <pre><code>~/ modulename/ modulename/ ...
<python><pip><python-module>
2024-09-11 10:42:22
1
5,737
ACarter
78,973,154
9,663,207
How do I create a Python API client which executes *some* methods asynchronously in the background?
<p>I have this (example) REST API client:</p> <pre class="lang-py prettyprint-override"><code>import requests class FakeHttpClient: base_url = &quot;https://api.example.com&quot; def __init__(self) -&gt; None: self.session = requests.Session() def get_user_info(self, user_id: str) -&gt; dict: ...
<python><asynchronous><python-requests><aiohttp>
2024-09-11 09:57:02
2
724
g_t_m
78,973,117
5,790,653
How to check if a subject is not in the all_subjects of emails
<p>I have a list of email subjects which were sent today (I connect to my IMAP server, and fetch all emails):</p> <pre class="lang-py prettyprint-override"><code>sent_subjects = [ 'subject1 backup up completed', 'subject2-2 backup failed', 'subject4 backup partial complete', 'email3 done', 'ak47 failed', 'mp5 is go...
<python><json><imap>
2024-09-11 09:52:08
1
4,175
Saeed
78,973,039
10,377,244
Efficiently generate user history with negative sampling for recommendation system using Polars API
<p>I’m working on a recommendation system, and I need to efficiently generate user history with negative sampling using the Polars API. I have two datasets:</p> <ol> <li>User-Article Interactions: β€’ This dataset contains the user_id and the article_id of articles that the user has read. Example:</li> </ol> <pre class...
<python><python-polars>
2024-09-11 09:35:11
1
1,127
MPA
78,973,036
5,688,247
Read csv without filling up empty values
<p>I have the following csv I want to read into Python (Spyder) and count the amount of blank values in column 2:</p> <div class="s-table-container"><table class="s-table"> <thead> <tr> <th>column 1</th> <th>column 2</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>N/A</td> </tr> <tr> <td>B</td> <td>N/A</td> </tr> <tr> ...
<python><pandas><read-csv>
2024-09-11 09:34:56
1
863
Jellyse
78,972,997
1,581,090
How to use "threading" in python in an unblocking way?
<p>I have a complete &quot;working&quot; python code which is supposed to contain two threads which run simultaneously, which populate some lists in a dict, and when the user presses CRTL-C these two threads should be stopped and some output from both threads should be written to a file:</p> <pre><code>import sys impor...
<python><multithreading>
2024-09-11 09:26:49
1
45,023
Alex
78,972,996
3,414,626
AWS Python Lambda - Package Size & Cold Starts
<p>I was wondering whether someone here shared the same experience.</p> <ul> <li>I have a Python Lambda which runs some β€œsimple” requests for recommending images based on a vector database (qdrant). The package itself already has a size of 65MB (e.g. qdrant client and firebase).</li> <li>Although I turned on provision...
<python><amazon-web-services><aws-lambda><cold-start>
2024-09-11 09:26:48
1
552
Richard
78,972,680
4,451,315
pyarrow chunkedarray get items at given indices
<p>Say I have</p> <pre class="lang-py prettyprint-override"><code>In [3]: import pyarrow as pa In [4]: ca = pa.chunked_array([[1,2,3], [4,5,6]]) </code></pre> <p>I'd like to extract elements <code>[1, 4, 2]</code> and end up with</p> <pre><code>&lt;pyarrow.lib.Int64Array object at 0x7f6eb43c2d40&gt; [ 2, 5, 3 ] ...
<python><pyarrow>
2024-09-11 08:07:12
1
11,062
ignoring_gravity
78,972,636
1,254,515
How to directly get the output of subprocess.check_output as valid json rather than reading the results stored in a file?
<p>I have a system command which produces json output: (<code>$ cmd -J &gt; file</code>). I can read this data perfectly well into a dict using:</p> <pre><code>with open(&quot;file&quot;, &quot;r&quot;) as i: data=json.loads(i) </code></pre> <p>I'd like to do the same thing without the intermediary file, directly g...
<python><json><python-3.x><subprocess>
2024-09-11 07:58:25
1
323
Oliver Henriot
78,972,427
3,555,115
Extract float values from string in Python
<p>I have a line as below and I need to extra the float values for SW A_done: and SW B_done:.</p> <pre><code>line = SW A_done: 191168 SW B_done: 27720 </code></pre> <p>I tried line.split(' ' ), and then look for value after A_done: but it seems to show lot of null values when SW A_done value is 0 and is not alwa...
<python>
2024-09-11 06:59:38
0
750
user3555115
78,972,393
3,405,291
Download location of Pytorch
<h1>Download fail</h1> <p>I'm running this Python code:</p> <p><a href="https://github.com/SimonGiebenhain/MonoNPHM/blob/05aafd8e7dbe3168bee7d5f93f47537acb877df3/scripts/preprocessing/run_facer.py#L153" rel="nofollow noreferrer">https://github.com/SimonGiebenhain/MonoNPHM/blob/05aafd8e7dbe3168bee7d5f93f47537acb877df3/s...
<python><pytorch>
2024-09-11 06:52:07
1
8,185
Megidd
78,972,381
5,197,329
read nested json inside csv file using pandas?
<p>I have a csv file that with rows that looks like this:</p> <pre><code>745198;2024-09-10 10:09:10.7;leaf-2;{&quot;Accelerometer&quot;: {&quot;X&quot;: 0.055297852, &quot;Y&quot;: 0.993530273, &quot;Z&quot;: 0.000244141}} 745199;2024-09-10 10:09:10.71;leaf-2;{&quot;Accelerometer&quot;: {&quot;X&quot;: 0.056274414, &qu...
<python><json><pandas><csv>
2024-09-11 06:49:41
2
546
Tue
78,972,238
4,851,073
Celery tasks with psycopg: ProgrammingError the last operation didn't produce a result
<p>I'm working on aproject in which I have</p> <ol> <li>A PostgreSQL 16.2 database</li> <li>A Python 3.12 backend using psycopg 3.2.1 and psycopg_pool 3.2.2.</li> <li>Celery for handling asynchronous tasks.</li> </ol> <p>The celery tasks uses the database pool through the following code:</p> <pre class="lang-py prettyp...
<python><postgresql><celery><psycopg3>
2024-09-11 06:01:38
1
810
Javierd98
78,972,160
604,128
Flask routing and connexion
<p>I have a flask application where I would like to add Connexion to validate my api endpoints. All api is bundled in a blueprint.</p> <p>My issue is that Connexion wants to control the routing. Either via connectionid in the OpenApi spec, which I find leaks implementation detail into a specification, or via a class sy...
<python><flask><connexion>
2024-09-11 05:29:24
1
512
Peer Sommerlund
78,972,135
1,795,641
How to access key and value from redis using RedisJSON module in python
<p>I have records stored like below in the Redis.</p> <pre><code>β€˜monitor':{'105894288': {'status': 'Screen', 'release': '23.4.5'}, '106521147': {'status': 'Screen', 'release': '23.4.5'}, '106521148': {'status': 'Screen', 'release': '23.4.5'}, '106521149': {'status': 'Screen', 'release': '23.4.6'} } </code></pre> <p...
<python><redis><redisjson>
2024-09-11 05:16:47
1
856
smm
78,972,060
24,758,287
How to extract values based on column names and put it in another column in polars?
<p>I would like to fill a value in a column based on another columns' name, in the Polars library from python (I obtained the following DF by exploding my variables' column names):</p> <p>Input:</p> <pre class="lang-py prettyprint-override"><code>df = pl.from_repr(&quot;&quot;&quot; β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”¬β”€...
<python><python-polars><exploded>
2024-09-11 04:30:00
5
301
user24758287
78,972,018
15,412,256
Polars Replacing Values of Other groups to the Values of a Certain Group
<p>I have the following <code>Polars.DataFrame</code>:</p> <pre class="lang-py prettyprint-override"><code>df = pl.DataFrame( { &quot;timestamp&quot;: [1, 2, 3, 1, 2, 3], &quot;var1&quot;: [1, 2, 3, 3, 4, 5], &quot;group&quot;: [&quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;b&quot;, &q...
<python><python-polars>
2024-09-11 04:03:03
2
649
Kevin Li
78,971,821
5,957,353
Different Starting Indices for Iterating over Large Files
<p>I want to begin by saying I have NOT programmed in many, many years, so sorry if this is a somewhat trivial question. My interest has been mathematics for the last couple of years</p> <p>Here's my code:</p> <pre><code>lastStop = False with open('K3.txt','r') as K3: with open('K4.txt','a') as K4: for tri...
<python><for-loop><large-files><pythonista>
2024-09-11 02:07:34
1
791
wyboo
78,971,796
3,325,401
How to use Hatch to run Python CLI
<p>I'm trying to work through a pretty basic &quot;hello world&quot; type of example to setup a Python CLI using the Hatch build system (which I understand uses the Click library under the hood).</p> <p>I've got a minimally reproducible example below, and the error I'm running into appears below the following code snip...
<python><command-line-interface><hatch>
2024-09-11 01:50:23
1
2,767
hobscrk777
78,971,681
3,486,684
How can I import Polars type definitions like `JoinStrategy`?
<p><code>JoinStrategy</code> is an input to <code>join</code>: <a href="https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.join.html" rel="nofollow noreferrer">https://docs.pola.rs/api/python/stable/reference/dataframe/api/polars.DataFrame.join.html</a></p> <p>My static type checking tool s...
<python><python-polars>
2024-09-11 00:23:31
1
4,654
bzm3r
78,971,666
2,612,259
Why does Pylance not complain about missing members of a Protocol?
<p>I am using Pylance with vscode and have set the type checking mode to 'strict'</p> <p>My understanding is that Pylance should flag Bar as not conforming to the Foo Protocol because of the commented foo method in Bar, but it does not.</p> <p>I if uncomment the line it does correctly complain that 'Method &quot;foo&qu...
<python><python-typing><pyright>
2024-09-11 00:11:31
2
16,822
nPn
78,971,520
8,652,920
How to disconnect from socket after connecting using socket.socket.connect_ex?
<p>I was following the instructions from this answer on how to check network ports in python: <a href="https://stackoverflow.com/a/19196218/8652920">https://stackoverflow.com/a/19196218/8652920</a></p> <p>for posterity I'll just repost it</p> <pre class="lang-py prettyprint-override"><code>import socket sock = socket.s...
<python><python-3.x><sockets><port>
2024-09-10 22:37:24
0
4,239
notacorn
78,971,477
14,684,366
Transform a list of dictionaries, based on key list
<p>In Python 3.9, I have a list of dictionaries:</p> <pre><code>variables = [ {'id': ['alpha'], 'ip': '10.10.10.10', 'name': 'primary'}, {'id': ['beta', 'gamma'], 'ip': '10.10.10.20', 'name': 'secondary'} ] </code></pre> <p>My goal is to transform it into this dictionary format:</p> <pre><code>result = { 'a...
<python><dictionary>
2024-09-10 22:15:31
2
591
Floren
78,971,452
10,471,715
Why Do Two Similar Code Snippets Yield Different Results for Symbolic Equations?
<p>I am calculating (what seems to me) the same thing in two ways but am getting different results. I'd appreciate any help in understanding the reason behind this.</p> <p>I have a list of symbolic equations, each defined as:</p> <p>a<sub>1</sub> * x<sub>1</sub> + a<sub>2</sub> * x<sub>2</sub> + ... + a<sub>30</sub> * ...
<python><math><sympy><symlink><equation-solving>
2024-09-10 21:59:56
1
504
Hamid Reza
78,971,412
7,700,802
How to measure new change in data
<p>Suppose you have this dataframe</p> <pre><code>d = {'date':['2019-08-25', '2019-09-01', '2019-09-08'], 'data':[31, 31, 31]} df_sample = pd.DataFrame(data=d) df_sample.head() </code></pre> <p>and you want to measure how much new data comes in on average each week. For example, we had 31 new rows on 8/25 and then ...
<python><pandas>
2024-09-10 21:40:12
1
480
Wolfy
78,971,305
3,050,730
How can I optimize the performance of this numpy function
<p>Is there any way optimizing the performance speed of this function?</p> <pre class="lang-py prettyprint-override"><code>def func(X): n, p = X.shape R = np.eye(p) delta = 0.0 for i in range(100): delta_old = delta Y = X @ R alpha = 1. / n Y2 = Y**2 Y3 = Y2 * Y ...
<python><numpy><performance><optimization><numba>
2024-09-10 20:49:57
1
523
nicrie
78,971,143
51,816
How to draw grid planes uniformly using matplotlib?
<p>Basically I have this code:</p> <pre><code>import matplotlib.pyplot as plt import numpy as np from itertools import product, combinations fig = plt.figure() ax = fig.add_subplot(1,1,1,projection='3d') </code></pre> <p>but that gets me this result:</p> <p><a href="https://i.sstatic.net/bZtvGNeU.png" rel="nofollow no...
<python><matplotlib><matplotlib-3d>
2024-09-10 19:57:12
1
333,709
Joan Venge
78,970,926
850,781
Multi-dimensional scipy.optimize.LinearConstraint?
<p>My linear constraint for <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html" rel="nofollow noreferrer"><code>scipy.optimize.minimize</code></a> is</p> <pre><code>ones = np.ones_like(x) np.outer(x, ones) - np.outer(ones, x) &gt; something </code></pre> <p>where <code>something<...
<python><numpy><scipy><scipy-optimize>
2024-09-10 18:52:40
2
60,468
sds
78,970,691
22,407,544
Is it possible to pause celery tasks during execution
<p>I have an app that does transcription. I want that if the user tries to reload they are alerted that reloading will stop their task from completing. I tried to use it with <code>unload</code> but it didn't work most of the time and I know that it is inconsistent. I would like to pause the task if the user tries to r...
<javascript><python><django><celery>
2024-09-10 17:40:39
0
359
tthheemmaannii
78,970,689
3,417,179
Gekko : Error in Resource Optimisation problem
<p>I am working on a optimisation problem and I am using Gekko to solve it. Consider the scenario where there are 2 machines and 5 users and each machines has 2 resources to distribute to users. The user gain some points based on the number of resource allocated. Also there are certain demands from the user before reso...
<python><linear-programming><nonlinear-optimization><gekko><mixed-integer-programming>
2024-09-10 17:38:58
1
1,516
Alok
78,970,536
4,451,315
pyarrow chunkedarray set at indices
<p>Say I have</p> <pre class="lang-py prettyprint-override"><code>In [1]: import pyarrow as ap In [2]: import pyarrow as pa In [3]: ca = pa.chunked_array([[1,2,3], [4,5,6]]) In [4]: ca Out[4]: &lt;pyarrow.lib.ChunkedArray object at 0x7f7afaaa4a90&gt; [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] </cod...
<python><pyarrow>
2024-09-10 16:52:08
2
11,062
ignoring_gravity
78,970,400
3,486,684
Using Polars, how do I do efficiently do an `over` that collects items into a list?
<p>As a simple example, consider the following, using <code>groupby</code>:</p> <pre class="lang-py prettyprint-override"><code>import polars as pl df = pl.DataFrame( [pl.Series(&quot;id&quot;, [&quot;a&quot;, &quot;b&quot;, &quot;a&quot;]), pl.Series(&quot;x&quot;, [0, 1, 2])] ) print(df.group_by(&quot;id&quot;)....
<python><dataframe><python-polars>
2024-09-10 16:16:29
1
4,654
bzm3r