QuestionId
int64
74.8M
79.8M
UserId
int64
56
29.4M
QuestionTitle
stringlengths
15
150
QuestionBody
stringlengths
40
40.3k
Tags
stringlengths
8
101
CreationDate
stringdate
2022-12-10 09:42:47
2025-11-01 19:08:18
AnswerCount
int64
0
44
UserExpertiseLevel
int64
301
888k
UserDisplayName
stringlengths
3
30
76,399,139
3,840,940
Spark PySpark Configuration in Visual Studio Code
<p>I try to configure Apache Spark PySpark in Visual Studio Code.</p> <pre><code>OS : Windows 11 java : 17 LTS python : Anaconda 2023.03-1-windows apache spark : spark-3.4.0-bin-hadoop3 VScode : VSCodeSetup-x64-1.78.2 </code></pre> <p>I install the &quot;Spark &amp; Hive Tools&quot; extension pack on VScode and add <co...
<python><apache-spark><visual-studio-code><pyspark>
2023-06-04 06:04:35
1
1,441
Joseph Hwang
76,399,115
8,401,374
ET.iterparse is not loading all XML tags inside a specifc tag in python with xml.etree.ElementTree
<p><strong>My code:</strong></p> <pre><code>tree = ET.iterparse(file_path, events=('start',)) for _, elem in tree: if 'product' in elem.tag: if elem.attrib.get('product-id') == &quot;B4_1003847_000&quot;: print(ET.tostring(elem)) breakpoint() process_p...
<python><xml><lxml><elementtree><large-data>
2023-06-04 05:55:46
0
1,710
Shaida Muhammad
76,399,078
5,380,656
Creating a TypedDict with enum keys
<p>I am trying to create a <code>TypedDict</code> for better code completion and am running into an issue.</p> <p>I want to have a fixed set of keys (an Enum) and the values to match a specific list of objects depending on the key.</p> <p>For example:</p> <pre class="lang-py prettyprint-override"><code>from enum import...
<python><enums><python-typing><typeddict>
2023-06-04 05:38:12
2
771
Charlie
76,398,598
4,611,374
Streamlit: Why does updating the session_state with form data require submitting the form twice?
<p>I appear to fundamentally misunderstand how Streamlit's forms and <code>session_state</code> variable work. Form data is not inserted into the <code>session_state</code> upon submit. However, submitting a second time inserts the data. Updating <code>session_state</code> values always requires submitting the form 2 t...
<python><forms><session-state><streamlit>
2023-06-04 01:09:39
1
309
RedHand
76,398,541
21,343,992
Connect to websocket server using IP address with Python websockets library
<p>New to Python. I'm trying to connect to a websocket server using the actual IP address.</p> <p>Connecting using the websocket URL works fine:</p> <pre><code>import websocket def on_message(wsapp, message): print(message) ws = websocket.WebSocketApp(&quot;wss://api.server.com:443/ws/stream&quot;, on_message=on_...
<python><websocket><tcp>
2023-06-04 00:38:05
1
491
rare77
76,398,466
6,577,503
Drawing a graph network in 3D
<p>Suppose I am a given a directed graph in python:</p> <pre><code>V = [ 1, 2, 3, 4, 5] E = { 1 : [ 2, 3, 4] 2: [ 1, 2, 3] 3 : [1, 4, 5] 4: [5] 5: [1, 3] } c = [ 81, 23, 43, 22, 100] </code></pre> <p>V and E represent the vertex and edge sets of the graph as a list and dictionary respectively. And c is a cost function...
<python><networkx>
2023-06-03 23:55:40
1
441
Anon
76,398,368
10,327,849
Pandas EXCLUSIVE LEFT OUTER JOIN with line count
<p>I am creating a transactions import tool that updates a DB with new transactions every day.</p> <p>I am getting an Excel file (<em>that I am opening using pandas</em>) with the entire month transactions and I am trying to filter only the new transactions by merging the new DataFrame with the existing one.</p> <p>For...
<python><pandas><dataframe><join>
2023-06-03 23:07:51
1
301
Yakir Shlezinger
76,398,117
11,065,874
how to override the default 200 response in fastapi docs
<p>I have this small fastapi application</p> <pre><code>import uvicorn from fastapi import FastAPI, APIRouter from fastapi import Path from pydantic import BaseModel from starlette import status app = FastAPI() def test(): print(&quot;creating the resource&quot;) return &quot;Hello world&quot; router = API...
<python><fastapi><openapi>
2023-06-03 21:33:25
2
2,555
Amin Ba
76,397,993
5,423,080
Plot function during pytest debugging in console mode
<p>I am writing a unit test for a scientific function and when I was trying to check its shape I obtained an error with <code>matplotlib</code>.</p> <p>I am using PyCharm Community Edition 2022.3.3, python 3.11, matplotlib 3.7.1 and PySide6 6.5.0 under Windows 10.</p> <p>When debugging the test, I was trying to plot th...
<python><matplotlib><pycharm><pytest>
2023-06-03 20:50:05
0
412
cicciodevoto
76,397,673
222,279
How do I sort a 2D numpy array using indicies stored in a 1D numpy array?
<p>I have a 1D numpy array containing row index values to a 2d array. How do I sort the 2D array based on the index values in the 1D array. For example:</p> <pre><code>indicies = np.array([2,3,0,1]) matrix = np.array([[20, 200],[3,300],[100,1000],[1,1]]) </code></pre> <p>I want to sort matrix based on the order of th...
<python><numpy><numpy-ndarray>
2023-06-03 19:13:26
2
13,026
GregH
76,397,643
13,078,279
API created for Flask app is extremely slow
<p>I am creating an app to monitor schoolbus arrivals for my school. For this, I have created a simple flask webapp, with an admin page used by admins to input buses that have arrived:</p> <pre class="lang-py prettyprint-override"><code>from flask import Flask, jsonify, request, render_template import sys app = Flask(...
<python><flask>
2023-06-03 19:06:15
0
416
JS4137
76,397,541
4,913,254
Save python libraries in a local directory to run pip install locally when running a docker container
<p>I want to create a docker container that needs to install python libraries. I could use something like <code>RUN pip install requirements.txt</code>. However, the server where I want to run this container have not connection to the Internet. My approach is to create a new folder in my work directory (e.g. python_lib...
<python><docker><conda>
2023-06-03 18:43:25
1
1,393
Manolo Dominguez Becerra
76,397,496
475,982
How do I represent an optional component in a grammar with pyparser?
<p>I am developing a parser that extracts the dose and name from expressions of medication dosages. For example, pulling &quot;10 mg&quot; and &quot;aspirin&quot; from &quot;10mg of aspirin&quot; and &quot;10 mg aspirin&quot;.</p> <p>My attempt in <code>pyparsing</code>.</p> <pre><code>import pyparsing as pp doseWord ...
<python><context-free-grammar><pyparsing>
2023-06-03 18:33:50
1
3,163
mac389
76,397,308
2,387,411
Selenium Python: How to capture li element with specific text
<p>I am trying to extract <code>urlToBeCaptured</code> and <code>Text to be captured</code> from the HTML. The structure looks as follows:</p> <pre><code>&lt;li&gt; &quot; text with trailing spaces &quot; &lt;a href=&quot;urlToBeCaptured&quot;&gt; &lt;span class =&quot;class1&gt; Text to be captured &lt;/span&g...
<python><selenium-webdriver><web-scraping><xpath><normalize-space>
2023-06-03 17:53:37
1
315
bekon
76,397,098
2,986,042
How to make a variable in global scope in Robot framework?
<p>I have create a small robot framework test suit which will communicate with trace32 Lauterbach. My idea is to run different functions name using a loop. Every loop, it will make a breakpoint in the Trace32 later batch. I have written a simple python script as library in the robot framework.</p> <p><strong>test.robot...
<python><robotframework><trace32><lauterbach>
2023-06-03 17:01:20
1
1,300
user2986042
76,397,082
15,520,615
Trying to execute code in SnowFlake Python Sheet Error: missing 1 required positional argument:
<p>I am trying to execute code in snowflake Python sheet, but I'm getting the error:</p> <pre><code>Traceback (most recent call last): Worksheet, line 12, in &lt;module&gt; TypeError: __init__() missing 1 required positional argument: 'conn' </code></pre> <p>Can someone take a look at my code and let me know where I'...
<python><snowflake-cloud-data-platform>
2023-06-03 16:58:16
1
3,011
Patterson
76,397,037
18,876,759
django full text search taggit
<h2>My application - the basics</h2> <p>I have a simple django application which allows for storing information about certain items and I'm trying to implement a search view/functionality.</p> <p>I'm using <code>django-taggit</code> to tag the items by their functionality/features.</p> <h2>What I want to implement</h2>...
<python><django><postgresql><tags><full-text-search>
2023-06-03 16:46:07
1
468
slarag
76,396,938
963,671
OptInt type function in Python
<pre class="lang-py prettyprint-override"><code>import pandas as pd import json mass=[] fall=[] year=[] req = requests.get(&quot;https://data.nasa.gov/resource/y77d-th95.json&quot;) response =req.json() for i in range(0,len(response)): mass.append(response[i]['mass']) fall.append(response[i]['fa...
<python>
2023-06-03 16:22:11
1
555
arpit
76,396,924
13,642,459
Nested for loop not looping on the first set, Python
<p>I have written this code in python. In the end I would like to use this to get the indices to cut up a 100x100 matrix into squares that overlap by 10. However, at the bottom there is a nested loop and the y values print how I think they should but not the x-values, the x-values never change... Can anyone help? Thank...
<python>
2023-06-03 16:20:07
1
456
Hugh Warden
76,396,922
22,009,322
How to draw broken bars if entities are duplicated
<p>I want to draw a broken bar diagram with a list of band members that joined and left a music band. I managed to draw a grid as I wanted to, but stuck with drawing the bars for band members since they are repeating. I know how to make it when band members are unique but date columns are repeating, f.e.: Year_start1, ...
<python><pandas><matplotlib>
2023-06-03 16:20:04
1
333
muted_buddy
76,396,701
12,304,000
import python libraries (eg: rapidjson) in airflow
<p>I want to use the Python library <strong>rapidjson</strong> in my Airflow DAG. My code repo is hosted on Git. Whenever I merge something into the master or test branch, the changes are automatically configured to reflect on the Airflow UI.</p> <p>My Airflow is hosted as a VM on AWS EC2. Under the EC2 instances, I se...
<python><amazon-ec2><airflow><airflow-webserver>
2023-06-03 15:20:02
1
3,522
x89
76,396,615
2,221,360
Make QPushButton as Progress Bar in PyQt or PySide
<p>My question is similar to what is mentioned in this thread for QPushButtion instead of QLineEdit <a href="https://stackoverflow.com/questions/36972132/how-to-turn-qlineedit-background-into-a-progress-bar">How to turn QLineEdit background into a Progress Bar</a>.</p> <p>Here is what I tried to implement which works b...
<python><pyqt><pyside>
2023-06-03 14:57:23
0
3,910
sundar_ima
76,396,594
19,003,861
Nested for loop - model.id in parent for loop does not match model.id in nested for loop (django)
<p>I am trying to access data from a parent to a child via a foreign key.</p> <p><strong>WHAT WORKS - the views</strong></p> <p>The data in the child is not &quot;ready to be used&quot; and need to be processed, to be represented in a progress bar in %.</p> <p>The data processing is handled in the views. When I print i...
<python><html><django><django-views><django-templates>
2023-06-03 14:50:36
2
415
PhilM
76,396,569
15,448,022
Calculating Collective Count of departments on individual dates from a given date range
<p>I have the following table</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Function</th> <th>Department</th> <th>Start Date</th> <th>End Date</th> </tr> </thead> <tbody> <tr> <td>Const</td> <td>Const 1</td> <td>2023-03-01</td> <td>2023-03-05</td> </tr> <tr> <td>Const</td> <td>Const 2</td...
<python><pandas><dataframe><datetime>
2023-06-03 14:45:33
1
378
aj7amigo
76,396,462
9,470,099
How to create my own debugger server for selenium?
<p>I am trying out selenium using Python, I seen this option in some places</p> <pre class="lang-py prettyprint-override"><code>chrome_options.add_experimental_option(&quot;debuggerAddress&quot;, debugger_address) </code></pre> <p>How can I create my own debugger server? I've been googling but couldn't find any documen...
<python><selenium-webdriver>
2023-06-03 14:14:11
0
4,965
Jeeva
76,396,262
19,130,803
Plotly: auto resize height
<p>I am creating a bar graph using <code>plotly express</code> inside <code>dash</code> application. The graph is getting displayed but I am having an issue with <code>height</code>.Currently I am using <code>default</code> height and width.</p> <p>Now for eg:</p> <ol> <li><p>dataframe having <code>field</code> column ...
<python><plotly>
2023-06-03 13:13:48
1
962
winter
76,396,157
264,136
Add a field in doc if it does not exist else update
<p>I am using the below code to update <code>job_start_time</code> in a doc:</p> <pre><code>myclient = pymongo.MongoClient(&quot;mongodb://10.64.127.94:27017/&quot;) mydb = myclient[&quot;UPTeam&quot;] mycol = mydb[&quot;perf_sdwan_queue&quot;] myquery = {&quot;$and&quot;:[ {&quot;job_job_id&quot;: current_job_id}, {&q...
<python><pymongo>
2023-06-03 12:46:32
1
5,538
Akshay J
76,396,112
1,831,784
Google Photos API: UnknownApiNameOrVersion when using googleapiclient.discovery.build
<p>I'm trying to use the Google Photos API with the Python client library googleapiclient.discovery.build method. However, I'm encountering an &quot;UnknownApiNameOrVersion&quot; error when attempting to create the client.</p> <p>Here's the code I'm using:</p> <pre><code>from google.oauth2 import service_account import...
<python><python-3.x><google-cloud-platform>
2023-06-03 12:34:45
0
3,035
Itachi
76,396,049
9,212,050
PySpark: Create a new column in dataframe based on another dataframe's cell values
<p>I have PySpark dataframe <code>dhl_price</code> of the following form:</p> <pre><code>+------+-----+-----+-----+------+ |Weight| A| B| C| D| +------+-----+-----+-----+------+ | 1|16.78|17.05|20.23| 40.1| | 2|16.78|17.05|20.23| 58.07| | 3|18.43|18.86| 25.0| 66.03| | 4|20.08|20.67|29.77| ...
<python><pandas><apache-spark><pyspark>
2023-06-03 12:18:48
1
1,404
Sayyor Y
76,395,984
1,946,418
singleton inheritance from a base class
<p>Tech: Python 3.11.2</p> <pre class="lang-py prettyprint-override"><code>from mylogging import MyLogging class BaseClass: def __init__(self) -&gt; None: self.logger = MyLogging(logName=self.__class__.__name__) # Singleton class ChildSingletonClass(BaseClass): __instance = None def __new__(cls)...
<python><oop><inheritance><singleton>
2023-06-03 12:01:38
1
1,120
scorpion35
76,395,953
131,874
Regex to catch email addresses in email header
<p>I'm trying to parse a <code>To</code> email header with a regex. If there are no <code>&lt;&gt;</code> characters then I want the whole string otherwise I want what is inside the <code>&lt;&gt;</code> pair.</p> <pre class="lang-python prettyprint-override"><code>import re re_destinatario = re.compile(r'^.*?&lt;?(?P&...
<python><regex><email-headers><email-address>
2023-06-03 11:52:19
2
126,654
Clodoaldo Neto
76,395,885
10,755,032
Python - How to get the article titles from either h2 or div tag in medium.com
<p>I am scraping medium.com. I have encountered a problem which is that some publications' article titles are in the <code>h2</code> tag whereas for some others it is in <code>div</code>. Now I am writing a function that takes in a link of the publication and returns the titles of articles in the page. I don't know whi...
<python><selenium-webdriver><web-scraping>
2023-06-03 11:39:20
1
1,753
Karthik Bhandary
76,395,799
1,319,998
Maximum size of compressed data using Python's zlib
<p>I'm writing a Python library that makes ZIP files in a streaming way. If the uncompressed or compressed data of a member of the zip is 4GiB or bigger, then it has to use a particular extension to the original ZIP format - zip64. The issue with always using this is that it has less support. So, I would like to only u...
<python><zip><zlib><deflate><python-zlib>
2023-06-03 11:17:40
3
27,302
Michal Charemza
76,395,757
2,013,747
Is there a built-in function to query a type hint for optionality/"None-ability" in Python 3.10 or later?
<p>Is there a function in the standard library to query whether the type hint for a field admits the None value?</p> <p>For example, it would return True for foo, bar, baz, and False for x, in class A below:</p> <pre><code>from dataclasses import dataclass from typing import Optional, Union @dataclass class A: foo...
<python><option-type><nullable>
2023-06-03 11:04:27
0
4,240
Ross Bencina
76,395,754
2,602,770
FLASK -Error occurred while reading WSGI handler:
<p>Error occurred while reading WSGI handler:</p> <p>Traceback (most recent call last): File &quot;C:\Python\Lib\site-packages\wfastcgi.py&quot;, line 791, in main env, handler = read_wsgi_handler(response.physical_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File &quot;C:\Python\Lib\site-packages\wfastcgi.py&quot;,...
<python><flask><iis>
2023-06-03 11:04:09
0
2,874
Bishnu
76,395,726
2,263,683
Add multiple OIDC authentication options in FastAPI
<p>I've added Google's OIDC authentication to my FastAPI application.</p> <pre><code>from fastapi import Depends from fastapi.security import OpenIdConnect oidc_google = OpenIdConnect(openIdConnectUrl='https://accounts.google.com/.well-known/openid-configuration') @app.get('/foo') def bar(token: Depends(oidc_google))...
<python><authentication><fastapi><openid-connect>
2023-06-03 10:55:47
0
15,775
Ghasem
76,395,615
5,431,734
documenting functions exposed by a pickle file
<p>I have written an application in python that goes through several iterations and at the end it returns a couple of dataframes (the estimates of the quantities we are interested in). I am also saving the application as a single pickle file which exposes to the user all the objects and functions that are involved in ...
<python><pickle>
2023-06-03 10:26:52
0
3,725
Aenaon
76,395,534
2,722,968
Typing hinting the return type of a fn returning a subclass
<p>I have a function that takes a class a parameter and returns a (constructed) subclass; essentially a class-decorator. In the most minimal example</p> <pre class="lang-py prettyprint-override"><code># Some baseclass that may come from the current module/stdlib/wherever class FooBase: pass # A user-defined subcla...
<python>
2023-06-03 10:02:24
1
17,346
user2722968
76,395,448
15,520,615
Snowflake snowpark Python Interpreter Error: NameError: name is not defined
<p>I'm executing a function in Python/Snowpark and I'm getting the error: <a href="https://i.sstatic.net/2SeXR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2SeXR.png" alt="enter image description here" /></a></p> <p>I appreciate this is a Python beginners error, however I'm not sure why I'm getting th...
<python><snowflake-cloud-data-platform>
2023-06-03 09:40:30
0
3,011
Patterson
76,395,346
10,012,856
Manage edge's weight and attributes with Netoworkx
<p>I'm facing on a trouble related to how I'm managing the edges and their weight and attributes in a <code>MultiDiGraph</code>.</p> <p>I've a list of edges like below:</p> <pre><code>[ (0, 1, {'weight': {'weight': 0.8407885973127324, 'attributes': {'orig_id': 1, 'direction': 1, 'flip': 0, 'lane-length': 3181.294317920...
<python><networkx>
2023-06-03 09:09:15
1
1,310
MaxDragonheart
76,395,255
1,473,517
How can I draw a line around the edge of the mask?
<p>I have making a heatmap with a mask. Here is a toy MWE:</p> <pre><code>import seaborn as sns import matplotlib.pyplot as plt import numpy as np images = [] vmin = 0 vmax = 80 cmap = &quot;viridis&quot; size = 40 matrix = np.random.randint(vmin, vmax, size=(size,size)) np.random.seed(7) mask = [] for _ in range(size...
<python><matplotlib><seaborn><heatmap>
2023-06-03 08:45:50
3
21,513
Simd
76,395,138
10,755,032
Python - Getting the titles of publications in medium.com
<p>I am scraping medium.com. I have one problem which I'm not sure how to tackle. Medium publications have different kinds of arrangements when it comes to their article arrangement. Some of them arrange normally in a list form, while some arrange in a grid format. Now when I am scraping through the normal-looking publ...
<python><selenium-webdriver><web-scraping><beautifulsoup>
2023-06-03 08:14:22
1
1,753
Karthik Bhandary
76,395,122
4,896,449
How to build an efficient and fast `Dockerfile` for a `pytorch` model running on CPU
<p>I am trying to get an optimally sized docker for running a pytorch model on CPU, creating a single stage works fine. However when I use the below code to create a two stage build, my docker downloads the CUDA/GPU version of pytorch.</p> <pre><code>FROM python:3.11-slim as builder WORKDIR /app # Set environment var...
<python><docker><pytorch>
2023-06-03 08:05:24
1
3,408
dendog
76,395,036
11,163,122
Converting np.int16 to torch.ShortTensor
<p>I have many NumPy arrays of dtype <code>np.int16</code> that I need to convert to <code>torch.Tensor</code> within a <code>torch.utils.data.Dataset</code>. This <code>np.int16</code> ideally gets converted to a <code>torch.ShortTensor</code> of size <code>torch.int16</code> (<a href="https://pytorch.org/docs/stable...
<python><numpy><pytorch><numpy-ndarray><pytorch-dataloader>
2023-06-03 07:43:00
1
2,961
Intrastellar Explorer
76,394,951
10,164,750
Getting an unusual/weird error in Pyspark
<p>I have written simple <code>Pyspark</code> <code>filter</code> operation. It works, well. After the <code>filter</code>, I am doing <code>select</code>, where I see some unusual behavior in the code.</p> <p>I tried many thing like. <code>persist</code> and <code>cache</code>. calling an <code>action</code> like <cod...
<python><amazon-web-services><apache-spark><pyspark><aws-glue>
2023-06-03 07:11:08
0
331
SDS
76,394,943
2,540,204
ibm_db_dbi::ProgrammingError when calling a stored procedure with pandas read_sql_query
<p>I am attempting to use <code>pandas.read_sql_query</code> to call a stored procedure in IBM's db2 and read the results into a dataframe. However when I do so, I receive the following error:</p> <blockquote> <p>ibm_db_dbi::ProgrammingError: The last call to execute did not produce any result set.</p> </blockquote> <...
<python><pandas><stored-procedures><db2>
2023-06-03 07:10:05
0
2,703
neanderslob
76,394,853
264,136
cant install jenkins using pip
<pre><code>C:\code&gt;pip install jenkins Collecting jenkins Using cached jenkins-1.0.2.tar.gz (8.2 kB) Preparing metadata (setup.py) ... done Installing collected packages: jenkins DEPRECATION: jenkins is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and ...
<python><pip>
2023-06-03 06:41:22
2
5,538
Akshay J
76,394,843
4,473,615
PyQt5 PDF border spacing in Python
<p>I have generated a PDF using PyQt5 which is working perfectly fine. Am just looking to have a border spacing, unable to do that using layouts. Below is the code,</p> <pre><code>from PyQt5 import QtCore, QtWidgets, QtWebEngineWidgets def printhtmltopdf(html_in, pdf_filename): app = QtWidgets.QApplication...
<python><pdf><pyqt5>
2023-06-03 06:39:22
1
5,241
Jim Macaulay
76,394,790
4,825,376
Python Multiprocessing Manager Error-‘ForkAwareLocal’ object has no attribute
<p>I wrote the following code using the <code>multiprocessing</code> module to execute two processes in parallel. One requirement is to access a shared Queue in the multiprocessing module used to store data by one process and read from it by another process. I tried to write it using the code below, I got this. Any hel...
<python><python-3.x><multiprocessing>
2023-06-03 06:18:35
1
950
Adham Enaya
76,394,713
10,173,016
How to apply different isin for each row of a DataFrame?
<p>I've got two arrays and want to compare rows. In particular, I want to check for each element in arr2 whether it is among corresponding row in arr1.</p> <p>Example given</p> <pre><code>arr1 = [[1, 7, 6, 2, 8], [1, 5, 4, 8], [8, 2, 5]] arr2 = [[8, 1, 5, 0, 7, 2, 9, 4], [0, 1, 8, 5, 3, 4, 7, 9...
<python><python-3.x><pandas>
2023-06-03 05:46:10
2
401
Joseph Kirtman
76,394,657
219,153
How to read SyGuS format into cvc5 Python script?
<p>There is number of examples in SyGuS format (<a href="https://sygus.org/language/" rel="nofollow noreferrer">https://sygus.org/language/</a>) in cvc5 repo, e.g. <a href="https://github.com/cvc5/cvc5/tree/main/test/regress/cli/regress0/sygus" rel="nofollow noreferrer">https://github.com/cvc5/cvc5/tree/main/test/regre...
<python><io>
2023-06-03 05:19:18
1
8,585
Paul Jurczak
76,394,543
3,487,441
Installing a python script to run from the command line
<p>I need to make some python utilities available to run from the command line (OSX Ventura). I've been looking over example and documentation for setup.py, but can't make any progress. Even with the simplest example possible I'm not making progress:</p> <p><strong>directory structure:</strong></p> <pre><code>./ex __...
<python><pip><setuptools><setup.py><python-packaging>
2023-06-03 04:20:08
2
1,361
gph
76,394,516
9,840,684
creating a function looping through multiple subsets and then grouping and summing those combinations of subsets
<p>I am attempting to build a function that processes data and subsets across two combinations of dimensions, grouping on a status label and sums on price creating a single row dataframe with the different combinations of subsets of the summed prices as output.</p> <p><strong>edit</strong> to clarify, what I'm looking ...
<python><pandas><loops><iterator><iteration>
2023-06-03 04:07:16
1
373
JLuu
76,394,480
4,726,035
Can't parse segment Firebase Token Python/Flask
<p>I am currently building a small API project using Flask. I want to authenticate the request using Firebase Auth. I am using the verify_id_token function in a small middleware.</p> <pre><code>def check_token(f): @wraps(f) def wrap(*args,**kwargs): token = request.headers.get('Authorization') if not token: ...
<python><firebase><flask><firebase-authentication>
2023-06-03 03:43:43
2
535
Mansour
76,394,463
1,019,129
Simulate decaying function
<p>Lets t be the time tick i.e. 1,2,3,4,5....</p> <p>I want to calculate and plot a cumulative decaying function f(inits[],peaks[],peak-ticks,zero-ticks). Preferably in python</p> <p>Where :</p> <pre><code>- inits[] is a list of points at time/tick t where a new 'signal' is introduced - peaks[] is a list of values whic...
<python><cumulative-sum><decay>
2023-06-03 03:33:34
1
7,536
sten
76,394,436
2,628,868
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://conda.anaconda.org/conda-forge/osx-64/current_repodata.json>
<p>when I tried to run this command in macOS 13.3 with M1 pro chip, show error like this:</p> <pre><code>&gt; conda install anaconda-clean Collecting package metadata (current_repodata.json): failed CondaHTTPError: HTTP 000 CONNECTION FAILED for url &lt;https://conda.anaconda.org/conda-forge/osx-64/current_repodata.js...
<python>
2023-06-03 03:23:57
0
40,701
Dolphin
76,394,423
1,088,796
Do I need any environment variables set to execute some code, call openai's api, and return a response?
<p>I was going through a course in OpenAI's API using an in-browser jupyter notebook page but wanted to copy some example code from there into a local IDE. I installed Python and the jupyter extention in VS Code and the OpenAI library. My code is below:</p> <pre><code>import openai import os # from dotenv import load_...
<python><openai-api><dotenv>
2023-06-03 03:17:15
1
2,741
intA
76,394,303
18,572,509
RuntimeError when trying to serve favicon with Flask
<p>I followed the instructions for serving favicons from <a href="https://flask.palletsprojects.com/en/1.1.x/patterns/favicon/" rel="nofollow noreferrer">Flask's docs</a>, and added the line <code>app.add_url_rule('/favicon.ico', redirect_to=url_for('static', filename='favicon.ico'))</code> to my server. But when I run...
<python><flask><favicon>
2023-06-03 02:11:05
0
765
TheTridentGuy supports Ukraine
76,394,296
13,891,321
Not all Plotly subplots scale equally
<p>I have working code to create 4 subplots on the same HTML output. When I used to have them as 4 separate HTML plots, the Z axes scaled as requested (0 to -5), but when I run them as a series of subplots, only the first plot scales as requested.</p> <pre><code>&quot;&quot;&quot;Plot 3D streamer surfaces.&quot;&quot;&...
<python><plotly>
2023-06-03 02:05:36
1
303
WillH
76,394,292
13,002,743
Filling NAN values in Pandas by using previous values
<p>I have a Pandas DataFrame in the following format.</p> <p><a href="https://i.sstatic.net/vyvMH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/vyvMH.png" alt="Sample DataFrame" /></a></p> <p>I am trying to fill the NaN value by using the most recent non-NaN value and adding one second to the time valu...
<python><pandas><datetime>
2023-06-03 02:03:36
3
365
Rishab
76,394,246
1,694,657
Streaming OpenAI results from a Lambda function using Python
<p>I'm trying to stream results from Open AI using a Lambda function on AWS using the OpenAI Python library. For the invoke mode I have: RESPONSE_STREAM. And, using the example <a href="https://github.com/openai/openai-cookbook/blob/main/examples/How_to_stream_completions.ipynb" rel="nofollow noreferrer">provided for...
<python><lambda><streaming><openai-api>
2023-06-03 01:35:03
2
1,271
Eric
76,394,194
14,293,020
Xarray write large dataset on memory without killing the kernel
<p><strong>Context:</strong> I have the following dataset: <a href="https://i.sstatic.net/dDYrQ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dDYrQ.png" alt="dataset" /></a></p> <p><strong>Goal:</strong> I want to <em>write</em> it on my disk. I am using chunks so the dataset does not kill my kernel.</...
<python><dask><netcdf><python-xarray><zarr>
2023-06-03 01:04:32
1
721
Nihilum
76,394,170
3,826,733
Cannot open file downloaded from Azure Storage account
<p>Why is it when downloaded I am not able to open a file which was uploaded to my Azure storage account as a block blob?</p> <p>Initially I thought it was because of the way I uploaded it. But manually uploaded files when downloaded wont open as well. This is the message I see when I try to open the downloaded file- <...
<python><azure><azure-blob-storage>
2023-06-03 00:50:25
0
3,842
Sumchans
76,394,066
5,378,132
FastAPI SQLAlchemy - How to Encrypt Table Column and then Decrypt when Querying Result?
<p>I have a table called <code>users</code>. I want to encrypt the <code>phone_number</code> column in the SQL table, and then decrypt <code>phone_number</code> when querying the <code>users</code> table and returning a User item.</p> <p>Here's an example:</p> <p><strong>models.py</strong></p> <pre><code>class Users(Ba...
<python><encryption><sqlalchemy><cryptography><fastapi>
2023-06-03 00:03:04
1
2,831
Riley Hun
76,393,832
11,485,896
Get physical address from a way containing nodes only
<p>I'm new to geocoding stuff.</p> <p>I have a list of addresses which I have to find the nearest <strong>residential</strong> buildings for. At first, I'm looking for basic data of these addresses using <code>geopy.geocoders.Nominatim</code> geolocator. The data I get from <code>Nominatim</code> are, among others, <co...
<python><openstreetmap><geopandas><osmnx><geopy>
2023-06-02 22:41:21
0
382
Soren V. Raben
76,393,695
9,795,817
PySpark: Replace null values with empty list
<p>I outer joined the results of two <code>groupBy</code> and <code>collect_set</code> operations and ended up with this dataframe (<code>foo</code>):</p> <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; foo.show(3) +---+------+------+ | id| c1| c2| +---+------+------+ | 0| null| [1]| | 7| [6]|...
<python><apache-spark><pyspark><null>
2023-06-02 22:05:52
2
6,421
Arturo Sbr
76,393,635
7,648
`strftime` acting unexpectedly
<p>I have the following Python code:</p> <pre><code>from datetime import datetime def get_session_id(date_of_mri): dt = datetime.strptime(date_of_mri, '%m/%d/%Y') date_time = dt.strftime(&quot;%Y%M%D&quot;) return date_time print(get_session_id('2/27/2002')) </code></pre> <p>This prints</p> <pre><code>200...
<python><date>
2023-06-02 21:47:44
1
7,944
Paul Reiners
76,393,584
4,802,101
OPC DA dll compatible with MS KB5004442
<p>I have an Python application that use OpenOPC to connect to our OPC Server. After the release of the Microsoft <a href="https://support.microsoft.com/en-us/topic/kb5004442-manage-changes-for-windows-dcom-server-security-feature-bypass-cve-2021-26414-f1400b52-c141-43d2-941e-37ed901c769c" rel="nofollow noreferrer">KB5...
<python><opc><dcom><open-opc>
2023-06-02 21:34:43
1
370
Dariva
76,393,348
3,845,439
How to offset twinx y-axis by specified amount?
<p>I am familiar to using <code>twinx()</code> to share an axis's x-axis with another subplot:</p> <pre><code>fig, ax1 = plt.subplots() ax2 = ax1.twinx() ax1.plot(xdata1, ydata1) ax2.plot(xdata2, ydata2) </code></pre> <p>This makes the <code>y=0</code> axis line up between <code>ax1</code> and <code>ax2</code>, but the...
<python><matplotlib><yaxis><twinx>
2023-06-02 20:38:50
1
440
PGmath
76,393,336
3,940,670
Calling Google Cloud Speech to Text API regional recognizers, using Python Client library, showing error 400 and 404
<p><strong>The goal:</strong> The goal is to use Python client libraries to convert a speech audio file to text through a Chirp recognizer.</p> <p><strong>Steps to recreate the error:</strong> I'm creating a recognizer following the steps in the link below, I am following the instruction and the Python code in the belo...
<python><google-cloud-platform><google-cloud-vertex-ai><google-cloud-speech><google-cloud-python>
2023-06-02 20:35:27
1
637
M.Hossein Rahimi
76,393,311
14,896,203
Aggregate based on two columns and then apply function on one column vs the rest
<p>Hello I have below demonstrated DataFrame and attempting to generate an aggregated result based on <code>unique_id</code> and <code>cutoff</code> where there is a calculation of a metric (such as MSE) between <code>y</code> and the rest of columns, except group by ones and <code>ds</code>.</p> <pre><code>shape: (5, ...
<python><python-polars>
2023-06-02 20:30:56
1
772
Akmal Soliev
76,393,255
11,613,489
Scraping using BeautifulSoup print an empty output
<p>I'm trying to scrape a website. I want to print all the elements with the following class name,</p> <blockquote> <p>class=product-size-info__main-label</p> </blockquote> <p>The code is the following:</p> <pre><code>from bs4 import BeautifulSoup with open(&quot;MadeInItaly.html&quot;, &quot;r&quot;) as f: doc= B...
<python><html><web-scraping><beautifulsoup>
2023-06-02 20:20:07
2
642
Lorenzo Castagno
76,393,080
19,410,411
How to get the optimal number of clusters using elbow method and return it?
<p>I need to find a way to return the number of optimal clusters from the elbow method implementation in python. How can I implement the elbow method in order to show the elbow method graph and then return the number of optimal clusters.</p>
<python><k-means>
2023-06-02 19:40:55
1
525
Mikelenjilo
76,393,074
13,058,538
Python multithreading for file reading results in slower performance: How to optimize?
<p>I am learning concurrency in Python and I have noticed that the <code>threading</code> module even lowers the speed of my code. My code is a simple parser where I read HTMLs from my local directory and output parsed a few fields as JSON files to another directory.</p> <p>I was expecting a speed improvement but the s...
<python><multithreading><python-multithreading><concurrent.futures>
2023-06-02 19:39:57
1
523
Dave
76,393,072
18,739,908
Reset badge count on Android using React Native Expo
<p>I'm using react native with expo. When a user goes to their notifications I want the badge count to update. The following code in my backend does that (python):</p> <pre><code>from exponent_server_sdk import PushClient, PushMessage def reset_badge_count(token, new_total): response = PushClient().publish(PushMess...
<python><react-native><push-notification><expo>
2023-06-02 19:39:42
0
494
Cole
76,392,943
17,275,588
Shopify API (using Python): File upload failed due to "Processing Error." Why?
<p>I am struggling to figure out why I'm not able to successfully upload images to the Files section of my Shopify store. I followed this code here, except mine is a Python version of this: <a href="https://gist.github.com/celsowhite/2e890966620bc781829b5be442bea159" rel="nofollow noreferrer">https://gist.github.com/ce...
<python><python-requests><graphql><shopify><shopify-api>
2023-06-02 19:14:43
2
389
king_anton
76,392,920
2,675,349
How to JOIN two dataframes and populate a column?
<p>I have two data frames as below,</p> <pre><code>DF1 Name;ID;Course;SID;Subject Alex;A1;Under;;chemistry Oak;A2;Under;;chemistry niva;A3;grad;;physics mark;A4;Under;;Med DF2 PID;ServiceId;Address;Active A1;svc1;WI;Yes A2;svc2;MI;Yes A...
<python><pandas><dataframe>
2023-06-02 19:11:36
3
1,027
Ullan
76,392,744
14,804,653
Can you use the programs you "pip install" in the Command-line?
<p>As a Python beginner, I was downloading the OpenAI's <a href="https://github.com/openai/whisper#setup" rel="nofollow noreferrer">Whisper</a> with the following command: <code>pip install -U openai-whisper</code>, and noticed that you can use Whisper in both <a href="https://github.com/openai/whisper#python-usage" re...
<python><pip><command-line-interface>
2023-06-02 18:41:47
2
318
Howard Baik
76,392,743
8,869,570
How to find all rows with time to a datetime with timezone info?
<p>I have a dataframe with a datetime column <code>dt</code> with the dtype <code>datetime64[ns, US/Eastern]</code>.</p> <p>I am trying to find all rows with the time <code>2023-01-01 12:00:00-05:00</code>.</p> <p>I tried to do this:</p> <pre><code>eastern = pytz.timezone('US/Eastern') query_dt = datetime.datetime(year...
<python><pandas><datetime>
2023-06-02 18:41:42
0
2,328
24n8
76,392,643
14,293,020
Xarray how to combine 2 dataset occasionally overlapping temporally, but not spatially?
<p><a href="https://i.sstatic.net/9cyCy.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9cyCy.png" alt="Sketch of the problem" /></a></p> <p><strong>Context:</strong> I have 2 datacubes (datacube_1, datacube_2) with 3D variables (dimensions <code>t,y,x</code>). They do not overlap spatially but their uni...
<python><merge><dataset><dask><python-xarray>
2023-06-02 18:23:48
0
721
Nihilum
76,392,521
12,955,349
How to plot data from snowflake into grouped bars overlaid with a line plot
<p>The requirement to have two bar graphs displayed either through sql or python library based on TYPE</p> <p>Below is the data from the table</p> <pre><code>with data as ( select 'DIRECT' as type , '2023-04-30' as report_month , 148 as returns_per_head , 30.00 as filing_count ,52.25 as total_count union select 'INDIR...
<python><pandas><matplotlib><snowflake-cloud-data-platform><grouped-bar-chart>
2023-06-02 18:02:15
1
1,058
Kar
76,392,467
22,009,322
How to consolidate labels in legend
<p>So, the script below requests data from postgres database and draws a diagram. The requested data is a table with 4 columns <code>(ID, Object, Percentage, Color)</code>.</p> <p>The data:</p> <pre><code>result = [ (1, 'Apple', 10, 'Red'), (2, 'Blueberry', 40, 'Blue'), (3, 'Cherry', 94, 'Red'), (4, 'O...
<python><pandas><matplotlib><bar-chart><legend>
2023-06-02 17:52:22
2
333
muted_buddy
76,392,424
17,275,588
Shopify API error: {"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}
<pre><code>import requests # Replaced with my actual Shopify credentials and file information!!! API_KEY = 'text' // using my Shopify App &quot;API key&quot; ACCESS_TOKEN = 'text' // using my Shopify App &quot;Admin API access token&quot; SHOP_NAME = 'text.myshopify.com' // using the root myshopify URL file_path = r&q...
<python><shopify><shopify-api>
2023-06-02 17:47:24
0
389
king_anton
76,392,359
895,587
Need to restart Databricks 13.0 cluster to iterate on development
<p>I want to iterate with development on a Databricks 13 cluster without the need to restart it for updating the code within my Python package.</p> <p>It seems that <strong>dbx execute</strong> does the job on Databricks 12.1, but when I try to run it with Databricks 13, it gets the old version.</p> <p>Also tried with<...
<python><databricks><databricks-dbx>
2023-06-02 17:34:55
0
302
André Salvati
76,392,337
3,416,774
Why does Jupyter in VS Code say "No module named 'gensim'" when it's already installed?
<p>In the below setup, I've made sure that the Python version running in Jupyter and the terminal is the same. Yet Jupyter still give error <code>No module named 'gensim'</code> when it is already installed. Why is that?</p> <p><img src="https://i.imgur.com/Y6fKFhN.png" alt="screenshot of VSCode showing the problem" />...
<python><visual-studio-code>
2023-06-02 17:31:54
1
3,394
Ooker
76,392,312
2,105,339
Should I use regular SQL instead of an ORM to reduce bandwith usage and fetching time?
<p>I'm building a ethereum explorer for fun with django ORM (never used it before). here is a part of my schema :</p> <pre><code>class AddressModel(models.Model): id = models.BigIntegerField(primary_key=True) first_seen = models.DateTimeField(db_index=True) addr = models.CharField(max_length=42, db_index=Tr...
<python><django><orm><ethereum>
2023-06-02 17:25:47
1
2,474
sliders_alpha
76,392,283
11,999,957
List comprehension in Python for if, elif, pass?
<p>I see syntax for if pass but not finding syntax for if elif pass: <a href="https://stackoverflow.com/questions/33691552/list-comprehension-with-else-pass">List comprehension with else pass</a></p> <p>Basically</p> <pre><code>if condition: something elif condition something else pass </code></pre>
<python>
2023-06-02 17:22:37
1
541
we_are_all_in_this_together
76,392,174
5,061,840
Java and Python return different values when converting the hexadecimal to long
<p>I noticed this difference when comparing xxhash implementations in both Python and Java languages. Calculated hashes by xxhash library is the same as hexadecimal string, but they are different when I try to get calculated hash as an integer(or long) value.</p> <p>I am sure that this is some kind of &quot;endian&quot...
<python><java>
2023-06-02 17:04:52
2
327
Tevfik Kiziloren
76,391,843
13,921,399
Cast pandas series containing list elements to a 2d numpy array
<p>Take the following series:</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd s = pd.Series([1, 3, 2, [1, 3, 7, 8], [6, 6, 10, 4], 5]) </code></pre> <p>I want to convert this series into the following array:</p> <pre class="lang-py prettyprint-override"><code>np.array([ [ 1., 1., 1., 1.]...
<python><pandas><numpy>
2023-06-02 16:13:55
2
1,811
ko3
76,391,681
6,936,489
Read csv in chunks with polars efficiently (with limited available RAM)
<p>I'm trying to read a big CSV (6.4 Go approx.) on a small machine (small laptop on windows with 8Go of RAM) before storing it into a SQLite database (I'm aware there are alternatives, that's not the point here).</p> <p><em>In case it's needed the file I'm using can be found on <a href="https://www.data.gouv.fr/fr/dat...
<python><dataframe><csv><python-polars>
2023-06-02 15:51:21
3
2,562
tgrandje
76,391,586
12,040,751
Async read_csv in Pandas
<p>In this <a href="https://stackoverflow.com/a/60368916/12040751">answer</a> to <a href="https://stackoverflow.com/questions/57871450/async-read-csv-of-several-data-frames-in-pandas-why-isnt-it-faster">async 'read_csv' of several data frames in pandas - why isn't it faster</a> it is explained how to asynchronously rea...
<python><pandas><python-asyncio>
2023-06-02 15:36:37
0
1,569
edd313
76,391,582
3,492,006
Convert date and time in string to timestamp
<p>I have a set of CSV's that all got loaded with a date field like: <code>Sunday August 7, 2022 6:26 PM GMT</code></p> <p>I'm working on a way to take this date/time, and convert it to a proper timestamp in the format <code>YYYY-MM-DD HH:MM</code></p> <p>In Python, I've tried something like below to return a proper ti...
<python><date><datetime><timestamp>
2023-06-02 15:35:39
3
449
WR7500
76,391,550
6,300,467
PyTorch equivalent of scipy.sparse.linalg.gmres
<p>I'm using scipy.sparse.linalg.gmres to efficiently solve <code>A.x = b</code>, however my problem is within the PyTorch framework. So, I have to detach my tensors to <code>numpy</code> then call <code>scipy</code> to solve this equation. However, other frameworks (like JAX) have their own equivalent function, <code>...
<python><pytorch><scipy><jax>
2023-06-02 15:30:30
0
785
AlphaBetaGamma96
76,391,465
12,493,545
How to start from example diverging REST interface?
<p>In the uvicorn <a href="https://www.uvicorn.org/" rel="nofollow noreferrer">exmaple</a>, one writes <code>uvicorn filename:attributename</code> and by that start the server. However, the interface I have generated has no such method <code>attributename</code> in <code>filename</code>. Therefore, I am unsure what to ...
<python><openapi-generator><uvicorn>
2023-06-02 15:18:03
1
1,133
Natan
76,391,329
20,220,485
How do you sort lists of tuples based on the count of a specific value?
<p>I am working on a NER problem—hence the BIO tagging—with a very small dataset, and I am manually splitting it into train, validation, and test data. Thus, to make the first of two splits, I need to sort lists of tuples into two lists based on the count of <code>'B'</code> in <code>data</code>.</p> <p>I am shuffling ...
<python><list><sorting><machine-learning><sampling>
2023-06-02 15:04:31
1
344
doine
76,391,344
21,787,377
Implementing Name Synchronization and Money Transfers in Transactions Model with Account Number Input
<p>I have the following models in my Django application:</p> <pre><code>class Transaction (models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) account_number = models.IntegerField() name = models.CharField(max_length=50) amount = models.DecimalField(max_digits=5, decimal_places=2) ...
<python><django><django-views><django-channels><banking>
2023-06-02 15:04:25
2
305
Adamu Abdulkarim Dee
76,391,296
10,097,229
How to know last occurence of while loop
<p>I have this piece of code where I am hitting an Azure REST API and it has <code>nextlink</code> in it which basically means that because the file is too large, it has nextlink as parameter with which it will again hit the API until the nextlink parameter does not come.</p> <pre><code>while 'nextLink' in json.loads(r...
<python><json><python-3.x><azure><loops>
2023-06-02 15:00:54
1
1,137
PeakyBlinder
76,391,230
11,564,487
Change the font size of the output of python code chunk
<p>Consider the following <code>quarto</code> document:</p> <pre><code>--- title: &quot;Untitled&quot; format: pdf --- ```{python} #|echo: false #|result: 'asis' import pandas as pd df = pd.DataFrame({'A': ['foo', 'foo', 'foo', 'bar', 'bar', 'bar'], 'B': ['one', 'one', 'two', 'two', 'one', 'one'], 'C': ['dul...
<python><pdf><latex><quarto>
2023-06-02 14:53:48
1
27,045
PaulS
76,391,192
10,082,088
Alteryx Error generating JWT token with python tool - NotImplementedError: Algorithm 'RS256
<p>I am having issues creating an Alteryx workflow that encodes a JWT token with the RS256 algorithm in the python tool.</p> <p>Here is my code:</p> <pre><code>################################# from ayx import Alteryx from ayx import Package import pandas ##Package.installPackages(package=&quot;cryptography&quot;,insta...
<python><jwt><alteryx>
2023-06-02 14:49:04
1
447
bocodes
76,391,153
5,620,975
Python Polars: Lazy Frame Row Count not equal wc -l
<p>Been experimenting with <code>polars</code> and of the key features that peak my interest is the <em>larger than RAM</em> operations.</p> <p>I downloaded some files to play with from <a href="https://s3.amazonaws.com/amazon-reviews-pds/tsv/index.txt" rel="nofollow noreferrer">HERE</a>. On the website: <em>First line...
<python><python-polars>
2023-06-02 14:42:40
1
1,461
Hanjo Odendaal