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,573,944
4,980,705
df.head(n).itertuples() loop is quite slow
<p>the following loop is quite slow (takes minutes), although it is calling a function, but the function <code>getstopscoordinates</code> is quite simple</p> <pre><code>for row in df_RoadSegments.head(2).itertuples(): df_RoadSegments[&quot;OriginCoordinates&quot;] = df_RoadSegments.apply(lambda x: getstopscoordinat...
<python><pandas>
2023-11-29 19:12:58
1
717
peetman
77,573,909
726,730
sub classing python pyqt5 QHeaderView
<p><strong>file: table.py</strong></p> <pre class="lang-py prettyprint-override"><code>from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.resize(400, 300) self.verticalLayout = QtWidgets.QVBoxLayout(Dialog) self.tableWidget = QtWidgets.QTab...
<python><pyqt5><qtablewidget><qheaderview>
2023-11-29 19:07:44
1
2,427
Chris P
77,573,873
5,437,090
Execute a Python script from another Python script with argparse input argument and extract an output
<p>Given:</p> <p><code>child.py</code>:</p> <pre><code>import argparse import json parser = argparse.ArgumentParser(description='A sample script with argparse') parser.add_argument('--query', type=str, help='Query Phrase', default=&quot;I love coding!&quot;) args = parser.parse_args() def customized_fcn(inp=&quot;Thi...
<python><subprocess><argparse>
2023-11-29 19:03:03
0
1,621
farid
77,573,764
8,102,500
Why TorchVision's GoogLeNet has this strange "normalization"?
<p>I'm reading the source code of <a href="https://github.com/pytorch/vision/blob/main/torchvision/models/googlenet.py" rel="nofollow noreferrer">TorchVision's GoogLeNet</a> and I found these lines strange and can't figure it out.</p> <pre class="lang-py prettyprint-override"><code>def _transform_input(self, x: Tensor)...
<python><pytorch><torchvision>
2023-11-29 18:42:31
1
1,203
Shuai
77,573,742
2,868,899
substring functionality when ignoring the stop
<p>Is there a way to use the string <code>length</code> instead of a <code>stop</code> with <code>SubString</code> instead of an error being thrown because <code>SubString</code> reached the end of the string before the <code>stop</code> was reached?</p> <p>In Python it works like this:</p> <pre><code>string = &quot;He...
<python><julia>
2023-11-29 18:40:05
0
2,790
OldManSeph
77,573,709
13,135,901
How is this chained indexing?
<p>I get <code>SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame</code> warning when trying to run the following code:</p> <pre><code>df = pd.DataFrame(np.random.randn(5, 3), columns=['A', 'B', 'C']) df2 = df[(df.A &gt; 0) | (df.B &gt; 0)] df2.at[-1, 'C'] = df['...
<python><pandas>
2023-11-29 18:33:55
0
491
Viktor
77,573,600
583,187
Format a number to 8 or 16 chars without "e" with highest precision
<p>I have the following python procedure. Input is any number (from a calculation) and format, where format can be 'long' or 'short'</p> <p>What i want to do: If the format is short, i want the output to be the number inputted but using a maximum of 8 chars (including sign). If the format is long, the output may use up...
<python><formatting><numbers><rounding><precision>
2023-11-29 18:15:02
1
2,841
Lumpi
77,573,562
1,290,485
How do I specify feature columns in Databricks AutoML?
<p>I am running Databricks AutoML in a Python notebook with the look-ups from the feature tables. However, the additional columns are always included, and all runs fail.</p> <pre><code>import databricks.automl automl_feature_lookups = [ { &quot;table_name&quot;:&quot;lakehouse_in_action.favorita_forecasting....
<python><databricks><automl>
2023-11-29 18:07:05
1
6,832
Climbs_lika_Spyder
77,573,501
1,230,945
Assign a new column in a multi-indexed dataframe
<p>I have the following multi-indexed dataframe:</p> <p><a href="https://i.sstatic.net/V4T9K.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/V4T9K.png" alt="Multi-indexed dataframe" /></a></p> <p>I want to add a new column labeled <code>returns</code> and assign the percentage change applied to the <code...
<python><python-3.x><pandas><dataframe><multi-index>
2023-11-29 17:57:41
1
723
Sunday Okpokor
77,573,416
5,399,268
How to get the correct pivoting for a pandas dataframe?
<p>I have following <code>pandas</code> DataFrame:</p> <pre><code>import pandas as pd df2 = pd.DataFrame({ 'nombreNumeroUnico': ['UP2_G1_B', 'UP2_G2_B'], 'pMax': [110.0, 110.0] }) df2 ((Out [1])): nombreNumeroUnico pMax 0 UP2_G1_B 110.0 1 UP2_G2_B 110.0 </code></pre> <h2>Expected resu...
<python><pandas><dataframe><pivot>
2023-11-29 17:42:22
2
4,793
Cedric Zoppolo
77,572,887
1,315,621
Random non deterministic results from pretrained retinanet
<p>I wrote the following class to perform instance segmentation and return the masks of a given class. The code seems to be running randomly and it's not deterministic. The labels printed (as well as the number of labels) change at every execution even if I am running the code on the same input image containing a singl...
<python><deep-learning><pytorch><image-segmentation><retinanet>
2023-11-29 16:22:27
1
3,412
user1315621
77,572,766
11,611,246
Unable to upload package using twine
<p>When I build my Python package, I get no warnings or errors:</p> <pre><code>H:\git\graphab4py&gt;py -m build * Creating venv isolated environment... * Installing packages in isolated environment... (setuptools&gt;=61.0, wheel) * Getting build dependencies for sdist... running egg_info writing src\graphab4py.egg-info...
<python><python-sphinx><restructuredtext><twine>
2023-11-29 16:05:28
1
1,215
Manuel Popp
77,572,731
11,578,996
Why is the linewidth inconsistent for this animated LineCollection?
<p>This animation is supposed to particles in motion with the leading component having alpha=1 and lw=4, with a tail of reducing lw and alpha. The alpha works, the lw is <strong>inconsistent</strong> even for the same particle - sometimes the leading edge is fat and the tail thin, sometimes the obverse is true. Why?!</...
<python><matplotlib><matplotlib-animation>
2023-11-29 16:00:12
1
389
ciaran haines
77,572,706
2,977,092
Untoggle *all* legend items in an Altair chart in a Jupyter notebook
<p>I'm trying to create a chart with Altair in a Jupyter notebook. It's basically a line-chart of various currency values over time. I included my code below.</p> <p>I can toggle currencies using the legend, and all is cool. I have one annoyance though: once I untoggle the last currency, all <strong>lines</strong> will...
<python><jupyter-notebook><toggle><legend><altair>
2023-11-29 15:55:49
0
739
luukburger
77,572,395
18,744,117
How to specify f-bounded polymorphism in python typing ( i.e. refering to the type of a subclass )
<p>An simple example of what I want to achieve:</p> <pre class="lang-py prettyprint-override"><code>from typing import TypeVar, Generic from abc import abstractmethod T = TypeVar( &quot;T&quot;, bound=&quot;Copyable['T']&quot; ) class Copyable( Generic[T] ): @abstractmethod def Copy( self ) -&gt; T: p...
<python><mypy><typing><f-bounded-polymorphism>
2023-11-29 15:16:32
1
683
Sam Coutteau
77,572,223
8,037,521
Forbid usage of defaults channel in Conda
<p>This one is getting a bit annoying for me: <code>defaults</code> channel is apparently paid and cannot be used commercially. Still, it is very difficult to get rid of it, as it keeps randomly re-appearing.</p> <p>I made an environment, installing everything from <code>conda-forge</code>, and exported that environmen...
<python><conda>
2023-11-29 14:53:49
1
1,277
Valeria
77,572,220
9,318,323
Execute statement with DB-API style bind params
<p>I am learning sqlalchemy and want to delete rows that are older than X number of days counting from today. When I try this:</p> <pre><code>from datetime import datetime, timedelta import sqlalchemy db_con_string = 'Driver={ODBC Driver 17 for SQL Server};Server=tcp...' connection_url = sqlalchemy.engine.URL.create(...
<python><sql-server><sqlalchemy>
2023-11-29 14:53:41
1
354
Vitamin C
77,572,077
6,619,692
Using SETUPTOOLS_SCM_PRETEND_VERSION for package version inside Docker with .git directory in dockerignore
<p>I'm using <a href="https://setuptools-scm.readthedocs.io/en/latest/usage/" rel="noreferrer">setuptools scm</a> to dynamically provide version numbers for a Python package, and have these lines in the pyproject.toml:</p> <pre><code>... dynamic = [&quot;dependencies&quot;, &quot;version&quot;, &quot;readme&quot;] [to...
<python><docker><version-control><setuptools>
2023-11-29 14:33:00
1
1,459
Anil
77,572,009
16,674,436
Plotting the frequency of number of comments per day over time
<p>In python, I have a data frame (<code>gme_interaction</code>) with three columns. One column is the time (<code>created</code>) when a post was commented. The second column is the number of comments the posts received (<code>num_comments</code>), and the third column in the actual comment.</p> <p>I want a graph that...
<python><matplotlib><plot><graph>
2023-11-29 14:24:52
0
341
Louis
77,571,915
5,786,649
How are dimensions handled in pytorch's tensors?
<p>How does the <code>size</code> parameter behave in creation of tensors? How does the <code>axis</code> parameter behave in methods like <code>torch.Tensor.sum()</code> and <code>torch.Tensor.softmax()</code>?</p> <p>I would like to give a good overview of how <code>pytorch.Tensor</code> instances in handle dimension...
<python><pytorch><tensor>
2023-11-29 14:15:08
1
543
Lukas
77,571,877
1,648,712
How can I open a specific database on Google Firestore in Python?
<p>I am using Firebase and setting/retrieving documents from Firestore with this code:</p> <pre><code>import firebase_admin from firebase_admin import credentials, firestore cred = credentials.ApplicationDefault() firebase_admin.initialize_app(cred, options={&quot;projectId&quot;: &quot;huq-jimbo&quot;}) firestore_cli...
<python><firebase><google-cloud-platform><google-cloud-firestore>
2023-11-29 14:11:13
2
414
jimbofreedman
77,571,796
595,870
How to create singleton object, which could be used both as type and value (similar to None)?
<p>I'd like to have custom NotSet value which could be used in type hinting similar to None.</p> <pre class="lang-py prettyprint-override"><code>NotSet = ? class Client: def partial_update( self, obj_id: int, obj_field: int | None | NotSet = NotSet, ... ): ...
<python><python-typing>
2023-11-29 13:59:56
2
6,078
Mikhail M.
77,571,576
4,436,572
performance improvement on numpy ndarray columnar calculation (row reduction)
<p>I'm doing row reduction on 3 dimensional ndarray (KxMxN), i.e., taking all values of a column and use a reduce function to produce a scalar value; eventually a KxMxN matrix would become a 2 dimensional ndarray of order KxN.</p> <p>What I am trying to solve:</p> <ol> <li>Take in a 3D-matrix and split it into 16 sub-m...
<python><performance><vectorization><numpy-ndarray><numba>
2023-11-29 13:30:51
2
1,288
stucash
77,571,555
6,367,851
Handle GO in pyodbc
<p>I wrote a Python script that uses <code>pyodbc</code> (via SQLAlchemy) to execute T-SQL files. Some files are littered with <code>GO</code> statements:</p> <pre class="lang-sql prettyprint-override"><code>-- query.sql USE db_name GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE OR ALTER VIEW ... </code>...
<python><sql-server><sqlalchemy>
2023-11-29 13:27:44
0
2,152
Mike Henderson
77,571,552
5,897,305
pyCharm warning in django code: Unresolved attribute reference 'user' for 'WSGIRequest'
<p>in my brandnew PyCharm professional edition I get the warning &quot;<em>Unresolved attribute reference 'user' for 'WSGIRequest'</em>&quot;. The warning occurs in the first line of <code>MyClass.post()</code> (see code below).</p> <pre><code>from django.views import generic from django.db import models from django.ht...
<python><django><pycharm>
2023-11-29 13:27:26
1
713
Humbalan
77,571,482
8,110,650
Why am I receiving ResourceWarning when testing Flask app
<p>In my Flask application which I am testing using <code>unittest</code>, when I use <code>send_from_directory</code> function in my route I am getting <code>ResourceWarning</code>.</p> <p>This is the route:</p> <pre class="lang-py prettyprint-override"><code>@app.route(&quot;/&lt;filename&gt;&quot;) def file_content(...
<python><unit-testing><flask>
2023-11-29 13:16:38
1
919
SrdjaNo1
77,571,395
15,913,281
Filter Numpy Array for Values Greater than Preceding Value
<p>Given the following array how can I filter to produce a new array that contains the values that are less than the next value by at least 3?</p> <p>In other words, I need to compare each value with its neighbour on the right and add it to a new array if that neighbour is higher by 3 or more.</p> <pre><code>ex_arr = [...
<python><numpy>
2023-11-29 13:03:40
1
471
Robsmith
77,571,319
1,153,506
Annotate Django Foreign Key model instance
<p>Is it possible in Django to annotate a Foreign Key instance?</p> <p>Suppose I have the following models:</p> <pre><code>class BaseModel(models.Model): pass class Foo(models.Model): base_model = models.ForeignKey('BaseModel', related_name='foos') class Bar(models.Model): base_model = models.ForeignKey('BaseMo...
<python><django><django-queryset><django-annotate><django-aggregation>
2023-11-29 12:53:47
1
1,987
andrea.ge
77,571,252
8,541,953
Change area calculation to km2 in ipyleaflet DrawControl
<p>When creating a DrawControl in ipyleaflet, I am able to draw a polygon in the map. An example below:</p> <pre><code>[![from ipyleaflet import Map, basemaps, basemap_to_tiles, DrawControl watercolor = basemap_to_tiles(basemaps.Stadia.StamenTerrain) m = Map(layers=(watercolor, ), center=(50, 354), zoom=5) draw_cont...
<python><leaflet><ipywidgets><ipyleaflet>
2023-11-29 12:41:35
1
1,103
GCGM
77,571,246
1,833,326
How to solve a Weighting Problem with pyspark
<p>I have matrix A of dimension [nXm] like</p> <pre><code>w1 w2 0 w3 0 w4 0 w5 0 </code></pre> <p>a vector <code>b</code> with known value of size [mX1]:</p> <pre><code>10 5 3 </code></pre> <p>and a vector <code>c</code> of size [nX1]</p> <pre><code>0 0 0 </code></pre> <p>I want now to find on solution (finding val...
<python><pyspark><model-fitting>
2023-11-29 12:40:39
1
1,018
Lazloo Xp
77,571,177
10,750,541
How to customize an upset graph with stacked bars (size, legend, combo order)
<p>I am trying to figure out in this example (<a href="https://upsetplot.readthedocs.io/en/stable/auto_examples/plot_discrete.html" rel="nofollow noreferrer">https://upsetplot.readthedocs.io/en/stable/auto_examples/plot_discrete.html</a>) how to:</p> <ol> <li>change the size of the figure</li> <li>move the legend at th...
<python><upsetplot>
2023-11-29 12:31:29
0
532
Newbielp
77,571,120
607,846
Test function with default argument
<p>Lets say I wish to test this function:</p> <pre><code>def get_user(user_id, adults_only=False): pass </code></pre> <p>where the implementation is not shown.</p> <p>I would like to test this using parameterised expand, something like this:</p> <pre><code>@paramaterized.expand([(True, &quot;none&quot;),(False, &qu...
<python><python-unittest>
2023-11-29 12:22:23
1
13,283
Baz
77,570,976
9,302,146
'cygpath: not found' & 'exec: cmd: not found' for Pyenv on Windows WSL 2
<p>I have been trying to get Tensorflow to recognize my GPU within WSL 2. However, I believe that is largely irrelevant for the problem I am having right now.</p> <p>Whenever I try to run the <code>pyenv</code> command within WSL I get the following error:</p> <pre class="lang-bash prettyprint-override"><code>/mnt/c/Us...
<python><windows-subsystem-for-linux><pyenv>
2023-11-29 12:01:37
3
429
Abe Brandsma
77,570,942
10,795,473
How can I write/show a Python Snowpark DataFrame with more than 64 rows?
<p>I'm using Python Snowpark to create a dataframe and show it or write it to my SnowFlake database but I'm having a strange error while doing so.</p> <p>The error raises when I &quot;.show()&quot; or &quot;.write()&quot; the DataFrame and when this contains more than 64 rows. The error says &quot;Cannot perform DROP. ...
<python><snowflake-cloud-data-platform>
2023-11-29 11:55:47
1
309
aarcas
77,570,598
8,228,558
"The network path was not found" error with multiple backslashes in the error-printed path
<p>I am trying to deploy a Flask application on a Windows Server. It works fine on local test but it fails to access the server folders on deployment. The main folder is a network one which looks like this:</p> <pre><code>mainpath = '//part1//part2/part3/folder' </code></pre> <p>I have a testing route in Flask that jus...
<python><windows><path>
2023-11-29 11:05:55
0
10,647
IoaTzimas
77,570,553
1,627,106
Conditionally required value in Pydantic v2 model
<p>I'm working with an API that accepts a query parameter, which selects the values the API will return. Therefore, when parsing the API response, all attributes of the Pydantic model used for validation must be optional:</p> <pre class="lang-py prettyprint-override"><code>class InvoiceItem(BaseModel): &quot;&quot;...
<python><pydantic>
2023-11-29 11:00:48
2
1,712
Daniel
77,570,541
895,727
Why do Python's match statements not raise an Exception when no pattern matches?
<p><a href="https://peps.python.org/pep-0634/" rel="nofollow noreferrer">PEP 634</a> and <a href="https://peps.python.org/pep-0635/" rel="nofollow noreferrer">PEP 635</a> introduce <em>structural pattern matching</em>. But no rationale is given why nothing happens, if none of the patterns matches:</p> <pre class="lang-...
<python><python-3.10>
2023-11-29 10:59:01
2
1,279
clonejo
77,570,456
497,219
Cannot list tapkey owners despite having right scopes
<p>I'm trying to get a list of owners/locks using the Tapkey REST api in Python. I verified the oauth credentials are correct, as I am getting an actual token.</p> <pre><code>import requests tapkey_api_url = &quot;https://my.tapkey.com&quot; tapkey_api_version = &quot;/api/v1&quot; tapkey_auth_server = &quot;https://l...
<python><tapkey>
2023-11-29 10:45:08
1
1,583
Jeroen Jacobs
77,570,408
3,628,232
AsyncResult vs callback for getting many results from apply_async()
<p>When using the <code>apply_async()</code> method from Python's <code>multiprocessing.Pool</code>, there are two options for storing the return value - either save the <code>AsyncResult</code> object and call <code>.get()</code>, or use a callback, i.e.:</p> <pre class="lang-py prettyprint-override"><code># Using Asn...
<python><callback><multiprocessing><python-multiprocessing>
2023-11-29 10:38:56
1
780
Peet Whittaker
77,570,404
13,163,943
Is there a way to always run black before python, but still have full command line functionality for python (be able to feed in any arguments etc)
<p>I often still do a lot of local testing on slightly long running scripts, I have some linting setups, but I'm often just using VIM on a fairly raw VM, and I've not quite cracked getting my perfect editing setup sorted quickly.</p> <p>What would often help me is if every time I tried to run a python script, black ran...
<python><pre-commit>
2023-11-29 10:38:49
1
366
George Pearse
77,570,302
1,249,683
How can I pass a keyword argument to a function when the name contains a dot `.`?
<p>Given a function that accepts &quot;**kwargs&quot;, e.g.,</p> <pre class="lang-py prettyprint-override"><code>def f(**kwargs): print(kwargs) </code></pre> <p>how can I pass a key-value pair if the key contains a dot/period (<code>.</code>)?</p> <p>The straightforward way results in a syntax error:</p> <pre clas...
<python><syntax><keyword-argument>
2023-11-29 10:25:01
1
500
xebtl
77,570,291
1,133,730
How to check the version of Spark Core, not pyspark
<p>I am running a different version of pyspark and spark core (what's installed in the cluster), is there a way to print the version of spark core? everything so far gives me the version of pyspark. I have tried the following from the user machines:</p> <pre><code>pyspark.__version__ ss.version # same as spark.versio...
<python><apache-spark><pyspark>
2023-11-29 10:23:03
1
3,541
fersarr
77,570,215
6,151,828
How does sklearn calculate AUC for random forest and why it is different when using different functions?
<p>I start with the example given for <a href="https://scikit-learn.org/stable/auto_examples/miscellaneous/plot_roc_curve_visualization_api.html" rel="nofollow noreferrer"><em>ROC Curve with Visualization API</em></a>:</p> <pre><code>import matplotlib.pyplot as plt from sklearn.datasets import load_wine from sklearn.en...
<python><scikit-learn><random-forest><roc><auc>
2023-11-29 10:11:42
1
803
Roger V.
77,570,187
16,171,413
Gracefully Handle Exception from raw user input wrapped in an int function
<p>Consider the function below:</p> <pre><code>def user_input(): try: a = int(input(&quot;Enter a number: &quot;)) except ValueError: print(f&quot;\n{a} is invalid.\n&quot;) else: return a </code></pre> <p>This doesn't handle exceptions gracefully but instead results in the following...
<python>
2023-11-29 10:07:16
2
5,413
Uchenna Adubasim
77,570,186
129,805
django-helpdesk 0.4.1 "extendMarkdown() missing 1 required positional argument: 'md_globals'"
<p>When I try to view /tickets/1/ I get the error:</p> <pre><code>extendMarkdown() missing 1 required positional argument: 'md_globals' /usr/local/lib/python3.9/dist-packages/markdown/core.py, line 115, in registerExtensions </code></pre> <p>How can I fix this?</p>
<python><python-3.x><django><markdown>
2023-11-29 10:07:11
1
45,159
fadedbee
77,570,066
7,347,925
How to accelerate convolving function?
<p>I have written a convolving function like this:</p> <pre><code>import numpy as np import numba as nb # Generate sample input data num_chans = 111 num_bins = 47998 num_rad = 8 num_col = 1000 rng = np.random.default_rng() wvl_sensor = rng.uniform(low=1000, high=11000, size=(num_chans, num_col)) fwhm_sensor = rng....
<python><arrays><numpy><matrix><numba>
2023-11-29 09:49:54
1
1,039
zxdawn
77,569,960
11,742,006
Failed building wheel for bcrypt when running pip install paramiko
<p>I'm trying run pip install paramiko, but i'm running into the following error : please help me, i already tried pip update, installing rust. it keep returning this kind of error. i already tried to use pip install pysftp too but the error is same.</p> <pre><code> =============================DEBUG ASSISTANCE=====...
<python><python-3.x><pip><paramiko><pysftp>
2023-11-29 09:33:57
1
524
victorxu2
77,569,715
10,748,166
reportlab, Long word or URI doesn't wrap inside table cell
<p>Creating a table with cells that contain long words doesn’t seem to work as expected, i.e. the words are not wrapped automatically inside the paragraphs and the table cell breaks page layout by being too wide. Additionally the rendered text of the URI contains strange characters ( <code>;</code> ) that are not in th...
<python><reportlab>
2023-11-29 08:50:34
0
305
mko
77,569,552
2,890,129
How to display a lets-plot plot in Spyder IDE
<p>I am using spyder ide and Lets-plot to generate a plot.</p> <pre><code>import numpy as np import polars as pl LetsPlot.setup_html() from lets_plot import * np.random.seed(12) data = pl.DataFrame( { &quot;cond&quot;:np.random.lognormal(0, 1, 400), &quot;rating&quot;:np.concatenate((np.random.normal(0, 1,...
<python><spyder><python-polars><lets-plot>
2023-11-29 08:27:11
1
439
Ramakrishna S
77,569,524
2,955,827
How to enable IDE IntelliSense with dynamic imported python classes?
<p>I have thousands of models in my package, each of them contains one class. Users can choose model they want to use by:</p> <pre class="lang-py prettyprint-override"><code>from myproject.type1.models.m1 import m1 </code></pre> <p>Very inconvenient.</p> <p>The subfolder looks like:</p> <pre><code>type1/ ├── __init__.p...
<python><visual-studio-code><pycharm><intellisense>
2023-11-29 08:21:34
2
3,295
PaleNeutron
77,569,518
5,084,560
cx_Oracle.DatabaseError: ORA-12847: retry parsing due to concurrent DDL operation
<p>I'm reading data from Oracle DB on python cx_Oracle. But sometimes it throws</p> <blockquote> <p>ORA-12847: retry parsing due to concurrent DDL operation</p> </blockquote> <p>I couldn't find anything about it on internet. It's just a select statement with some joins. Query result has almost 10M rows. There is nothin...
<python><oracle-database><cx-oracle>
2023-11-29 08:20:39
0
305
Atacan
77,569,483
17,136,258
Add empty row between every new market
<p>I want to change <code>.append</code> to <code>.concat</code>. I got the following error <code>ValueError: Must pass 2-d input. shape=(1, 2, 2)</code>. I looked already at <a href="https://stackoverflow.com/questions/75956209/error-dataframe-object-has-no-attribute-append">Error &quot;&#39;DataFrame&#39; object has ...
<python><pandas><dataframe>
2023-11-29 08:14:32
2
560
Test
77,569,468
17,267,064
Unable to retrieve video url in a Twitter's post using Selenium
<p>I am trying to scrape twitter using Selenium in Python. However, I am unable retrieve the video clip's download/streaming url.</p> <p>Refer below tweet for instance.</p> <p><a href="https://twitter.com/Tesla/status/1711184330792579093" rel="nofollow noreferrer">https://twitter.com/Tesla/status/1711184330792579093</a...
<python><html><selenium-webdriver><twitter>
2023-11-29 08:11:53
1
346
Mohit Aswani
77,569,466
1,568,919
Get main file name from inside a library function
<p>Suppose I have 2 files <code>A.py</code> and <code>B.py</code>. They both do</p> <pre><code>import C print(C.get_my_name()) </code></pre> <p>and in the lib file C.py</p> <pre><code>def get_my_name(): ???? </code></pre> <p>Is there a way to define the <code>get_my_name</code> function such that when <code>A.py</c...
<python>
2023-11-29 08:11:38
2
7,411
jf328
77,569,348
519,422
How to skip a value when replacing values in an external file with values from a dataframe?
<p>I have a file that's made up of entries like:</p> <pre><code>A first = 4 | 1_3_5_4 Name1 labelToSkip i = 1000000 j = -3 k = -15 end B first = 4 | 9_2_2_4 Name2 labelToSkip i = 150000 j = -3 k = -20 end ... </code></pre> <p...
<python><python-3.x><pandas><dataframe><file-io>
2023-11-29 07:45:01
1
897
Ant
77,569,069
2,986,583
Working with Twitter OAuth 2.0 Authorization Code Flow with PKCE (User Context)
<p>I'm trying to play with the twitter API using tweepy.</p> <p>This is my code:</p> <pre><code>oauth2_user_handler = tweepy.OAuth2UserHandler( client_id=client_id, redirect_uri=redirect_uri, scope=scopes, client_secret=client_secret, ) auth_url = oauth2_user_handler.get_authorization_url() print('Ple...
<python><twitter><tweepy>
2023-11-29 06:43:11
1
360
asafd
77,569,044
15,948,240
Compute a distance matrix in a pandas DataFrame
<p>I would like to compute a distance distance between all elements of two series:</p> <pre><code>import pandas as pd a = pd.Series([1,2,3], ['a', 'b', 'c'] ) b = pd.Series([4, 5, 6, 7], ['k', 'l', 'm', 'n']) def dist(x, y): return x - y #(or some arbitrary function) </code></pre> <p>I did achieve the expected res...
<python><pandas><dataframe><distance>
2023-11-29 06:39:36
1
1,075
endive1783
77,568,727
15,956,657
What could be causing "collect2.exe: error: ld returned 1 exit status" when manually compiling C++ with pybind11?
<p>I have a C++ script which compiles with pybind11 to create a file that python can use. I got it to work on my Ubuntu machine with python 3.8, but when I try to do it on my Windows machine it fails with <code>collect2.exe: error: ld returned 1 exit status</code>.</p> <p>From the research that I've done, the issue is...
<python><c++><g++><pybind11>
2023-11-29 05:13:39
0
363
alvrm
77,568,701
678,572
How to wrap a Python executable to call another Python executable and use all of the argparse options?
<p>I have the following Python executable called <code>fastq_preprocessor.py</code> in my path. I'd like to create a wrapper called <code>fastq_preprocessor</code> that calls <code>fastq_preprocessor.py</code> which is in the same directory as <code>fastq_preprocessor</code>. I want to be able to use all of the comma...
<python><command-line-interface><executable><argparse>
2023-11-29 05:05:48
0
30,977
O.rka
77,568,379
14,488,413
How to run t-test on multiple pandas columns
<p>I want to write a code (with few lines) that runs t-test on <code>Product</code> and <code>Purchase_cost</code>,<code>warranty_years</code> and <code>service_cost</code> at the same time.</p> <pre><code># dataset import pandas as pd from scipy.stats import ttest_ind data = {'Product': ['laptop', 'printer','printe...
<python><pandas><for-loop><scipy>
2023-11-29 03:16:04
1
322
nasa313
77,568,373
13,891,321
Control duplication of legend items in Python Plotly.express
<p>I am using plotly.express to produce a figure with 3 subplots. The legend repeats for each subplot, so I have 3 legend listings (one for each subplot) for each item. All operate together when I click them to turn off/turn on (which is fine, no need for independent operation). Is there a way to reduce this to 1 legen...
<python><python-3.x><plotly>
2023-11-29 03:14:10
1
303
WillH
77,568,371
1,397,922
How to display value of another fields of related field in Odoo form views
<p>is that possible to display value of another fields of related field? For example, by default, in Sale Order, the displayed value of <code>partner_id</code> is the value of <code>partner_id.name</code> .. how if I want to display value of <code>partner_id.mobile</code> instead of their default?</p> <p>I've tried exp...
<python><xml><odoo><odoo-8><odoo-15>
2023-11-29 03:13:46
2
550
Andromeda
77,568,251
4,451,521
Why a print modifies a pairwise?
<p>I have the following code</p> <pre><code>import pandas as pd import itertools as it data={ 'X': [1, 2, 3, 4, 5,6,7,8,9,10], 'Y': [5, 4, 3, 2, 1,2,3,4,5,5], 'Cat':[&quot;cat&quot;,&quot;dog&quot;,None,None,&quot;dog&quot;,&quot;dog&quot;,None,None,&quot;cat&quot;,&quot;dog&quot; ] } df = pd.DataFrame(da...
<python>
2023-11-29 02:31:19
0
10,576
KansaiRobot
77,568,216
20,122,390
How can I link lists of different sizes with numpy or pandas?
<p>I have a list of 7 python elements (it will always be 7 elements because they correspond to the 7 days of the week) For example:</p> <pre><code>values = [0.10870379696407702, 0.10279934722899532, 0.07997459688639645, 0.09342230637708339, 0.13035629501918441, 0.1704615636877088, 0.12471332159008049] </code></pre> <p>...
<python><pandas><numpy>
2023-11-29 02:19:11
1
988
Diego L
77,567,998
4,896,087
How to override a parent class property attribute in Pydantic
<p>I want to override a parent class property decorated attribute like this:</p> <pre><code>from pydantic import BaseModel class Parent(BaseModel): name: str = 'foo bar' @property def name_new(self): return f&quot;{'_'.join(self.name.split(' '))}&quot; class Child(Parent): name_new = 'foo_bar_foo' <...
<python><pydantic>
2023-11-29 01:00:30
1
3,613
George Liu
77,567,995
12,725,674
IndexError When Processing Downloaded PDF Files
<p>I've encountered an issue while automatically downloading .pdf files and subsequently moving them to a specific folder using Python. I've implemented a function to check if the download is completed before proceeding with the file processing. However, sometimes I'm facing an <code>IndexError: list index out of range...
<python><list>
2023-11-29 01:00:09
1
367
xxgaryxx
77,567,918
1,564,195
Need to convert a datetime.tzinfo *region* to a ZoneInfo region
<p>I'm writing a calendar application, and I have been trying to track down why canceled / rescheduled calendar entries keep appearing on my calendar. I traced the problem to a time zone issue with rruleset.</p> <p>Let's say that I have a recurring weekly event and I'm in the US Eastern time zone. They're all scheduled...
<python><datetime><python-dateutil><zoneinfo>
2023-11-29 00:31:13
0
865
David Stein
77,567,641
1,230,724
Clear module import cache after executing Python code from zip file
<p>I'm looking for a way to reliably clear the module import cache after loading and executing code from zip files (the zip files with Python code serve as a &quot;plugin&quot;).</p> <p>The current way I'm using causes stale code to be executed, meaning code from previously imported zip files is executed. I'm looking f...
<python><module><zip><python-import>
2023-11-28 23:01:46
0
8,252
orange
77,567,521
10,623,444
Optimize computation of similarity scores by executing native polars command instead of UDF functions
<p><strong>Disclaimer (1):</strong> This question is supportive to <a href="https://stackoverflow.com/q/77541498/10623444">this SO</a>. After a request from two users to elaborate on my case.</p> <p><strong>Disclaimer (2) - added 29/11:</strong> I have seen two solutions so far (proposed in this SO and the supportive o...
<python><user-defined-functions><python-polars>
2023-11-28 22:29:45
3
1,589
NikSp
77,567,407
18,587,779
How to add an input to a group in the obs web socket
<p>Obs WebSocket docs define that groups in OBS are actually scenes, but renamed and modified. In obs-web sockets, we treat them as scenes where we can.</p> <pre><code>import obsws_python as obs cl = obs.ReqClient(host='localhost', port=4444, password='password', timeout=3) cl.create_input(&quot;Group&quot;,&quot;m...
<python><websocket><obs>
2023-11-28 21:59:03
0
318
Mark Wasfy
77,567,365
9,788,900
Plot a graph from a dictionary in python
<p>I have a dictionary with following key-value pairs.</p> <pre><code>21 {'05': {'210527_NS5001_01_AHT': 244.64}} 22 {'11': {'221101_NS5002_02_AHV': 173.79, '221104_NS5002_03_AHC': 192.17}} 23 {'03': {'230331_NS5002_04_AH3': 222.73}, '04': {'230405_NS5002_05_AHG': 223.97}} </code></pre> <p>Where, 21, 22, 23 are years, ...
<python><matplotlib>
2023-11-28 21:52:09
1
343
Callie
77,567,341
499,362
Problem validating a certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate
<p>A site my application submits requests to recently updated their SSL certificate and since that change, our requests have been failing with the well know certificate exception:</p> <p><code>requests.exceptions.SSLError: HTTPSConnectionPool(host='XXX.YYY', port=443): Max retries exceeded with url: / (Caused by SSLErr...
<python><ssl><openssl><ssl-certificate>
2023-11-28 21:47:39
0
9,900
Michael C. O'Connor
77,567,326
4,726,737
Why does my altair mark_text() layer come out blurry/duplicated?
<p>I am trying to make heatmaps with text on top. I found a great <a href="https://altair-viz.github.io/user_guide/marks/text.html" rel="nofollow noreferrer">tutorial</a> from the Altair website was trying to adapt my dataset to tutorial which works fine for me. But when I run it with my own data:</p> <pre class="lang-...
<python><streamlit><altair>
2023-11-28 21:44:42
1
338
Derek Fulton
77,567,276
16,707,518
Performing a pandas operation on only a subset of columns when a specific criterion in one column is met
<p>I've got a data table with a fairly large amount of columns - around 60. For a subset of around 10 of the columns, I'd like to perform a simple addition of a single value when the value in the date column is a specific date.</p> <p>I've simplified it here - but I'd like to be able to specify the columns in the dataf...
<python><pandas>
2023-11-28 21:35:53
1
341
Richard Dixon
77,567,068
1,456,253
Is there a way of turning off progress indication for plink?
<p>I have a python plink wrapper that essentially calls down to the plink cli via calls that look like:</p> <pre><code>def plink_wrapper(cmd): subprocess.run( cmd, capture_output=True, shell=shell, check=check, encoding=&quot;utf-8&quot; ) return result.stdout </code></pre> <p>And my specific ca...
<python><plink-genomics>
2023-11-28 20:49:36
0
2,397
code11
77,567,056
823,633
Implementing a parallel evaluation queue for Jupyter notebook
<p>I want to execute long running functions in parallel within a Jupyter notebook, without blocking the notebook itself. However, I also want to add completely unrelated jobs to the queue at any time, even while the queue is still processing previous jobs. Basically, this would be analogous to an extremely simple versi...
<python><jupyter-notebook><pickle><python-multiprocessing>
2023-11-28 20:46:58
1
1,410
goweon
77,566,914
519,422
How to write specific values from a Pandas (Python) dataframe to a specific place in a file (i.e., after an identifier)?
<p>I have a file that's made up of entries like:</p> <pre><code>A first = 4 | 1_3_5_4 Name1 labelToSkip i = 1000000 j = -3 k = -15 end B first = 4 | 9_2_2_4 Name2 labelToSkip i = 150000 j = -3 k = -20 end ... </code></pre> <p...
<python><python-3.x><pandas><dataframe><file-io>
2023-11-28 20:14:20
1
897
Ant
77,566,724
4,126,269
Handle circular import of subclasses types in abstract class
<p>I am facing a circular import error when I define type aliases for the subclasses of an abstract class.</p> <p>This is an example of what I'm trying to achieve:</p> <pre class="lang-py prettyprint-override"><code>#abstract_file_builder.py from abc import ABC, abstractmethod from typing import Generic, MutableSequen...
<python><python-typing>
2023-11-28 19:38:36
1
936
CarlosMorente
77,566,660
8,223,979
How to produce barplot in bins?
<p>I produce a barplot like this:</p> <pre><code>sns.barplot(data=number_counts, x=&quot;number&quot;, y=&quot;counts&quot;) </code></pre> <p>number_counts is a dataframe that looks like this:</p> <pre><code>number counts 1 7 2 8 3 10 4 12 5 14 6 9 7 6 8 3 9 2 10 1 ...etc </code></pre> <p>However, I'd like that the x-...
<python><seaborn><bar-chart><histogram>
2023-11-28 19:28:44
1
1,097
Caterina
77,566,656
2,192,824
How to use Bazel to build ELF file for linux?
<p>I'm new to Bazel, but I want to use Bazel to build my python codes to an ELF file (currently I'm building it to .par file). The purpose is to build an ELF file so that we can launch the program by double clicking the file, just like in windows double clicking an .exe file. Is there any way to do that?</p> <p>Thanks!...
<python><linux><bazel><elf>
2023-11-28 19:28:38
0
417
Ames ISU
77,566,461
6,562,240
Pandas For Loop with Two Variables
<p>I am trying to create a new column in a dataframe based on the values in two other columns:</p> <pre><code>names_df['Surname'] = [ 'MISSING' if i != '' and j == '' else j for i, j in names_df['Name Entry 1'], names_df['Name Entry 2'] ] </code></pre> <p>However I am getting an invalid syntax error but I don'...
<python><pandas>
2023-11-28 18:54:14
3
705
Curious Student
77,566,421
4,542,117
Python IDW with latitude / longitude points
<p>Utilizing one of the answers from: <a href="https://stackoverflow.com/questions/3104781/inverse-distance-weighted-idw-interpolation-with-python?noredirect=1&amp;lq=1">Inverse Distance Weighted (IDW) Interpolation with Python</a></p> <p>I am looking to convert this IDW method into a latitude / longitude problem. For ...
<python><numpy>
2023-11-28 18:45:24
0
374
Miss_Orchid
77,566,289
2,558,241
In Django ORM, wildcard \b does not work (Postgres database)
<p>All other wildcards work correctly but for example when I want to use <code>&quot;\bsome\b&quot;</code> pattern, it can't find any result however, there are many rows in the database that have a word &quot;some&quot; inside them.</p> <p>Other wild cards like <code>., +, *, \w</code> and ... work properly.</p> <p>Any...
<python><django><postgresql><django-orm>
2023-11-28 18:24:52
1
1,436
Mehrdad Salimi
77,566,198
6,141,238
In Python, why is y**2 sometimes incorrect when y is a numpy array?
<p>First I compute a square in the IDLE shell of Python 3.12.0:</p> <pre><code>&gt;&gt;&gt; x = 123456 &gt;&gt;&gt; x**2 15241383936 </code></pre> <p>This agrees with my TI-89. Now I compute what I would think would be the same square using numpy arrays:</p> <pre><code>&gt;&gt;&gt; import numpy as np &gt;&gt;&gt; y = ...
<python><arrays><numpy><exponent>
2023-11-28 18:08:56
1
427
SapereAude
77,566,113
9,008,162
I'm getting WinError 10060; might it be caused by a python thread visiting the server too frequently?
<p>I use a Python thread to download data from APIs. I'm not sure how it gets to the server, but I set it to make no more than 1000 calls every minute. It works good most of the time, but occasionally I get <strong>WinError 10060</strong> (without modifying my code). Whenever this happens, I simply re-download and it t...
<python><multithreading><sockets>
2023-11-28 17:54:27
0
775
saga
77,566,062
7,077,532
Python Dataframe: Transpose 4/5 Columns in a Dataframe And Hold Date Column Without Transposing
<p>I have a sample input dataframe:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Name</th> <th style="text-align: right;">Date</th> <th style="text-align: right;">Score</th> <th style="text-align: right;">Target</th> <th style="text-align: right;">Difference</th> </tr> </thead> <tbody> <...
<python><group-by><multiple-columns><transpose>
2023-11-28 17:45:06
1
5,244
PineNuts0
77,566,046
7,267,480
pyearth package installation issue (need to use MARS on Python 3.10)
<p>I have a question regarding an old package to do a multivariate adaptive regression splines for my research. for me it's crucial to have an ability to define the max. number of knots to fit the data because the function is pretty complex.</p> <p>Maybe some of you can suggest a similar Python package to do multivaria...
<python><sql-server-mars>
2023-11-28 17:42:54
1
496
twistfire
77,565,921
14,912,118
How to Generate SAF-T XML (Standard Audit File)
<p>I need to generate the SAF-T XML and using pandas dataframe, but I am very new for generating SAF-T XML using python.</p> <p>Below is the output which I am expecting</p> <pre><code>&lt;root xmlns:nl=&quot;urn:StandardAuditFile-Taxation-Financial:NO&quot; xsi:schemaLocation=&quot;urn:StandardAuditFile-Taxation-Financ...
<python><pandas><xml><dataframe>
2023-11-28 17:24:00
0
427
Sharma
77,565,865
520,556
Python nltk RegexpTokenizer with all words and one specific phrase/chunk
<p>Is it possible to redefine a standard <code>nltk.tokenize.RegexpTokenizer</code> to select all words as tokens and allow only one special phrase/chunk? For example, a standard setup would be:</p> <pre><code>from nltk.tokenize import RegexpTokenizer tokenizer = RegexpTokenizer(r'\w+') </code></pre> <p>Is it possible...
<python><regex><nltk>
2023-11-28 17:15:22
1
1,598
striatum
77,565,852
5,125,925
Python jwt decode returning Could not deserialize key data error
<p>I have a jwt token generated from aws cognito which gets authenticated in aws api gateway and successfully calls my aws lambda behind the gateway. Everything works and this is a valid jwt received in my aws lambda python, but I'm unable to parse this valid JWT in my python code. Below is the snippet of python method...
<python><jwt>
2023-11-28 17:13:15
0
720
ZCode
77,565,668
3,650,477
How to setup the logging of my application with built with Flask and run with gunicorn
<p>I have created a simple application that returns a json object on demand based on a GET request. I have used the <a href="https://flask.palletsprojects.com/en/2.3.x/" rel="nofollow noreferrer">Flask</a> framework, and then I run in production with <a href="https://gunicorn.org/" rel="nofollow noreferrer">gunicorn</a...
<python><flask><gunicorn><python-logging>
2023-11-28 16:42:49
0
2,729
Pythonist
77,565,397
5,459,343
Sphinx documentation tree without full path to module
<p>I'm trying to create an automated documentation sphinx with autodoc and autosummary extension. I'm also using the <code>pydata_sphinx_theme</code>.</p> <p>My goal is to automatically create a tree of objects (let's stick with python functions for now) that will be shown in the primary sidebar of the documentation.</...
<python><python-sphinx><autodoc><autosummary>
2023-11-28 16:06:40
1
573
J.K.
77,565,339
1,714,692
How to specify the value for a multiindex in a pandas dataframe?
<p>Suppose I want to build a pandas dataframe using multiple indexing.</p> <p>I start defining the expected columns of the dataframe:</p> <pre><code>df = pd.DataFrame(columns=[&quot;val&quot;,]) </code></pre> <p>Then I build some entries and their indexing:</p> <pre><code>for j in range(1,5): tuples = [(str(j), i) fo...
<python><pandas><dataframe><multi-index>
2023-11-28 15:59:42
1
9,606
roschach
77,565,329
3,070,181
Changing tkinter default font in a conda environment
<p>I am running a small test program</p> <p><strong>font.py</strong></p> <pre><code>import tkinter as tk import tkinter.font as tkFont root = tk.Tk() font_size = 24 fonts = [ 'Arial', 'Droid sans Mono', 'Fira Code', 'TSCu_comic', 'Inconsolata', ] for font in fonts: my_font = tkFont.Font(f...
<python><tkinter><miniconda>
2023-11-28 15:58:38
1
3,841
Psionman
77,565,283
19,130,803
pandas: get scalar value by column
<p>I have a dataframe and I want get a single scalar value from column <code>store_id</code> which contains same values for all rows.</p> <pre><code>df = pd.DataFrame( { &quot;id&quot;: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], &quot;contents&quot;: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], &quot;store_id&quot...
<python><pandas>
2023-11-28 15:53:09
2
962
winter
77,565,230
9,003,184
Web Scraping returns T&C link
<p><a href="https://cycling.data.tfl.gov.uk/" rel="nofollow noreferrer">This URL</a> has some CSV data files I'd like to use for analysis under the folder 'usage-stats'. However, I'm unable to scrape data from this page. When I try using the below code, I can only see the terms and conditions page instead of the links ...
<python><web-scraping><beautifulsoup><python-requests>
2023-11-28 15:44:14
1
488
a_jelly_fish
77,565,163
2,215,094
OpenEmbedded (Yocto) recipe for Python validators library
<p>I want to include the Python library <em><a href="https://pypi.org/project/validators/" rel="nofollow noreferrer">validators</a></em> in my OpenEmbedded build. I am working with the Kirkstone release and the latest version of <em>validators</em> is 0.22.0. There is no recpipe, so I added it myself:</p> <pre><code>in...
<python><setuptools><openembedded>
2023-11-28 15:34:57
2
385
Jan Schatz
77,565,028
5,132,101
how do i mock requests.get().url with side_effect?
<p>I have the following code:</p> <pre><code>def consuming_api_swapi_index_page(initial_page: int = 1): &quot;&quot;&quot;Swapi index page.&quot;&quot;&quot; check = HTTPStatus.OK results = [] while check == HTTPStatus.OK: response = requests.get( f'https://swapi.dev/api/people/?page...
<python><mocking><pytest>
2023-11-28 15:18:35
1
2,047
britodfbr
77,564,964
10,847,096
Checking if a tensors values are contained in another tensor
<p>I have a torch tensor like so:</p> <pre class="lang-py prettyprint-override"><code>a=[1, 234, 54, 6543, 55, 776] </code></pre> <p>and other tensors like so:</p> <pre class="lang-py prettyprint-override"><code>b=[234, 54] c=[55, 776] </code></pre> <p>I want to create a new mask tensor where the values of <code>a</cod...
<python><pytorch>
2023-11-28 15:09:15
1
993
Ofek Glick
77,564,963
7,295,599
Communication via PyUSB to Agilent E4980A
<p>Communication to USB devices drives me crazy. It's now at least the third USB device creating problems:</p> <ul> <li>the first device (<a href="https://stackoverflow.com/q/59105167/7295599">OWON oscilloscope</a>) had erroneous software and wrong documentation and I <a href="https://stackoverflow.com/q/75410653/72955...
<python><usb><serial-communication><libusb><pyusb>
2023-11-28 15:09:10
1
27,030
theozh