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,373,819
897,272
Python Global variable which appears to be correctly set is being return as None due to module being imported twice?
<p>I was attempting to have a simple singleton in my 'context' module; yes I know singleton's are bad and I hate using one, this is the least-ugly of lots of bad options for moving forward with refactoring spaghetti code as we move to get rid of context entirely.</p> <p>Here is my first version of the module.</p> <pre>...
<python><python-3.x><singleton>
2024-04-23 16:23:10
1
6,521
dsollen
78,373,809
4,237,254
Field value not being populated except when it's being debugged
<p>I'm having a weird problem where normally <code>field_val</code> should be set to some particular value but is being set to &quot;&quot;. When I debug in vscode and look into the value from the debugger, inspecting it (possibly triggering something), suddenly the variable becomes available. When I'm not debugging th...
<python><django><django-admin>
2024-04-23 16:20:02
1
2,831
BcK
78,373,765
10,426,490
How to trigger the `Blob Renamed` EventGrid Event using Azure Python SDK?
<p>When looking at the possible event types for an EventGrid Subscription, one is <code>Blob Renamed</code>.</p> <p><a href="https://i.sstatic.net/ktqJf.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ktqJf.png" alt="enter image description here" /></a></p> <p>How is this event triggered when using the A...
<python><azure-eventgrid><azure-python-sdk>
2024-04-23 16:12:01
1
2,046
ericOnline
78,373,660
11,447,747
How can I establish an SSH tunnel to a database for Dask?
<p>I want to connect to postgres db using Dask where the database is behind an SSH tunnel. While there are methods to create SSH tunnels in Python, I haven't found a straightforward way to integrate this with Dask's connection mechanisms.</p> <p>One potential solution is to locally port forward the database connection ...
<python><ssh><dask><dask-dataframe><dask-kubernetes>
2024-04-23 15:55:01
1
341
Faizan
78,373,511
3,258,600
Force setuptools to skip cache for certain python dependencies
<p>Is there an option in the setup.cfg <code>install_requires</code> or in alternately in the pyproject.toml file to skip the cache when loading certain pip dependencies.</p> <p>I have libraries in a local PyPi repository that get updated during development and I don't want to have to go through the hassle of having to...
<python><pip><setuptools><pyproject.toml>
2024-04-23 15:28:28
0
12,963
kellanburket
78,373,468
4,907,639
Input shape error when updating pretrained CNN from binary classification to multiclassification
<p>I have a dataset of 3 classes of images, subdivided into training/validation/testing folders:</p> <pre><code>new_base_dir = '/Users/.../img_dir' import os from tensorflow.keras.utils import image_dataset_from_directory train_dataset = image_dataset_from_directory( os.path.join(new_base_dir, 'train'), imag...
<python><tensorflow><keras><deep-learning><conv-neural-network>
2024-04-23 15:20:21
1
2,109
coolhand
78,373,278
9,343,043
Create interval of data from dataframe with given median
<p>I have a large data frame of subjects. For simplcity's sake I have posted a smaller modified version of my data frame below.</p> <pre><code>subject age sex A 5.35 Female B 5.70 Male C 6.00 Female D 6.07 Male E 6.25 Male F 6.88 Male G 7.00 Female H...
<python><pandas><median>
2024-04-23 14:48:11
2
871
florence-y
78,373,158
899,200
Optimizing Path Through Large Directed Acyclic Graph Tree
<p>This is a rephrasing/different approach to <a href="https://stackoverflow.com/questions/77804202/fitting-curve-with-restricted-relative-orientations">Fitting curve with restricted relative orientations</a>.</p> <p>I have a directed acyclic graph that flows from Level 0 to Level 3500. Edges only occur between levels,...
<python><optimization><directed-acyclic-graphs>
2024-04-23 14:30:41
0
414
CrazyArm
78,372,815
14,253,961
Print statistics in train
<p>To train cifar100 dataset, I find this function train, while I'm newer in Pytorch, I would like to understand the value 10000, because when I change it, the loss change</p> <pre><code>def train(net,trainloader,epochs,use_gpu = True): net.train() criterion = nn.CrossEntropyLoss() optimizer = torch.optim.S...
<python><pytorch>
2024-04-23 13:37:59
1
741
seni
78,372,803
1,238,967
Grouping rows in a Pandas dataframe based on one column, sorting based on a second column, and selecting elements in a third column (not pivoting)
<p>I have a dataframe, df_prices, which contain information about a set of objects. AI have 3 columns: 'uid', 'date' and 'price', where 'uid' has multiple (repeated) entries:</p> <pre><code>df_prices index uid date price 0 123 02-02-2000 11100 1 123 01-01-2000 22200 2 123 03-03-2000 44000...
<python><pandas><dataframe><sorting>
2024-04-23 13:36:32
0
1,234
Fabio
78,372,776
10,071,715
Is there a way to group data by value in one column to produce a sum of contents in other column in pandas?
<p>I'm sorry if this is a repeat, I can't find anything that gives me an answer...</p> <p>I have a dataframe containing pixel values and the number of pixels of that value. It looks something like this:</p> <pre><code>Value Count 0.1457 900 0.1458 1800 0.1459 900 0.2144 1800 0.4357 2700 0.5764 900 0...
<python><pandas>
2024-04-23 13:32:28
4
1,007
SHV_la
78,372,696
1,439,912
pandas.DataFrame advanced groupby clustering
<p>Given the following dataframe (Python 3)</p> <pre><code>df = pd.DataFrame({'Name':['Smith', 'Brown', 'Smith', 'Miller'], 'Country': ['US', 'GB', 'DE','US']}, index=[0,1,2,3]) df.index.name = 'ID' df ID Name Country 0 Smith US 1 Brown GB 2 Smith DE 3 Miller US </code></pre> <p>I want to perform &...
<python><pandas><grouping><cluster-analysis><networkx>
2024-04-23 13:19:49
0
480
Pontus Hultkrantz
78,372,643
7,695,845
Numba parallelization doesn't help performance in Monte-Carlo simulation?
<p>This is a follow-up question to a <a href="https://stackoverflow.com/questions/78334676/monte-carlo-simulation-of-pi-with-numba-is-the-slowest-for-the-lowest-number-of/78336106?noredirect=1#comment138143733_78336106">question</a> I asked before, but I think I should start over. I am trying to implement a Monte-Carlo...
<python><numba><montecarlo>
2024-04-23 13:14:06
1
1,420
Shai Avr
78,372,618
7,302,169
acme error - AttributeError: module 'jax' has no attribute 'linear_util'
<p>I am using acme framework to run some experiments, and I installed acme based on documentation. However, I have attribute error that raised likely from JAX, HAIKU, and when I looked into github issue, there was no solution given at this time. Can anyone take a look what package dependecy caused this issue?</p> <p><s...
<python><jax><haiku><acme-deepmind>
2024-04-23 13:10:26
1
941
Jerry07
78,372,458
19,580,067
Call Back Error:updating graph.figure in Plotly Dash
<p>I tried to visualise the stock data using candle light chart in plotly, dash. But the chart doesn't showup throwing call back error. This is the first time I'm using plotly. So not sure how to get it fixed.</p> <p>The chart works well if I pull data from the csv file but not showing up when pulled the data directly ...
<python><plotly><visualization><plotly-dash>
2024-04-23 12:42:55
0
359
Pravin
78,372,333
918,093
pcolormesh showing white gaps between cells of data
<p>I'm trying to graph a series of cells represented by the top left coordinate. The cells are spaced 20 units apart. When I graph the data with pcolormesh I get the individual cells with white gaps representing presumably the missing data between each cell. How can I force the cells to be 20x20 instead of 10x10?</p> <...
<python><matplotlib>
2024-04-23 12:22:08
1
720
labarna
78,372,313
7,566,673
pandas explode list values row wise
<p>I have a Dataframe like this</p> <pre><code>data = [[1, [10, 11]], [1, [15, 16]], [2, [20, 24]], [2, [22, 23]]] df = pd.DataFrame(data, columns = ['id', 'val']) id val 0 1 [10, 11] 1 2 [15, 16] </code></pre> <p>Here length of each list in <code>val</code> is same.</p> <p>I want to explode <code>val</...
<python><pandas>
2024-04-23 12:19:49
1
1,219
Bharat Sharma
78,372,168
2,530,674
Move isort configs to vscode settings.json
<p>I understand that <a href="https://stackoverflow.com/questions/67059648/vscode-how-to-config-organize-imports-for-python-isort">VSCode: how to config &#39;Organize imports&#39; for Python (isort)</a> may be related, but all the answers seems outdated.</p> <p>I have the following in my pyproject.toml file and my sett...
<python><visual-studio-code><isort>
2024-04-23 11:58:06
2
10,037
sachinruk
78,372,145
3,520,792
403 Error while creating a spreadsheet using a GCP Service Account credentials in gspread python despite correct scopes
<p>I'm encountering a 403 error when attempting to create a Google spreadsheet using the gspread library in Python, despite setting what I believe to be the correct authentication scopes for my service account. The error details are:</p> <pre><code>{ &quot;code&quot;: 403, &quot;message&quot;: &quot;Request had ins...
<python><google-cloud-platform><google-drive-api><service-accounts><gspread>
2024-04-23 11:54:37
0
526
Vipul Vishnu av
78,371,971
13,998,438
Removing the wide margins in a streamlit app
<p>I am making a streamlit app, but there is a huge amount of white space on the left and right sides of my graph. I want to remove the margins and place some graphs horizontally. How can I remove the margins on the left and right side of the app? I got this code from a tutorial I've been following.</p> <pre><code>impo...
<python><streamlit>
2024-04-23 11:27:47
1
606
325
78,371,846
13,227,420
How to return multiple properties while using a split extension in jsonpath-ng?
<p>I'm working with a dictionary in Python, such as:</p> <pre><code>event = {'name': 'team1 - team2', 'competitionId': 19790, 'sportId': 3} </code></pre> <p>I am trying to extract the name value and split it using the split extension. The extraction works as expected when returning the name value separately, like this:...
<python><json><python-3.x><jsonpath-ng>
2024-04-23 11:06:18
1
394
sierra_papa
78,371,754
4,108,376
Storing numpy array in raw binary file
<p>How to store a 2D numpy <code>ndarray</code> in raw binary format? It should become a raw array of float32 values, in row-major order, no padding, without any headers.</p> <p>According to the documentations, <code>ndarray.tofile()</code> can store it as binary or textual, but the <code>format</code> argument is a st...
<python><numpy><numpy-ndarray>
2024-04-23 10:50:50
1
9,230
tmlen
78,371,663
6,197,439
PyQt5 QTableView header with two lines of text, each with different font?
<p>The minimal example code below renders the following GUI:</p> <p><a href="https://i.sstatic.net/aqTP7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/aqTP7.png" alt="enter image description here" /></a></p> <p>What I would like to achieve, instead, is this (manually edited image):</p> <p><a href="http...
<python><qt><pyqt5>
2024-04-23 10:35:07
0
5,938
sdbbs
78,371,595
1,818,935
Unexpected output from pandas' DataFrameGroupBy.diff function
<p>Consider the following piece of python code, which is essentially copied from the first code insert in <a href="https://pandas.pydata.org/docs/user_guide/groupby.html#transformation" rel="nofollow noreferrer">the <em>Transformation</em> section</a> of <em>pandas</em>' user guide's <em>Group by: split-apply-combine</...
<python><pandas>
2024-04-23 10:21:50
1
6,053
Evan Aad
78,371,117
7,677,894
How to use different "with" under "if" statement in python?
<p>The source code is like:</p> <pre><code>with A: do_some() </code></pre> <p>I want to choose differenct <code>with</code> statement base on <code>if</code> conditions like the code below. And the <code>do_some()</code> is still under <code>with</code> statement.</p> <pre><code>if cond1: with A: else: with...
<python>
2024-04-23 09:06:45
2
983
Ink
78,371,003
14,667,788
Parallel a process in Python
<p>I am learning how to run simple function on multiple threads in Python.</p> <p>Assume this simple code:</p> <pre class="lang-py prettyprint-override"><code> from itertools import product all_combinations = [] for cas in range(3): target_sum = 10 combinations = product(range(target_sum + 1), repeat=4) ...
<python><parallel-processing>
2024-04-23 08:48:04
1
1,265
vojtam
78,370,980
11,149,556
Customizing Y-axis Major Ticks on Symlog Scale
<p>I am working on a boxplot in Python using Seaborn and Matplotlib where the Y-axis is set to a symmetrical logarithmic scale. I'm attempting to place major ticks at specific intervals using a custom <code>SymmetricalLogLocator</code>, but I'm encountering unexpected results. Below is my minimal working example:</p> <...
<python><matplotlib><seaborn><logarithm><yticks>
2024-04-23 08:44:57
0
479
ex1led
78,370,958
2,233,500
How to make AWS Lambda / API Gateway return an image?
<h2>Original question</h2> <p>I'm writing a Lambda function and I want it to return an image and I cannot make it work.</p> <p>Usually, given the URL of an ordinary image, in Python, I can load the image using PILLOW and BytesIO this way:</p> <pre class="lang-py prettyprint-override"><code>response = requests.get(IMAGE...
<python><aws-lambda><aws-api-gateway>
2024-04-23 08:42:12
0
867
Vincent Garcia
78,370,548
6,573,770
Filter data from dataframe using each element of a list
<p>I have a dataframe:</p> <pre><code>import pandas as pd </code></pre> <p>#Create a sample dataframe</p> <pre><code>df = pd.DataFrame({ 'material_sub_category_id': [8038, 10063, 8038, 9539], 'auction_id': [400, 401, 402, 403], 'material_name': ['pig iron', 'sponge iron', 'pig iron' , 'billet'], 'auc_ru...
<python><pandas><dataframe>
2024-04-23 07:23:58
0
329
Ami
78,370,502
4,277,485
Pandas, find difference between two columns, each having different datatype values
<p>consider following input data</p> <div class="s-table-container"><table class="s-table"> <thead> <tr> <th style="text-align: left;">prod</th> <th style="text-align: center;">col1</th> <th style="text-align: right;">col2</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">One</td> <td style="text-align: ce...
<python><pandas><datetime><timedelta>
2024-04-23 07:17:18
2
438
Kavya shree
78,370,307
3,142,695
How to change variable/dynamic json content
<p>This is how I modify a tsconfig.json file in a python script. But as you can see, the most part is quite the same, so this is not a very elegant solution. As I'm new to python, I need some help how to write this code more efficient.</p> <p>And also there is another <code>if</code> case where I have to add a single p...
<python>
2024-04-23 06:40:35
1
17,484
user3142695
78,370,271
498,154
Dependency check with liccheck fails - Expected matching RIGHT_PARENTHESIS for LEFT_PARENTHESIS, after version specifier
<p>In a django app, with poetry as the dependency/packaging manager, I am using a library (also a django one) that is used by multiple django apps.</p> <p>Those different apps are using different versions of django. So, in the <code>pyproject.toml</code> file <strong>of the library</strong>, the <code>django</code> dep...
<python><django><python-poetry>
2024-04-23 06:32:44
0
334
kostia
78,369,936
10,003,538
Django CloudinaryField: Setting Default Privacy on Upload and Generating Presigned URLs for Public Access
<p>I'm working on a Django project where I have a model Media with an image field stored using CloudinaryField.</p> <p>Currently, I'm able to upload images via multipart/form, and I can generate a public link using <code>media_object.image.url</code>. However, I'm facing two challenges:</p> <ol> <li><p>Default Upload P...
<python><python-3.x><django><cloudinary>
2024-04-23 04:50:03
1
1,225
Chau Loi
78,369,880
342,553
error: call to undeclared function 'OPENSSL_sk_find_all'
<p>Trying to install M2Crypto==0.41.0 on Python 3.10 on OSX v13, but got a lot of similar errors like:</p> <pre><code>src/SWIG/_m2crypto_wrap.c:10746:17: error: call to undeclared function 'OPENSSL_sk_find_all'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] re...
<python><m2crypto>
2024-04-23 04:25:21
1
26,828
James Lin
78,369,812
1,592,334
Is there a way to fix can't compare offset-naive and offset-aware datetimes when copying files between s3 buckets
<p>I am trying to write a python script that will move specific files from source s3 bucket to target s3 bucket. The objective is to copy specific files to the target bucket in the initial run. on the second run, it compares the max lastmodified date in target with the lastmodified date in the source, then it uses that...
<python><amazon-web-services><amazon-s3>
2024-04-23 03:56:50
1
1,095
Abiodun Adeoye
78,369,755
4,732,111
Polars compare two dataframes - is there a way to fail immediately on first mismatch
<p>I'm using polars.testing <code>assert_frame_equal</code> method to compare two sorted dataframes containing same columns and below is my code:</p> <pre><code>assert_frame_equal(src_df, tgt_df, check_dtype=False, check_row_order=False) </code></pre> <p>For a dataframe containing 5 million records, it takes long time ...
<python><pandas><python-polars>
2024-04-23 03:26:09
3
363
Balaji Venkatachalam
78,369,740
12,314,521
Is there any way to cancel initialize object class if there is an error occurs in Python?
<pre><code>class EntityRetrieval(object): def __init__(self, entity_kb_path: str): &quot;&quot;&quot; Args entity_kb_path: path of entity knowledge base (string) which is json format &quot;&quot;&quot; try: entit...
<python><class>
2024-04-23 03:22:24
2
351
jupyter
78,369,674
8,124,392
How to autoselect a result from a list
<p>This is the output of my Segment Anything Model: <a href="https://i.sstatic.net/fVga7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fVga7.png" alt="enter image description here" /></a></p> <p>These are the segmentation results:</p> <pre><code>masks = [ mask['segmentation'] for mask in so...
<python><deep-learning><computer-vision><image-segmentation>
2024-04-23 02:55:38
2
3,203
mchd
78,369,583
1,115,716
Combine two rows in a CSV and preserve the number of columns
<p>I have a CSV file with some values represented thusly:</p> <pre><code>Superman/, 250lbs, Batman/, 180lbs Clark Kent, , Bruce Wayne, </code></pre> <p>I need to combine the rows such that it looks like:</p> <pre><code>Superman/Clark Kent, 250lbs, Batman/Bruce Wayne, 180lbs </code></pre> <p>Obviously I need to delete ...
<python><csv>
2024-04-23 02:04:54
1
1,842
easythrees
78,369,487
16,312,980
What to put in dt parameter or "sample spacing" for pycwt's `wct()` or their wavelet coherence test function?
<p>I am trying to create some stuff from an academic paper, and one point it <a href="https://www.mathworks.com/help/wavelet/ref/wcoherence.html" rel="nofollow noreferrer">requires wavelet coherence or <code>wcoherence()</code> from <code>matlab</code></a>.</p> <p>I am required to use python so the next best alternativ...
<python><matlab><wavelet><wavelet-transform>
2024-04-23 01:26:16
0
426
Ryan
78,369,485
259,543
Pass array argument into C++ function from Python via SWIG
<p>I've got an interface such as:</p> <pre class="lang-cpp prettyprint-override"><code>int func(int array[]); </code></pre> <p>I must call it from Python via SWIG. <em>The binding code is already compiled</em> and I do not want to edit, compile or otherwise mess with SWIG, but the overload for <code>func(int[])</code> ...
<python><c++><swig>
2024-04-23 01:25:28
1
5,252
alecov
78,369,157
10,962,766
Regex pattern for different date formats does not seem to capture all desired cases
<p>I am trying to process a txt file line per line to find date information in different patterns and write them to a consistent YYYY, YYYY-MM and YYYY-MM-DD format.</p> <p>My input formats across different lines of narrative text are:</p> <pre><code>1) YYYY, e.g. 1890 2) MM.YYYY, e.g. 10.1765 3) M.YYYY, e.g. 9.1700 4)...
<python><regex><match>
2024-04-22 22:38:37
2
498
OnceUponATime
78,369,152
85,381
Custom orange learner in python script is failing
<p>I am trying to implement a custom learner in Orange similar to the stack learner.</p> <p><a href="https://i.sstatic.net/hTrHw.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/hTrHw.png" alt="enter image description here" /></a></p> <p>The input learners return <code>yes</code>, <code>no</code> and <cod...
<python><data-mining><orange>
2024-04-22 22:37:12
0
10,928
iain
78,368,877
4,666,912
Most efficient way to create a time varying dataframe
<p>I have the following dataframe:</p> <pre><code>from_year to_year id gender 1990 1993 1 Female 1987 1992 2 Male 2000 2000 3 Male 2010 2011 4 Female </code></pre> <p>I would like to produce the following time varying dataframe:</p> <pre><code>id year gender 1 1...
<python><pandas>
2024-04-22 21:07:40
2
2,343
BKS
78,368,435
10,145,953
PyMuPDF converted image into a numpy array?
<p>I have an existing function using <code>pdf2image</code> to convert each page of a PDF into images. For a variety of reasons, I am no longer able to use <code>pdf2image</code> and must now instead use <code>PyMuPDF</code>, however, I am having trouble yielding the same results as I did from <code>pdf2image</code>.</...
<python><arrays><numpy><pymupdf><pdf2image>
2024-04-22 19:13:20
1
883
carousallie
78,368,325
3,851,085
Celery name task execution and get task execution by name
<p>I have a Celery task called <code>my_task</code>. I create multiple exeucutions of the task by calling <code>my_task.delay()</code> multiple times. I want to give a unique label/name to each execution, and to be able to get and stop a task execution for a given label/name. How can I do something like this?</p>
<python><celery><django-celery>
2024-04-22 18:50:02
1
1,110
Software Dev
78,368,287
6,824,949
2nd gen Cloud function response size too large
<p>I have a 2nd gen HTTP Python cloud function that queries a large Bigquery table and returns large amounts of data, like this:</p> <pre><code>from google.cloud import bigquery import functions_framework client = bigquery.Client() @functions_framework.http def qry_bq(request): request_json = request.get_json(...
<python><google-cloud-functions>
2024-04-22 18:39:29
2
348
aaron02
78,368,208
2,710,855
Python - Raspberry Pi as BLE sender for sensor data
<p>I'm using my RaspberryPi as a device that tracks various sensor data. Now I want to create a Mobile App (Flutter) to read the data in real time using bluetooth low energy (BLE).</p> <p>I know that there are many tutorials out there, but all of them are more or less to complex. I need a really really simple python sc...
<python><raspberry-pi><bluetooth><bluetooth-lowenergy>
2024-04-22 18:21:10
1
2,415
Mike_NotGuilty
78,368,186
23,260,297
Move data in dataframe based on a value of a different column
<p>I have a dataframe that looks like this:</p> <pre><code>Put/Call StrikePrice fixedprice floatprice fixedspread floatspread Put 10 0 20 0 0 Put 10 0 20 0 0 nan 0 0 0 13 15 nan ...
<python><pandas>
2024-04-22 18:15:48
2
2,185
iBeMeltin
78,368,177
1,060,209
make TCPServer/HTTPServer not send the [FIN, PSH, ACK] packet
<p>Have a python web server listening on port <code>8080</code>, based on <code>socketserver.TCPServer</code>. But there are intermittent failures in the communication between the client and the server, esp. when the server sends the <code>[FIN, PSH, ACK]</code> packet to the client, when serving the data the client is...
<python><httpserver><tcpserver>
2024-04-22 18:15:08
0
4,881
Qiang Xu
78,368,109
2,685,034
Can API Gateway with Lambda only response a JSON string type body?
<p>I am using API Gateway with Python lambda. I created the openapi.yml as below code:</p> <pre><code> responses: &quot;200&quot;: description: &quot;200 response&quot; content: application/json: schema: type: array items: type: object ...
<python><json><lambda>
2024-04-22 17:59:17
1
307
Ben P
78,368,062
1,411,376
Celery with redis doesn't seem to honor visibility_timeout
<p>We want stalled tasks to be picked up by a new worker so we're using <code>task_acks_late: True</code> along with <code>visibility_timeout</code>. Some of the tasks can take a pretty long time to run so we attempted to update the visibility_timeout.</p> <p>Celery settings are as follows:</p> <pre class="lang-py pret...
<python><python-3.x><redis><celery>
2024-04-22 17:47:22
0
795
Max
78,367,950
7,169,710
psycopg3 dynamic sql.Identifier with alias/label
<p>The problem I am trying to solve is getting <code>feature</code> data from JSON fields so that resulting column name is preserved. This translates in trying to understand whether there is a better and/or safer way to dynamically define column aliases using psycopg(3).</p> <p>I currently have the implemented the foll...
<python><sql><postgresql><psycopg2><psycopg3>
2024-04-22 17:25:51
1
405
Pietro D'Antuono
78,367,868
10,704,952
Datahub actions getting failed for hello_world action, giving PipelineConfig validation error
<p>I'm trying to follow datahub-actions quick start <a href="https://datahubproject.io/docs/actions/" rel="nofollow noreferrer">https://datahubproject.io/docs/actions/</a> but when i do <code>datahub actions -c hello_world.py</code> i'm getting below error</p> <pre><code>[2024-04-22 22:33:35,602] INFO {datahub_acti...
<python><datahub>
2024-04-22 17:08:58
1
673
Vijay Jangir
78,367,705
4,198,514
Tkinter Limits Frame vs Canvas
<p>Creating an ImageGallery I used a scrolled Frame for thumbnails.</p> <p>This scrolled Frame gets filled with ~300 labels that hold the images. The Frame however seems to be limited at around max(shortInt), the canvas seems not to be that limited.</p> <p>From what I gathered from similar questions is that there is a ...
<python><tkinter>
2024-04-22 16:35:46
0
2,210
R4PH43L
78,367,686
4,462,831
Why Django Signals async post-save is locking other async ORM calls?
<p>I have a Django 5 application that use websockets using <code>channels</code>, and I'm trying to switch to <a href="https://channels.readthedocs.io/en/latest/topics/consumers.html#asyncjsonwebsocketconsumer" rel="nofollow noreferrer">AsyncConsumers</a> to take advantage of asyncronous execution for I/O or external A...
<python><django><python-asyncio><django-channels><django-signals>
2024-04-22 16:32:13
0
355
EdoG
78,367,560
4,815,263
How to add multiple columns in of a CSV file and then add a column in the last column and put the summation in this column?
<p>How to add three columns in below given sample CSV and add those to integers to the fifth column by adding them all.</p> <p>Sample:-</p> <pre><code>Emdid,name,basic_sal,Allowance,Perk 11,Dave,1100,500,50 22,Gina,1000,600,50 33,Kyle,2000,300,100 </code></pre> <p>Output:-</p> <pre><code>Emdid,name,basic_sal,Allowance,...
<python><shell>
2024-04-22 16:08:39
1
651
satyaki
78,367,555
10,985,257
Mock Module Variable instead of a callable
<p>If I want to Mock a variable inside a module with the following code:</p> <pre class="lang-py prettyprint-override"><code>@pytest.fixture(autouse=True) def mock_default(mocker, tmp_path): &quot;&quot;&quot;Mock Default Config File Path.&quot;&quot;&quot; mocker.patch(&quot;mypackage.mymodule.DEFAULT&quot;, r...
<python><mocking><pytest>
2024-04-22 16:07:48
1
1,066
MaKaNu
78,367,252
8,035,710
Submitting Python Request to ASP.Net Form Service - No Data Returned
<p>I'm trying to automate data retrieval from this website - <a href="https://renewablesandchp.ofgem.gov.uk/Public/ReportViewer.aspx?ReportPath=/DatawarehouseReports/CertificatesExternalPublicDataWarehouse&amp;ReportVisibility=1&amp;ReportCategory=2" rel="nofollow noreferrer">https://renewablesandchp.ofgem.gov.uk/Publi...
<python><asp.net><forms><web-scraping><python-requests>
2024-04-22 15:15:03
0
327
Ayrton Bourn
78,367,230
793,961
plotly: change background color for areas of polar chart
<p>There has been a <a href="https://stackoverflow.com/questions/60281382/plotly-how-to-assign-background-colors-to-different-ranges-in-a-radar-or-polar">question</a> about how to colorize the <em>rings</em> of a plotly polar chart. I would like to add different background colors depending on the categories.</p> <p>Con...
<python><plotly>
2024-04-22 15:11:19
1
7,450
muffel
78,367,206
4,105,440
Simple Horizontal layout of graph nodes in networks diagram
<p>I have a dataframe containing flight connection data in a network representation</p> <div class="s-table-container"><table class="s-table"> <thead> <tr> <th>edge</th> <th>source</th> <th>target</th> <th>type</th> </tr> </thead> <tbody> <tr> <td>ZRH_ZRH_-1_base_ZRH_PMI_470_flight_idle0_start</td> <td>ZRH source</td> ...
<python><networkx><graph-theory><graphviz>
2024-04-22 15:06:12
1
673
Droid
78,367,100
880,783
Does this code adding -256 to a uint8 fail in numpy 2 due to NEP 50?
<p>The following code works in numpy 1.26.4, but not in numpy 2.0.0rc1, giving</p> <blockquote> <p>OverflowError: Python integer -256 out of bounds for int8</p> </blockquote> <pre class="lang-py prettyprint-override"><code>import numpy as np np.array([1], dtype=np.int8) + (-256) </code></pre> <p>Is that expected? Is i...
<python><numpy>
2024-04-22 14:50:07
1
6,279
bers
78,367,014
5,985,921
Quantiles of a series with polars as dataframe
<p>Say I have a dataframe in polars with a column <code>outcome</code> that is some float.</p> <pre class="lang-py prettyprint-override"><code>df = pl.from_repr(&quot;&quot;&quot; ┌─────┬──────────┐ │ a ┆ outcome │ │ --- ┆ --- │ │ i64 ┆ f64 │ ╞═════╪══════════╡ │ 2 ┆ 0.17745 │ │ 2 ┆ 0.712477 │ │ 2 ┆...
<python><aggregation><python-polars><quantile>
2024-04-22 14:37:32
2
1,651
clog14
78,366,926
1,231,450
Calculation of point of control in Pandas
<p>Suppose, we have yet another dataframe with finance data:</p> <pre><code>timestamp,close,security_code,volume,bid_volume,ask_volume 2024-02-05 01:00:01.383985+00:00,4968.5,ES,1,1,0 2024-02-05 01:00:01.383985+00:00,4968.5,ES,1,1,0 2024-02-05 01:00:01.383985+00:00,4968.5,ES,1,1,0 2024-02-05 01:00:01.383985+00:00,4968....
<python><pandas>
2024-04-22 14:22:22
1
43,253
Jan
78,366,610
6,484,726
Using ListSerializer inside "to_representation" of Serializer class
<p>I want to create multiple objects based on data received in nested json array. In order to do so I created a <code>serializers.Serializer</code> and overriden <code>to_representation</code> method to use <code>ListSerializer</code> for serialization of newly created objects.</p> <p>Simplified code look like so (for ...
<python><django-rest-framework>
2024-04-22 13:29:35
1
398
hardhypochondria
78,366,521
3,305,534
How to add packages to Graalvm python polyglot?
<p>I followed the StackOverflow question <a href="https://stackoverflow.com/questions/77315830/how-to-install-graalvm-with-python">Here</a> and the subsequent link <a href="https://medium.com/graalvm/truffle-unchained-13887b77b62c" rel="nofollow noreferrer">https://medium.com/graalvm/truffle-unchained-13887b77b62c</a> ...
<python><java><graalvm><graalpython>
2024-04-22 13:16:41
1
740
Sriram Sridharan
78,366,381
5,997,555
Checking if integers in list are consecutive - including cyclic iteration
<p>I have a list of integers from 1 to <code>n</code>.</p> <p>How can check if a subset of this list contains only consecutive numbers, accounting for a cyclic iteration (i.e. after <code>n</code> the iteration continues with <code>1</code>)</p> <p>Assuming my function is called <code>foo</code> and <code>n=36</code>, ...
<python>
2024-04-22 12:50:14
2
7,083
Val
78,366,269
1,656,671
Define a dot(a,b) function + properties and simplify / expand
<p>I would like to define a function + rules, and let sympy use the rule for simplification:</p> <pre><code>a,b,c = symbols(&quot;a b c&quot;) dot = function(&quot;dot&quot;) rule1 = Eq( dot(a+b,c) , dot(a,c)+dot(b,c)) rule2 = Eq( dot(a,b) , dot(b,a) ) </code></pre> <p>Now, use the above to <code>expand</code> and <co...
<python><sympy><symbolic-math>
2024-04-22 12:33:26
2
1,036
QT-1
78,366,268
4,098,506
How to work with PosrgreSQL's point type in peewee?
<p>How do I work with PostrgreSQL's geometric type <code>point</code>? When I create the model code with pwiz, a point column is defined as <code>column_name = UnknownField() # point</code>. When I try to read this field, I only get a <code>db_schema.UnknownField</code> with no data in it. When I try to write it, it w...
<python><postgresql><peewee>
2024-04-22 12:33:04
0
662
Mr. Clear
78,366,208
547,231
How can we cast a `ctypes.POINTER(ctypes.c_float)` to `int`?
<p>I think this is a simple task, but I could not find a solution on the web to this. I have a external C++ library, which I'm using in my Python code, returning a <code>ctypes.POINTER(ctypes.c_float)</code> to me. I want to pass an array of these pointers to a <code>jax.vmap</code> function. The problem is that <code>...
<python><ctypes><jax>
2024-04-22 12:24:50
1
18,343
0xbadf00d
78,366,113
9,833,362
pytest fixtures in nested Classes
<p>I have written the following testcase using pytest.</p> <pre><code>import pytest data_arg = [&quot;arg1&quot;, &quot;arg2&quot;] class TestParentClass1: @pytest.fixture(scope=&quot;class&quot;, params=data_arg,autouse=True) def common_setup(self, request): print(f'Configure the system according to {re...
<python><unit-testing><testing><pytest><fixtures>
2024-04-22 12:07:50
1
475
Shreyansh Jain
78,366,104
11,337,114
Unable to connect to cloud datastore from local legacy project based on python2.7 and django 1.4
<p>I have a <code>django==1.4</code> project (<code>python==2.7</code>) that I wanted to run and make some changes. I am unable to connect to cloud datastore from my local codebase. Right now, when I run the project using <code>dev_appserver.py</code> like:</p> <p><code>dev_appserver.py PROJECT_NAME --enable_console</c...
<python><django><python-2.7><google-app-engine><google-cloud-datastore>
2024-04-22 12:05:25
1
365
Akif Hussain
78,365,983
1,869,090
Python sockets and windows
<p>I got this small script:</p> <pre><code>import socket with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as server_socket: server_socket.bind((&quot;127.0.0.1&quot;, 5353)) </code></pre> <p>Running it under windows, I got the error <code>PermissionError: [WinError 10013] Der Zugriff auf einen Socket war aufg...
<python><windows><sockets>
2024-04-22 11:41:49
2
3,429
t777
78,365,846
6,002,727
Text conversion processing and extracting information
<p>I have a call center software which consist of industry specific calls, in which all calls are recorded and then all calls transform into text. After transforming into text, every calls is passed to other agent who is human, who extract all information from text. I have to extract information from AI, or some sort o...
<python><nlp><bots><artificial-intelligence>
2024-04-22 11:17:10
0
1,627
Faraz Ahmed
78,365,344
5,761,010
cv2.stereoRectify works only when the rotation and translation are from camera 2 to camera 1
<p>I am using the euroc-mav dataset to create a disparity map from stereo images: <a href="https://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets" rel="nofollow noreferrer">https://projects.asl.ethz.ch/datasets/doku.php?id=kmavvisualinertialdatasets</a>.</p> <p>In this dataset the cameras are alre...
<python><opencv><ros><robotics>
2024-04-22 09:50:38
0
1,293
Idan Aviv
78,365,343
13,977,239
unexpected behavior with `inspect.getmembers` on @property methods that throw exceptions
<p>I feel like I'm encountering a rather strange behavior in Python. Try it out yourself:</p> <pre class="lang-py prettyprint-override"><code>import inspect class SomeClass: def __init__(self): inspect.getmembers(self, predicate=inspect.ismethod) def this_is_okay(self): raise Exception('an err...
<python><class><properties><decorator><abstract-syntax-tree>
2024-04-22 09:50:25
1
575
chocojunkie
78,365,335
16,674,436
DataFrame groupby function returning tuple from column instead of the value
<p>Here is my pandas DataFrame:</p> <pre><code> id_country txt_template_1 txt_template_2 id_set id_question txt_question 0 NEUTRAL template neutral 1 template neutral 2 1 1 1_1 1 NEUTRAL template neutral 1 template neutral 2 1 2 1_2 2 NEUTRAL template neutral 1 template neutral...
<python><dataframe><group-by><tuples>
2024-04-22 09:48:30
1
341
Louis
78,365,173
1,769,197
matplotlib: failed to plot time series bars at the right timeframe
<p>Basically, i have the following data below from 9am to 1pm on a particular date. When I tried to create a time series bar plot, the bars are overlapping each other and the plot kept displaying a timeframe that is way wider than the 9am -1pm window. How to fix this using matplotlib without seaborn?</p> <p>Note that t...
<python><matplotlib>
2024-04-22 09:19:55
1
2,253
user1769197
78,365,076
7,052,826
Reading .xlsx file with Python Pandas changes some '<' to '<.1'
<p>I was given a very messy .xlsx file. It contains a multiheader. A small selection of these double headers looks like this.</p> <div class="s-table-container"><table class="s-table"> <thead> <tr> <th>zoxamide</th> <th></th> <th>zoxamide</th> <th></th> </tr> </thead> <tbody> <tr> <td>zOaAd [ug/l] [NVT] [AW]</td> <td>&...
<python><pandas>
2024-04-22 09:05:51
0
4,155
Mitchell van Zuylen
78,364,965
2,007,927
How to set an automated action to change Active status of a view on Odoo (v14)
<p>I have created a view which creates a popup on our website. The idea is the show this popup when the company is closed due to the public holidays. I set the public holidays in the calendar and I would like to trigger this view <code>Active</code> status when the date meets with those dates of public holiday.</p> <p>...
<python><odoo><odoo-14>
2024-04-22 08:46:13
0
586
george
78,364,791
2,886,789
How to do multipart/mixed requests?
<p>I'm tinkering with a website which is part of what SAP provides companies to do their work time accounting.</p> <p>I found out that what I'm planning to do is actually a post request, and here is what I took from the Chrome developer console Request payload field. I recorded this when I clicked on the button that I ...
<python><python-requests><odata>
2024-04-22 08:10:01
1
389
daeda
78,364,647
1,537,366
Avoiding accidental execution of python scripts as bash scripts
<p>I like to run my python scripts directly in bash like so</p> <pre><code>$ ./script.py </code></pre> <p>But sometimes I forget the shebang line <code>#!/usr/bin/env python3</code>, and it has the potential to overwrite a file named <code>np</code> if the script has <code>import numpy as np</code> (and if you click a ...
<python><bash><shebang>
2024-04-22 07:41:57
1
1,217
user1537366
78,364,486
16,383,578
How to tell if an archive file is corrupt?
<p>I have downloaded 424 files from <a href="http://www.nexusmods.com" rel="nofollow noreferrer">www.nexusmods.com</a>, they have a combined size of 21.576GiB.</p> <p>The average download speed is 1MiB/s, because I am a non premium user and subject to NexusMods' download speed cap. The download took well over 6 hours, ...
<python>
2024-04-22 07:09:15
1
3,930
Ξένη Γήινος
78,364,279
1,559,401
Server-sent events (SSE) using Python httpx-sse
<p>I recently moved my API client code from <code>requests</code> to <code>httpx</code>. Meanwhile, the backend added SSE support that I would like to take advantage of.</p> <p>I looked into the topic and the only thing I was able to find (in the context of <code>httpx</code>) is the <a href="https://pypi.org/project/h...
<python><server-sent-events><httpx>
2024-04-22 06:15:58
0
9,862
rbaleksandar
78,364,276
11,447,747
How does dask handles the datasets larger than the memory?
<p>I'm seeking guidance on efficiently profiling data using Dask.</p> <p>I've opted to use Dask to lazily load the DataFrame, either from SQL tables (dask.read_sql_table) or CSV files (dask.read_csv).</p> <p>I am using this code</p> <pre><code>df = dd.read_sql_table(args) df= client.persist(df) ... ... df[column].min()...
<python><dask><dask-distributed>
2024-04-22 06:15:21
1
341
Faizan
78,364,010
10,138,470
Replicating records in Pandas based on some condition and efficiently
<p>I have a pandas data frame with records like the below:</p> <pre><code>df = pd.DataFrame({ 'APPN': [1001, 1002, 1003, 1004, 1005, 1006], 'Applct_Id_1': ['A', 'B', 'C', 'D', None, 'F'], 'Applct_Id_2': [None, 'E', 'F', None, 'G', None], 'Applct_Id_3': ['W', 'Z', None, 'Y', None], 'Name': ['Alice'...
<python><pandas>
2024-04-22 04:46:37
1
445
Hummer
78,363,959
4,264,017
numpy.linalg.LinAlgError: Matrix is singular to machine precision
<p>I'm trying to use bai-perron code from <a href="https://github.com/ceholden/pybreakpoints" rel="nofollow noreferrer">https://github.com/ceholden/pybreakpoints</a> repo.</p> <p>My python version is 3.12.2</p> <p>The code I wrote is similar to their test.</p> <pre class="lang-py prettyprint-override"><code> from py...
<python><numpy><linear-algebra>
2024-04-22 04:28:31
0
2,987
Anurat Chapanond
78,363,851
5,942,100
dynamically mapping an excel spreadsheet using python and pandas
<p>I have a large excel spreadsheet that I need to read data from certain rows, columns and cells and then output into a different dataframe format. How would I capture the data in specific cells while also ensuring the data can be captured when the spreadsheet is changed? Meaning more columns or rows could be added, b...
<python><pandas><loops>
2024-04-22 03:34:24
0
4,428
Lynn
78,363,438
5,790,653
.replace() method not replacing within for loop but works manually
<p>This is my code:</p> <pre class="lang-py prettyprint-override"><code>numbers = {'1' : '۱', '2' : '۲', '3' : '۳', '4' : '۴', '5' : '۵', '6' : '۶', '7' : '۷', '8' : '۸', '9' : '۹', '0' : '۰', ',': '٬', '.': '.'} pricing = ['12,412,424,214', '124,124,214', '243,363', '3,363,463', '6,789,543', '124,689'] </code></pre> <...
<python>
2024-04-21 23:26:20
1
4,175
Saeed
78,363,340
3,843,029
Is it possible to define a subclass in python that creates a new atomic attribute?
<p>I'll call an &quot;atomic&quot; attribute of a python class to be one from which all other user defined attributes derive. For example, the attribute <code>a</code> in the class below is atomic to <code>A</code> because all user defined attributes (decorated with <code>@property</code>) derive from it.</p> <pre clas...
<python><oop><subclassing>
2024-04-21 22:32:56
0
570
gdavtor
78,363,045
8,713,442
Return null when multiple values has same mode
<p>Sharing one sample code . For column b as u can see both values{1,2} has same frequency{2} so mode is returning both values but I want null . Which logically means that it is unable to find one unique value which is most occuring.</p> <pre><code>import polars as pl if __name__ == '__main__': df = pl.DataFrame(...
<python><python-polars>
2024-04-21 20:14:07
1
464
pbh
78,362,710
1,082,349
Manually convert Stata running month format to datetime
<p>Stata has several date formats, running day, running datetime, number of months since epoch (...).</p> <p><a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_stata.html" rel="nofollow noreferrer">Pandas can automatically convert these to datetime when importing a .dta file</a>. Stata 18 n...
<python><pandas><stata>
2024-04-21 18:24:31
1
16,698
FooBar
78,362,395
2,179,994
Replacing multiple overlapping substrings in a string
<p>I have a string in an HTML document.</p> <pre><code>astring = &quot;R=500 mm, φ=180°, Z=599 mm von TL Boden oben. Unterliegende Schale: Boden oben.&quot; </code></pre> <p>I want to replace substrings of <code>astring</code> to make links. For this I have a list of dicts like</p> <pre><code>lst = [{'id': 'coordinate_...
<python><string><replace>
2024-04-21 16:48:10
1
2,074
jake77
78,362,390
51,816
How to extract the audio stream from an mp4 video file?
<p>Basically I am using this python code but when I put the extracted audio stream below the video stream with the same audio, they don't line up.</p> <p>One interesting detail is when I used the video editor itself to save the entire audio in the project when I have only the video stream, MP3 format also has a delay/l...
<python><video><ffmpeg><wav><moviepy>
2024-04-21 16:46:06
0
333,709
Joan Venge
78,362,161
6,494,707
addling the difference value of stripplot groups in seaborn
<p>I have used <a href="https://seaborn.pydata.org/archive/0.11/generated/seaborn.stripplot.html" rel="nofollow noreferrer">this example</a> of <code>stripplot</code> of seaborn</p> <pre><code>[ax = sns.stripplot(x=&quot;day&quot;, y=&quot;total_bill&quot;, hue=&quot;smoker&quot;, data=tips, palette=...
<python><matplotlib><plot><seaborn>
2024-04-21 15:40:44
1
2,236
S.EB
78,362,147
1,070,092
pyqtgraph plot with x-Axis in date units
<p>I try to plot a chart with dates in the x-axis. But the units displayed are in hours and minutes.</p> <pre><code>import sys import datetime import pyqtgraph as pg from PySide6.QtWidgets import QApplication, QMainWindow class MainWindow(QMainWindow): def __init__(self): super().__init__() self....
<python><pyqtgraph>
2024-04-21 15:35:19
1
345
Vik
78,362,091
7,496,406
How to start jupyter notebook in vscode using jupyter extension with workspace specified
<p>I am currently using the following <code>settings.json</code> file in my <code>.vscode</code> folder</p> <pre><code>{ &quot;terminal.integrated.env.windows&quot;: { &quot;PYTHONPATH&quot;: &quot;${workspaceFolder}&quot; } } </code></pre> <p>This allows me to run <code>jupyter notebook</code> from the...
<python><visual-studio-code><jupyter-notebook>
2024-04-21 15:17:28
1
1,371
Jrakru56
78,361,743
6,638,903
Getting tabular data into a dataframe from a PHP webpage
<p>This webpage ('*<a href="https://www.nseindia.com/market-data/top-gainers-losers*%27" rel="nofollow noreferrer">https://www.nseindia.com/market-data/top-gainers-losers*'</a>) has 2 tables ('gainers' and 'losers').</p> <p>I want a code to read the contents of the webpage and download these 2 tables into 2 separate da...
<python><python-3.x><dataframe>
2024-04-21 13:33:36
1
825
Tanmoy
78,361,630
3,477,339
Baseline3 TD3, reset() method too many values to unpack error
<p>The env is <code>python 3.10</code>, <code>stable-baseline3 2.3.0</code> and I'm trying TD3 Algorithm.</p> <p>I'm keep getting same error for whatever I do.</p> <p>As far as I know, the reset method has return as same as observation space defined</p> <p>The environment I made has reset method like below</p> <pre><co...
<python><machine-learning><stablebaseline3>
2024-04-21 12:58:27
1
497
GatesPlan
78,361,556
3,244,776
converting pem file to encrypted private key file of PBES1 format in Python
<p>I am writing a program where I am trying to convert the certs, which is of pem format into <code>PBES1</code> private key (the one with <code>-----BEGIN ENCRYPTED PRIVATE KEY-----</code> and <code>-----END ENCRYPTED PRIVATE KEY-----</code> header and footer.)</p> <p>Below is the code I wrote. I am specific about the...
<python><ssl><encryption><cryptography><pem>
2024-04-21 12:31:27
0
3,185
nohup