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 ⌀ |
|---|---|---|---|---|---|---|---|---|
76,231,965 | 1,783,793 | Add hint of duration for each iteration in tqdm | <p>I have a list of tasks that each take a different amount of time. Let's say, I have 3 tasks, with durations close to 1<em>x, 5</em>x, 10*x. My tqdm code is something like:</p>
<pre class="lang-py prettyprint-override"><code>from tqdm import tqdm
def create_task(n):
def fib(x):
if x == 1 or x == 0:
... | <python><tqdm> | 2023-05-11 22:21:29 | 2 | 2,634 | fegemo |
76,231,956 | 5,942,100 | Separate numerical values from alphabetic characters within a column as well as expand dates | <p>I would like to separate the numerical values from the alphabetic characters within a column as well as to expand the quarters in a date.</p>
<p><strong>Data</strong></p>
<pre><code>state stat1 type stat2 qtr
NY up AAA01 Gr Q1 24
NY up AAA02 Re Q1 24
NY up BB01 ... | <python><pandas> | 2023-05-11 22:19:10 | 1 | 4,428 | Lynn |
76,231,859 | 12,820,223 | Chunking misses out some files | <p>I have 10000 files which I'm trying to split into 7 chunks and create simlinks to in a different place. For some reason, the last chunk ends up with exactly the same number of files as the other chunks, even though 10000 doesn't divide by 7 so it should have four extra. Why is this happening and how can I fix it?</p... | <python><python-2.7> | 2023-05-11 21:58:59 | 1 | 411 | Beth Long |
76,231,846 | 1,750,360 | Overriding not working when calling method using reference name | <p>My primary goal was to have a dictionary to select method to run. It was easy to do per <a href="https://stackoverflow.com/a/9168387/1750360">this</a> suggestion.
But now I am somehow blocked on using the inheritance concept to call child overridden method.</p>
<pre><code>class A():
def sum(self, id: int):
... | <python> | 2023-05-11 21:56:40 | 1 | 1,631 | pxm |
76,231,804 | 2,698,972 | How to modularize code into multiple files with access to app decorators in FastAPI | <p>I want to distribute my FastAPI code into multiple files so as to make it clear for team, so instead of using decorator i tried using APIRoute , but in this way I can't use FastAPI decorator in other file.
Lets say I have my <code>main.py</code> like this</p>
<pre><code>... import statements
rts = [
APIRoute(&q... | <python><python-3.x><fastapi> | 2023-05-11 21:46:00 | 1 | 1,041 | dev |
76,231,768 | 1,118,236 | Keras change the layer names of a save model and get ValueError Graph disconnected | <p>I would like to change layer names of a trained and saved Keras(2.3.1) model as follows: user_embedding_123 and item_embedding_284 are the only two Input layers of the model.</p>
<pre><code>from keras.models import load_model, save_model
from keras.layers import Input, Dense
from keras.models import Model
model = l... | <python><keras><tf.keras> | 2023-05-11 21:37:37 | 1 | 4,041 | Munichong |
76,231,751 | 945,939 | Python script using subprocess run has different output when run directly in Powershell than when run in Jenkins | <p>I have a python script that runs a git command <code>git log --pretty=format:%H branch -n 20</code></p>
<p>It runs the command using <code>process = subprocess.Popen(commandLine, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)</code></p>
<p>When we run the git command in powershell directly, or through t... | <python><powershell><jenkins> | 2023-05-11 21:33:38 | 1 | 599 | James |
76,231,449 | 9,161,607 | How to transform the data based on the column name | <p>I am trying to transform my <code>df</code> where some of the column names are melted in wide-to-long form.</p>
<p>My <code>df</code> looks like this:</p>
<pre><code>id, university, # CA Holiday, # CA Hours, # WA Holiday, # WA Hours
1 abc 1 5 NA 3
2 def 5... | <python><pandas> | 2023-05-11 20:41:41 | 2 | 2,793 | floss |
76,231,351 | 10,794,031 | How to apply @enum.nonmember? | <p>I was trying to come up with a use case for the new <a href="https://docs.python.org/3/library/enum.html#enum.nonmember" rel="noreferrer"><code>@enum.nonmember</code></a> decorator in Python 3.11. The docs clearly mention it is a decorator meant to be applied to members.
However, when I tried literally decorating a ... | <python><enums><python-decorators><python-3.11> | 2023-05-11 20:20:07 | 1 | 13,254 | bad_coder |
76,231,321 | 5,563,584 | Converting a numpy image array based on a boolean mask | <p>I have 2 numpy arrays. One is a 3D integer array (image RGB values) with dimensions (988, 790, 3) and the other is a mask boolean array with the same shape. I want to use the mask to convert False values in the image array to black and leave true values as is.</p>
<p>I tried <code>(image & mask)</code> which app... | <python><python-3.x><numpy><numpy-ndarray> | 2023-05-11 20:14:59 | 2 | 327 | greenteam |
76,230,996 | 11,956,484 | Replace float values with strings based on two different conditions | <p>In my df I have a column of results:</p>
<pre><code>Results
755
1065
2733
40
116
241
345
176
516
5000
</code></pre>
<p>What I would like to do is replace all values <=55 with the string Low and all values >=3500 with the string High, retaining all other values. So the end result would be:</p>
<pre><code>Resul... | <python><pandas> | 2023-05-11 19:21:11 | 3 | 716 | Gingerhaze |
76,230,979 | 6,591,677 | OpenAI turbo-3.5 API returning error with complex prompts | <p>With simple prompts like "Hey" or "Tell me [this]" or "Summarize [this]", it works fine. But when I run more complex prompts like "List this and that and explain...", it breaks. There's no other change besides the complexity. The error message:
<code>APIConnectionError: Error ... | <python><python-3.x><openai-api><chatgpt-api> | 2023-05-11 19:19:02 | 0 | 479 | superbot |
76,230,931 | 219,153 | What is the way to mutate 2D array with Python multiprocessing? | <p>I was expecting that array <code>a</code> will be mutated in this Python 3.11 script:</p>
<pre><code>import multiprocessing as mp
def incr(a):
for i in range(len(a)):
a[i] += 1
if __name__ == "__main__":
a = mp.Manager().list([[0, 1, 2], [3, 4, 5]])
with mp.Pool(2) as pool:
pool.map(inc... | <python><python-multiprocessing> | 2023-05-11 19:11:12 | 1 | 8,585 | Paul Jurczak |
76,230,846 | 8,618,242 | How to increase the accuracy of my model fitting using Scipy Optimization | <p>I want to make a curve fitting of the following data:
<a href="https://github.com/vuillaut/datascience_intro/blob/main/Scipy/data/munich_temperatures_average.txt" rel="nofollow noreferrer">munich_temperatures_average.txt</a></p>
<p>I have tried:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
... | <python><scipy><scipy-optimize><model-fitting> | 2023-05-11 18:58:10 | 1 | 4,115 | Bilal |
76,230,831 | 964,143 | Can you use a custom script to activate a python environment in vs code? | <p>Is it possible to set a custom activate script to active a Python environment, on terminal launch, in VS Code.</p>
<p>Right now, it uses the normal activate script, e.g. <code>/Users/..../my_python/bin/activate</code></p>
<p>It would be nice to be able to run another script that also does other things as part of ter... | <python><visual-studio-code> | 2023-05-11 18:56:01 | 1 | 674 | BrainPermafrost |
76,230,795 | 918,866 | Replace characters with a count of characters | <p>I have <code>XXXXXXX99</code> and I'd like to replace it with <code>X(7)99</code> because there are 7 <code>X</code> characters followed by <code>99</code>.</p>
<pre><code>>>> import re
>>> s = "XXXXXXX99"
>>> re.sub(r"(X+)", "X(the count)", s)
'X(the count)99... | <python><regex> | 2023-05-11 18:50:29 | 4 | 1,701 | jsf80238 |
76,230,597 | 1,631,306 | converting RGB to HSV looses the boundary | <p>I have following image
<a href="https://i.sstatic.net/ySbFl.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ySbFl.png" alt="enter image description here" /></a></p>
<p>and I want to generate the mask for the area under green color. My code is following:</p>
<pre><code> img = cv2.imread(path + file,... | <python><image><opencv><image-processing> | 2023-05-11 18:20:49 | 1 | 4,501 | user1631306 |
76,230,596 | 9,983,652 | no minor tick setting for plotly go.Figure? | <p>when using plotly express, we can set minor tick like below post</p>
<p><a href="https://stackoverflow.com/questions/73756610/how-to-set-minor-ticks-in-plotly">How to set minor ticks in plotly</a></p>
<p>However, when using go.Figure(), It tried like in below manual and I got an error, so how to set minor tick for d... | <python><plotly> | 2023-05-11 18:20:35 | 1 | 4,338 | roudan |
76,230,417 | 10,284,437 | Python3, Selenium4 how to open a new 'TAB' from particular node? | <p>In Selenuim4 I have an input node that do a POST request when you click on it.</p>
<p>By default, it change the current window.</p>
<p>I prefer to open a new TAB to process this page and latter, return to main page to avoid</p>
<pre><code>selenium.common.exceptions.StaleElementReferenceException:
Message: stale elem... | <python><selenium-webdriver><selenium-chromedriver> | 2023-05-11 17:56:27 | 1 | 731 | Mévatlavé Kraspek |
76,230,297 | 482,819 | Necessity of TypeAlias in Python | <p>I am trying to understand in which cases <code>TypeAlias</code> is necessary in Python. Consider the following code:</p>
<pre class="lang-py prettyprint-override"><code>class Internal:
def f(self):
print("Hello!")
class Container:
internal = Internal
RenamedInternal = Internal
ContainerInternal... | <python><class><alias><typing> | 2023-05-11 17:40:02 | 0 | 6,143 | Hernan |
76,230,187 | 4,377,095 | In Pandas DataFrame how can I increment the values per row if it matches a character | <p>This is somewhat similar to <a href="https://stackoverflow.com/questions/76211854/in-pandas-how-can-i-increment-values-correctly-for-each-row-and-column/76212089#76212089">this</a> question but a little bit complex.</p>
<p>Assuming I have this table:</p>
<pre><code>data = {'column1': ['A1', 'A1', 'A1', 'A1'],
... | <python><pandas><dataframe> | 2023-05-11 17:26:06 | 2 | 537 | Led |
76,230,176 | 5,069,105 | Load Python standard module from Modular Mojo | <p>From the available information and docs, Mojo claims to be fully compatible with Python syntax and modules.</p>
<p>However, from the <a href="https://www.modular.com/mojo" rel="nofollow noreferrer">Playground notebook</a>, I can't seem to be able to load any module from Python:</p>
<pre><code>In:
import os
import ti... | <python><mojolang> | 2023-05-11 17:24:46 | 1 | 1,789 | Raf |
76,230,150 | 19,675,781 | How to display intersection values instead of distinct values in Upset plot | <p>I tried to create an upset plot and display intersection among different sets. <br />
But my upset plot is displaying dinstinct value counts among sets. <br />
How do I change it to intersections instead of distinct counts?</p>
<p>This is my code:</p>
<pre><code>mammals = ['Cat', 'Dog', 'Horse', 'Sheep', 'Pig', 'Cat... | <python><python-3.x><visualization><upsetplot> | 2023-05-11 17:21:27 | 1 | 357 | Yash |
76,230,112 | 12,820,223 | Fast copying of files with two different names | <p>Edit: I've changed the names of the data so that they're all the same
Edit: I decided to use a symlink as suggested in the comments, but now <code>SeventhList</code> is too short, it has 1428 elements in it when it should have 1432 elements. Why is this and how can I change it? <code>len(AllFileList)</code> is 10000... | <python><optimization><copy> | 2023-05-11 17:15:49 | 0 | 411 | Beth Long |
76,230,067 | 13,132,640 | Numpy conditional but only in some indices? | <p>I have an array of shape [10,200,50]. I would like to replace all values which are:</p>
<ol>
<li>Greater than 33</li>
<li>Fall within a set of indices on the third axis: indices=[0,1,15,20,19]</li>
</ol>
<p>So - any value which has any of those indices on axis 3 AND is greater than 33 will be replaced by the number ... | <python><numpy> | 2023-05-11 17:08:02 | 1 | 379 | user13132640 |
76,230,057 | 7,179,546 | Use keyFile in mongo5 | <p>I'm trying to set up Mongo5 with docker-compose and it's failing for me. I'm using pymongo 3.13.0 and motor 2.5 in the application that attaches to this Mongo</p>
<p>My Dockerfile:</p>
<pre><code>FROM mongo:5.0
RUN mkdir /keys
COPY src/setup/replica.key /keys/replica.key
RUN chown 999:999 /keys/replica.key
RUN chmod... | <python><mongodb> | 2023-05-11 17:06:54 | 0 | 737 | Carabes |
76,230,048 | 5,179,643 | Pandas: selecting specific rows and specific columns using .loc() and/or .iloc() | <p>I have a Pandas dataframe that looks like this:</p>
<pre><code>df = pd.DataFrame ({
'id': [1, 17, 19, 17, 22, 3, 0, 3],
'color': ['Green', 'Blue', 'Orange', 'Yellow', 'White', 'Silver', 'Purple', 'Black'],
'shape' : ['Circle', 'Square', 'Circle', 'Triangle', 'Rectangle', 'Circle', 'Square', 'Triangle'],
'person... | <python><pandas> | 2023-05-11 17:06:17 | 2 | 2,533 | equanimity |
76,229,976 | 1,056,563 | How to use check if a pytest patched method were invoked [and with which parameters]? | <p>How can a <em>patch()</em> object be used to check if the method it represents had been invoked?
The following is pseudocode for the intended task</p>
<pre><code> from unittest.mock import patch
# "filter" is a method on BlobFilter class
mpatch = patch('platform.blob_reader... | <python><mocking><pytest> | 2023-05-11 16:55:18 | 1 | 63,891 | WestCoastProjects |
76,229,957 | 578,721 | How to increase a number within a lambda in Python? | <p>It is possible to increase a number object like <code>int</code> within a lambda function?</p>
<p>Imagine having a peek function like:</p>
<pre class="lang-py prettyprint-override"><code>def _peek(cb, iter):
for i in iter:
cb(i)
</code></pre>
<p>How can I peek and add these values to a sum like in this f... | <python><lambda> | 2023-05-11 16:52:44 | 2 | 450 | Mike Reiche |
76,229,874 | 3,247,006 | How to save "Shipping address" to fill it automatically every time I go to Stripe Checkout with Django? | <p>I set <a href="https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-shipping_address_collection" rel="nofollow noreferrer">shipping_address_collection</a> in <strong>Django View</strong> as shown below:</p>
<pre class="lang-py prettyprint-override"><code># "views.py"
import stripe
... | <python><django><django-views><stripe-payments><python-stripe-api> | 2023-05-11 16:42:32 | 2 | 42,516 | Super Kai - Kazuya Ito |
76,229,805 | 817,659 | Pandas DataFrame arithmetic | <p>Say you have a <code>DataFrame</code> with n rows, in this case 3 rows:</p>
<pre><code> High Low
0 100 90
1 110 95
2 105 80
</code></pre>
<p>I would like to compute the biggest difference between a row, and it's subsequent rows as follows.</p>
<p>So for example, the first computation is the High ... | <python><pandas><functional-programming> | 2023-05-11 16:32:51 | 3 | 7,836 | Ivan |
76,229,790 | 1,780,761 | python slowing down every minute or so on windows | <p>I have a clean windows pc, with just python and the bear minimum installed. the problem i am facing is that every 3/4 minutes the execution of my python code slows down by a factor of 3 for a few seconds. it looks like the OS is taking some CPU Power away from python. Its not affected by any specified function, it j... | <python><multithreading> | 2023-05-11 16:31:12 | 0 | 4,211 | sharkyenergy |
76,229,577 | 1,484,601 | How to report step failure if a test does not pass | <p>In a GitHub Actions workflow, I run pytest:</p>
<pre class="lang-yaml prettyprint-override"><code>- name: running pytest
run: poetry run pytest
</code></pre>
<p>When this is run on the server, one of the tests does not pass:</p>
<pre><code>Run poetry run pytest
============================= test session starts ===... | <python><pytest><github-actions> | 2023-05-11 16:02:43 | 1 | 4,521 | Vince |
76,229,471 | 7,085,162 | Read an excel file, manipulate the data but retain the original formatting using Pandas | <p>I have code that essentially reads an excel file, that excel file has a header / filter on the first few lines, then the columns are below that. I have to load that into a dataframe, apply a filter and then export out to a new excel.</p>
<p>The issue however is that once exported, I obviously loose the header/filter... | <python><pandas><excel><dataframe> | 2023-05-11 15:50:01 | 1 | 1,069 | William |
76,229,276 | 1,732,969 | AWS lambda boto3 invoke with file as payload | <p>I'm integrating a new AWS Lambda with an existent API running also in lambda. I want to call that API in lambda directly by instead of using postman.</p>
<p>Right now, I have a postman collection that calls the API lambda and then the flow starts. Now, I need to code that AWS lambda invoke from another lambda.</p>
<... | <python><amazon-web-services><amazon-s3><aws-lambda><boto3> | 2023-05-11 15:26:05 | 0 | 1,593 | eduardosufan |
76,229,274 | 7,337,831 | How to get last week number with year? | <p>I want to create a function that gives last week with the year</p>
<p>for example, the current week number is 19, so the function should give the result <code>2023_W18</code>. And the weeks should start from Monday to Sunday. So I run the script on Monday, and it will give last week's number.</p>
<p>I found a few ex... | <python> | 2023-05-11 15:25:53 | 2 | 4,526 | lucy |
76,229,246 | 6,141,688 | How to attribute an image in a variable in unix inside a python script | <p>I have this code:</p>
<pre><code>os.system('convert xc:red xc:black xc:white +append swatch.png')
os.system('convert red_1.jpg +dither -remap swatch.png start.png')
</code></pre>
<p>In first line I create a saved colored Image like this:</p>
<p>But I would like just to attribute this image a variable, without open t... | <python><unix><os.system> | 2023-05-11 15:22:20 | 1 | 347 | Greg Rov |
76,228,990 | 3,815,773 | Check which Python process is running 'myscript.py' on Windows, Linux | <p>Finding out that Python is running is rather easy. But how can I find out which Python process is the one running <code>myscript.py</code>?</p>
<p>I took help from this <a href="https://stackoverflow.com/questions/7787120/check-if-a-process-is-running-or-not-on-windows">Check if a process is running or not on Window... | <python><psutil> | 2023-05-11 14:56:06 | 1 | 505 | ullix |
76,228,791 | 2,562,058 | Conda 23.3.1: what shall be the content of build.sh? | <p>I found <code>grayskull</code> for creating <code>meta.yml</code> files and I found <a href="https://github.com/MichaelsJP/conda-package-publish-action" rel="nofollow noreferrer">this github action</a> for publishing on conda.</p>
<p>However, said github action require a build.sh file and according to <a href="https... | <python><anaconda><conda><miniconda> | 2023-05-11 14:31:55 | 1 | 1,866 | Barzi2001 |
76,228,787 | 16,383,578 | How to check if an IP address is reserved without using ipaddress module in Python? | <p>According to <a href="https://en.wikipedia.org/wiki/Reserved_IP_addresses" rel="nofollow noreferrer">Wikipedia</a>, the following are all the reserved IPv4 addresses:</p>
<pre><code>RESERVED_IPV4 = [
'0.0.0.0/8',
'10.0.0.0/8',
'100.64.0.0/10',
'127.0.0.0/8',
'169.254.0.0/16',
'172.16.0.0/12',... | <python><python-3.x><ip-address> | 2023-05-11 14:31:34 | 3 | 3,930 | Ξένη Γήινος |
76,228,595 | 2,562,058 | conda won't update environment through environment.yml | <p>I have an <code>environment.yml</code> file with the following content:</p>
<pre><code>channels:
- conda-forge
- defaults
dependencies:
- python=3.10
- pandas
- matplotlib
- control
- scipy
- pathlib
- numpy
- tomli
- sphinx
- furo
- sphinx-toolbox
- sphinx-autodoc-typehints
- pytest
... | <python><anaconda><conda><miniconda> | 2023-05-11 14:11:48 | 0 | 1,866 | Barzi2001 |
76,228,417 | 21,881,451 | "cannot import name 'EVENT_TYPE_OPENED' from 'watchdog.events' " | <p>I'm trying to make a REST api (begginer) but when i tried to initialize the server from this code:</p>
<pre><code>from flask import Flask
app = Flask(__name__)
if __name__=='__main__':
app.run(debug=True, port=4000)
</code></pre>
<hr />
<p>i get this error in the prompt:</p>
<pre><code> from watchdog.events im... | <python><flask><python-watchdog> | 2023-05-11 13:54:46 | 4 | 323 | brian valladares |
76,228,371 | 375,432 | Replace missing values with mean using Ibis | <p>How can I use <a href="https://ibis-project.org" rel="nofollow noreferrer">Ibis</a> to fill missing values with the mean?</p>
<p>For example, if I have this data:</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
import ibis
from ibis import _
ibis.options.interactive = True
df = pd.DataFrame... | <python><ibis> | 2023-05-11 13:50:00 | 1 | 763 | ianmcook |
76,228,323 | 14,385,814 | How to past multiple list from ajax to Django | <p>I have an issue which I want to get all the data from <code>list</code>, so I want to loop every single data from selected items and insert it to database,
currently it returns the data like this when I print it <code>['[object Object]', '[object Object]']</code>,
how can I insert these data one by one? or just prin... | <javascript><python><jquery><django><ajax> | 2023-05-11 13:44:59 | 1 | 464 | BootCamp |
76,228,297 | 7,465,516 | Is this PyCharm-inspection a false positive? "Cannot find reference '__class__' in 'None'" | <p>In my codebase there is some amount of <code>None.__class__</code>.
PyCharm marks this as as a warning:</p>
<blockquote>
<p><code>Cannot find reference '__class__' in 'None'</code></p>
</blockquote>
<p>I am using PyCharm 2022.3 (Community Edition) if that matters.</p>
<p>However, when I try it out in REPL I get this... | <python><intellij-idea><pycharm><nonetype> | 2023-05-11 13:41:00 | 2 | 2,196 | julaine |
76,228,147 | 4,681,355 | Python selenium browser accepts cookies and returns`AttributeError` | <p>I'm scraping data from a sports website. This is one of the pages, where the code gets stuck:</p>
<p><a href="https://www.unitedrugby.com/clubs/dhl-stormers/kwenzo-blose" rel="nofollow noreferrer">https://www.unitedrugby.com/clubs/dhl-stormers/kwenzo-blose</a></p>
<p>When opening it with an incognito browser you'll ... | <python><parsing><selenium-webdriver><web-scraping> | 2023-05-11 13:25:15 | 2 | 622 | schmat_90 |
76,228,098 | 2,386,113 | How to update Spyder from version 5.4.1 to 5.4.3 with anaconda? [SSL: CERTIFICATE_VERIFY_FAILED] | <p>I am absolutely new to the installation of python IDE. I want to use the latest version of Spyder. To do that, I installed <strong>anaconda</strong>, with which Spyder is bundled together.</p>
<p>When I opened the Spyder, I got the messagebox (screenshot below) that I should update my Spyder version:</p>
<p><a href=... | <python><anaconda><spyder> | 2023-05-11 13:18:56 | 1 | 5,777 | skm |
76,228,059 | 15,569,921 | 3D surface plot with different length of arrays | <p>I want to create one 3D surface plot while the length of the arrays for each iteration is different hence different length of axis. I have a working example here for better understanding. You notice that <code>J</code> is dependent on <code>M</code> so the length of arrays in each iteration is different. When I plot... | <python><matplotlib><3d><matplotlib-3d> | 2023-05-11 13:14:19 | 0 | 390 | statwoman |
76,227,987 | 1,934,212 | Get list of files within a time range based on file names containing timestamps | <p><a href="https://replit.com/@ralphfehrer/GlobFilesWithinFileRange?v=1" rel="nofollow noreferrer">A simplified python project</a> with the structure</p>
<p><a href="https://i.sstatic.net/tQMvh.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/tQMvh.png" alt="enter image description here" /></a></p>
<p>Co... | <python><glob> | 2023-05-11 13:05:51 | 1 | 9,735 | Oblomov |
76,227,968 | 3,482,266 | Type Hinting: Use of Elipsis | <p>I'm trying to use Elipsis. Here's the declaration of the method</p>
<pre class="lang-py prettyprint-override"><code>def func_test(
self,
top_k: int,
tensor_1: torch.Tensor,
tensor_2: torch.Tensor,
) -> list[list[int], ...]:
</code></pre>
<p>Pylance, in Visual Studio Code, is giving me the error</p... | <python><python-typing> | 2023-05-11 13:03:23 | 1 | 1,608 | An old man in the sea. |
76,227,963 | 13,612,961 | What is the right way to send Messages to a channel or user via a slackbot? | <p>I am working on a solution that automates a certain process using a slackbot.
The actual process is automated using a pipeline. If a user types the command, the slackbot starts pipeline for the user over an api request. The slackbot should then inform the user when the pipeline is finished.</p>
<p>What is the right ... | <python><slack-api><bolt><slack-bot> | 2023-05-11 13:03:01 | 1 | 569 | Lumberjack |
76,227,893 | 12,176,973 | ffmpeg black screen issue for video video generation from a list of frames | <p>I used a video to generate a list of frames from it, then I wanted to create multiple videos from this list of frames.
I've set starting and ending frames indexes for each "sub video", so for example,
<code>indexes = [[0, 64], [64, 110], [110, 234], [234, 449]]</code>, and those indexes will help my code g... | <python><video><ffmpeg> | 2023-05-11 12:56:56 | 1 | 311 | arlaine |
76,227,846 | 2,383,529 | Numpy print floats <1 without the leading 0 | <p>I need to display and inspect large numpy matrices of floats in the interval <code>[0,1]</code> and am trying to avoid line wrapping, so each printed value should be as short as possible. I'm already using <code>np.set_printoptions(precision=2)</code> which yields something like</p>
<pre><code>[[1. 0.93 0.87 0.9 ... | <python><numpy><floating-point> | 2023-05-11 12:51:44 | 2 | 1,901 | waldol1 |
76,227,827 | 11,117,255 | No data found for this date range, symbol may be delisted | <p>I tried to pull data on a stock symbol using the Yahoo finance python module. I checked the other questions that are on a similar topic and most of them say to try to run the program during market hours, but that does not help.</p>
<p>This is my code:</p>
<pre><code>import yfinance as yf
yf.download('QQQ', '2020-01-... | <python><pandas><yahoo-finance><yfinance> | 2023-05-11 12:49:43 | 1 | 2,759 | Cauder |
76,227,735 | 5,321,862 | How to choose whether to persist or discard changes in HDF5 file before closing | <p>I'd like to manipulate a set of data in an <code>hdf5</code> file and be able to decide, before closing the file, whether to discard every changes or not.
From the doc of <a href="https://docs.h5py.org/en/stable/high/file.html#file-drivers" rel="nofollow noreferrer">File drivers</a>:</p>
<blockquote>
<p>HDF5 ships w... | <python><hdf5><h5py><pytables> | 2023-05-11 12:36:36 | 2 | 1,462 | Buzz |
76,227,724 | 7,822,387 | how to call databricks notebook from python using rest api | <p>I want to create a python notebook on my desktop that pass an input to another notebook in databricks, and then return the output of the databricks notebook. For example, my local python file will pass a string into a databricks notebook, which will reverse the string and then output the result back to my local pyth... | <python><rest><azure-databricks><databricks-rest-api> | 2023-05-11 12:35:14 | 1 | 311 | J. Doe |
76,227,685 | 3,247,006 | How to create tables with "models.py" in the main folder where "settings.py" is in Django? | <p>I'm trying to create a table with <code>models.py</code> in the main folder <code>core</code> where <code>settings.py</code> is as shown below:</p>
<pre class="lang-none prettyprint-override"><code>django-project
|-core
| |-models.py # Here
| └-settings.py
|-app1
└-app2
</code></pre>
<p>This is <code>models.py</co... | <python><django><django-models><migration><django-migrations> | 2023-05-11 12:31:18 | 1 | 42,516 | Super Kai - Kazuya Ito |
76,227,399 | 547,231 | How do I read doubles from a binary file in a loop? | <p>Simple question, but I don't find a helpful answer on the web. I have file create with C++, where I first output a <code>std::size_t k</code> and then write <code>2 * x</code> <code>double</code>s.</p>
<p>I need to first read the <code>std::size_t k</code> in python and then iterate in a loop from <code>0</code> to... | <python><numpy> | 2023-05-11 11:56:41 | 1 | 18,343 | 0xbadf00d |
76,227,359 | 15,757,310 | Is there a way to make a deployment to AWS EKS using boto3? | <p>I've reading through many documentations trying to figure out way to deploy objects to EKS using a python script or client. My objective is to be able then to trigger AWS Lambda that deploy objects to EKS.</p>
<p>Is there a possible way ?</p>
| <python><amazon-web-services><aws-lambda><boto3><amazon-eks> | 2023-05-11 11:52:43 | 0 | 863 | arhe10 |
76,227,184 | 5,704,159 | show Figure as plot instead of browser | <p>I'm new in plot\figure and trying to show my output in local plot instead of showing in browser.</p>
<p>This is my code and my output shows in my browser.
How can I show it in plot window?</p>
<pre><code>import plotly.express as px
import pandas as pd
df = pd.DataFrame(dict(value = [3739 3770, 4761, 42125, 4957, 5... | <python><plotly> | 2023-05-11 11:33:11 | 0 | 429 | gogo |
76,227,172 | 4,691,830 | Create pandas data from one date and timestrings without colons | <p>I want to read times from a file that includes <a href="https://en.wikipedia.org/wiki/Satellite_navigation" rel="nofollow noreferrer">GNSS</a> times, among a lot of other data. The expected result is a pandas array (Index or Series) with datetime datatype, with the date of the dataset applied.</p>
<p>In an intermedi... | <python><pandas><timestamp><python-datetime> | 2023-05-11 11:31:48 | 1 | 4,145 | Joooeey |
76,226,974 | 539,023 | How to write unit test to check database creation | <p>I have a sample function as below that receives the database name and creates a new database. I would like to write a unit test for this function. Any idea how to write test case for it? Many thanks.</p>
<pre><code>import psycopg2
def create_database(db_name):
conn = psycopg2.connect(
database="pos... | <python><unit-testing> | 2023-05-11 11:10:42 | 0 | 20,230 | kta |
76,226,866 | 2,749,397 | Drawing dividers between different colors in a segmented colorbar | <p><a href="https://i.sstatic.net/IkRgs.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IkRgs.png" alt="enter image description here" /></a></p>
<p>I would like to draw black horizontal dividers between the different individual colors in the segmented colorbar.</p>
<p><strong>mcve</strong></p>
<pre><code... | <python><matplotlib><colorbar> | 2023-05-11 10:57:01 | 1 | 25,436 | gboffi |
76,226,717 | 7,396,613 | Memory Error in numpy.save() in list of lists but not list of dicts | <p>I am creating a dataset, it would ideally be comprised in a list with different lists (matrix).
The final size of the dataset should be <code>(n_data, 10, 20, 3)</code>, being n_data the amount of data available.</p>
<p>I receive a list which contains n_data elements, being each one a dict. A test example, instead o... | <python><json><numpy><numpy-ndarray> | 2023-05-11 10:38:20 | 0 | 1,525 | M.K |
76,226,696 | 803,127 | FastAPI + Uvicorn + multithreading. How to make web app to work with many requests in parallel? | <p>I'm new to Python development. (But I have doenet background)
I do have a simple FastAPI application</p>
<pre><code>from fastapi import FastAPI
import time
import logging
import asyncio
import random
app = FastAPI()
r = random.randint(1, 100)
logging.basicConfig(level="INFO", format='%(levelname)s | %(asc... | <python><multithreading><fastapi><uvicorn> | 2023-05-11 10:36:23 | 1 | 2,654 | Anubis |
76,226,693 | 8,110,010 | How to decently destroy opengl resources when using QOpenGLWidget in pyqt5 | <p>First of all, My codes are as follows:</p>
<pre class="lang-py prettyprint-override"><code>from PyQt5.QtWidgets import QApplication, QOpenGLWidget, QMainWindow
from PyQt5.QtGui import QPainter, QOpenGLShader, QOpenGLShaderProgram, QMatrix4x4, QOpenGLBuffer, QOpenGLVertexArrayObject
from PyQt5.QtCore import Qt, QTime... | <python><python-3.x><pyqt5><pyopengl><qtopengl> | 2023-05-11 10:35:45 | 1 | 865 | Finley |
76,226,619 | 12,858,691 | GCP code editor python debugger does not show its output | <p>Testing the GCP code editor I noticed that the python debugging console does not show its own output. Eg for <code>1+1</code> it should show <code>2</code>. I know from my vscode that sometimes the output is shown in another console/terminal. Any suggestions on how to get the input within the debugging console?</p>
... | <python><google-cloud-platform> | 2023-05-11 10:26:15 | 0 | 611 | Viktor |
76,226,579 | 9,488,023 | Change value in a Pandas dataframe column based on several conditions | <p>What I have is a long Pandas dataframe in Python that contains three columns named 'file', 'comment', and 'number'. A simple example is:</p>
<pre><code>import pandas as pd
df_test = pd.DataFrame(data = None, columns = ['file','comment','number'])
df_test.file = ['file_1', 'file_1', 'file_1_v2', 'file_2', 'file_2', '... | <python><pandas><dataframe><indexing><conditional-formatting> | 2023-05-11 10:22:27 | 2 | 423 | Marcus K. |
76,226,385 | 1,115,237 | Dynaconf Object Access Fails After Loading Configuration from S3 Unless Iterated Over | <p>I'm encountering a strange issue while loading TOML configuration files from an AWS S3 bucket into a Dynaconf object in Python.</p>
<p>Here's a simplified version of the code I'm using:</p>
<pre><code>import os
import boto3
from dynaconf import Dynaconf
def load_settings(template_name: str) -> Dynaconf:
s3 =... | <python><amazon-web-services><amazon-s3><settings><dynaconf> | 2023-05-11 09:58:59 | 2 | 8,953 | Shlomi Schwartz |
76,226,239 | 17,267,064 | Mail move error | Imaplib | COPY command error: BAD [b'Command Argument Error. 12'] | <p>I wish to move emails to my custom folder named 'Test Folder' using imaplib library. I am able to move email to "Archive" folder but not in my custom made folder.</p>
<p>I get below error when attempted to copy an email to my 'Test Folder'.</p>
<pre><code>error Traceback... | <python><python-3.x><imaplib> | 2023-05-11 09:41:55 | 0 | 346 | Mohit Aswani |
76,226,189 | 16,423,684 | What's an easy to get explanation for the difference between built-in types and objects? | <p>I'm referring to <a href="https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/RubyPythonCocoa/Articles/RubyPythonMacOSX.html" rel="nofollow noreferrer">this article</a>. I can't fully understand this sentence:</p>
<blockquote>
<p>While Python code can contain both objects and built-in types, i... | <python><ruby> | 2023-05-11 09:36:45 | 0 | 557 | a.hess |
76,225,994 | 1,021,819 | How can I create and update a dict simultaneously? | <p>I see a tonne of answers on how to update an existing <code>dict</code> if a key doesn't exist, but my question is different. How can I update a dictionary but create the <em>dictionary</em> if it doesn't exist?</p>
<p>Use case - single cell of Jupyter notebook:</p>
<pre class="lang-py prettyprint-override"><code>my... | <python><jupyter-notebook> | 2023-05-11 09:15:56 | 1 | 8,527 | jtlz2 |
76,225,890 | 10,836,309 | module 'PyPDF2' has no attribute 'ContentStream' error | <p>I am trying to run the following code to replace text inside a PDF file:</p>
<pre><code>import os
import re
import PyPDF2
from io import StringIO
# Define a function to replace text in a PDF file
def replace_text_in_pdf(input_pdf_path, output_pdf_path, search_text, replace_text):
# Open the input PDF file in re... | <python><pypdf> | 2023-05-11 09:05:10 | 2 | 6,594 | gtomer |
76,225,840 | 6,631,639 | snakemake target rule as variable for python code | <p>I have a snakemake workflow that does a lot of work before it reaches the definition of the rules (querying files, accessing databases, filtering a data frame). Not all of this work is necessary, depending on the target rule I want to invoke.</p>
<p>How can I know which target rule is selected on the command line? T... | <python><snakemake><directed-acyclic-graphs><orchestration> | 2023-05-11 08:58:23 | 3 | 527 | Wouter De Coster |
76,225,668 | 12,285,101 | Remove duplicated values appear in two columns in dataframe | <p>I have table similar to this one:</p>
<pre><code>index name_1 path1 name_2 path2
0 Roy path/to/Roy Anne path/to/Anne
1 Anne path/to/Anne Roy path/to/Roy
2 Hari path/to/Hari Wili path/to/Wili
3 Wili path/to/Wili Hari pa... | <python><pandas><drop> | 2023-05-11 08:36:24 | 1 | 1,592 | Reut |
76,225,650 | 11,169,692 | How to convert json into excel format using python | <p>I tried to convert json file into excel but somehow panda is not able to do it for all the keys.</p>
<p>I have a json input:</p>
<pre><code>{
"result": [
{
"level": "L3_SW",
"name": "L23",
"type": "CM&quo... | <python><pandas> | 2023-05-11 08:34:36 | 1 | 503 | NoobCoder |
76,225,612 | 1,278,896 | Why some python class properties aren't visible within the class in certain positions? | <p>I've coded something like</p>
<pre class="lang-py prettyprint-override"><code>#!/usr/bin/env python3
'''
Illustration
'''
class C1:
lst1 = "one", "two", "three"
lst2 = "red", "green", "blue"
dct1 = { "ten": 10, "eleven": 11... | <python> | 2023-05-11 08:30:35 | 0 | 1,047 | jno |
76,225,556 | 9,488,023 | Add a value to each cell in a Pandas dataframe column if another column contains a certain string | <p>I have a very long and complicated Pandas dataframe in Python consisting of many columns, but an example would be something like:</p>
<pre><code>df_test = pd.DataFrame(data = None, columns = ['file','comment','number'])
df_test.file = ['file_1', 'file_1_v2', 'file_2', 'file_3', 'file_4', 'file_4_v2', 'file_5']
df_te... | <python><pandas><dataframe><indexing> | 2023-05-11 08:24:04 | 1 | 423 | Marcus K. |
76,225,517 | 15,239,717 | How Can I Write and Run a Django User Registration Unit Test Case | <p>I am working on a Django Project that contain two apps; account and realestate and I have a user registration form for registration. This Registration Form is working correctly on my local machine but I want to write and run a Django Unit test for it to be sure everything is working internally well.
Below is my Regi... | <python><django> | 2023-05-11 08:20:26 | 2 | 323 | apollos |
76,225,350 | 9,182,743 | groupby mean of datetime64[ns] column | <p>I have a datafrmame:</p>
<ul>
<li>user_id object</li>
<li>local time datetime64[ns]</li>
<li>value int32</li>
</ul>
<pre class="lang-py prettyprint-override"><code> user_id local time value
0 user1 2023-01-01 00:00:00 3
1 user1 2023-01-01 00:00:00 3
2 user1 2023-0... | <python><pandas><group-by> | 2023-05-11 08:01:39 | 2 | 1,168 | Leo |
76,225,163 | 14,365,042 | Why can't Series.fillna() fill all NaN values? | <p>I want to fill the <code>NaN</code>s in a dataframe with random values:</p>
<pre><code>df1 = pd.DataFrame(
list(zip(
['0001', '0001', '0002', '0003', '0004', '0004'],
['a', 'b', 'a', 'b', 'a', 'b'],
['USA', 'USA', 'USA', 'USA', 'USA', 'USA'],
[np.nan, np.nan, 'Jan', np.nan, np.nan... | <python><pandas><fillna> | 2023-05-11 07:37:28 | 2 | 305 | Joe |
76,225,072 | 2,473,382 | How to set up the ID of a json element in rdflib | <p><strong>Context</strong></p>
<p>I am loading a rdf file in <a href="https://rdflib.readthedocs.io/en/stable/" rel="nofollow noreferrer">rdflib</a>, and am trying to export it in json-ld.</p>
<p>The original rdf looks like:</p>
<pre class="lang-xml prettyprint-override"><code><cim:Substation rdf:ID="_1234&quo... | <python><rdf><json-ld><rdflib><linked-data> | 2023-05-11 07:27:19 | 1 | 3,081 | Guillaume |
76,224,945 | 944,146 | Fastest way to get a dictionary of counts of objects between 2 pandas series | <p>Lets say I have two equal length lists: ss and ee. Each contain values such that ss[i] >= ee[i] and ss[i+1] >= ee[i] is true for all i.</p>
<p>For example:</p>
<pre class="lang-py prettyprint-override"><code>ss = [0,10,20,30]
ee = [3,15,23,40]
vals = [0,1,2,5,7,10,11,16,21,22,23,29,31,35,45]
</code></pre>
<p>... | <python><pandas> | 2023-05-11 07:08:07 | 2 | 664 | pseudoabdul |
76,224,917 | 21,404,794 | Pandas replace(np.nan, value) vs fillna(value) which is faster? | <p>I'm trying to replace NaNs in different columns and I wanted to know which one is better (faster) for this task, replace or fillna.</p>
<p>Here's some sample code for the fillna option:</p>
<pre class="lang-py prettyprint-override"><code>df = pd.DataFrame({'key': ['K0', 'K1', 'K2', 'K3', 'K4', 'K5'],
... | <python><pandas><dataframe><performance> | 2023-05-11 07:04:02 | 1 | 530 | David Siret Marqués |
76,224,897 | 6,430,403 | Scheduling job in APScheduler weekdays between 2 times | <p>I want to schedule a job mon-fri, between two given times, say 10:20 to 18:35, for every 5 minute.<br />
So it will run: 10:25, 10:30, 10:35, ..., 18:30, 18:35. every weekday.<br />
I tried combining CronTrigger with IntervalTrigger but wasn't able to make it. Can anyone help?</p>
| <python><multithreading><triggers><cron><apscheduler> | 2023-05-11 07:01:26 | 1 | 401 | Rishabh Gupta |
76,224,705 | 7,921,635 | How to validate a JSON list of dictionaries using Marshmallow in Python? | <p>How can I validate nestes json data using Marshmallow?</p>
<p>This was I came up with, currently I get:</p>
<p><code>{'_schema': ['Invalid input type.']}</code>
note sure why.</p>
<pre><code>from marshmallow import Schema, fields, validate
class AuthUserSchema(Schema):
user = fields.String()
password = fie... | <python><validation><marshmallow> | 2023-05-11 06:26:50 | 1 | 427 | Nir Vana |
76,224,539 | 11,192,313 | Remove/Erase object from image using python | <p>I have been trying to Remove/Erase an object from image which is highlighted with red color using opencv <a href="https://i.sstatic.net/U6Vj5.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/U6Vj5.png" alt="Original Image" /></a></p>
<p>I have achieved a bit closer result but it's just reducing the tra... | <python><python-3.x><opencv><image-processing> | 2023-05-11 05:58:43 | 2 | 345 | Muhammad Adeel Shoukat |
76,224,536 | 1,100,107 | Integral on a polyhedral non-rectangular domain with Python | <p>You are a Python user and you want to evaluate this triple integral:</p>
<p><a href="https://i.sstatic.net/g5Nlo.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/g5Nlo.png" alt="enter image description here" /></a></p>
<p>for a certain function <code>f</code>, say <code>f(x,y,z) = x + y*z</code>.</p>
<... | <python><integral> | 2023-05-11 05:58:33 | 1 | 85,219 | Stéphane Laurent |
76,224,436 | 1,568,590 | How to an extra string to the display of an object with "display" in Jupyter, using Python? | <p>I have a number of mathematical objects created with SymPy, which display fine in Jupyter using "display". For example, there are a number of functions which I can display with:</p>
<pre><code>display(f1(x))
display(f2(x))
</code></pre>
<p>and so on. But what I want is to prefix each line with some expla... | <python><string><jupyter><display> | 2023-05-11 05:40:37 | 1 | 1,414 | Alasdair |
76,224,359 | 21,305,238 | PyCharm gives me a type warning about my metaclass; mypy disagrees | <p>I was trying to write a metaclass named <code>Singleton</code>, that, of course, implement the singleton design pattern:</p>
<pre class="lang-py prettyprint-override"><code>class Singleton(type):
def __new__(cls, name, bases = None, attrs = None):
if bases is None:
bases = ()
if attrs i... | <python><pycharm><mypy><python-typing><metaclass> | 2023-05-11 05:20:57 | 2 | 12,143 | InSync |
76,224,352 | 10,576,322 | Logging messages from __init__.py of an imported module in Python | <p>I wrote some libraries and part of the code relies on environment variables.</p>
<p>Therefor the <strong>init</strong>.py files of those libraries have some logic to parse env files or set defaults.</p>
<p>Since this envvars influence the code, I set up a logger in <strong>init</strong>.py and I am logging whether a... | <python><logging><import><python-import><python-logging> | 2023-05-11 05:19:27 | 1 | 426 | FordPrefect |
76,224,256 | 4,348,400 | What is the model argument in the super().__init__() in the example subclassing of pymc.Model? | <p>The <a href="https://www.pymc.io/projects/docs/en/stable/api/generated/pymc.Model.html" rel="nofollow noreferrer"><code>pymc.Model</code></a> docs show this example:</p>
<pre class="lang-py prettyprint-override"><code>class CustomModel(Model):
# 1) override init
def __init__(self, mean=0, sigma=1, name=''):
... | <python><subclass><pymc> | 2023-05-11 04:57:06 | 1 | 1,394 | Galen |
76,224,122 | 199,166 | Including zero counts for unobserved categoricals in Pandas DataFrame value_counts | <p>In Pandas, calling <a href="https://pandas.pydata.org/docs/reference/api/pandas.Series.value_counts.html" rel="nofollow noreferrer">value_counts</a> on a <a href="https://pandas.pydata.org/docs/reference/api/pandas.Categorical.html" rel="nofollow noreferrer">Categorical</a> series will make sure that each possible v... | <python><pandas> | 2023-05-11 04:16:42 | 1 | 12,578 | cbare |
76,224,121 | 17,128,041 | Unable to install Contrast-agent package on Poetry | <p>Getting the below error when I install contrast package using <code>poetry install</code> command:</p>
<p><code>RuntimeError: Failed to build Contrast C extension. It is necessary for autotools (autoconf, automake) to be installed in order for Contrast to build properly. On lightweight systems such as Alpine, it may... | <python><docker><python-poetry><contrast> | 2023-05-11 04:16:40 | 1 | 1,599 | sidharth vijayakumar |
76,224,086 | 5,579,099 | When (and how) do executors yield control back to the event loop? | <p>I am trying to wrap my head around <code>asyncio</code> for the first time, and I think I've got a basic grasp on coroutines & how to await their corresponding objects. Now, I've encountered <code>AbstractEventLoop.run_in_executor</code>, and the concept makes sense in the abstract (no pun intended): you have so... | <python><python-asyncio><python-multithreading> | 2023-05-11 04:08:10 | 2 | 394 | Pacopenguin |
76,224,024 | 3,247,006 | What is "can_delete_extra" for in Django Admin? | <p>I have <code>Person</code> model and <code>Email</code> model which has the foreign key of <code>Person</code> model as shown below:</p>
<pre class="lang-py prettyprint-override"><code># "models.py"
class Person(models.Model):
name = models.CharField(max_length=20)
def __str__(self):
retu... | <python><django><django-models><django-admin> | 2023-05-11 03:47:23 | 1 | 42,516 | Super Kai - Kazuya Ito |
76,223,664 | 6,395,930 | Installing top2vec package, particularly in H2O Notebooks, and the error | <p>After installing python top2vec package in H2O notebooks (!pip install top2vec), I am getting the following error when importing top2vec:</p>
<pre><code>import top2vec
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
</code></pre>
<p>I trie... | <python><package><incompatibility><h2o.ai><top2vec> | 2023-05-11 02:04:37 | 1 | 853 | Sam S. |
76,223,497 | 19,506,623 | How to create subelements with conditions in list? | <p>I have a list like this</p>
<pre><code>a = [3, 2, 1, 2, 3, 1, 3, 1, 2]
</code></pre>
<p>I'm trying to get a new list with elements separated in sublist for following conditions:</p>
<p>1-) Separate in sublists the sequences from 1 to N (N in this case is 3)</p>
<p>2-) Separate in sublists the sequences from 1 to N e... | <python><list> | 2023-05-11 01:08:59 | 2 | 737 | Rasec Malkic |
76,223,362 | 19,048,408 | In a Polars group_by aggregation, how do you concatenate string values in each group? | <p>When grouping a Polars dataframe in Python, how do you concatenate string values from a single column across rows within each group?</p>
<p>For example, given the following DataFrame:</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
df = pl.DataFrame(
{
"col1": ["a&... | <python><python-polars> | 2023-05-11 00:23:05 | 2 | 468 | HumpbackWhale194 |
76,223,056 | 21,767,810 | Why does multithreading operations on a single numpy array improve performance? | <p>In short, my question is <strong>shouldn't Python block multiple accesses to the same memory?</strong></p>
<h4>In detail</h4>
<p>Say I want to do some computations on one hundred numpy arrays. My data is stored as a contiguous <code>np.ndarray</code> with shape <code>(100, 1000, 1000)</code>. As per the code below, ... | <python><multithreading><numpy> | 2023-05-10 22:48:53 | 0 | 970 | simeonovich |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.