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,521,658
5,344,240
VSCode Python/Pylance does not gray out unaccessed variable
<p>In below screenshot when hovering over the grayed out variables Pylance (correctly!) says they are not accessed, e.g.; <code>&quot;_baz&quot; is not accessed Pylance</code>. My question is about <code>waz</code>, which is clearly not accessed in either tabs, still not grayed out. Why isn't it grayed out?</p> <p><a h...
<python><visual-studio-code><pylance>
2023-11-21 09:26:04
2
455
Andras Vanyolos
77,521,499
949,251
How to make `os.path.isdir()` work for mapped network drives?
<p>When I boot my PC, <code>os.path.isdir(&quot;R:\\&quot;)</code> returns <code>False</code>, where <code>R:\</code> is a mapped network drive. Once I access the mapped drive at least once from Windows Explorer, the command works and keeps working until I reboot.</p> <p>I know that I can get around this using UNC path...
<python><windows><mapped-drive>
2023-11-21 08:58:13
0
831
Cerno
77,521,378
2,667,387
Confusing output with pandas rolling window with datetime64[us] dtype
<p>I get confusing results from <code>pandas.rolling()</code> when the dtype is <code>datetime64[us]</code>. Pandas version is 2.1.1. Let <code>df</code> be the dataframe</p> <pre><code> day x 0 2021-01-01 3 1 2021-01-02 2 2 2021-01-03 1 3 2021-01-05 4 4 2021-01-08 2 5 2021-01-14 5 6 2021-01-15 ...
<python><pandas><datetime><rolling-computation>
2023-11-21 08:38:38
2
863
DustByte
77,521,373
25,645
python pandas writing parquet file I just read: Conversion failed for column
<pre><code>import pandas as pd file = pd.read_parquet(&quot;/Users/myuser/Downloads/input.parquet&quot;) file.to_parquet(&quot;/Users/hazout/mysuer/output.parquet&quot;) </code></pre> <p>I am trying to read and write a parquet file (I plan to modify it too, but first things first).</p> <p>I get <code>pyarrow.lib.ArrowT...
<python><pandas><parquet>
2023-11-21 08:37:47
0
49,641
Nathan H
77,521,240
14,516,016
Executing workflow commands for GitHub Actions using a Python script
<p>I am trying to log a <a href="https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message" rel="nofollow noreferrer">warning message</a> in my GitHub Actions workflow using a Python script.</p> <p>The script writes the following output in the workflow:</p> <pre c...
<python><logging><github-actions>
2023-11-21 08:14:28
1
1,359
Aditya
77,520,973
772,354
OpenCV detect liquid level in a tube
<p>I have image like this below</p> <p><a href="https://i.sstatic.net/TzbZc.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TzbZc.jpg" alt="tube" /></a></p> <p>Can anyone suggest how to detect the level of the liquid? Is this too blurry to process? I have tried Canny and findContour and cannot detect the...
<python><opencv><image-processing><computer-vision>
2023-11-21 07:22:45
0
747
Bharata
77,520,963
8,595,891
Using locally deployed llm with langchain's openai llm wrapper
<p>I have deployed llm model locally which follows openai api schema. As it's endpoint follows openai schema, I don't want to write separate inference client.</p> <p>Is there any way we can utilize existing openai wrapper by langchain to do inference for my localhost model.</p> <p>I checked there is a <a href="https://...
<python><openai-api><langchain><py-langchain>
2023-11-21 07:20:51
1
1,362
Pranjal Doshi
77,520,936
4,281,353
tensorflow - tf.keras.Model.fit causes run out of data for validation data with validation_steps being set
<p>Trying to understand the <code>validation_steps</code> parameter of <a href="https://www.tensorflow.org/api_docs/python/tf/keras/Model#fit" rel="nofollow noreferrer">tf.keras.Model.fit</a>.</p> <blockquote> <p>Total number of steps (batches of samples) to draw before stopping when performing validation at the end of...
<python><tensorflow><machine-learning>
2023-11-21 07:14:37
2
22,964
mon
77,520,930
9,495,110
torch.utils.data.random_split() is not splitting Dataset
<p>I am using <code>ImageFolder</code> to load the data from a directory:</p> <pre><code>full_dataset = ImageFolder('some_dir', transform=transform) </code></pre> <p>When I print its length it gives: 32854. Now I want to split the <code>Dataset</code> returned by <code>ImageFolder</code> into train and test dataset usi...
<python><pytorch><dataset>
2023-11-21 07:12:51
1
1,027
let me down slowly
77,520,904
22,466,650
How to form a group based on nearest days of previous and next weeks?
<p>I was asked to re build my previous question so I deleted it and created this one.</p> <p>My input is a dataframe with two columns :</p> <pre><code>df = pd.DataFrame({'DATE': ['Tuesday, November 7, 2023', 'Wednesday, November 8, 2023', 'Thursday, November 9, 2023', 'Friday, November 10, 2023', 'Monday, November 13, ...
<python><pandas>
2023-11-21 07:08:46
1
1,085
VERBOSE
77,520,713
17,519,895
How to update weights of a base Keras PointNet model?
<p>I trained a PointNet regression model and then saved it's weights by</p> <pre><code>model.save_weights('/home/rev9ai/aleef/Dainsta/model/beta_v0.weights.ckpt') </code></pre> <p>The saved files were</p> <ul> <li>beta_v0.weights.ckpt.data-00000-of-00001</li> <li>beta_v0.weights.ckpt.index</li> </ul> <p>Now I want to u...
<python><tensorflow><keras><regression><mlmodel>
2023-11-21 06:25:18
1
421
Aleef
77,520,491
21,305,238
PyCharm cannot infer @cache-d methods' return types
<p>PyCharm's type checker works well with this:</p> <pre class="lang-py prettyprint-override"><code>from functools import cache class MyType: pass @cache def f() -&gt; MyType: ... v = f() # v: MyType </code></pre> <p>...but not this:</p> <pre class="lang-py prettyprint-override"><code>class C: @cache def m...
<python><pycharm><python-typing>
2023-11-21 05:28:54
1
12,143
InSync
77,520,334
10,219,156
how to change the rows and columns in pandas dataframe
<p>i have code like this which creates dataframe from the dictionary, but the output is differant from what is expected. Have given the code as follows with steps</p> <pre><code>options_pnl={'BTC': {'Pnl(since 6pm)': Decimal('7831.52228528'), 'Pnl(4 hr)': Decimal('2930.47450133'), 'Pnl(1 hr)': Decimal('1416.8130630...
<python><pandas><dataframe><numpy><dictionary>
2023-11-21 04:38:40
2
326
Madan Raj
77,520,302
5,162,426
Labelling contours manually via clabel adds spurious new lines to the plot
<p>I have a set of contours made with <code>plt.contourf</code>. I am now trying to label the contours with <code>plt.clabel</code> with <code>manual=True</code>. This opens the plot, and prompts me to click on the figure to add labels. When I do this, new spurious contours are added to the plot, which are not correct ...
<python><matplotlib><contour><contourf>
2023-11-21 04:27:19
1
3,032
pretzlstyle
77,520,193
4,038,800
TTS Tacotron2 Fine-tuning: Missing Layers and No Output Sound
<p>I’m attempting to use <a href="https://github.com/coqui-ai/TTS" rel="nofollow noreferrer">TTS</a> to fine tune a Tacotron2 TTS model. If it makes a difference, I'm using Python 3.9.1 and I'm fine-tuning the latest <code>tts_models--en--ljspeech--tacotron2-DDC</code>.</p> <p>During the fine-tuning process, when I loa...
<python><deep-learning><pytorch><text-to-speech>
2023-11-21 03:46:38
0
919
DonCarleone
77,520,191
10,219,156
How to change dataframe structure in pandas
<p>I have created a dataframe from two dicts like this</p> <pre><code>import pandas as pd summary={'BTC': {'DAE': -11661300, 'Vega': -661, 'Theta': 109, 'Gamma': -32391}, 'ETH': {'DAE': -533985, 'Vega': -227, 'Theta': 518, 'Gamma': -289779}} summary_df = pd.DataFrame.from_dict(summary) summary_df = summary_df.transpos...
<python><pandas><dataframe><numpy><dictionary>
2023-11-21 03:46:28
1
326
Madan Raj
77,520,074
9,443,671
How can I effectively split text coming from a stream where the output is not necessarily new words but might be letters
<p>so I have a stream of text which comes in where the next item coming in is the all the previously generated text + some additional text which may either be a new word, letter, or part of a word. I'm trying to effectively split the text/arrange the text in a way which allows me to fully reconstruct the text as it's s...
<python><string><text><stream>
2023-11-21 03:03:14
1
687
skidjoe
77,519,992
5,482,999
Query a collection by an array of document ids with python
<p>I have list of ids I want to query from a collection. If I use:</p> <pre><code>query = firebase_client.collection('my_collection').where( field_path=field_path.FieldPath.document_id(), op_string='in', value=list_of_ids ).stream() </code></pre> <p>Works, but gives me the warning:</p> <blockquote> <p>UserWarning: ...
<python><firebase><google-cloud-firestore><google-cloud-python>
2023-11-21 02:36:10
0
1,924
Guanaco Devs
77,519,970
12,931,358
How to create a huggingface dataset and import from a list?
<p>I have a list and I want to convert it to a huggingface dataset for training model, I follow some tips and here is my code,</p> <pre><code>from datasets import Dataset class MkqaChineseDataset(Dataset): def __init__(self, data): # super().__init__() if add this, it shows super().__init__() TypeError: __i...
<python><huggingface-datasets>
2023-11-21 02:27:56
1
2,077
4daJKong
77,519,960
179,234
.deployment file not working while doing zip deployment of an azure app
<p>I have an application that I am trying to deploy to an existing app to an offline server.</p> <p>The application is two parts: a nodejs frontend and a python backend app. I use the zip deployment method to wrap everything and use it in the server (explained here <a href="https://learn.microsoft.com/en-us/azure/app-s...
<python><azure-web-app-service><azure-deployment><offlineapps>
2023-11-21 02:23:05
0
1,417
Sarah
77,519,883
1,348,798
Is there a way to group by list in pandas?
<p>I have a set of data that looks like this in pandas. I want to group by value in list such that:</p> <pre><code>column1 column2 column3 1 14 P22 3 43 P65 4 43 141 3 14 146 5 43 P51 </code></pre> <p>becomes:</p> <pre><code>column1 column2 column3 1 14 ...
<python><pandas>
2023-11-21 01:57:16
2
329
Marc
77,519,881
10,378,232
How to guarantee the value in multiple processes is increased or decreased correctly in python?
<p><strong>My needs</strong></p> <p>At present, there are several groups of data that need to perform computation-type tasks, and every time a group of data is executed, java will be notified and the generated result file will be passed to java, and I will tell Java when all tasks are executed (that is, when the last g...
<python><python-3.x><parallel-processing><multiple-processes>
2023-11-21 01:56:08
1
412
Runstone
77,519,830
13,178,529
Breaking values of multiple of 20 (20,40,60,80...) into candles of 20 (Stocks)
<p>I have the following logic which reads data from a stock exchange file and builds an Excel data table or a chart.</p> <p>I'm building a graphic like the following: <a href="https://i.sstatic.net/q2XPg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/q2XPg.png" alt="enter image description here" /></a><...
<python><python-3.x><charts><logic><stock>
2023-11-21 01:33:09
0
1,200
Nilton Schumacher F
77,519,523
15,476,955
Missing convert_trajectory_transformer_original_pytorch_checkpoint_to_pytorch.py (notebook/Jupyter/transformers)
<p>I tried on a notebook to install the package transformers, it failed:</p> <p><code>!pip install transformers</code></p> <p>I get this:</p> <pre><code>FULLTRACE: Collecting transformers Obtaining dependency information for transformers from https://files.pythonhosted.org/packages/12/dd/f17b11a93a9ca27728e12512d167e...
<python><jupyter-notebook><huggingface-transformers>
2023-11-20 23:35:26
1
1,168
Utopion
77,519,494
3,842,845
CSV file not processing in concatenation if not saved manually
<p>I am trying to run a python code that grabs data from daily csv files and processes to create a dataframe that meets the requirement.</p> <p>This is code that runs <strong>fine</strong> (if I open csv file, <strong>saved</strong> and run):</p> <pre><code>import re import pandas as pd from io import StringIO def ...
<python><azure><csv><concatenation>
2023-11-20 23:26:59
0
1,324
Java
77,519,280
6,534,818
PySpark: CumSum with Salting over Window w/ Skew
<p>How can I use salting to perform a cumulative sum window operation? While a tiny sample, my id column is heavily skewed, and I need to perform effectively this operation on it:</p> <pre><code>window_unsalted = Window.partitionBy(&quot;id&quot;).orderBy(&quot;timestamp&quot;) # exected value df = df.withColumn(&qu...
<python><apache-spark><pyspark><apache-spark-sql>
2023-11-20 22:32:37
1
1,859
John Stud
77,519,206
13,596,420
Polars equivalent to Pandas min_count on groupby
<p>I'm trying to find the equivalent of a <code>min_count</code> param on polars groupby, such as in <code>pandas.groupby(key).sum(min_count=N)</code>.</p> <p>Let's suppose the dataframe</p> <pre class="lang-py prettyprint-override"><code>df = pl.from_repr(&quot;&quot;&quot; ┌───────┬───────┐ │ fruit ┆ price │ │ --- ...
<python><python-polars>
2023-11-20 22:14:13
3
306
viniciusbaca
77,518,956
783,314
debugging workflows and/or activities in VSCode or similar
<p>If we have code for Temporal workflows/activities and want to step through the code line-by-line in a debugger, for example with VSCode, is there any reasonably easy way of doing that?</p> <p>I saw that there is a Temporal VSCode extension, but it seems to only be written for TypeScript.</p> <p>I've tried pulling so...
<python><temporal-workflow>
2023-11-20 21:20:10
0
8,953
Stephen
77,518,816
12,369,606
Can I install a Python package in a Conda environment while a script is currently being executed in the environment?
<p>I used a SLURM manager to submit a bunch of scripts that all run in one Conda environment. I would like to install a new Python package to this environment. Do I need to wait until all of my scripts are done running? Or can I install the package now without messing anything up?</p>
<python><conda><hpc>
2023-11-20 20:49:10
1
504
keenan
77,518,740
13,881,506
Why is nums[3:-1:-1] empty instead of the first 4 elements of nums in reverse? Python list slice with positive start, -1 stop, and -1 step
<p>Say I have a list called <code>nums</code> and I want to get a reversed, prefix of <code>nums</code> - i.e. the first <code>start</code> elements of <code>nums</code> in reverse order. <strong>Assuming <code>0 &lt;= start &lt;= n</code> where <code>n = len(nums)</code></strong>, the following work</p> <h5>Get prefix...
<python><python-3.x><list><slice>
2023-11-20 20:35:56
0
1,013
joseville
77,518,556
1,564,070
Confusing output from Python cProfile - queue and threading
<p>I'm trying to find performance bottlenecks in a Python application. The crux of the app is reading data from a text file and inserting it into and RDBMS. I'm using direct ODBC SQL and the program is single-threaded. I do not use the threading or queue libraries at all.</p> <p>Output from cProfile is below. I'm t...
<python><performance-testing><profiler>
2023-11-20 19:57:41
0
401
WV_Mapper
77,518,472
4,506,929
How do I add a subplot to an existing figure?
<p>Consider that I have a pre-existing figure like:</p> <pre class="lang-py prettyprint-override"><code>from matplotlib import pyplot as plt fig, axes = plt.subplots(nrows=2, ncols=3) </code></pre> <p><a href="https://i.sstatic.net/pUkHA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pUkHA.png" alt="ent...
<python><matplotlib><subplot>
2023-11-20 19:38:01
1
3,547
TomCho
77,518,388
19,053,778
Creating a ColumnTransformer pipeline with user defined functions
<p>I´m trying to create a <code>ColumnTransformer</code> pipeline to then pass on a general processing pipeline and it will be mainly used to scale specific columns and add new columns to the data (like cube, etc)</p> <p>I was trying this</p> <pre><code>from sklearn.compose import ColumnTransformer from sklearn.preproc...
<python><scikit-learn>
2023-11-20 19:22:02
1
496
Chronicles
77,517,975
9,415,280
tf dataset "TypeError: unhashable type: 'list'" error on trainning
<p>I try to use tensorflow dataset with a lstm model. It is my first project integrating tf dataset, so all advices to do it better is welcome.</p> <p>Here all my fonctions to get data from many csv and process it to dataset:</p> <pre><code>def csv_loader(path): return tf.data.experimental.CsvDataset( ...
<python><tensorflow><tf.data.dataset><tf.dataset>
2023-11-20 17:52:45
2
451
Jonathan Roy
77,517,974
16,308,381
Flask-session dictionary not persisting between endpoint requests from React/Axios/Chrome/CORS; but it works from Postman
<p>I'd like to 1. outline the problem, 2. show my code, 3. show what happens and what I've done to diagnose the problem, 4. show where I've already looked to solve the problem, and finally, 5. ask a few questions. I apologize in advance that it's a long post, but I've looked everywhere and it's been hard to pinpoint wh...
<python><reactjs><flask><cors><flask-session>
2023-11-20 17:52:11
0
392
pvasudev16
77,517,944
13,630,719
How to resolve error building python-Levenshtein-wheels?
<p>When I try to run a precommit locally and I'm getting the following error log:</p> <p>Failed to build python-Levenshtein-wheels stderr: error: subprocess-exited-with-error</p> <pre><code> × Building wheel for python-Levenshtein-wheels (pyproject.toml) did not run successfully. │ exit code: 1 ╰─&gt; [214 lines o...
<python>
2023-11-20 17:47:24
2
1,342
ENV
77,517,937
1,415,826
shouldn't this date format fail validation?
<p>I am using <code>strptime()</code> to create a datetime object to validate the string format. The format should be <code>mmddyy</code> for example <code>112023</code></p> <p>Using this format code <code>&quot;%m%d%y</code> for the 2 digit day, month, and year works as expected</p> <pre><code>file_name_date = &quot;1...
<python><python-datetime>
2023-11-20 17:45:57
1
945
iambdot
77,517,922
3,861,775
Subclassing Polygon in Shapely
<p>I'm working with Shapely in Python and trying to subclass the Polygon class. However, I'm encountering an error when trying to add a custom attribute during object creation. Could you please provide guidance on how to subclass the Polygon class in Shapely and add custom attributes without running into this error?</p...
<python><shapely>
2023-11-20 17:42:41
1
3,656
Gilfoyle
77,517,864
7,194,375
Running setup works in jupyter lab but not in vscode debug environment, although using same python path
<p>I am running this code in my jupyterlab and in vscode, it works in jupyterlab but does not in vscode. The error appears in the setup function of pycaret. This is my code:</p> <pre><code>from pycaret.regression(.oop) import * #tried with and without oop from pycaret.datasets import get_data data = get_data('insuranc...
<python><machine-learning><regression><pycaret>
2023-11-20 17:28:40
1
408
AldegarRızvan
77,517,808
7,307,125
How to trim and match columns to obtain the common time values and corresponding values?
<p>The equipment (two scopes) give data in different number of points, and triggers in the same moment (0 on time column). (No chance to find same settings).</p> <p>What I would like to achieve is to align the time with its corresponding values (if missing it may be interpolated, data doesn't change fast here).</p> <p>...
<python><pandas><dataframe>
2023-11-20 17:20:15
2
351
smajli
77,517,536
18,587,779
keyboard library interfered with python input
<p>When I press on &quot;p&quot; it triggers input with &quot;p&quot; in the start :</p> <pre><code>import keyboard def print_your_name(): x = input(&quot;Enter Your Name: &quot;) print(x) keyboard.add_hotkey('p', print_your_name) keyboard.wait(&quot;esc&quot;) </code></pre> <p>output:</p> <pre><code>Enter ...
<python><python-3.x><keyboard>
2023-11-20 16:35:46
2
318
Mark Wasfy
77,517,488
8,324,480
Exclude global patterns in setuptools.packages.find is not working
<p>I have a package <code>Foo</code> where I want to exclude both the <code>test</code> files located in folders <code>tests</code> and the file(s) <code>conftest.py</code>.</p> <p>My <code>pyproject.toml</code> configuration is:</p> <pre><code>[tool.setuptools.packages.find] exclude = ['Foo*tests', '*conftest'] includ...
<python><setuptools><packaging>
2023-11-20 16:26:39
0
5,826
Mathieu
77,517,429
5,134,285
AWS CDK How to handle Fn.getAtt to return integer
<p>I am utilizing a custom resource to retrieve an integer value. However, despite the CDK parameter specifically requiring an integer, I encounter an error stating <code>type of argument must be one of (int, float); got str instead</code>. Is there a method within CDK to ensure that the value is received as an integer...
<python><amazon-web-services><aws-cdk>
2023-11-20 16:17:48
0
1,404
GeoCom
77,517,370
6,875,230
Generate list of pattern contained in dictionary values Python
<p>I have the following dictionary as an input of a Python script:</p> <pre><code>d = { 'A':[[1,2,7]], 'B':[[1,3,7], [1,3], [1,7]], 'C':[[1,3,7], [2,6]], 'D':[[1,3,2], [2,1,3]] } </code></pre> <p>and I want the following patterns as outputs:</p> <pre><code>{ (2,7):['A'], (3,7):['C'], (2,6):['C'], (2,3):['D'], (1,2):['...
<python><algorithm><data-structures>
2023-11-20 16:08:29
3
528
Stefano
77,517,303
25,277
Rdflib query value of a related triple
<p>On below example ttl I'm trying to run a query that would give me the <code>relationshipLabel</code> for specific combination of <code>subject</code> and <code>object</code> stated as <code>canRelateTo</code>.</p> <p>So for example: I want to query the value of relationshipLabel for the combination of</p> <ul> <li>d...
<python><sparql><rdf><rdflib><turtle-rdf>
2023-11-20 15:55:19
0
2,967
Gero
77,517,230
6,041,915
Proper URI for mlflow models predict CLI
<p>I have a remote mlflow server up and running. I have also a model in its artifact store. mlflow provides a snippet that can be used for inference:</p> <pre><code>import mlflow logged_model = 'runs:/d3d28efecca44e728a8520d9392267e4/model' mlflow.set_tracking_uri(&quot;http://my.server.address:5001&quot;) # Load model...
<python><mlflow>
2023-11-20 15:45:58
0
702
Jakub Małecki
77,517,225
6,373,357
how to resolve IndexError: list index out of range in python
<p>I am working on one question from Leetcode <a href="https://leetcode.com/problems/maximum-strong-pair-xor-i/description/" rel="nofollow noreferrer">2932. Maximum Strong Pair XOR I</a>. but get the error <code>IndexError: list index out of range</code> under return statement. however I do not see the problem from lin...
<python><python-3.x>
2023-11-20 15:45:30
2
9,309
jacobcan118
77,517,181
10,682,062
Is there a common way to deploy a Django application with Windows Server ISS?
<p>I deployed a Django application on a Windows Server 2016 of a customer, but he wants it deployed through ISS, which as a Linux person i had no idea what it was.</p> <p>So I searched for it, and how to deploy a Django application using ISS.</p> <p>The best content I could find about this was on <a href="https://www.m...
<python><django><deployment><windows-server>
2023-11-20 15:40:18
1
398
Eduardo Fellipe
77,517,162
38,368
Visual Studio Code working with Python with PYTHONPATH and separate source and tests folders
<p>Given a project structure:</p> <pre><code>* project * src * my_package * __init__.py * code_file.py * tests * __init__.py * my_package * __init__.py * code_file_test.py </code></pre> <p>How do I get Visual Studio code to identify that src is the root for code files so this wil...
<python><visual-studio-code><python-unittest><pythonpath>
2023-11-20 15:37:53
1
18,277
Danny Varod
77,517,057
2,414,957
AttributeError: module 'numpy' has no attribute 'bool'. when importing glumpy
<pre><code>&gt;&gt;&gt; import glumpy /home/mona/anaconda3/envs/clean-pvnet/lib/python3.10/site-packages/glumpy/gloo/variable.py:82: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar. gl.GL_BOOL : ( 1, gl.GL_BOOL, np.bool), Traceback (most recent call last): Fi...
<python><numpy><conda><glumpy>
2023-11-20 15:24:09
2
38,867
Mona Jalal
77,516,898
6,494,707
How to make sure generated random boundingboxes within another boundingbox are not overlapping?
<p>I have a boundingbox</p> <pre><code>a = [233.9259, 16.3902, 356.8651, 426.9131] import shapely.geometry bbox = (233.9259, 16.3902, 356.8651, 426.9131) polygon = shapely.geometry.box(*bbox, ccw=True) polygon.bounds # (233.9259, 16.3902, 356.8651, 426.913 </code></pre> <p>and I randomly generated 10 random boundin...
<python><python-3.x><polygon><shapely>
2023-11-20 15:00:12
1
2,236
S.EB
77,516,874
978,074
Moto and boto3 mocks only when specifying the specific python file
<p>I'm using moto to mock my aws calls in my unit tests. When i run <code>pytest tests/test_file.py</code> the unit test will be successful and boto3 gets mocked.</p> <p>When i run <code>pytest tests/</code> to detect all the test files in the directory, <code>boto3</code> doesnt get mocked by moto. Causing an error be...
<python><unit-testing><pytest><boto3><moto>
2023-11-20 14:57:39
0
633
dwardu
77,516,784
2,955,997
python tkinter add spacing to label with multiple lines
<p>I'm using tkinter with python 3.9.10.</p> <p>I have a label which include multiple lines. The spacing between the lines is very narrow and I'm trying to increase it. will appreciate and suggestion.</p> <p>My code:</p> <pre><code>from tkinter import * window = Tk() window.geometry(window_size) window.title(&quot;Terp...
<python><tkinter>
2023-11-20 14:47:08
0
5,832
ibezito
77,516,518
2,386,605
How to enforce Pydantic error raising for wrong generic types
<p>Below you can see my code</p> <pre><code>from pydantic import BaseModel from typing import TypeVar, Generic T = TypeVar('T') class GenericItem(BaseModel, Generic[T]): item: T # Examples of using GenericItem string_item = GenericItem[str](item=&quot;example&quot;) int_item = GenericItem[int](item=42) # This w...
<python><python-3.x><pydantic><typing>
2023-11-20 14:07:06
1
879
tobias
77,516,515
595,599
can not parse a simple FIX message using simplefix
<p>I'm trying to parse a FIX message using Python <code>simplefix</code>:</p> <pre class="lang-py prettyprint-override"><code>import simplefix parser = simplefix.FixParser() parser.append_buffer(&quot;8=FIX.4.2|35=A|49=SENDER_COMP_ID|56=TARGET_COMP_ID|34=1|98=0|108=30|10=112|&quot;) message = parser.get_message() </cod...
<python><fix-protocol>
2023-11-20 14:06:48
0
1,298
DuduArbel
77,516,323
9,479,925
How to do formatting and trimming in polars dataframe?
<p>I have a data frame with about 100 columns with a type of pl.Utf8, I would like to do trim/proper/title of each column at one go.</p> <pre><code>df_.with_columns(pl.all().str.strip_chars()) </code></pre>
<python><python-polars>
2023-11-20 13:37:28
1
1,518
myamulla_ciencia
77,516,280
461,499
Install youtokentome in poetry requires Cython, unable to configre correctly
<p>I'm trying to convert <a href="https://github.com/MahmoudAshraf97/whisper-diarization" rel="nofollow noreferrer">whipser-diarization</a> to <code>poetry</code>.</p> <p>It goes well until I add <code>nemo_toolkit[asr]==1.20.0</code>, which depends on <code>youtokentome</code> (that name is well thought of, btw)</p> <...
<python><cython><python-poetry><openai-whisper>
2023-11-20 13:31:01
2
20,319
Rob Audenaerde
77,516,173
3,743,899
python Tkinter - how to loop on data with a next button
<p>My goal is to read a JSON file create a GUI with labels containing the first data set. Now I want a next button which should update the GUI and update the labels with the second data set and so on.</p> <p>So I expect to see (after start): 127#13:21:17#13:34:30 And after clicking next I expect: 168#13:16:50#13:30:35 ...
<python><tkinter>
2023-11-20 13:16:22
1
678
Yaerox
77,516,160
20,176,161
Excluding a list of string using str.contains: error: nothing to repeat at position 181436
<p>I have a list of strings that i am trying to exclude from a dataframe.</p> <p>The string format are as follows:</p> <pre><code>Filtre=list(transactions_located.titre.unique()) </code></pre> <p>The output is:</p> <pre><code>['1abcvd/C', '1abcvdee/C', '1abcvdeedd/C', '1abcvdfdfs/32', '1abcvdfadfd/C',....] </code></pre...
<python><pandas><string><dataframe><list>
2023-11-20 13:13:31
1
419
bravopapa
77,515,931
3,623,537
Python Debugger (PDB): open currently active python file in editor
<p>Is there some way to get during debugging with <code>pdb</code>:</p> <ul> <li>currently opened python file</li> <li>currently active line of code</li> <li>indent on the current line of code</li> </ul> <p>and open the file in default text editor?</p> <p>Example. After running the code below and then using <code>s</co...
<python><pdb>
2023-11-20 12:31:39
1
469
FamousSnake
77,515,875
1,084,174
Getting error “error: subprocess-exited-with-error” while installing using "pip install --cert"
<p>I have tried to install using anaconda prompt,</p> <blockquote> <p>pip --cert &quot;D:\DDownloads\MyCert.pem&quot; install tflite_support</p> </blockquote> <p>And ended up with error,</p> <pre><code> Collecting tflite_support Using cached tflite-support-0.1.0a1.tar.gz (390 kB) Preparing metadata (setup.py) ... ...
<python><installation><pip><package><anaconda>
2023-11-20 12:20:40
1
40,671
Sazzad Hissain Khan
77,515,630
853,561
Incorrect Method Name in Python Logging Output: Always Displays 'logging:callHandlers:1706' Instead of Actual Method Name
<p>I am encountering an issue with Python logging.</p> <p>The expected method name in the log output is replaced with <code>logging:callHandlers:1706</code></p> <p>Initially, my log entries displayed in the format <code>[level] [date] [method] [text]</code> but now the 'method' field consistently shows 'logging:callHan...
<python><logging>
2023-11-20 11:44:02
1
344
magnum87
77,515,483
2,636,044
Mocking method that calls other methods
<p>I have a class</p> <pre><code>class X: def __init__(self, db): self.db = db def get_data_from_friend(self): return None def get_data_from_db(self): return self.db.get_my_db_data() def get_data(self): if data := self.get_data_from_friend(): return data return self.get_data_from_...
<python><pytest><python-unittest><python-unittest.mock>
2023-11-20 11:21:54
1
1,339
Onilol
77,515,253
8,030,746
Why am I getting this sqlite3.ProgrammingError error?
<p>The error is:</p> <pre><code>sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 1 supplied. </code></pre> <p>And this is the code causing it:</p> <pre><code>data = c.execute('''SELECT * FROM job WHERE title LIKE &quot;%?%&quot;''', (user_input,)).fetchall() <...
<python><sql><sqlite><flask>
2023-11-20 10:50:21
1
851
hemoglobin
77,515,235
5,305,512
Pose estimation web app running extremely slow in deployment
<p>I have the following script for taking 2 input videos of people dancing, compare them frame-by-frame for the body movements (pose estimation), and then display the accuracy with which the user video is able to copy the movements of the person in the benchmark video real time:</p> <pre><code>import streamlit as st im...
<python><performance><deployment><streamlit><mediapipe>
2023-11-20 10:47:34
0
3,764
Kristada673
77,515,042
3,979,391
Celery with postgresql giving error "can't adapt type 'AsyncResult'"
<p>I am using <code>postgresql</code> as my backend for Celery (v5.3.5).</p> <p>Celery is returning an SQL error when I call ready() on the task <code>ASyncResult</code>:</p> <pre><code>sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) can't adapt type 'AsyncResult' [SQL: SELECT celery_taskmeta.id AS celery_...
<python><postgresql><sqlalchemy><celery>
2023-11-20 10:18:55
1
1,697
Giles
77,514,946
9,021,547
Out of sample prediction with SARIMAX
<p>I am building a seasonal ARIMA model using the <code>SARIMAX</code> package from <code>statsmodels</code>. The following is an illustration of the model:</p> <pre><code>import pandas as pd import numpy as np from statsmodels.tsa.statespace.sarimax import SARIMAX date_range = pd.date_range(start='2000-01-01', end='2...
<python><statsmodels><predict><sarimax>
2023-11-20 10:03:51
1
421
Serge Kashlik
77,514,893
13,222,679
how to create xml as an instance from xsd in python
<p>i have xsd file and my task is to create an empty xml based on that xsd i tried to use an external package that i found on github here's the link <a href="https://github.com/fortesp/xsd2xml" rel="nofollow noreferrer">https://github.com/fortesp/xsd2xml</a> and here's what i tried</p> <pre><code>!git clone https://git...
<python><xml><xsd>
2023-11-20 09:56:05
1
311
Bahy Mohamed
77,514,329
4,580,542
How to resolve ImportError: No module named bs4
<p>I'm trying to run some python code, I've installed Python and BeautifulSoup, but I'm getting this error.</p> <p>Any ideas?</p> <p>Thanks</p> <p><code>main.py</code></p> <pre><code>from bs4 import BeautifulSoup with open('index.html', 'r') as html_file: content = html_file.read() print(content) </code></pre>...
<python><beautifulsoup>
2023-11-20 08:16:28
1
1,063
Joe Consterdine
77,514,316
1,306,892
Confusion understanding Google Trends with pytrends: column normalization, search representation, and monthly aggregation
<p>The following code</p> <pre><code>from pytrends.request import TrendReq pytrends = TrendReq(hl='it', tz=0, timeout=None) keywords = ['dichiarazione', 'redditi'] pytrends.build_payload(keywords, timeframe='2004-01-01 2017-01-01', geo='IT') pytrends.interest_by_region(resolution='COUNTRY', inc_low_vol=True, inc_ge...
<python><google-trends>
2023-11-20 08:12:41
1
1,801
Mark
77,514,237
742,269
Getting numbers from an array using mask and regex
<p>Having this array with <code>code</code> and <code>collection</code>, where <code>X</code> is a mask that can be &quot;any number&quot;:</p> <pre><code>input_array = [{&quot;code&quot;: &quot;XXXX10&quot;, &quot;collection&quot;: &quot;one&quot;}, {&quot;code&quot;: &quot;XXX610&quot;, &quot;collection&quot;: &quot;...
<python><regex><python-re>
2023-11-20 07:56:44
6
8,475
Avión
77,514,185
2,840,697
How do we just select lists from the imported module?
<p>Let's say I did the following:</p> <pre><code>from X import A, B, C, D </code></pre> <p>What I want to do is that combine all lists in A, B, C, D to make a single big list:</p> <pre><code>all_list=[] for each_variable in (X.A, X.B, X.C, X.D combined): if each_variable is a list: all_list.extend(each...
<python><loops><directory><iterator>
2023-11-20 07:43:58
2
942
user98235
77,514,059
943,713
Python pattern match on an operator
<p>I'm trying to build a function that would match on a operator , like <code>-</code> :</p> <pre><code>def testM(x): match x: case (operator.sub,a,b): return operator.sub(a,b) case ('-',a, b): return a-b case (&quot;+&quot;,a,b): return a+b case (...
<python><pattern-matching><literals>
2023-11-20 07:10:37
1
1,883
Shawn Zhang
77,514,020
3,848,207
What's wrong with this Python function to upload file to github?
<p>I have the following Python function to upload a file to github repository.</p> <pre><code>def upload_to_github(github_token: str, source_file: str, destination_folder: str, github_repo: str, git_branch: str) -&gt; None: &quot;&quot;&quot; Uploads a file to a GitHub ...
<python><github><pygithub>
2023-11-20 07:01:27
1
5,287
user3848207
77,513,843
5,696,601
Normalized colormap distorted
<p>I want to normalise a colormap and came across <a href="https://gis.stackexchange.com/a/330175/97137">this</a> answer on Stackexchange. It does exactly what I want. Or at least it did. However, the answer and the code are five years old and the code no longer fully reproduces the desired result.</p> <p>What do I nee...
<python><matplotlib><geopandas>
2023-11-20 06:19:42
0
1,023
Stücke
77,513,798
7,520,419
Given a Pandas DataFrame With a MultiIndex of Size 2, How Can I Access Data Using Only the Second Set of Index Values?
<p>I've been trying to figure out how to use MultiIndexes in Pandas. Here's the details. Given the following dataset:</p> <pre><code>user movie rating 196 242 3 186 302 3 22 377 1 244 51 2 166 346 1 </code></pre> <p>Where &quot;user&quot; and &quot;movie&quot; are used as Indexers and &quot;ratin...
<python><pandas><dataframe>
2023-11-20 06:07:18
0
606
Sintrias
77,513,762
14,108,609
Why is not possible to change the grey color in axes/axis title of graph in streamlit
<p><a href="https://i.sstatic.net/7bQcf.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7bQcf.png" alt="image of the streamlit multiline graph plotted using st.write and plotly" /></a></p> <pre><code> fig = sp.make_subplots(specs=[[{&quot;secondary_y&quot;: True}]]) fig.add_trace(go.Line(...
<python><plotly><visualization><dashboard><streamlit>
2023-11-20 05:54:54
1
1,351
Janzaib M Baloch
77,513,504
12,931,358
TypeError: list indices must be integers or slices, not str when import HF dataset from local path
<p>I want to use <code>map</code> function after importing huggingface dataset [mkqa], so I download <a href="https://github.com/apple/ml-mkqa/raw/main/dataset/mkqa.jsonl.gz" rel="nofollow noreferrer">it</a> firstly, then put all to local path, <code>&quot;/data/mkqa-Chinese&quot;</code> and,</p> <pre><code>from datase...
<python><huggingface-datasets>
2023-11-20 04:25:16
1
2,077
4daJKong
77,513,130
1,285,061
python datetime delta inaccuracy - Sidereal period
<p>In python datatime module I noticed a gap. Datetime does leap year adjustment automatically, using sidereal year length.</p> <p>How to achieve scientific accuracy in these date calculations?</p> <p>The difference is expected to be exactly <code>200</code>, but it is <code>199.99377806650291</code></p> <p>This is mes...
<python><datetime><timedelta>
2023-11-20 01:38:04
1
3,201
Majoris
77,513,010
9,273,406
Skipping Authentication in FastAPI Based on POST request parameter
<p>I am currently working on a FastAPI project and facing a challenge in implementing a custom authenticator. My goal is to skip authentication based on the value of a specific parameter in the request body and return a hardcoded user ID when the condition is met.</p> <p>Here's a simplified version of my main.py file w...
<python><oauth-2.0><fastapi><auth0>
2023-11-20 00:30:33
1
4,370
azizbro
77,512,691
1,757,321
Retrieval-augmented generation without OpenAIEmbeddings
<p>I'm playing with HuggingFace and some of the models on there. I'm trying to achieve something along the lines of <a href="https://python.langchain.com/docs/use_cases/question_answering/" rel="nofollow noreferrer">RAG</a>. Seems like a pretty clear guide with all the needed ingredients and recipe. But the cooking seq...
<python><nlp><artificial-intelligence><langchain>
2023-11-19 22:11:20
1
9,577
KhoPhi
77,512,673
7,077,532
Python Dataframe: Expand Single "Date" Column Dataframe by Adding Second Column From a List of Names To Each Date
<p>Let's say I have the following sample input dataframe below. Please note my real table contains hundreds of dates.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Date</th> </tr> </thead> <tbody> <tr> <td>2023-04-02</td> </tr> <tr> <td>2023-07-14</td> </tr> </tbody> </table> </div> <p>T...
<python><dataframe><list><loops><merge>
2023-11-19 22:02:02
3
5,244
PineNuts0
77,512,666
1,116,171
Python create time interval from human readable string
<p>Is there a Python library to convert human readable time interval to 2 datetimes?</p> <p>Example:</p> <pre><code>Str(TimeInterval(&quot;last week&quot;)) # return a tuple (datetime(2023,11,12,0,0,0), datetime(2023,11,19,23,59,59)) </code></pre> <p>Same for today, yesterday, last month, 2 months ago, year-to-date, et...
<python><datetime><humanize>
2023-11-19 21:59:33
1
1,932
Charlie
77,512,663
9,320,666
How to make mypy ignore no-untyped-def error on internal (private) methods
<p>I'm using mypy with <code>disallow-untyped-defs</code> flag so it complains when I create a method that doesn't have type annotation on parameters or return (<code>error: Function is missing a type annotation [no-untyped-def]</code>).</p> <p>This is usually what I want. I want to make sure all public methods have t...
<python><mypy><python-typing>
2023-11-19 21:57:59
1
1,898
Seljuk Gulcan
77,512,620
2,446,374
palm api often returns nothing
<p>I'm using the palm api from python - and using either text_generation or chat - it does the same thing. I send in a prompt like:</p> <pre><code>summarise this: a bunch of text </code></pre> <p>and it works perfectly - but I want a summary of my <em>conversation</em>. so if I send in this:</p> <pre><code>summarise...
<python><palm-api>
2023-11-19 21:41:36
0
3,724
Darren Oakey
77,512,614
1,251,549
How set description to DAG tags in apache airflow?
<p>Tags for DAG are created automatically. But is there a way to create meaningful description for the tag? So user can not only use tags for searching but see description of tags that are used.</p>
<python><airflow><airflow-2.x>
2023-11-19 21:39:16
1
33,944
Cherry
77,512,179
15,542,245
Unexpected list index affects word option for difflib.get_close_matches()
<p>Question: I am required to use this indexing of tokens in my difflib call: <code>difflib.get_close_matches(tokens[0], jobList, n=1, cutoff=0.85)</code> in order to get my required output. If I use what I expect. Which is <code>tokens[j]</code> then my output is affected by having the token <code>Asst</code> still ap...
<python><list><indexing>
2023-11-19 19:25:11
1
903
Dave
77,512,098
3,740,545
How to add space between bars using Plotly?
<pre><code>import plotly.express as px df = px.data.tips() fig = px.histogram( pd.DataFrame({'price': prices}), x=&quot;price&quot;, ) fig.show() </code></pre> <p><a href="https://i.sstatic.net/77phy.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/77phy.png" alt="enter image description her...
<python><plotly>
2023-11-19 19:03:15
1
7,490
Franco Piccolo
77,512,072
6,324,055
How to properly declare optional dependencies both as extras and in dedicated groups in Poetry?
<p>From Poetry documentation about the difference between groups and extras:</p> <blockquote> <p>Dependency groups, other than the implicit main group, must only contain dependencies you need in your development process. Installing them is only possible by using Poetry. To declare a set of dependencies, which add addit...
<python><dependency-management><python-poetry>
2023-11-19 18:52:55
0
6,586
Louis Lac
77,512,056
116,906
Why is this stubbed Brython page giving cascading errors?
<p>I have a stub of a webpage that is designed to make jQuery UI and Brython with Python's standard library be available:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=&quot;utf-8&quot; /&gt; &lt;title&gt;Game&lt;/title&gt; &lt;link rel=&quot;stylesheet&quot...
<python><jquery><brython>
2023-11-19 18:46:20
1
6,021
Christos Hayward
77,511,910
7,530,099
Flask app in apache environment creating duplicate log entries and escalating db conns
<p>I have a python flask app which uses SQLAlchemy and flask-sqlalchemy. In the dev environment I use the built-in flask server connecting to a local postgres 14 db. The staging environment uses apache with mod-wsgi connecting to a postgres 12 db. The apache site config looks like this (anonymized):</p> <pre><code>&...
<python><postgresql><flask><flask-sqlalchemy><mod-wsgi>
2023-11-19 18:08:32
0
426
Momus
77,511,750
6,410,450
In plotly, how can I create a subplot figure with different numbers of subplots per row?
<p>I'd like to create a plotly figure that has 1 large subplot in the first row and 2 side-by-side subplots in the 2nd row. plotly.subplots.make_subplots forces me to create a rectangular grid, so I'd have to do a 2x2 grid or a 2x1 grid, which isn't what I'm looking for. Is there a way to do this in plotly?</p>
<python><plotly><subplot>
2023-11-19 17:25:40
1
2,245
Troy D
77,511,660
3,312,274
How do I make JS fetch function receive json/data from flask API in the same order as sent by flask?
<p>How do I make JS fetch receive json/data from flask API in the same order as sent by flask?</p> <p><strong>flask API:</strong></p> <pre><code>@api_bp.route(&quot;/users&quot;) def users(): all_users = User.query.all() data = list([u.to_dict() for u in all_users]) return data </code></pre> <p>print(data):...
<javascript><python><flask><bootstrap-vue>
2023-11-19 16:57:11
1
565
JeffP
77,511,634
386,861
Choropleth doesn't display in Altair
<p>I'm trying to create a choropleth from some data but something isn't working.</p> <pre><code>import altair as alt import pandas as pd from vega_datasets import data dat = { 'country': [ 'France', 'Belgium', 'United Kingdom', 'Iraq', 'Turkey (including Gallipoli)', 'Iran', 'Germany', 'Italy', 'In...
<python><pandas><altair>
2023-11-19 16:49:13
1
7,882
elksie5000
77,511,555
13,955,154
RAG model not reading json files
<p>I'm trying to implement a simple rag that reads a list of input files and answers to questions based on their content:</p> <pre><code>documents = SimpleDirectoryReader(&quot;/content/Data/&quot;).load_data() llm = LlamaCPP( model_url='https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF/resolve/main/mis...
<python><embedding><langchain><large-language-model>
2023-11-19 16:20:27
1
720
Lorenzo Cutrupi
77,511,403
13,803,549
Order Django queryset by value closest to 0
<p>I have a queryset that is returning a list of entries that are tied for the lead in a contest...</p> <pre class="lang-py prettyprint-override"><code> leaders = ContestEntry.objects.filter(name=game, wins=wins) </code></pre> <p>After I get this data I need to put them in order by a second field ('difference') as ...
<python><django><sorting><django-queryset>
2023-11-19 15:41:09
2
526
Ryan Thomas
77,511,351
12,285,101
split rows into columns in pandas dataframe
<p>I have table similar to this table:</p> <pre><code> id val 0 abc_1 5 1 abc_1 3 2 abc_1 7 3 abc_2 12 4 abc_2 6 5 abc_2 9 ... </code></pre> <p>I want to &quot;split&quot; the rows into columns based on the id, so the result should be:</p> <pre><code> id val1 val2 v...
<python><pandas><pivot-table>
2023-11-19 15:25:52
2
1,592
Reut
77,511,233
15,239,717
How can I send an email in a Django function-based view using the Brevo API?
<p>I have developed a Django web application and integrated sending customize email using <strong>Brevo</strong> formally known as <strong>SendinBlue</strong>.</p> <p>My <code>settings.py</code> file for sending emails is configured fine, because I am able to receive a password reset email, but I am unable to sending e...
<python><django><sendinblue>
2023-11-19 14:54:20
0
323
apollos
77,511,162
5,852,692
SQLalchemy custom __repr__ different behaviour
<p>I have some SQLalchemy tables which are relational:</p> <pre><code>DBNetwork (parent) -&gt; DBNode (child) </code></pre> <p>When I call the a specific <code>DBNetwork</code> instance the <code>__repr__</code> function works as expected, only displaying the <code>DBNetwork</code> instance attributes. However, after I...
<python><dictionary><sqlalchemy><repr>
2023-11-19 14:32:50
1
1,588
oakca
77,511,122
17,758,716
How to parse an HTML table, into a portable data-set; DSV, JSON, etc
<p>I'd like to capture all the data from an <em><a href="https://en.wikipedia.org/wiki/HTML" rel="nofollow noreferrer">HTML</a> table</em>, and place it into a data-set. Preferably, a <em><a href="https://en.wikipedia.org/wiki/Delimiter-separated_values" rel="nofollow noreferrer">DSV</a></em>, or a <em><a href="https:/...
<python><csv><parsing><html-table><dataset>
2023-11-19 14:22:23
2
6,266
Reilas