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,499,954
13,848,874
Why did they opt for the message "most recent call last"?
<p>If <em>&quot;most recent call last&quot;</em> means the most recent call is at the end of the stack, so what? What does this imply? How is this piece of information useful for me?</p>
<python>
2024-05-18 13:58:49
1
473
Malihe Mahdavi sefat
78,499,926
17,867,413
How to get outer key in a protobuf
<p>I am reading data from 2 proto files:</p> <p>file.proto: this is a wrapper</p> <p>file2.proto: this has all the columns</p> <p>file.proto:</p> <pre><code>syntax = &quot;proto3&quot;; package com.oracle; import &quot;file2.proto&quot;; option go_package = &quot;github.com/cle/sdk/go_sdk&quot;; // This is the inbo...
<python><protocol-buffers>
2024-05-18 13:46:26
1
1,253
Xi12
78,499,881
72,911
Testing python code with different byteorder / endianness
<p>I'm writing some python code that is sensitive to the byteorder / endianness. I want to ensure my unit tests are run in both byteorders.</p> <p>I'm currently running my tests on x86_64 Linux, which has little byteorder. What is the easiest way to run my python unit tests with big byteorder?</p>
<python><linux><unit-testing><endianness>
2024-05-18 13:28:43
0
9,642
Gary van der Merwe
78,499,781
1,121,892
Why is pyright issuing a type incompatibility error here?
<pre><code>from pandas import DataFrame, Series # This function prunes the dataframe rows to those meeting specified criteria def prune_to_wanted_rows(st_df: DataFrame, recency_date: str) -&gt; DataFrame: st_df = st_df[ # pyright error message (see below) here (st_df[&quot;assetType&quot;] == &quot;ore&quo...
<python><pandas><dataframe><pyright>
2024-05-18 12:52:57
2
319
brec
78,499,364
893,254
What is the default `datetime.now()` timezone?
<pre><code>from datetime import datetime from datetime import timezone print(f'datetime.now(): {datetime.now()}') print(f'current timezone: {datetime.now().tzinfo}') # prints `None` </code></pre> <p>As seen in the above code snippet, the default timezone for a <code>datetime</code> object created with <code>datetime.n...
<python><datetime><timezone>
2024-05-18 10:10:02
0
18,579
user2138149
78,499,295
5,837,992
Using SKLearn KMeans With Externally Generated Correlation Matrix
<p>I receive a correlation file from an external source. It is a fairly straightforward file and looks like the following.</p> <p><a href="https://i.sstatic.net/pYHLvrfg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pYHLvrfg.png" alt="enter image description here" /></a></p> <p>A sample csv can be fou...
<python><pandas><import><k-means><sklearn-pandas>
2024-05-18 09:40:55
2
1,980
Stumbling Through Data Science
78,499,234
1,115,833
huggingface optimum circular dependency issue
<p>I have a fresh virtual env where I am trying to exec an onnx model like so:</p> <pre><code># Load Locally Saved ONNX Model and use for inference from transformers import AutoTokenizer from optimum.onnxruntime import ORTModelForCustomTasks sentence = &quot;This is a test sentence.&quot; local_onnx_model = ORTModelFo...
<python><huggingface><onnx><onnxruntime>
2024-05-18 09:22:25
1
7,096
JohnJ
78,499,193
1,469,465
How to reverse a URL in format namespace:view:endpoint?
<p>I have a Django project with the following urlpattern defined on project level:</p> <pre><code>urlpatterns = [ path('', include(('ws_shopify.urls', 'ws_shopify'), namespace='shopify')), ] </code></pre> <p>The file <code>ws_shopify.urls</code> defines the following urlpatterns:</p> <pre><code>urlpatterns = [ ...
<python><django><django-rest-framework><url-pattern>
2024-05-18 09:10:41
1
6,938
physicalattraction
78,499,036
7,695,845
How to draw a large number of circles/spheres in matplotlib efficiently?
<p>I want to make a simulation of a large number of particles colliding with each other in matplotlib (on the order of ~10,000 particles). I want to make both 1D, 2D, and 3D simulations and I am struggling with how to draw a large number of particles with a given radius efficiently. In 1D and 2D, I figured out that my ...
<python><matplotlib>
2024-05-18 07:59:15
0
1,420
Shai Avr
78,499,028
5,378,816
What does the tempfile.mkstemp(text=...) parameter actually do?
<p>Is the <code>text=True|False</code> parameter in <code>mkstemp</code> something Windows specific? I'm sorry that I have to ask, but I'm a UNIX/Linux person.</p> <p>At the low level of file descriptors - where the <code>mkstemp</code> operates - are all files just bytes. I was surprised to see the <code>text=</code> ...
<python>
2024-05-18 07:55:17
2
17,998
VPfB
78,499,014
6,696,746
How to collapse or better organize long Jupyter notebook cells in Pycharm IDE?
<p>I'm working with long Jupyter notebooks (.ipynb files) that contain numerous cells and outputs, and it's becoming cumbersome to navigate through them in PyCharm. The IDE doesn't seem to natively support cell collapsing, which makes managing the notebook quite difficult.</p> <p>Are there any plugins, settings, or wor...
<python><jupyter-notebook><pycharm><jupyter>
2024-05-18 07:50:11
1
474
icaine
78,498,783
14,472,762
Can we use post_save signals in apps.py?
<p>There. I'm using django python. I've custom user model. I've created a separate django signals file. there is my method. I'm importing them in my apps.py and wanting to use there. cause, post_migrate signals are working that way. but post_save is different cause that takes model. whereas postmigrate are working with...
<python><python-3.x><django><django-models><django-rest-framework>
2024-05-18 06:02:43
1
958
Ahmed Yasin
78,498,781
3,623,537
check if assessing an address will cause a segfault without crashing python
<p>What I've tried:</p> <ol> <li><code>faulthandler</code> is really useful to get a traceback where segfault occurred but it doesn't allow handling it properly.</li> </ol> <pre class="lang-py prettyprint-override"><code>import faulthandler faulthandler.enable() import ctypes try: # Windows fatal exception: access...
<python><segmentation-fault><ctypes><python-c-api>
2024-05-18 06:01:54
1
469
FamousSnake
78,498,727
1,232,087
Can we use python f-string placeholder with index number?
<p>How can we achieve the following in Python 3.6 using <a href="https://www.w3schools.com/python/python_string_formatting.asp" rel="nofollow noreferrer">f-string</a> (<strong>instead</strong> of using <code>format()</code>) method?</p> <pre><code>quantity = 3 itemno = 567 price = 49 myorder = &quot;I want {0} pieces o...
<python><python-3.x><python-3.6>
2024-05-18 05:23:12
2
24,239
nam
78,498,541
6,676,101
How do I replace all numbers with something other than a number, using Python and regular expressions?
<p>Suppose that we want to replace all integers (<code>0</code>, <code>1</code>, <code>2</code>, <code>3</code>, ...) with a new-line character <code>\n</code>.</p> <p>How would we do that?</p> <p>Input: <code>&quot;1 apple 2 orange 3 kiwi&quot;</code> Output: <code>&quot;\n apple \n orange \n kiwi&quot;</code></p>
<python><regex>
2024-05-18 03:06:03
1
4,700
Toothpick Anemone
78,498,510
16,687,283
Python generic protocol with method taking instance of the protocol (e.g. Functor)
<p>With the current typing implementation, how far can we make this work as expected? Is there any innate problem in this approach?</p> <p>The problematic point is the method of generic protocol, taking an instance of self, where the type variable could be different from self.</p> <pre class="lang-py prettyprint-overri...
<python><mypy><python-typing>
2024-05-18 02:38:39
0
553
lighthouse
78,498,481
23,805,311
UserWarning: Plan failed with a cudnnException: CUDNN_BACKEND_EXECUTION_PLAN_DESCRIPTOR
<p>I'm trying to train a model with Yolov8. Everything was good but today I suddenly notice getting this warning apparently related to <code>PyTorch</code> and <code>cuDNN</code>. In spite the warning, the training seems to be progressing though. I'm not sure if it has any negative effects on the training progress.</p>...
<python><pytorch><nvidia><torchvision><cudnn>
2024-05-18 02:13:18
2
409
Mary H
78,498,394
1,613,983
How do I receive a non primitive object as query parameter?
<p>I'm trying to receive a nontrivial query parameter object. At the moment I'm doing this via a json-encoded string since objects seem to be assumed to arrive in the body in <code>fastapi</code>, so I've had to do something like this on the server:</p> <pre><code>class MyParam(pydantic.BaseClass): param1: list[str] ...
<python><fastapi>
2024-05-18 01:03:39
1
23,470
quant
78,498,374
2,345,484
How to add stacked bar plot in a subplot in Plotly?
<p>I have a data frame <code>df</code>, it has over 100 columns, I want to plot a stacked bar plot for these 100 columns, <code>plotly.express</code> is very nice, I can just do this</p> <pre><code>import plotly.express as px # df.columns = ['date', 'val1', 'val2', ..., 'val100', 'cost', 'numSales'] cols_to_be_stacked ...
<python><plotly>
2024-05-18 00:49:22
1
3,280
Allanqunzi
78,498,284
12,956,240
Bokeh Bar Chart - how to remove separator lines (x axis with nested categories)
<p>I've successfully created a Bokeh bar chart with nested categories by following the examples at the official bokeh site (<a href="https://stackoverflow.com">https://docs.bokeh.org/en/latest/docs/user_guide/basic/bars.html</a>)</p> <p>However, despite a thorough review of all the styling attributes and how they work,...
<python><bokeh>
2024-05-17 23:41:11
1
310
m.arthur
78,498,023
2,355,903
Removing rsid information from word XML in VBA
<p>I am trying to translate a bunch of .doc documents to .docx. I am using the script below, which works fine on its own.</p> <pre><code>Sub TranslateDocIntoDocx() Dim objWordApplication As New Word.Application Dim objWordDocument As Word.Document Dim strFile As String Dim strFolder As String strFolde...
<python><xml><vba><ms-word>
2024-05-17 21:35:56
1
663
user2355903
78,497,891
10,161,315
How to incorporate data cleansing into trained model
<p>If I cleanse the data and impute median value into NaN values, am I supposed to somehow incorporate this into my model that will be used on the test data? In other words, doesn't my test data need to be cleansed and imputed as well, or will the training take care of this?</p> <p>I want to say it needs to be incorpo...
<python><machine-learning><data-cleaning><mlmodel>
2024-05-17 20:47:39
1
323
Jennifer Crosby
78,497,859
20,022,511
Failed to install module `PyStruct` using pip
<p>I wanted to install the module <code>PyStray</code> for a project.</p> <p>I used the generic command -&gt; <code>pip install Pystruct</code></p> <p>Here is the error :</p> <pre><code>Collecting Pystruct Using cached pystruct-0.3.2.tar.gz (5.6 MB) Installing build dependencies ... done Getting requirements to b...
<python><pip>
2024-05-17 20:38:27
1
1,373
MT_276
78,497,824
2,893,712
Pandas Split By First Delimiter and Add Excess to Different Column
<p>I have a column in my dataframe for email addresses. Sometimes the field contains multiple emails separated by <code>; </code></p> <pre><code>EMAIL COMMENT email1@example.com Example Comment email2@example.com; email3@exampl...
<python><pandas><dataframe><split>
2024-05-17 20:26:12
2
8,806
Bijan
78,497,582
46,503
How to add spaces between sentences but ignore links?
<p>I need to put a space between sentences like:</p> <pre><code>&quot;This is one.This is two&quot; </code></pre> <p>should be:</p> <pre><code>&quot;This is one. This is two&quot; </code></pre> <p>In Python, I used the following regular expression:</p> <pre><code>text = re.sub(r'\.([A-Z])', r'. \1', text) </code></pre...
<python><regex>
2024-05-17 19:23:16
2
5,287
mimic
78,497,389
5,284,054
Python tkinter close first window while opening second window
<p>I'm trying to close the first window as the second window opens. Both windows close, or the first window closes and the second window never opens.</p> <p>This question has a similar problem but was solved by addressing the imported libraries: <a href="https://stackoverflow.com/questions/74816578/tkinter-is-opening-a...
<python><tkinter>
2024-05-17 18:32:09
2
900
David Collins
78,497,266
11,441,069
View Not Called in Django: Possible URLs.py Configuration Problem
<p>I'm facing a strange issue with Django. I have set up a simple form in a template that submits to a view, but I'm not getting the expected 404 response. Instead, I'm being redirected to the URL http://localhost:8000/clear/ without seeing the 404 error.</p> <p>Here is my setup:</p> <p>Template:</p> <pre><code>&lt;for...
<python><python-3.x><django>
2024-05-17 18:03:46
0
509
Krzysztof Krysztofczyk
78,497,151
1,460,910
Parsing dict like structure to dict
<p>I want to parse this input to output.</p> <pre><code>input = { &quot;a.b.c[0][0].d&quot;: &quot;i&quot;, &quot;a.b.c[0][1].e-f&quot;: &quot;j&quot;, &quot;a.b.c[0][2].g-h[0]&quot;: &quot;x&quot;, &quot;a.b.c[0][3].g-h[1]&quot;: &quot;y&quot;, &quot;a.b.c[0][4].g-h[2]&quot;: &quot;z&quot;, &qu...
<python><dictionary>
2024-05-17 17:39:56
0
555
Pranaya Behera
78,497,111
14,517,452
pydantic model incorrectly applies validation
<p>I have a model defined like this;</p> <pre><code>class SomeModel(BaseModel): name: str class SomeOtherModel(BaseModel): name: int class MyModel(BaseModel): items: List[Union[SomeModel, SomeOtherModel]] @validator(&quot;items&quot;, always=True) def validate(cls, value): by_type = list(...
<python><pydantic>
2024-05-17 17:26:31
2
748
Edward Spencer
78,497,084
2,192,423
Why the setter for the child class is called when calling super()
<p>I have been struggling with this for few hours now. I thought to seek the help of this community.</p> <p>I am creating a class to inherit from numpy.ndarray. I also need to create a getter and a setter for the dtype property.</p> <pre><code>import numpy as np class myarray(np.ndarray): __dtype = None def _...
<python><numpy><numpy-ndarray>
2024-05-17 17:21:57
0
849
MrAliB
78,496,873
3,015,186
How to write CSV data directly from string (or bytes) to a duckdb database file in Python?
<p>I would like to write CSV data directly from a bytes (or string) object in memory to duckdb database file (i.e. I want to avoid having to write and read the temporary .csv files). This is what I've got so far:</p> <pre class="lang-py prettyprint-override"><code>import io import duckdb data = b'a,b,c\n0,1,2\n3,4,5...
<python><duckdb>
2024-05-17 16:29:13
2
35,267
Niko Fohr
78,496,800
7,773,783
Error when calling cursor.execute with psycopg2 sql.SQL object
<p>I am trying to execute a raw update query using psycopg2 in django. The code is as below:</p> <pre><code>from django.db import connection from psycopg2 import sql model_instances_to_update = [] for model_instance in models_queryset: model_instances_to_update.append( sql.Identifier( f&quo...
<python><postgresql><psycopg2><django-orm><database-cursor>
2024-05-17 16:08:48
1
1,139
Lax_Sam
78,496,761
5,565,275
Selecting coefficient rows for statsmodels.iolib.summary.Summary
<p>I am building a real estate model and one-hot encoded the first three digits of zip code. I don't want to see all those zip codes. How can I print(model.summary()) for all the other features?</p>
<python><statsmodels>
2024-05-17 16:00:09
1
443
Duy Đặng
78,496,560
1,123,336
Is there a way to shut down the Python multiprocessing resource tracker process?
<p>I submitted a <a href="https://stackoverflow.com/questions/78460988/how-to-shut-down-the-resource-tracker-after-running-pythons-processpoolexecutor">question</a> a week ago about persistent processes after terminating the ProcessPoolExecutor, but there have been no replies. I think this might be because not enough p...
<python><python-multiprocessing>
2024-05-17 15:20:20
1
582
Ray Osborn
78,496,523
5,429,320
Passing "shopify_access_token" in the header of my request to API endpoint from Shopify web app
<p>I have an embedded Shopify app that my store uses. The app is just the front end and I have a few Azure Function App to host my different APIs for the app.</p> <p>In these function app I have a helper file which will take headers from the request and verify the Shopify token. This is to restrict the endpoints from b...
<python><python-3.x><azure-functions><shopify><shopify-app>
2024-05-17 15:12:56
1
2,467
Ross
78,496,475
6,751,456
django bulk update with batch in multiple transactions
<p>I've a certain code that updates bulk rows:</p> <pre><code>from simple_history.utils import bulk_update_with_history from django.utils.timezone import now bulk_update_list = [] for chart in updated_chart_records: chart.coder_assignment_sequence = count chart.queue_id = work_queue_pk chart.level_id = rol...
<python><django><bulkupdate><database-locking><django-simple-history>
2024-05-17 15:02:37
0
4,161
Azima
78,496,335
19,363,912
Get XOR between 2 dataframes
<p>How to get difference between 2 pandas dataframes (symmetric difference)?</p> <pre><code>import pandas as pd a = pd.DataFrame({'a': [1, 2], 'b': ['x', 'y']}) b = pd.DataFrame({'a': [1, 2, 3], 'b': ['x', 'z', '']}) result = pd.DataFrame({'a': [2, 2, 3], 'b': ['y', 'z', ''], 'source': ['a', 'b', 'b']}) </code></pre> <...
<python><pandas><xor>
2024-05-17 14:37:18
1
447
aeiou
78,496,328
12,415,855
Permisson Error when writing openpy-workbook?
<p>i try to open and save an openpyxl workbook using the following code:</p> <pre><code>import openpyxl as ox if __name__ == '__main__': wb = ox.load_workbook(&quot;colSort.xlsx&quot;, rich_text=True) wb.save(&quot;TEST.xlsx&quot;) </code></pre> <p>But i get this Permission Error -</p> <pre><code>$ python test.py T...
<python><openpyxl>
2024-05-17 14:36:24
1
1,515
Rapid1898
78,496,267
2,955,541
Adding a Private Attribute to a Subclassed NumPy Array
<p>In the <a href="https://numpy.org/devdocs/user/basics.subclassing.html#slightly-more-realistic-example-attribute-added-to-existing-array" rel="nofollow noreferrer">NumPy documentation</a>, it is demonstrated that you can add a custom attribute by subclassing the ndarray:</p> <pre><code>import numpy as np class Real...
<python><arrays><numpy>
2024-05-17 14:25:23
1
6,989
slaw
78,496,200
2,082,026
How to pass on the chopped details from URL in Django?
<p>I have a project with the following <code>urls.py</code>.</p> <pre class="lang-py prettyprint-override"><code>urlpatterns = [ path('category*/', include('student.urls')) // * could be replaced by a number ] </code></pre> <p>In that project I then have an application student whose <code>urls.py</code> looks like ...
<python><django><django-urls>
2024-05-17 14:10:15
1
498
Rishik Mani
78,496,083
3,258,600
Create an SQLAlchemy relationship between schemas without circular imports
<p>I have models in two different schemas with a foreign key relationship like this.</p> <p>File 1:</p> <pre><code>Base = declarative_base(metadata=MetaData(schema=&quot;a&quot;)) class Advertiser(Base): __tablename__ = 'advertisers' id = Column(Integer, primary_key=True) campaigns = relationship(&quot;Ca...
<python><sqlalchemy>
2024-05-17 13:48:24
1
12,963
kellanburket
78,496,068
6,419,513
Passing Sample Weights to Sklearn Pipeline object with XGBoost
<p>There are some good questions on this <a href="https://stackoverflow.com/questions/36205850/sklearn-pipeline-applying-sample-weights-after-applying-a-polynomial-feature-t">topic</a>, however, I haven't found any solution to this error involving using XGBoost models with <code>sample_weight</code> in sklearn's <code>...
<python><scikit-learn><pipeline><xgboost>
2024-05-17 13:45:26
0
1,732
a.powell
78,496,010
6,714,667
How can i compare each list in a list of lists and compare one of the last elements of the preceding list with first element of next list?
<pre><code>lists = [['1. what is your name','alice','what is your age','98'], ['2. how old are you','24','city of birth','washington 3. None what is your fav subject?'], ['3. what is your fav subject? please choose from maths, english, science','maths','school','elemetary oak'] ] </code></pre> <p>i have the above list ...
<python><list><python-itertools>
2024-05-17 13:33:14
1
999
Maths12
78,495,832
4,211,297
why is Pydantic saying email is missing when I'm declaring it
<p>In the code below, I'm creating an api that would accept a notification that should send an email. There are fields I want to add to the notification like an ID and TS after its been submitted. I have modeled it like below.</p> <pre><code>class NotificationPriority(Enum): high = &quot;high&quot; medium = &...
<python><fastapi><pydantic>
2024-05-17 12:59:48
1
2,351
Pompey Magnus
78,495,627
1,070,092
XML data created by pytesseract does not show elements
<p>I created an xml file with pytesseract in the following way:</p> <pre><code>from xml.etree import ElementTree as ET import pytesseract xml = pytesseract.image_to_alto_xml(&quot;test.png&quot;) root = ET.fromstring(xml) for string_element in root.iter(&quot;String&quot;): print(string_element.attrib) </code></...
<python><xml><python-tesseract>
2024-05-17 12:19:32
1
345
Vik
78,495,571
1,169,091
How to get the response from the AI Model
<p>I adapted this code from <a href="https://www.datacamp.com/tutorial/llama-cpp-tutorial" rel="nofollow noreferrer">https://www.datacamp.com/tutorial/llama-cpp-tutorial</a></p> <pre><code>from llama_cpp import Llama # GLOBAL VARIABLES my_model_path = &quot;./model/zephyr-7b-beta.Q4_0.gguf&quot; CONTEXT_SIZE = 512 # L...
<python><llamacpp>
2024-05-17 12:09:09
1
4,741
nicomp
78,495,548
1,726,805
How can I convert a json file to a pandas dataframe
<p>I have a json file with this structure:</p> <pre><code>[ { &quot;name&quot;: &quot;myName&quot;, &quot;type&quot;: { &quot;x&quot;: { &quot;id&quot;: [ &quot;x1&quot;, &quot;x2&quot; ] }, &quot;y&quot;: { &quot;id&quot;: &quot;y1&quot; }, ...
<python><json><pandas>
2024-05-17 12:04:46
2
609
Matthijs
78,495,482
78,903
How do I await a coroutine within a non-async function in Python?
<p>Consider this contrived example:</p> <pre class="lang-py prettyprint-override"><code>import asyncio async def main(): print(non_async_function()) def non_async_function(): # Syntax error due to &quot;await&quot;. return await async_function() async def async_function(): return &quot;foo&quot; if ...
<python><asynchronous><async-await>
2024-05-17 11:52:42
3
2,866
Kiran Jonnalagadda
78,495,333
10,806,496
Celery executes tasks sequentially, one after another
<p>I have a Django application that has large I/O-bound tasks.</p> <p>I use Celery to run these tasks in threads and manage the progress in the UI with a progress bar.</p> <p>Here's my configuration :</p> <p><strong>Django version</strong> : 5.0.2</p> <p><strong>Celery version</strong> : 5.3.6</p> <p><strong>Redis vers...
<python><python-3.x><django><celery><gevent>
2024-05-17 11:26:53
1
324
Mougnou
78,495,301
5,457,202
How to plot large dataset of Shapely LineString with Plotly?
<p>I've been given a DXF file at work to analyse it, and they want me to plot it as well. This file contains a layout of a private area. The data looks like this:</p> <pre><code>Layer PaperSpace SubClasses Linetype EntityHandle Text geometry 860 0 None AcDbEntity:AcDbPolyline None ...
<python><pandas><plot><plotly><shapely>
2024-05-17 11:20:51
0
436
J. Maria
78,495,189
395,069
How is Dataframe normalization being done?
<p>I am trying to understand the Normalization of the Dataframe values. Here is the scenario from the famous disaster i.e. Titanic and here is the code and result from a query:</p> <pre class="lang-py prettyprint-override"><code>dftitanic.groupby('Fsize')['Survived'].value_counts(normalize=False).reset_index(name='perc...
<python><dataframe><normalization>
2024-05-17 10:58:59
1
2,213
Farrukh Waheed
78,495,188
5,722,359
Is there a ready solution to quickly extract the contents of pipenv `Pipfile.lock` to a Python dictionary?
<p>The contents of the <code>pipenv</code> <code>Pipfile.lock</code> file looks like a nested Python dictionary.</p> <p>Is there a ready solution (function/class/module) to quickly extract the contents of <code>Pipfile.lock</code> to a Python dictionary?</p> <p>I tried:</p> <pre><code>content = [] with open(Pipfilelock...
<python><pipenv>
2024-05-17 10:58:44
1
8,499
Sun Bear
78,495,170
2,695,082
Replace an expression containing '/' with div function call in Python
<p>I am working on Python code to replace an expression containing '/' with actual function call. For eg: '(n/7-7) +(n/3+3)' should become '(div(n,7)-7 + ( div(n,3)+3)'. Please note only '/' operand needs to be replaced.</p> <p>I am using ast.NodeVisitor for the same.</p> <pre class="lang-py prettyprint-override"><code...
<python><abstract-syntax-tree>
2024-05-17 10:54:30
1
329
user2695082
78,494,817
13,942,929
How to adjust my external custom library import in __init__.py?
<p>So I have a big folder called Geometry and I divided in CPP folder and Cython folder as follows.</p> <pre><code>- Geometry - CPP (Where all the cpp codes are) - Cython - src folder - Geometry Package - Point Package - __init__.py - libcustom.so - Circle Package - __init__.py - libc...
<python><cython><ctypes>
2024-05-17 09:43:12
1
3,779
Punreach Rany
78,494,790
76,701
Jax: Passing a constant argument into a scanned function
<p>I'm refactoring a project written in Jax.</p> <p>There's a function, let's call it <code>foo</code>, that gets fed into <code>jax.lax.scan</code>. It has an argument <code>bar</code> that is currently part of the carry (i.e. the first argument, which is a tuple of different variables that gets passed ahead to the ne...
<python><jax>
2024-05-17 09:38:19
0
89,497
Ram Rachum
78,494,758
874,380
Gunicorn with muiltple works but shared memory
<p>My Falcon + Gunicorn backend accesses a relational database holding data that forms a graph – a table with nodes and a table with edges. Since the graph is not large (a couple of hundred nodes and edges) I load the data once a startup into a Networkx <code>DiGraph</code> and keep it in memory. Thus, when I request t...
<python><networkx><gunicorn><falconframework>
2024-05-17 09:30:33
1
3,423
Christian
78,494,317
11,304,830
Tours and activities *prices* using Amadeus API
<p>I am trying to collect the price of tours and activities using the Python API with Amadeus. I read a couple of papers collecting the price of German package holidays using Amadeus Germany GmbH (which I assume to have the same API and data availability). However, despite searching for many examples, I wasn't able to ...
<python><amadeus>
2024-05-17 08:09:17
1
1,623
Rollo99
78,493,571
2,360,477
Pandas df to Apache iceberg table
<p>I'm trying to insert into a Iceberg table, but I'm getting issues due to the data types mismatching. I've pasted a part of my code. The error message I'm getting is : &quot;errorMessage&quot;: &quot;Schema change detected: {'new_columns': {}, 'modified_columns': {'low': 'decimal(13,10)', 'close': 'decimal(13,10)', '...
<python><pandas><apache-iceberg>
2024-05-17 05:08:21
1
1,075
user172839
78,493,562
11,922,765
Python data filtering to remove outliers around a density plot
<p>Referring to the below plot, I would like to remove all the outliers outside the density region marked in black color oval shape. I can use simple horizontal filters, like, -4 &lt; data &lt; 4. But outliers still remain. I am looking for any technique that precisely captures the density samples but drops the outlier...
<python><dataframe><scikit-learn><cluster-analysis><outliers>
2024-05-17 05:05:26
1
4,702
Mainland
78,493,544
6,123,824
How to get single colorbar with shared x- and y-axis for seaborn heatmaps in subplot?
<p>I want to plot multiple confusion matrices in a single plot with a single colorbar and with a shared x- and y-axis. Here is my code I have tried so far</p> <pre><code>#Calculate the onfusion matrices predicted_mod1 = df_binary[&quot;Model1&quot;] actual_class = df_binary[&quot;Observed&quot;] out_df_mod1 = pd.DataF...
<python><matplotlib><seaborn><pivot-table><heatmap>
2024-05-17 04:56:59
1
8,294
UseR10085
78,493,405
1,779,091
Is running python inside an activated venv similar to using venv\python.exe?
<p>I'm trying to schedule a python script to run in an venv via windows task scheduler.</p> <p>In a normal command prompt I would have done:</p> <pre><code>Cd\foldername Venv\scripts\activate Python filename.py </code></pre> <p>However in task scheduler is the following doing the same?</p> <pre><code>C:\foldername\venv...
<python>
2024-05-17 03:58:07
0
9,866
variable
78,493,334
17,867,413
Time data '2024-05' does not match format '%Y-%m-%dT%H:%M:%S' (Protobuff)
<p>I am creating a protobuffer from a json and json strcture loooks like this:</p> <pre class="lang-json prettyprint-override"><code> { &quot;answerUpdateRequest&quot;: { &quot;entity&quot;: { &quot;type&quot;: &quot;ORGANIZATION&quot;, &quot;id&quot;: &quot;UU1234321234ID&quot; ...
<python><python-3.x><protocol-buffers><protobuf-net>
2024-05-17 03:24:37
2
1,253
Xi12
78,493,313
3,179,698
When install jupyterhub, many other files installed
<p>Hi I just installed jupyterhub using <code>conda install jupyterhub</code></p> <p>However It not work until I installed notebook.</p> <p>I noticed when I install jupyterhub, it has some other component installed, like jupyterhub-singleuser, jupyter-kernel,jupyter-lab,jupyter-notebook,jupyter-server,etc.</p> <p>My qu...
<python><jupyter-notebook><jupyterhub>
2024-05-17 03:17:11
1
1,504
cloudscomputes
78,493,186
2,153,235
Robust way to fix Errno 13 from reopening files on Windows?
<p>I am following a <a href="https://www.geeksforgeeks.org/working-with-wav-files-in-python-using-pydub" rel="nofollow noreferrer">tutorial on PyDub</a>. The very first exercise is to play a WAV file. Here is my adapted code. I'm not too worried about the warning at this point, as I am trying to resolve the <code>[Er...
<python><pydub>
2024-05-17 02:14:17
1
1,265
user2153235
78,493,059
5,284,054
Python tkinter change OptionMenu during runtime
<p>My second dropdown list is dependent on my first dropdown list. I can make it work by creating a second OptionMenu that overwrites the first OptionMenu. The following code works.</p> <p>However, I'm looking for way that will use the same OptionMenu, but will substitute in a new list for the <code>second_choice_pro...
<python><tkinter><tkinter.optionmenu>
2024-05-17 01:15:36
1
900
David Collins
78,492,801
8,474,432
How to implement MC dropout in keras?
<p>I'm very new to ML and especially more sophisticated techniques like dropout. I have a simple 1D CNN (regression problem), and I would like to capture uncertainties in the predictions for each output pixel. I would like to take advantage of MC dropout for this. This is the model where I've now added a dropout layer ...
<python><tensorflow><keras><dropout>
2024-05-16 23:12:05
0
1,216
curious_cosmo
78,492,749
7,547,047
Update python dictionary value as a list of strings enclosed within double quotes
<p>I am trying to call a post request using python where the body is a dictionary in which one parameter has to change based on the values of a list.</p> <p>The list is as below:</p> <pre><code>my_list = ['a14mnas','ty6798h'] </code></pre> <p>The body for the api call is as below:</p> <pre><code>api_body = { &quot;...
<python><json><list><dictionary><python-requests>
2024-05-16 22:52:28
0
397
msksantosh
78,492,715
9,669,142
Call function in Python script in a Gitlab repositry from another script in another Gitlab repository
<p>I have two Gitlab repositories that are both private and on an internal server. The first repo (let's call this Repo A) contains a Python script with some general functions. The second repo (Repo B) contains multiple Python scripts that are developed by the users. Calling a function in another Python script can easi...
<python><gitlab>
2024-05-16 22:34:46
1
567
Fish1996
78,492,708
7,662,164
JAX custom_jvp with 'None' output leads to TypeError
<p>I try to define a function whose jvp is only defined for selected output(s). Below is a simple example:</p> <pre><code>from jax import custom_jvp, jacobian @custom_jvp def func(x, y): return x+y, x*y @func.defjvp def func_jvp(primals, tangents): x, y = primals t0, t1 = tangents primals_out = fu...
<python><typeerror><jax><automatic-differentiation>
2024-05-16 22:30:43
1
335
Jingyang Wang
78,492,549
1,030,287
Pandas resample bi-monthly on even months
<p>I've got the following daily data:</p> <pre><code>1983-03-30 0.001224 1983-03-31 -0.003741 1983-04-04 0.005121 1983-04-05 0.009171 1983-04-06 0.006395 1983-04-07 0.009030 1983-04-08 0.006961 1983-04-11 -0.003950 1983-04-12 0.018837 1983-04-13 -0.000324 ... </code></pre> <p>I'd li...
<python><pandas>
2024-05-16 21:33:02
2
12,343
s5s
78,492,471
15,163,656
Openvpn WARNING: Failed running command (--auth-user-pass-verify): could not execute external program with python/bash auth script
<p>I am trying to execute auth flow with openvpn auth-pass-verify options. sample config from openvpn.conf:</p> <pre><code>auth-user-pass-verify /etc/openvpn/auth2.sh via-file verify-client-cert require script-security 3 </code></pre> <p>And the scripts I am trying to use</p> <pre class="lang-bash prettyprint-override"...
<python><linux><bash><openvpn>
2024-05-16 21:04:27
0
357
DISCO
78,492,373
9,095,840
Are there any modern image formats that use plain Huffman coding?
<p>I have some images that are very noisy, but the values are all in a narrow range of near-zero uint8 values. I think Huffman coding might be optimal for compressing them, since there is a lot of bit-wise redundancy but not a lot of sequence redundancy. However I can't find any image formats that use the plain bit-wis...
<python><image><compression><huffman-code><image-compression>
2024-05-16 20:39:12
1
1,824
markemus
78,492,310
5,284,054
Python tkinter cloase first window while opening second window
<p>I'm trying to close the first window as the second window opens. Both windows close, or the first window closes and the second window never opens.</p> <p>This question has a similar problem but was solved by addressing the imported libraries: <a href="https://stackoverflow.com/questions/74816578/tkinter-is-opening...
<python><class><tkinter>
2024-05-16 20:22:06
1
900
David Collins
78,492,179
5,284,054
Python tkinter class multiple windows
<p>Using tkinter, I'm trying to open one window from another window and doing so by creating the windows in a class.</p> <p>This question talks about tkinter and class, but not multiple windows: <a href="https://stackoverflow.com/questions/51867579/python-tkinter-with-classes">Python Tkinter with classes</a></p> <p>Thi...
<python><class><tkinter>
2024-05-16 19:49:16
1
900
David Collins
78,492,177
11,394,520
Slowly Updating Side Inputs & Session Windows - Transform node AppliedPTransform was not replaced as expected
<p>In my apache beam streaming pipeline, I have an unbounded pub/sub source which I use with <a href="https://beam.apache.org/documentation/programming-guide/#session-windows" rel="nofollow noreferrer">session windows</a>.</p> <p>There is some bounded configuration data which I need to pass into some of the DoFns of th...
<python><stream><google-cloud-dataflow><apache-beam><stream-processing>
2024-05-16 19:48:51
2
560
Thomas W.
78,491,897
358,980
Heroku Golang api with some python callouts
<p>I have a heroku golang 'app' thats deploying fine. The issue is that it calls some python scripts as the result of some REST requests. I have a <code>requirements.txt</code> in my <code>/bin</code> (python) dir but I'm wondering if it's possible to have the golang deploy process also process pip3 python3 requirement...
<python><heroku>
2024-05-16 18:43:43
1
4,112
Mike S
78,491,825
12,560,539
check python code location after pip installl
<p>I am using setuptools to manage my python project,</p> <pre><code>from setuptools import setup, find_packages setup( name=&quot;falcon&quot;, version=&quot;1.0.0&quot;, packages=find_packages(), install_requires=open(&quot;./requirements.txt&quot;).readlines(), entry_points={ &quot;conso...
<python>
2024-05-16 18:25:53
0
405
Joe
78,491,788
825,227
Trim trailing NaN values in Python dataframe
<p>Is there a way to trim trailing NaNs for each column in a dataframe?</p> <p>Acquainted with <code>dropna()</code> and its parameters (eg, axis, how) for dealing with stuff like this but doesn't seem to address this case.</p> <p>Sample data looks like this:</p> <pre><code> 1 2 3 4 5 ...
<python><pandas><dataframe>
2024-05-16 18:17:52
1
1,702
Chris
78,491,778
3,100,515
Pytest dependency doesn't work when BOTH across files AND parametrized
<p>I'm running into a problem wherein pytest_dependency works as expected when</p> <p>EITHER</p> <ul> <li>Doing parametrization, and dependent tests are in the same file</li> </ul> <p>OR</p> <ul> <li>Not doing parametrization, and dependent tests are in a separate file</li> </ul> <p><strong>But</strong>, I can't get th...
<python><pytest><pytest-dependency>
2024-05-16 18:15:07
1
5,678
Ajean
78,491,673
1,513,388
NATS Python example equivalent to 'nats reply' and 'nats request`
<p>I'm trying to learn more about NATS and I'm working through the python examples <a href="https://github.com/ConnectEverything/nats-by-example/tree/main" rel="nofollow noreferrer">here</a> and <a href="https://github.com/nats-io/nats.py" rel="nofollow noreferrer">here</a> I started with the command line and tested th...
<python><nats.io>
2024-05-16 17:48:29
0
7,523
user1513388
78,491,610
5,837,992
Comparing One Record in Pandas Dataframe To All Other Records in Dataframe
<p>I have a situation where I want to compare every value in one column of a dataframe against every other value in the same column. In this case, for every product, I want to see for Hyundais the comparison to Kias in each warehouse</p> <p>There are ~10,000 products (500,000 records total) that I want to compare - ev...
<python><pandas><loops><compare>
2024-05-16 17:33:06
1
1,980
Stumbling Through Data Science
78,491,587
7,687,981
Multiclass UNet with n-dimensional satellite images
<p>I'm trying to use a UNet in Pytorch to extract prediction masks from multidimensional (8 band) satellite images. I'm having trouble getting the prediction masks to look somewhat expected/coherent. I'm not sure if the issue is the way my training data is formatted, my training code, or the code I'm using to make pred...
<python><machine-learning><deep-learning><pytorch><semantic-segmentation>
2024-05-16 17:28:46
1
815
andrewr
78,491,565
4,209,368
Why first criteria only executed when filtering the rows by matching two columns in Python Pandas Dataframe
<p>I have below code to filter out rows of earliest year and month in the data. I used the logical operator '&amp;' as in the Method 1 segment of this below code. But Method 1 segment of below code filter out rows if first criteria condition met no matter second criteria met or not as it seems. Method 2 gives the corre...
<python><pandas>
2024-05-16 17:22:23
1
619
Dhay
78,491,423
2,153,235
pandas read_csv silently not parsing separate date & time fields despite provision of date_format
<p>I'm am reading a CSV file <a href="http://archive.ics.uci.edu/static/public/360/air+quality.zip" rel="nofollow noreferrer"><code>AirQualityUCI.csv</code></a> containing date data [1]. Here are a sample of 10 lines, including the 1st line for field names:</p> <pre><code>Date;Time;CO(GT);PT08.S1(CO);NMHC(GT);C6H6(GT)...
<python><pandas><datetime><read-csv>
2024-05-16 16:46:01
1
1,265
user2153235
78,491,419
4,076,764
sentence-transformers progress bar can't disable
<p>We're using <code>sentence transformers</code> to batch encode large text</p> <pre><code>model = SentenceTransformer('/app/resources/all-MiniLM-L6-v2') embeddings = [] for obj in data: text = obj['text'] row = {'id': obj['id'],'embedding' : np.ndarray.tolist(model.encode(text)} embeddings.append(row) </...
<python><torch><tqdm>
2024-05-16 16:45:48
1
16,527
Adam Hughes
78,491,362
5,403,987
How to combine non-contiguous numpy slices
<p>I have a numpy array with shape (M, N, N) - it's effectively a bunch (M) of (N,N) covariance matrices. I want to be able to extract submatrices out of this with shape (M, P, P). But I'm trying to access non-contiguous indices. Here's an example:</p> <pre><code>import numpy as np # Display all the columns np.set_pri...
<python><numpy><numpy-slicing>
2024-05-16 16:34:47
0
2,224
Tom Johnson
78,491,233
4,343,563
How to list all packages that are being used in python script?
<p>I want to check all the packages that are being used by my python script. I have a list of imports at the top of the script, but I'm not sure if those packages are actually getting used. So I want to check, of all the commands/functions I am using within by script, which of my imports are being used.</p> <p>For exam...
<python><import>
2024-05-16 16:09:12
1
700
mjoy
78,491,230
2,036,035
Why is my simple vec3 pyo3 pyclass so much slower than py glm's equivalent class at construction and multiplication?
<p>I'm trying to create a Python extension in Pyo3 that creates a type that is similar to a vec3/glm vec3, but instead from rust.</p> <p>I've created the following directory structure:</p> <pre class="lang-none prettyprint-override"><code>. β”œβ”€β”€ Cargo.toml β”œβ”€β”€ pyproject.toml β”œβ”€β”€ python β”‚ └── main.py └── src └── lib....
<python><python-3.x><rust><ffi><pyo3>
2024-05-16 16:09:04
1
5,356
Krupip
78,491,105
903,188
How do I get pydantic to report a violation if a YAML mapping to an optional attribute omits the space after the colon?
<p>The assertion at the end of the following code fails because there is no space between <code>walk</code> and <code>True</code> in the yaml:</p> <pre><code>import yaml from pydantic import BaseModel, parse_obj_as from typing import List class path_cls (BaseModel): path : str walk : bool = False other : b...
<python><yaml><pydantic>
2024-05-16 15:45:33
1
940
Craig
78,490,549
279,097
Polars: read_parquet with how='diagonal'
<p>Is there a way to do the same as the &quot;how&quot; parameter from pl.concat but with read_parquet?</p>
<python><dataframe><python-polars>
2024-05-16 14:16:40
2
415
Mac Fly
78,490,272
7,179,546
How to debug when a process receives a SIGABORT signal in Python
<p>I'm running an application in Python that uses asyncio and it's failing when I'm calling the function <code>await asyncio.gather()</code></p> <p>The error I'm getting is just <code>Process 90788 failed to create lock file</code> and the process just exits, without showing any traces of the error. I can see that the ...
<python><python-asyncio><sigabrt>
2024-05-16 13:34:18
0
737
Carabes
78,490,267
2,057,516
How to type hint an abstractmethod property and make mypy happy?
<p>Rewriting this question, because it turns out what I thought the problem was, wasn't the problem. In fact, I have a seemingly equivalent case that mypy doesn't complain about.</p> <p>Here is an example where there has no mypy complaints that seems equivalent:</p> <pre><code>class TableLoader(ABC): @property ...
<python><mypy><python-typing>
2024-05-16 13:33:24
1
1,225
hepcat72
78,490,201
904,910
Langchain GenericLoader Unsupported mime type when loading java files
<p>I am trying to take a bunch of java files and create an embedding to be used by an LLM.</p> <p>So want to read java files to create the embeddings in a chroma db.</p> <p>I have previously managed to do this successfully with pdf files but now I want to use my java code in the embeddings.</p> <p>I have a method</p> <...
<python><langchain>
2024-05-16 13:22:14
0
460
chhil
78,490,151
188,331
AutoTokenizer.from_pretrained took forever to load
<p>I used the following code to load my custom-trained tokenizer:</p> <pre><code>from transformers import AutoTokenizer test_tokenizer = AutoTokenizer.from_pretrained('raptorkwok/cantonese-tokenizer-test') </code></pre> <p>It took forever to load. Even if I replace the <code>AutoTokenizer</code> with <code>PreTrainedTo...
<python><huggingface-transformers><huggingface-tokenizers>
2024-05-16 13:14:02
3
54,395
Raptor
78,490,140
1,498,018
Python pandas read_excel fills blank cells with 0
<p>I am at a complete loss over this. I'm reading in a horrible Excel file with pandas using the following line:</p> <pre><code>pd_df = pd.read_excel(file_path, sheet_name=sheet, header=10, skipfooter=7, dtype='string', na_filter=False) </code></pre> <p>For one sheet, pandas apparently replaces/fills all empty cells wi...
<python><pandas><excel>
2024-05-16 13:12:53
1
1,673
Lilith-Elina
78,490,018
4,271,491
How to best handle badly concatenated json
<p>I receive a single json file from a client which is not correct. <br>The client concatenates multiple json resposnses into one file:</p> <pre><code>{ object1 { ... } } { object2 { ... } } ... </code></pre> <p>When I parse it with dataframe in pyspark, I always get a count o...
<python><json><pyspark>
2024-05-16 12:52:32
1
528
Aleksander Lipka
78,489,976
8,035,076
Google Cloud Job logs splitting single line log into multiple lines
<p>I am running a python script in GCP cloud jobs and the logs are getting weirdly split into multiple lines. Pretty much unreadable. Is there a way to avoid this</p> <pre><code>log = getLogger() log_formatter = Formatter( &quot;[%(process)d] [%(threadName)s] %(asctime)s %(name)s: %(message)s&quot; ) for handler in...
<python><google-cloud-functions><google-cloud-run>
2024-05-16 12:46:25
0
917
gd vigneshwar
78,489,962
7,227,627
PyVista ray_trace for structured grids?
<p><strong>What I want to do</strong></p> <p>For a boundary meteorological application in complex terrain I would like to check whether a sun ray hits the topography so that the cell under consideration is shaded (see photo)</p> <p><strong>What I have done and what the problem is</strong></p> <p>PyVista has in form of ...
<python><pyvista>
2024-05-16 12:44:49
1
1,998
pyano
78,489,951
4,434,140
how do I log on my azure cosmosdb for mongodb from aks through my workload identity?
<p>I have a private Azure Cosmos DB for MongoDB account (RU) together with a private AKS cluster. I want to access the MongoDB server from the AKS cluster through a workload identity. I followed the tutorial</p> <p><a href="https://learn.microsoft.com/en-us/azure/aks/learn/tutorial-kubernetes-workload-identity" rel="no...
<python><mongodb><azure-aks><workload-identity>
2024-05-16 12:42:03
1
1,331
Laurent Michel
78,489,892
9,295,873
Python - Azure App Service for Containers running multiple Celery Beat instances and duplicating tasks
<p>We have a Python project and we are handling scheduled tasks using Celery infrastructure. We have deployed our Celery beat and worker components in 2 separate Azure App Services for Containers.</p> <p>The issue that we are facing is that tasks are being duplicated. After checking the app service logs, I could see th...
<python><azure><containers><azure-appservice><celerybeat>
2024-05-16 12:31:23
1
631
Shubh Rocks Goel