QuestionId
int64
74.8M
79.8M
UserId
int64
56
29.4M
QuestionTitle
stringlengths
15
150
QuestionBody
stringlengths
40
40.3k
Tags
stringlengths
8
101
CreationDate
stringdate
2022-12-10 09:42:47
2025-11-01 19:08:18
AnswerCount
int64
0
44
UserExpertiseLevel
int64
301
888k
UserDisplayName
stringlengths
3
30
⌀
77,564,880
1,422,096
Built-in decorator to log method calls
<p>The following code (or custom solutions from <a href="https://stackoverflow.com/questions/5103735/better-way-to-log-method-calls-in-python">Better way to log method calls in Python?</a> or solutions with <code>inspect</code>) works to log method calls:</p> <pre><code>import logging, sys logging.basicConfig(stream=s...
<python><python-decorators><python-logging>
2023-11-28 14:55:30
1
47,388
Basj
77,564,689
512,480
VScode attach to unprepared remote python process?
<p>I have a Python process running on a raspberry pi processor elsewhere in my house. It has been working smoothly enough, long enough, that I quit running it in debug mode and just ran it the normal way, directly from the raspberry pi. I did not use debugpy. Now it shows evidence of a bug. I'd like to attach from my ...
<python><visual-studio-code><remote-debugging>
2023-11-28 14:29:38
1
1,624
Joymaker
77,564,517
3,521,180
how to dynamically insert random value to a column in excel through pandas?
<p>I have below two functions:</p> <pre><code>import pandas as pd import random import string def random_alphanumeric(length, hyphen_interval=4): characters = string.ascii_letters + string.digits random_value = ''.join(random.choice(characters) for _ in range(length)) return '-'.join(random_value[i:i + hyp...
<python><python-3.x><pandas><dataframe>
2023-11-28 14:03:30
1
1,150
user3521180
77,564,403
11,342,139
How to resolve PulseAudio connection test failed: Failed to connect to pulseaudio server?
<p>Multiple days now I have been trying to setup a python service that runs on debian and streams music via bluetooth. The bluetooth part works fine. I am using <code>dbus</code>. The problem comes with the `pulsectl` pulse audio service running on the debian computer. The error is below. It keeps telling that it cann...
<python><debian><dbus><pulseaudio>
2023-11-28 13:47:48
1
1,046
Angel Hadzhiev
77,564,191
860,233
FastAPI Websocket messages are being queued up and only being sent at the end of the user session
<p>For some reason, some of my websocket messages are only being sent when a session is over or right before a websocket becomes disconneted. I have connection and session management code and I'm making sure to pass around the same websocket object, even veryfying the ID as a debugging step. I am relatively new to pyth...
<python><reactjs><fastapi>
2023-11-28 13:17:52
0
930
Glenncito
77,564,148
15,222,211
How can retrieve the mandatory attributes of a Pydantic object?
<p>How to identify mandatory attributes in a Pydantic object. In the following example, the method <code>mandatory_attributes</code> does it manually. Is it possible to identify all mandatory attributes automatically?</p> <pre class="lang-py prettyprint-override"><code>from pydantic import BaseModel, Field class MyCl...
<python><pydantic>
2023-11-28 13:11:22
1
814
pyjedy
77,564,110
4,451,521
How can I make a histogram with two consecutive bars in plotly?
<p>I have the following code:</p> <pre><code>import pandas as pd import numpy as np import matplotlib.pyplot as plt # Sample data (replace this with your actual DataFrame) data = { 'CU': [1.5, 2.3, 1.8, 3.2, 2.5, 2.0, 3.8, 3.0], 'ER': [0.2, 0.5, np.nan, 0.7, 0.8, 0.4, 0.9, 0.6], } df = pd.DataFrame(data) prin...
<python><plotly>
2023-11-28 13:03:35
1
10,576
KansaiRobot
77,563,999
12,851,171
Passing argument on SparkKubernetesOperator
<p>I am using a spark with airflow, but not able to pass the arguments. I have tried multiple ways please suggest where right way to do this this.</p> <p>dag.py file:</p> <pre><code>base_operator = SparkKubernetesOperator( application_file=&quot;spark-pi.yaml&quot;, task_id='segment_tag_...
<python><apache-spark><kubernetes><pyspark><airflow>
2023-11-28 12:45:13
1
303
Shivam Gupta
77,563,897
3,935,797
Bert topic clasiffying over a quarter of documents in outlier topic -1
<p>I am running Bert topic with default options</p> <pre><code>import pandas as pd from sentence_transformers import SentenceTransformer import time import pickle from bertopic import BERTopic llm_mod = &quot;all-MiniLM-L6-v2&quot; model = SentenceTransformer(llm_mod) embeddings = model.encode(skills_augmented, show...
<python><nlp><bert-language-model><topic-modeling>
2023-11-28 12:32:26
1
1,028
RM-
77,563,738
12,163,252
groupby and aggregate on the resulting groups
<p>I have a dataframe with a column Status which values are either 'OPEN' or 'CLOSED'. I would like to do a <code>groupby()</code> on multiple columns and use the following rule for that Status column: <em>if there is one or more 'OPEN' values in the group then the aggregate should return 'OPEN' else 'CLOSED'</em></p> ...
<python><pandas><group-by>
2023-11-28 12:07:09
2
453
Hotone
77,563,636
2,641,187
Python type hints for type promotion
<p>Consider a function that performs type promotion, e.g. a simple multiplication of two numbers that can both be either <code>int</code> or <code>float</code>:</p> <pre class="lang-py prettyprint-override"><code>def mul(a: int | float, b: int | float): # return type? return a * b </code></pre> <p>This function re...
<python><mypy><python-typing>
2023-11-28 11:50:21
3
931
Darkdragon84
77,563,490
4,350,650
Can I assign a specific environment/docker image to my Kaggle notebook?
<p>I want to create a new Kaggle notebook that would be relying on the same environment than an older Kaggle notebook I have.<br /> <strong>Why ?</strong> Because I want to use the commit &amp; save function allowing you to run stuff in the background, without having it running my entire original notebook as it would ...
<python><docker><jupyter-notebook><kaggle>
2023-11-28 11:25:51
0
2,099
Mayeul sgc
77,563,309
3,751,931
shap force plots for multiclass problems
<p>I am trying to get to show the force plots for a given test example to all show in the same plot in the case of a multiclass classification problem.</p> <p>My best attempt:</p> <pre><code>explainer = shap.TreeExplainer(model) shap_test = explainer.shap_values(x_test) fig, axs = plt.subplots(6, 1, figsize=(10, 5 * ...
<python><machine-learning><shap><xai>
2023-11-28 10:56:02
0
2,391
shamalaia
77,563,236
6,221,742
GPT4All prompt size
<p>Name: gpt4all Version: 2.0.2</p> <p>I am trying to query a database using GPT4All package using my postgresql database. Below is the code</p> <pre><code>from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler from langchain_experimental.sql import SQLDatabaseChain from langchain import SQLDat...
<python><langchain><py-langchain><gpt4all>
2023-11-28 10:45:53
1
339
AndCh
77,563,053
8,037,521
Installing local dependency with pip install
<p>I am using the Setuptools build backend for a <code>pyproject.toml</code>-based project.</p> <p>I have this project structure:</p> <pre><code>- project_root - dependency_lib - pyproject.toml - * other files * - src - package_name - __init__.py * different .py f...
<python><setuptools><python-packaging>
2023-11-28 10:20:23
0
1,277
Valeria
77,562,638
9,974,205
How can I find pairs and triplets of values in a pandas dataframe
<p>I have a pandas dataframe in Python that contains the following pair of columns.</p> <p>I need to count how many times pairs and triplets of combination of data appear with and without considering the order. As an example, let's say that I have a dataframe with two columns, <code>Classification</code> and <code>Indi...
<python><pandas><dataframe><dataset><series>
2023-11-28 09:24:00
1
503
slow_learner
77,562,470
7,959,614
Merge dictionaries with same key using ChainMap
<p>I have two dictionaries</p> <pre><code>a = {'123': {'player': 1, 'opponent': 2}, '18': {'player': 10, 'opponent': 12} } b = {'123': {'winner': 1}, '180': {'winner': 2} } </code></pre> <p>The goal is to merge them together and get one dictionary that looks as follows:</p> ...
<python><dictionary><mapping>
2023-11-28 08:59:11
3
406
HJA24
77,562,252
14,771,666
How to find the probability cutoff that maximize inner product of two tensors?
<p>I have two tensors:</p> <pre><code>import torch target = torch.randint(2, (3,5)) #tensor of 0s &amp; 1s pred = torch.rand(3, 5) #tensor of prob # transformed_pred = ? </code></pre> <p>How can I choose a cutoff probability to transform <code>pred</code> into a tensor of 0s &amp; 1s (<code>transformed_pred</code>) s...
<python><pytorch><probability><dot-product>
2023-11-28 08:21:39
1
368
Kaihua Hou
77,562,167
3,336,412
SQL Alchemy maps UUID-primary key to string
<p>I'm working with SQLModel and I created following base-table and table:</p> <pre class="lang-py prettyprint-override"><code>class GUIDModel(PydanticBase): &quot;&quot;&quot; Provides a base mixin for tables with GUID as primary key &quot;&quot;&quot; guid: Optional[UUID] = Field( ..., ...
<python><sqlalchemy><uuid><sqlmodel>
2023-11-28 08:04:27
1
5,974
Matthias Burger
77,562,148
11,267,783
Issue using GridSpec and colorbar with Matplotlib
<p>I want to create a specific plot using GridSpec. However with my code, colorbars are changing the width_ratios.</p> <p><a href="https://i.sstatic.net/jdKz0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jdKz0.png" alt="enter image description here" /></a></p> <pre><code>import numpy as np import matp...
<python><matplotlib>
2023-11-28 08:02:13
1
322
Mo0nKizz
77,561,864
9,798,210
How to use pdf document in the agent using Langchain
<p>My code uses &quot;wikipedia&quot; to search for the relevant content. Below is the code</p> <h1>Load tools</h1> <pre><code>tools = load_tools( [&quot;wikipedia&quot;], llm=llm) agent = initialize_agent( tools, llm, agent=AgentType.CHAT_ZERO_SHOT_REACT_DESCRIPTION, handle_parsing_errors=True,...
<python><langchain><large-language-model><pdfium>
2023-11-28 07:00:38
1
1,835
merkle
77,561,851
10,633,596
Getting HTTP Error 403 Forbidden when making call to GitLab server using Python code
<p>I have written a small Python code to get the Storage usage of a GitLab repository. However when I run my code then I get this <code>403 Forbidden error</code>. This repo, say <strong>test_repo_1</strong> is under a <strong>test_group_1</strong>. I have created the token with Maintainer role both at project level an...
<python><gitlab-api><python-gitlab>
2023-11-28 06:56:43
1
1,574
vinod827
77,561,774
1,467,552
How does Polars auto-cache mechanism work on LazyFrames?
<p>As stated <a href="https://twitter.com/RitchieVink/status/1570477690297147392/photo/1" rel="noreferrer">here</a>, Polars introduced an auto-cache mechanism for LazyFrames that occures multiple times in the logical plan, so the user will not have to actively perform the cache.<br /> However, while trying to examine t...
<python><dataframe><python-polars>
2023-11-28 06:34:49
2
1,170
barak1412
77,561,524
9,983,652
when to use feature selection when doing hyperparameter optimization?
<p>I am using skopt(scikit-optimize) to find best hyperparameters for random forest model. I have a lot of features. To avoid overfitting, I'd like to add feature selection like using RFE. But I am not sure when to use feature selection, during each iteration of estimating each combination of parameters or after findin...
<python><scikit-optimize>
2023-11-28 05:25:33
0
4,338
roudan
77,561,384
10,200,497
dateutil.parser._parser.ParserError: hour must be in 0..23:
<p>The dataframe is on my drive:</p> <pre><code>url = 'https://drive.google.com/file/d/12R6nMvN81GJHSBEElP8NiXXkwtuv04wf/view?usp=sharing' url = 'https://drive.google.com/uc?id=' + url.split('/')[-2] df = pd.read_csv(url) sym time online_price 0 1000FLOKIUSDT 00:04.9 0.02567 1 1000F...
<python><pandas>
2023-11-28 04:38:06
1
2,679
AmirX
77,561,341
13,771,657
Getting GPS boundaries for each hexbin in a python plotly 'hexbin_mapbox' heat map - Both centroid GPS point and GPS points for each corner of hexbin
<p>I have created a hexbin &quot;heat map&quot; in Python using plotly by mapping a number of locations (using GPS latitude / longitude), along with the value of each location. See code below for sample df and hexbin figure plot.</p> <p><strong>Data Desired</strong></p> <p>When I mouse-over each hexbin, I can see the ...
<python><pandas><plotly><gps><latitude-longitude>
2023-11-28 04:23:15
2
528
BGG16
77,561,306
5,719,396
Spark reads in parallel but writes partitions with only one core
<p>I have a 300 GB csv file that I am writing to an existing iceberg table using a local Spark cluster. My context is initialized like this:</p> <pre><code>.master(&quot;local[*]&quot;) \ .config(&quot;spark.driver.memory&quot;, &quot;30g&quot;) \ .config(&quot;spark.executor.memory&quot;, &quot;15g&quot;) \ .config(&q...
<python><apache-spark><pyspark><apache-iceberg>
2023-11-28 04:12:08
1
7,566
iskandarblue
77,561,280
5,718,551
Const pydantic field value
<p>I have the below Pydantic model</p> <pre class="lang-py prettyprint-override"><code>import datetime import pydantic class MealsService(pydantic.BaseModel): class MealItem(pydantic.BaseModel): course: str name: str quantity: int unitPrice: float | None type: str = &quot;me...
<python><pydantic>
2023-11-28 04:03:08
2
944
Inigo Selwood
77,561,224
14,250,641
Extracting Sequences from Padded DNA Sequences
<p>I have a DataFrame with two columns, 'padded_seq' and 'seq', where 'padded_seq' contains padded DNA sequences, and 'seq' contains target sequences.</p> <p>Simple example DataFrame:</p> <pre><code> padded_seq seq 0 AATTGGC TTG 1 AATTGGC TTG 2 AATTGGC TTG ...
<python><pandas>
2023-11-28 03:37:44
0
514
youtube
77,560,983
4,451,521
Plot with colors depending on data
<p>I would like to plot some data but with colors depending on certain conditions. Ideally I would like to do it in both plotly and matplotlib (separate scripts)</p> <p><strong>The data</strong></p> <p>For example I have the following data</p> <pre><code>import pandas as pd data = { 'X': [1, 2, 3, 4, 5,6,7,8,9,10]...
<python><matplotlib><plotly>
2023-11-28 02:18:31
2
10,576
KansaiRobot
77,560,739
2,985,331
scikit-learn FeatureUnion never exits
<p>I have two versions of a pipeline, one of which runs, one of which doesn't.</p> <p>Version 1. This runs reasonably quickly. Approximately 4 hours on a machine with 32G and 16 cores. In this version I am doing a differential methylation analysis to outside of this to select several hundred variables from a set of mor...
<python><scikit-learn>
2023-11-28 00:38:46
1
451
Ben
77,560,697
9,973,177
websockets : ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK)
<p>I'm trying to exchange data between 2 processes using websockets but I get a connectionClosedOK after the first request. Tried a few suggestions but can't really figure out how to fix it... as far as I understand the error happens on <code>res = await asyncio.wait_for(websocket.recv(), timeout=10)</code></p> <p>The ...
<python>
2023-11-28 00:25:26
1
952
Will
77,560,538
113,538
How to print a char ** var from python LLDB
<p>I'm trying to print out a char ** using the python LLDB lib. To be clear it the char **argv from the main function in a C program. It should have 3 strings in the array from the input.</p> <p>When launching the C program and stopping right after main(int argc, char **argv) in xcode i can just do p argv[0] and p argv...
<python><c><lldb>
2023-11-27 23:31:10
2
895
Brian
77,560,516
4,398,966
does __new__ over ride __init__ in python
<p>I have the following code:</p> <pre><code>class Demo: def __new__(self): self.__init__(self) print(&quot;Demo's __new__() invoked&quot;) def __init__(self): print(&quot;Demo's __init__() invoked&quot;) class Derived_Demo(Demo): def __new__(self): pri...
<python><init><derived-class><base-class>
2023-11-27 23:23:49
3
15,782
DCR
77,560,502
3,195,451
Pandas .any() vs. Python any() on Dataframe
<p>What is the reason to prefer Pandas implementation of <code>.any()</code> instead of Python's builtin <code>any()</code> when used on a DataFrame? Is there a performance reason to this, since Pandas DataFrames are column-major? My hunch is perhaps the Pandas method is implemented in such a way that it is faster fo...
<python><pandas><dataframe><any>
2023-11-27 23:19:00
2
2,499
Daniel
77,560,495
875,295
Possible non optimization in list comprehension
<p>If I do the following:</p> <pre><code>import sys for i in range(30): print(sys.getsizeof([1 for _ in range(i)])) </code></pre> <p>I get outputs that are powers of 2, whereas if I do this:</p> <pre><code>for i in range(30): print(sys.getsizeof([1]*i)) </code></pre> <p>I get smaller sizes that are linearly in...
<python><list-comprehension>
2023-11-27 23:18:11
0
8,114
lezebulon
77,560,464
9,582,542
MongoDB bulk loading 36000 files
<p>I am newbie to mongoDB. Currently I have a dataframe with the full path to 36000 json files. I downloaded the mongoimport and placed it in my install bin directory. I would like to create a loop of some sort to load all files into my local install of mongodb. Should I do this in python or does the mongoimport have t...
<python><mongodb><mongoimport>
2023-11-27 23:09:09
1
690
Leo Torres
77,560,371
4,980,705
Pandas Apply using input from first row and not from each row
<p>I have the following table and want to use the RoadSegmentOrigin as input for a new column OriginCoordinates</p> <pre><code>RoadSegmentOrigin,RoadSegmentDest,trip_id,planned_duration AREI2,JD4,107_1_D_1,32 JD4,PNG4,107_1_D_1,55 PNG4,TVA2,107_1_D_1,55 </code></pre> <p>This is what I'm using:</p> <pre><code>df_RoadSeg...
<python><pandas><dataframe>
2023-11-27 22:45:00
0
717
peetman
77,560,354
13,142,245
Locust: How to specify volume of requests in time period?
<p>I'm interested in using Locust to load test an endpoint. From <a href="https://docs.locust.io/en/stable/writing-a-locustfile.html#environment-attribute" rel="nofollow noreferrer">documentation</a> (see third &quot;Note&quot; section.)</p> <blockquote> <p>For example, if you want Locust to run 500 task iterations per...
<python><locust>
2023-11-27 22:41:27
1
1,238
jbuddy_13
77,560,247
5,549,107
How to return json object with QHttpServer
<p>I am trying to create a simple rest api with QHttpServer in Python. I had checked examples in C++. However, I couldn't get it to work in Python. When <code>callback_api</code> returns a string, it is visible as plain text, but any other return value creates a response with empty body and status code 200. Moreover st...
<python><qt><pyside><pyside6>
2023-11-27 22:16:50
1
304
Reactionic
77,560,118
901,426
python 'socket' has no attribute 'CAN_J1939'
<p>just making a pretty straightforward J1939 reader with the <code>socket</code> library:</p> <pre class="lang-py prettyprint-override"><code>import socket with socket.socket(socket.PF_CAN, socket.SOCK_DGRAM, socket.CAN_J1939) as s: s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) addr = &quot;can3&quo...
<python><can-bus><j1939>
2023-11-27 21:45:42
0
867
WhiteRau
77,560,096
6,368,549
Python - Parsing / extracting sections using Python
<p>was hoping someone could give me some suggestions.</p> <p>So, I have a large HTML document. I need to extract data between 2 tags. It's a dynamic document, so it can be different each time/ But there are a couple of constants. The starting point of extraction will be the section that starts with &quot;Notes t...
<python><html><parsing>
2023-11-27 21:40:31
1
853
Landon Statis
77,560,095
10,620,003
Build the different df from one df based on the ids columns in a df with multiple Nans
<p>I have a dataframe which has multiple Nan values. I want to build three different dataframe from it. Here is an example of my df:</p> <pre><code>df = pd.DataFrame({'a':[10, np.nan, np.nan, 22, np.nan], 'b':[23, 12, 7, 4, np.nan], 'c':[13, np.nan, np.nan, np.nan, 65]}) a b c 0 10.0. 23.0 13.0 1 NaN...
<python><pandas><dataframe>
2023-11-27 21:40:27
3
730
Sadcow
77,559,996
6,930,340
Define dependency in pyproject.toml depending on operating system
<p>I am using <code>pyproject.toml</code> according to PEP 631 (i.e. NO <code>poetry</code>, I am using <code>pdm</code>). I need to specify a dependency version according to the operating system.</p> <p>So far, I tried something like this:</p> <pre><code>[project] ... dependencies = [ &quot;kaleido==0.0.3; platfor...
<python><python-packaging><pyproject.toml><pdm>
2023-11-27 21:19:04
0
5,167
Andi
77,559,948
22,212,435
Event button release doesn't work if another event happens
<p>The problem occurs when a mouse button is pressed and not released, another click <code>event</code> happens which interrupts the current <code>event</code>. I will try to show this with the following code example:</p> <pre><code>import tkinter as tk root = tk.Tk() l = tk.Label(bg='red', width=30, height=30) l.pack...
<python><tkinter>
2023-11-27 21:05:10
1
610
Danya K
77,559,867
3,906,786
How to nest a list of attrs classes into an attrs class
<p>I have a list of dicts and I'd like to use <code>python-attrs</code> to convert them into classes.</p> <p>Here's the sample data:</p> <pre class="lang-ini prettyprint-override"><code>[[characters]] first_name = 'Duffy' last_name = 'Duck' [[characters]] first_name = 'Bugs' last_name = 'Bunny' [[characters]] first_n...
<python><python-3.x><python-attrs>
2023-11-27 20:50:30
2
983
brillenheini
77,559,790
5,473,533
Python Tkinter TreeviewSelect event got called twice (it should only be called once)
<p>I am having a problem with the Tkinter Treeview code below. The code generates a Combobox and a treeview.</p> <p>Every time, when I select a value in Combobox, it will automatically update the value in the treeview, like following:</p> <p><a href="https://i.sstatic.net/LclUu.jpg" rel="nofollow noreferrer"><img src="...
<python><tkinter><treeview>
2023-11-27 20:35:29
1
523
Hao Shi
77,559,452
1,492,613
why inplace=True behave differently when apply to a single column view than apply to a multiple columns?
<p>I have been heavily using scipy and numpy form many years. There performance is very important so we normally do not copy data whenever possible. I also use pandas superficially for more than 10 years. I usually thought inplace=True means no-copy on data during operation.</p> <p>However, recently I encountered some ...
<python><pandas><dataframe>
2023-11-27 19:29:22
0
8,402
Wang
77,559,433
18,377,883
Can't install command-not-found on pip
<p>I wanna install the pip package command-not-found which is defined in my requirements.txt like this: <code>command-not-found==0.3</code> on my Ubuntu machine but i get this error:</p> <pre><code>ERROR: No matching distribution found for command-not-found==0.3 </code></pre> <p>I heard that there is an apt package <co...
<python><ubuntu><pip>
2023-11-27 19:25:21
2
1,681
vince
77,559,227
5,013,143
How to get an instance attribute which is the name of the instance itself?
<p>I have a Python class named <code>myClass</code> having one argument or more, say <code>a</code>, and an instance which I call <code>obj</code>, as follows:</p> <pre><code>class myClass: def __init__(self, a): self.a = a ... def method1(self): ... obj = myClass(3) </code></pre> <p>I ...
<python>
2023-11-27 18:40:21
1
7,483
Stefano Fedele
77,559,176
15,781,591
Unable to set custom timestamp xticks in seaborn lineplot [python]
<p>My dataframe looks like this: <a href="https://i.sstatic.net/7xOMv.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7xOMv.png" alt="enter image description here" /></a></p> <p>We see category values for a given Date/Time timestamp, showing year, month, day, and the time.</p> <p>Plotted as a lineplot in...
<python><datetime><seaborn><strftime>
2023-11-27 18:31:01
1
641
LostinSpatialAnalysis
77,558,995
9,462,829
install tensorflow wheel through requirements.txt
<p>I'm working on a project and my processor is old, so I need to install a specific Tensorflow wheel, from here: <a href="https://github.com/fo40225/tensorflow-windows-wheel/tree/master/2.9.0/py39/CPU%2BGPU/cuda117cudnn8sse2" rel="nofollow noreferrer">https://github.com/fo40225/tensorflow-windows-wheel/tree/master/2.9...
<python><tensorflow><github>
2023-11-27 17:53:22
1
6,148
Juan C
77,558,894
9,026,704
How to upload a file larger than 32MB from django admin panel hosted in Cloud Run?
<h2>Problem</h2> <p>I need to upload zip files with a size of ~800MB to a GCP Cloud Storage bucket using Django's admin panel. My Django API is hosted in Cloud Run, and I just found out Cloud Run has a request size limit of 32MB. I want to know if there's any workaround for this.</p> <h2>What I tried</h2> <p>I have tri...
<python><django><google-cloud-platform><google-cloud-run>
2023-11-27 17:36:18
0
337
Nicholas Kemp
77,558,692
7,615,684
Change Bitbucket's Private repo to Public repo using RESTAPI
<p>I want to convert few of my private repositories to public repo.</p> <pre><code>import requests workspace = '' base_url = 'https://api.bitbucket.org/2.0/' session = requests.Session() session.auth = (username, password) headers = { 'Content-Type': 'application/json' } data = { &quot;type&quot;: &quot;repos...
<python><rest><python-requests><bitbucket>
2023-11-27 17:04:04
1
1,356
NavaneethaKrishnan
77,558,411
1,210,665
Python regex for matching next line if present
<p>I have to match some lines as below.</p> <p><em>Case 1</em>:</p> <pre><code>[01:32:12.036,000] &lt;tag&gt; label: val3. STATUS = 0x1 [01:32:12.036,001] &lt;tag&gt; label: val3. MISC = 0x8 [02:58:34.971,000] &lt;tag&gt; label: val2. STATUS = 0x2 </code></pre> <p><em>Case 2</em>:</p> <pre><code>[01:32:12.036,000] &lt;...
<python><python-3.x><regex>
2023-11-27 16:21:04
2
914
VinayChoudhary99
77,558,347
4,980,705
Use Python to calculate timing between bus stops
<p>The following is an example of the .csv file of thousands of lines I have for the different bus lines.</p> <p><strong>Table:</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>trip_id</th> <th>arrival_time</th> <th>departure_time</th> <th>stop_id</th> <th>stop_sequence</th> <th>sto...
<python><pandas><numpy>
2023-11-27 16:11:19
3
717
peetman
77,558,217
390,897
Blender Python Package Cannot be Resolved in VSCode
<p>I'm trying to get Blender's Python library (bpy) working with VSCode, but for some reason, despite having the correct interpreter selected, VSCode cannot resolve the package. What's strange is that Jupyter autocomplete has no issues.</p> <p>Other libraries, such as Numpy, import without any issues.</p> <p>Note that ...
<python><python-import>
2023-11-27 15:48:46
1
33,893
fny
77,558,059
4,249,338
How to check if a path is a relative symlink in python?
<p><code>os</code> package has <code>os.path.islink(path)</code> to check if <code>path</code> is a symlink. How do I determine if a file located at <code>path</code> is a <em>relative</em> symlink?</p> <p>Note that <code>path</code> can be an absolute path (i.e. <code>path == os.path.abspath(path)</code>), e.g. <code>...
<python>
2023-11-27 15:24:39
1
656
gg99
77,557,930
8,270,512
dataframe to string for posting in a jira comment
<p>I am trying to create a string representation of a pandas DataFrame that can be formatted as a table in JIRA comments. My issue arises when newline characters (\n) in the string are not being correctly interpreted by JIRA, when I try to paste the string.</p> <p>Code: Here's the Python function I'm using to convert a...
<python><jira>
2023-11-27 15:06:30
0
1,141
ZakS
77,557,712
5,959,601
Continous Update of Python Qt Plot
<p>Consider the sample PySide6 code below. I have a class <strong>SampleWindow</strong> which generates some set of values continuously (x and y). I would also like to plot and visualize them parallelly, for which <strong>ScatterPlotDialog</strong> class has been writtten. However, I am having issues with the continuo...
<python><pyside><pyqtgraph>
2023-11-27 14:37:06
1
449
StanGeo
77,557,706
11,040,661
FastAPI protecting shared variable with multiprocessing lock
<p>My objective is to have a stateful app that is optimized for latency, albeit going against 12-factor pattern. Thus, I need a state manager that can safely handle concurrency/race conditions to a certain extent. Take a look at the example below:</p> <pre class="lang-py prettyprint-override"><code>import copy from fas...
<python><fastapi><uvicorn><multiprocess><starlette>
2023-11-27 14:35:51
0
1,111
Silver Flash
77,557,539
13,641,680
How to run Python Azure SDK in a Github Actions workflow with federated credentials authentication
<p>I have a Python tool that wants to interact with Azure SDK (list and upload blobs). Typically I would use something like:</p> <pre class="lang-py prettyprint-override"><code>from azure.identity import DefaultAzureCredential from azure.storage.blob import BlobServiceClient creds = DefaultAzureCredential() client = B...
<python><azure><federated-identity><azure-sdk>
2023-11-27 14:11:02
1
1,750
everspader
77,557,529
10,985,257
Building Debian Python Package with Poetry
<p>I try to build a debian package from the python package <code>python-pam</code>.</p> <p>I followed mostly this <a href="https://gist.github.com/gh-888/0c69a350a8bcfff0c12b2d1c553b6fb6" rel="nofollow noreferrer">gist</a>.</p> <p>Because the description is based on <code>setup.py</code>, but <code>python-pam</code> is...
<python><debian><packaging>
2023-11-27 14:09:12
0
1,066
MaKaNu
77,557,459
6,562,240
Dynamically Adding Columns to DataFrame based on str.split() output
<p>I currently have a dataframe with one column containing contact names such as:</p> <pre><code>Andrew Jones James Hugh Peter Michael </code></pre> <p>I am trying to split the names into mutiple columns so that I can separate first names from last names:</p> <pre><code>df[['Name Part One', 'Name Part Two', 'Name Part ...
<python><pandas><split>
2023-11-27 13:57:37
1
705
Curious Student
77,557,453
3,336,423
Scipy: Bessel iterative filtering different than single shot filtering
<p>I have this piece of code that applies a Bessel filter:</p> <p><strong>One-shot version:</strong></p> <pre><code>import scipy.signal fc_bessel = 0.14 # [Hz] ordre_bessel = 3 b,a = scipy.signal.bessel(ordre_bessel, fc_bessel, 'low', analog=False, output='ba', fs=300) filter_once = scipy.signal.lfilter(b, a, input...
<python><scipy><filtering>
2023-11-27 13:56:41
1
21,904
jpo38
77,557,429
10,909,217
Validate a function call without calling a function
<p>I'd like to know if I can use pydantic to check whether arguments <em>would</em> be fit for calling a type hinted function, but <em>without</em> calling the function.</p> <p>For example, given</p> <pre><code>kwargs = {'x': 1, 'y': 'hi'} def foo(x: int, y: str, z: Optional[list] = None): pass </code></pre> <p>I ...
<python><pydantic>
2023-11-27 13:53:01
2
1,290
actual_panda
77,557,426
14,777,704
Is it an efficient and a good practice to pass huge pandas dataframes as function parameters and also return them from functions?
<p>I apologize for asking a dumb question but kindly advise me regarding this.</p> <p><strong>Scenario a: I need to write 1.5GB pandas dataframes as csv files into SharePoint location.</strong></p> <p>Approach 1:</p> <pre><code># function to write dataframe to sharepoint location def writeData(largeDataframe,uname,pwd,...
<python><pandas><dataframe>
2023-11-27 13:52:28
2
375
MVKXXX
77,557,158
12,276,279
How can I add arrows in maps using geopandas and matplotlib with the arrows having color gradients?
<p>I want to show trade flow between countries in a map. For this, I want to add 1 or 2 arrows to and from country as shown below. The arrow should have color gradients, which represent certain numeric values.</p> <p>1.How can I add arrows on top of countries in maps using geopandas or other packages?</p> <ol start="2"...
<python><matplotlib><geospatial><spatial>
2023-11-27 13:09:48
1
1,810
hbstha123
77,557,107
4,404,805
Python: int() returning unexpected results
<p>I have a scenario where I cannot use Python's inbuilt rounding functions so I have written a custom rounding function but it's not giving the expected result for a particular usecase. This is what I have tried (I have kept the output as the comments):</p> <pre><code>import pandas as pd def custom_rounder(value, sca...
<python><pandas><dataframe><apply><series>
2023-11-27 13:03:04
0
1,207
Animeartist
77,557,037
2,725,810
The phenomenon of AWS Lambda function running time not affected by cold starts
<p>I have a script to keep two Lambda functions warm:</p> <pre class="lang-py prettyprint-override"><code>PING_DELAY = 60 last_ping = -PING_DELAY while True: try: timer = Timer() timestamp_str = \ datetime.now().strftime(&quot;%d.%m.%Y %H:%M:%S.%f&quot;)[:-3] print(f&quot;Ping at...
<python><aws-lambda>
2023-11-27 12:50:38
1
8,211
AlwaysLearning
77,556,881
3,256,651
Display plotly go figure in widget
<p>I would like to make a widget in jupyter lab with a plotly go figure.</p> <p>I started by copying this example: <a href="https://plotly.com/python/figurewidget-app/?_ga=2.180976559.943274886.1701077393-1452099185.1695387650" rel="nofollow noreferrer">https://plotly.com/python/figurewidget-app/?_ga=2.180976559.943274...
<python><plotly><jupyter-lab><ipywidgets>
2023-11-27 12:24:22
0
1,922
esperluette
77,556,682
6,562,240
Lambda Function "unhashable type: Series" error
<p>I am attempting to set the value of a column equal to &quot;United States of America&quot; if the first 3 characters of another column equal &quot;USA&quot;, else I want to preserve the existing value of the column.</p> <pre><code>df['Country'] = df['Country ID'].map(lambda x: 'United States of America' if x[:3] == ...
<python><pandas><lambda>
2023-11-27 11:53:19
0
705
Curious Student
77,556,547
4,069,931
Bumpversion optional dev version
<p>I am using the Bumpversion utility (<a href="https://github.com/peritus/bumpversion" rel="nofollow noreferrer">https://github.com/peritus/bumpversion</a>) to increase the version of my application.</p> <p>And I want to make <code>dev</code> build - add a suffix to a regular version <strong>optionally</strong>. With ...
<python><version><bump2version>
2023-11-27 11:31:57
1
874
Hardwired
77,556,489
21,034,926
Tkinter - Create table using database fetched data
<p>I'm learning Python and I want to make a GUI using Tkinter module. I'm reading some articles about usage and now I'm trying to create a simple table that needs to be pupulated from data fetched from a supabase indatnce. I've writed this code but when I try to debug it the application will crash. How I need to fix it...
<python><tkinter><supabase>
2023-11-27 11:20:48
1
501
OHICT
77,556,413
9,974,205
How can I extract subchains of names from pandas dataframe
<p>Following <a href="https://stackoverflow.com/questions/77555573/how-can-i-extract-chains-of-customers-from-a-pandas-dataframe">this question</a>, I have the following code capable of finding chains of customers in a database per delivery person sortie.</p> <pre><code>import pandas as pd data = { 'DateTime': ['0...
<python><pandas><database><dataframe><series>
2023-11-27 11:07:38
1
503
slow_learner
77,556,210
13,861,187
Django, How to access request data in include template
<p>In my Django project, I have some templates that includes in base template using {% include %} tag. How do I access request data in this included template? How do I access context variables in this included template?</p> <p>I was expecting that request data is accessible in any template.</p>
<python><django><templates><request><include>
2023-11-27 10:35:16
1
888
Pycm
77,556,102
9,072,753
How to make chunked streaming PUT request to BaseHTTPRequestHandler not loose bytes?
<p>Consider the following MCVE, that runs a python program that:</p> <ul> <li>sets the global variable <code>FIXME</code> set during startup from the first command line argument</li> <li>in one thread starts a HTTP server <ul> <li>that listens to chunked PUT requests using <code>select</code> on the <code>self.rfile.fi...
<python><linux><http><select>
2023-11-27 10:18:23
1
145,478
KamilCuk
77,555,936
252,194
Error when using checkinstall to create Python 3.12 installer on Debian 11
<p>I am using checkinstall 1.6.3 to create a .deb installer for Python 3.12 on Debian 11.</p> <p>I used this description as an outline for doing it and had it working in the past for Python 3.11 on the same system: <a href="https://stackoverflow.com/questions/63314253/how-to-install-python3-8-using-checkinstall-on-debi...
<python><python-3.x><pip><debian><checkinstall>
2023-11-27 09:49:56
0
401
tompi
77,555,911
2,820,289
Pandas: group dataframe on variables depending on threshold
<p>I have a dataframe, and I want to group it on some variables <code>a</code>, <code>b</code>, <code>c</code>. If I group the dataset by <code>a</code>, and count the number of rows for all levels of <code>a</code>, if some level of <code>a</code> has fewer rows than some threshold, I do not want to continue grouping ...
<python><pandas><group-by>
2023-11-27 09:46:29
1
685
Helen
77,555,841
9,564,152
How to retry failed tasks in celery chunks or celery starmap
<p>I would like to know how to configure these tasks correctly so that the failed tasks can be retried. One thing I have noted is if one of the tasks in the chunk fails, the whole chunk (I assume executed by celery.starmap) fails</p> <p>Here are some related questions I have checked:</p> <p>-https://stackoverflow.com/q...
<python><django><celery>
2023-11-27 09:36:31
0
583
Eric O.
77,555,742
5,873,325
Streamlit : Dynamically open multiple pdfs files in different tabs
<p>I have a Streamlit application where I can upload some pdf files and then select the files I want to work on from a select box and they will be displayed in the main panel. Now instead of displaying all the selected pdfs one after the other, I wonder if it’s possible to dynamically open every selected file in a new ...
<python><file-upload><tabs><streamlit>
2023-11-27 09:20:32
2
640
Mejdi Dallel
77,555,698
9,846,358
Cannot click the <svg></svg> and input the value
<p>Cannot click the <code>&lt;svg width=&quot;16&quot; height=&quot;16&quot; viewBox=&quot;0 0 16 16&quot; fill=&quot;none&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;...&lt;/svg&gt;</code> and input the <code>&lt;input class=&quot;opacity-0 absolute top-0 left-0 w-full h-full&quot; type=&quot;date&quot; max=...
<python><css><selenium-webdriver><xpath>
2023-11-27 09:14:21
1
797
Mary
77,555,606
2,005,869
How best to create an intake catalog from a collection of CSV files?
<p>I'm trying to figure out the best way to create an intake catalog from a collection of CSV files, where I want each CSV file to be an individual <code>source</code>.</p> <p>I can create a <code>catalog.yml</code> for one CSV by doing:</p> <pre class="lang-py prettyprint-override"><code>import intake source1 = intake...
<python><csv><intake>
2023-11-27 08:57:18
1
16,655
Rich Signell
77,555,573
9,974,205
How can I extract chains of customers from a Pandas dataframe?
<p>I have a pandas dataframe with information about the deliveries done by a delivery person. In this pandas dataframe there are four columns. The first one is <code>DateTime</code>, the second one is <code>SortieNumber</code>, the third one is <code>CustomerName</code> and the fourth one is <code>ProductCode</code>.</...
<python><pandas><database><dataframe><series>
2023-11-27 08:52:09
2
503
slow_learner
77,555,529
3,484,477
Where can one find the open source Python implementation of `cv2.warpAffine`?
<p>Where is the python implementation of modules of OpenCV, like <code>https://github.com/opencv/opencv</code>, for example for <code>cv2.warpAffine</code>?</p>
<python><opencv>
2023-11-27 08:44:11
1
1,643
Meysam Sadeghi
77,555,527
21,049,944
How to effectively create duplicate rows in polars?
<p>I am trying to transfer my pandas code into polars but I have a difficulties with duplicating lines (I need it for my pyvista visualizations). In pandas I did the following:</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd df = pd.DataFrame({ &quot;key&quot;: [1, 2, 3], &quot;value&quot;: [4,...
<python><dataframe><python-polars>
2023-11-27 08:43:28
3
388
Galedon
77,555,492
1,113,579
Python: True fire-and-forget POST request without waiting for response even in separate thread
<p>In Python 3.10, I want to send some data to an API Server using the POST method without waiting for response. I have seen many solutions which use a separate thread to make the POST request, but my requirement is not to wait for response <strong>even in the separate thread</strong>. I want a true fire-and-forget API...
<python><multithreading><python-requests><fire-and-forget>
2023-11-27 08:37:46
1
1,276
AllSolutions
77,555,312
2,601,515
Langchain / ChromaDB: Why does VectorStore return so many duplicates?
<pre><code>import os from langchain.llms import OpenAI import bs4 import langchain from langchain import hub from langchain.document_loaders import UnstructuredFileLoader from langchain.embeddings import OpenAIEmbeddings from langchain.text_splitter import RecursiveCharacterTextSplitter from langchain.vectorstores impo...
<python><openai-api><langchain><py-langchain><chromadb>
2023-11-27 08:01:32
3
401
narcissa
77,555,284
16,405,935
Read two sheets and concat
<p>I have one dataframe with two sheets as below:</p> <pre><code>import pandas as pd sheet_1 = pd.DataFrame({'KIFRS BS / IS': ['', 'CCY Type :', 'COA Code', '11000000000'], 'Unnamed: 1': ['', 'EQU', 'COA English Name', 'ABC'], 'Unnamed: 2': ['', '', 'Base Currency Exchange Amt.',...
<python><pandas>
2023-11-27 07:55:15
1
1,793
hoa tran
77,554,773
2,251,058
Send Image File to slack using http request sending blank image
<p>I am trying to send a graph to slack channel using Http Request, but I am able to see only a blank png. If I use the slack WebClient to send the same graph it succeeds but not using an http request.</p> <pre><code>data_anomalies_trend_pd = data_anomalies_trend.toPandas() plt.figure(figsize=(10, 6)) plt.plot(data_an...
<python><python-3.x><slack>
2023-11-27 05:58:26
1
3,287
Akshay Hazari
77,554,764
14,534,480
Replace values in pandas column with lists by values in other dataframe
<p>I have dataframe with column that contains lists with id of objects and objects alias in other dataframe. I want to replace <code>id</code> in column with lists in first dataframe by <code>alias</code> from second.</p> <p>First:</p> <pre><code>df = pd.DataFrame({'objects': ['', '', '']}) df.objects[0] = [] df.object...
<python><pandas>
2023-11-27 05:55:08
2
377
Kirill Kondratenko
77,554,491
11,748,924
Catching MessageError exception from userdata.get() in Google Colaboratory secrets
<p>I'm trying to use the userdata.get() function in Google Colab to retrieve a secret, and I want to handle the case where the secret doesn't exist. Here's my code:</p> <pre><code>from google.colab import userdata try: userdata.get('mySecret') except MessageError: print(&quot;The mySecret doesn't exists&quot;) </co...
<python><google-colaboratory>
2023-11-27 04:10:06
1
1,252
Muhammad Ikhwan Perwira
77,554,393
15,781,591
How to make line segments transparent based on value using seaborn in python
<p>I am using the following example code presented by user &quot;dnswlt&quot; for creating a multiple lineplot using seaborn in python:</p> <pre><code>num_rows = 20 years = list(range(1990, 1990 + num_rows)) data_preproc = pd.DataFrame({ 'Year': years, 'A': np.random.randn(num_rows).cumsum(), 'B': np.rando...
<python><plot><seaborn>
2023-11-27 03:30:26
2
641
LostinSpatialAnalysis
77,554,214
2,307,441
Transpose df columns based on the column names in Pandas
<p>I have a pandas dataframe as below and I would like to transpose the df based on the column Names</p> <p>I want transpose all the coumns that has _1,_2,_3 &amp; _4. I have 100+ Values in my df, Below is the example data.</p> <pre class="lang-py prettyprint-override"><code> import pandas as pd data = { # One...
<python><pandas><dataframe>
2023-11-27 02:16:30
2
1,075
Roshan
77,553,886
8,755,792
PyTorch distributed from two ec2 instances hangs
<pre><code># env_vars.sh on rank 0 machine #!/bin/bash export MASTER_PORT=23456 export MASTER_ADDR=... # same as below, private ip of machine 0 export WORLD_SIZE=2 export GLOO_SOCKET_IFNAME=enX0 export RANK=0 # env_vars.sh on rank 1 machine #!/bin/bash export MASTER_PORT=23456 export MASTER_ADDR=... # same as above...
<python><pytorch><distributed-computing>
2023-11-26 23:32:25
1
1,246
Eric Auld
77,553,830
12,279,326
Updating False values in a list based on the previous iteration
<p>I have a list of lists:</p> <pre><code>['col1', False, False, False, False, False] ['col1', 'col2', False, False, False, False] ['col1', False, 'col3a', False, False, False] ['col1', False, 'col3b', False, False, False] ['col1', False, False, 'col4', False, False] ['col1', False, False, 'col4', False, False] </code>...
<python>
2023-11-26 23:16:30
3
948
dimButTries
77,553,816
9,213,600
Keras RBF (radial basis functions) layer for image classification is not working
<p>I want to build an image classifier using an RBF layer, Keras, and the fashionMNIST dataset. The model compiles correctly, the only issue I have is that the model is not learning anything, basically classifies any image to some label it comes up with ending up with 10% accuracy all the time (please note that the fas...
<python><machine-learning><keras><scikit-learn><deep-learning>
2023-11-26 23:09:33
0
1,104
Ali H. Kudeir
77,553,676
16,988,223
Dask dataframe condition to compare column doesn't working
<p>I'm trying to compare the column names of a dask dataframe to then change the column data type, however my condition never is true:</p> <pre><code>column_name = &quot;names&quot; print(f&quot;Col Name: {column_name} \n&quot;) # names # Change column datatype: for i in dataframe_for_db.select_dtypes(include='object')...
<python><dataframe><dask>
2023-11-26 22:13:32
1
429
FreddicMatters
77,553,523
1,960,266
tokenizer and parser returns wrong answer for a postfix notation
<p>I have coded a tokenizer and a recursive parser for a postfix expression. My code is the following:</p> <pre><code>import re token_patterns = [ ('OPERATOR', r'[+\-*/]'), ('NUMBER', r'\d+'), ('WHITESPACE', r'\s+'), ] def tokenize(source_code): tokens = [] source_code = source_code.strip() w...
<python><parsing><tokenize><recursive-descent>
2023-11-26 21:19:57
1
3,477
Little
77,553,414
12,193,952
Refactoring FastAPI application: Best practices for handling overlapping parameters
<p>I am working on a <strong>Python</strong> application. It is an <strong>FastAPI</strong> based API and it's main purpose is to provide calculations controlled by received <strong>query parameters</strong>. The project has grown a lot and the number of available API parameters is around 150. I wanted to do some refac...
<python><python-3.x><class><pydantic>
2023-11-26 20:39:09
0
873
FN_