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,188,680
1,482,271
How do I form a suds request in Python using a WSDL that uses the "any" type?
<p>Note, this is not a duplicate of <a href="https://stackoverflow.com/questions/77189479/how-to-pass-any-type-parameter-in-soap-request-using-zeep-in-python">How to pass &quot;Any&quot; type parameter in SOAP request using zeep in Python</a>.</p> <p>This question relates to using suds, the other to zeep, and the probl...
<python><xml><wsdl><suds>
2023-09-27 15:01:37
0
335
mroshaw
77,188,408
1,106,951
Pandas Excel to DF throwing the unexpected keyword argument 'index' Error
<p>Importing Excel into a Pandas DataFrame without the Index giving me this error</p> <blockquote> <p>TypeError: read_excel() got an unexpected keyword argument 'index'</p> </blockquote> <p>As far as I can see, I am not doing any thing wrong here</p> <pre><code>import pandas as pd df = pd.read_excel('Prod_User.xlsx', s...
<python><pandas>
2023-09-27 14:26:20
1
6,336
Behseini
77,188,326
3,501,622
Set lineplot marker for only one line
<p>I am trying to plot a seaborn lineplot with 2 lines: one with markers and one without. In the documentation (<a href="https://seaborn.pydata.org/generated/seaborn.lineplot.html" rel="nofollow noreferrer">https://seaborn.pydata.org/generated/seaborn.lineplot.html</a>), it says that, in order to achieve this, I have t...
<python><seaborn><linechart>
2023-09-27 14:17:20
1
671
Daniel
77,188,170
19,155,645
TypeError: 'NoneType' object is not iterable when using ucimlrepo
<p>I want to use the <a href="https://archive.ics.uci.edu/dataset/2/adult" rel="nofollow noreferrer">Adult dataset from the UCI ML Repo</a>.</p> <p>For this I'm following the &quot;import in python&quot; option in the page, which gives this code:</p> <pre><code>pip install ucimlrepo from ucimlrepo import fetch_ucirepo...
<python><dataset><typeerror><data-analysis>
2023-09-27 13:56:19
4
512
ArieAI
77,188,137
2,123,706
Can multiprocessing decrease latency of a sqlalchemy writing to server
<p>I have a sqlalchemy session, and want to input a 300k row 24 col (~300MB) of data</p> <pre><code>database_con = f'mssql://@{server}/{database}?driver={driver}' engine = create_engine(database_con) con = engine.connect() df.to_sql( name=&quot;data&quot;, con=con, if_exists=&quot;...
<python><sqlalchemy><parallel-processing>
2023-09-27 13:51:41
0
3,810
frank
77,187,866
226,342
Refreshing layout in multi page Dash app due to watchdog file event
<p>I have a multi page Dash app.</p> <p>app.py:</p> <pre><code>app = dash.Dash(__name__, use_pages=True, suppress_callback_exceptions=True) ... </code></pre> <p>I then have a page:</p> <p>pages/resources.py:</p> <pre><code>dash.register_page(__name__, order=4, title='πŸ—ƒοΈ Resources') </code></pre> <p>Layout is defined a...
<python><plotly-dash><python-watchdog>
2023-09-27 13:14:19
1
2,005
Henrik
77,187,839
4,244,347
How to serialize Jinja2 template in PySpark?
<p>I want to use a Jinja2 template to create a column in a df using PySpark. For example, if I have a column <code>name</code>, use the following template to create another column called <code>new_name</code>.</p> <pre><code>from jinja2 import Template TEMPLATE = &quot;&quot;&quot; Hello {{ customize(name) }}! &quot;&...
<python><apache-spark><pyspark><serialization><jinja2>
2023-09-27 13:11:33
2
936
smaug
77,187,827
11,925,053
Xcode project (originally Python Kivy) not building to iPhone
<p>Short summary: The app created by python kivy which was converted to Xcode project using kivy-ios/toolchain runs on the simulator and in some cases can be built to my iPhone. But I don’t understand what I am doing different on the occasions where it does not run on my iPhone</p> <pre><code>-Mac M1 arm64 -Ventura 13....
<python><ios><xcode><kivy>
2023-09-27 13:09:35
3
309
costa rica
77,187,721
17,471,060
Best way to filter Polars dataframe from finding elements within multiple columns
<p>I would like to know an elegant way to filter dataframe based on condition that elements within a list are found in multiple columns of the dataframe. For example, I want to filter <code>df</code> based on all elements with <code>to_keep</code> are found in columns <code>c1</code> &amp; <code>c2</code>.</p> <pre cla...
<python><dataframe><python-polars>
2023-09-27 12:55:50
0
344
beta green
77,187,616
2,956,276
Python: Parse numbers with non-breaking space as group separator
<p>I want to parse number written according to specific locale. I need to support any locale.</p> <p>It seems that <code>locale.atof</code> is the proper solution:</p> <pre class="lang-py prettyprint-override"><code>from locale import setlocale, LC_NUMERIC, atof setlocale(LC_NUMERIC, ('en_US', 'utf-8')) print(atof(&qu...
<python>
2023-09-27 12:41:15
0
1,313
eNca
77,187,551
755,229
map' object is not a mapping --- why does python return such an exception
<p>I think this rather may be an english Grammer issue, but still I like to understand why would python say the result of map operation is not a mapping?</p> <pre><code>In [60]: a=[1,2,3,4] In [61]: b=['a','b','c','d'] In [62]: {**map(a,b)} ...: -------------------------------------------------------------------...
<python><dictionary><mapping>
2023-09-27 12:33:40
1
4,424
Max
77,187,538
14,649,310
How to map a field to different key for serilization and de-serilization with Python dataclass
<p>I want to serialize and de-serialize some data with a dataclass, but one field in the received data has a different name than the class attribute I want to map it to for example in the data I have : <code>{&quot;accountId&quot;:123,&quot;shortKey&quot;: 54}</code> and I want to map it to a dataclass like:</p> <pre><...
<python><python-dataclasses><marshmallow>
2023-09-27 12:31:49
1
4,999
KZiovas
77,187,497
2,112,406
No member named 'replace' in namespace 'std::ranges' message in github actions, even with -std=c++20
<p>I have a python package on github, that runs C++ code with pybind. I figured I'd add github actions to do tests. The build fails on macos-latest (the irony being that it compiles just fine on my local macos machine) with the following message:</p> <pre><code>FAILED: CMakeFiles/sequence_analysis_cpp.dir/src/sequence....
<python><c++><cmake><github-actions>
2023-09-27 12:26:29
1
3,203
sodiumnitrate
77,187,461
662,509
Getting ODBC Driver 17 error while connecting to azure SQL
<p>I'm getting the following error while connection my code to azure SQL from local machine (windows) and also when deployed to azure function (python/linux)</p> <blockquote> <p>sqlalchemy.exc.OperationalError: (pyodbc.OperationalError) ('08001', '[08001] [Microsoft][ODBC Driver 17 for SQL Server]TCP Provider: A non-re...
<python><sqlalchemy><azure-sql-database><pyodbc>
2023-09-27 12:21:34
1
673
AsitK
77,187,280
8,790,507
Is there any way to filter a multi-indexed pandas DataFrame using a dict?
<p>Please consider the following DataFrame:</p> <pre><code>mi = pd.MultiIndex( levels = [[1, 2, 3], ['red', 'green', 'blue'], ['a', 'b', 'c']], codes = [[1,0,1,0], [0,1,1,2], [1,0,0,1]], names = [&quot;Key1&quot;, &quot;Key2&quot;, &quot;Key3&quot;]) df = pd.DataFrame({ &quot;values&quot;: [1, 2, 3, 4...
<python><pandas>
2023-09-27 11:54:34
3
1,594
butterflyknife
77,187,028
12,590,879
Should I create a separate requests.Session object for each domain I access?
<p>Assuming that in my backend I'm hitting multiple different domains/IPs, should I create a different <code>requests.Session</code> object for each domain, to avoid ever having something like this happen?</p> <pre><code>domain A is hit using the session, new TCP connection is created domain A is hit using the session,...
<python><http><session><python-requests>
2023-09-27 11:20:36
0
325
Pol
77,187,025
15,341,457
Scrapy - xpath returns empty list
<p>I'm scraping restaurant reviews from yelp, specifically from this <a href="https://www.yelp.it/biz/roscioli-roma-4?rr=4" rel="nofollow noreferrer">url</a></p> <p>I'm trying to get the list of review containers and, after testing with the chrome console, that would be given by the following xpath expression:</p> <p><...
<python><http><web-scraping><xpath><scrapy>
2023-09-27 11:20:11
1
332
Rodolfo
77,187,001
12,881,307
Clean architechture Entities depending on entities
<p>I am writing a python application following Robert Cecil Martin's Clean Architechture book. I have the following entities:</p> <pre><code>@dataclass class Factory(): name: str latitude: float longitude: float @dataclass class Event(): message: str timestamp: datetime source: Factory </code...
<python><clean-architecture>
2023-09-27 11:18:00
1
316
Pollastre
77,186,985
6,327,202
Datadog python tracing floods with logs and errors
<p>I tried to remove datadog python tracing on my Ubuntu server with <code>pip uninstall ddtrace</code>, but it seems smth went wrong</p> <p>When I try commands like <code>pip freeze</code> or even <code>supervisorctl status</code></p> <p>I receive that logs constantly:</p> <pre><code>INFO:datadog.autoinstrumentation(p...
<python><ubuntu><datadog>
2023-09-27 11:15:40
1
1,165
Snobby
77,186,601
18,140,022
Can I parameterise tables using Pandas read_sql function?
<p>I got a database with multiple projects which follows a similar structure to the following:</p> <ul> <li>Schemas for our client Bob: bob_legal, bob_docs, bob_misc</li> <li>Schemas for our client Jess: jess_legal, jess_docs, jess_misc</li> </ul> <p>I am currently using f-strings to build the query:</p> <pre class="la...
<python><pandas><sqlalchemy>
2023-09-27 10:23:15
1
405
user18140022
77,186,338
12,285,101
Trying to read list of tuples with date-pairs in bash is failing using argparse
<p>I have python script that one of its' parameters is list of tuples:</p> <pre><code>def my_func(my_date_list: list=None, #List of dates to be used. Example for list : [('2017-07-02', '2017-08-15'),('2019-09-02', '2019-11-21')]): ... </code></pre> <p>This function works when I run it from my Jupyter notebook. However...
<python><bash><list><tuples><argparse>
2023-09-27 09:45:19
1
1,592
Reut
77,186,131
1,618,465
Detect if connection is HTTP or HTTPS and handle it in python
<p>I have a socket listening on a port and I don't know what kind of connections I'm getting on it. It can be HTTP, HTTPS or something different. I would like that my server will handle at least HTTP and HTTPS by identifying the fist bytes of traffic that it receives. I wrote some code that reads the first received byt...
<python><http><sockets><ssl><https>
2023-09-27 09:17:07
0
1,961
user1618465
77,186,059
2,178,942
Generating an array of random numbers with conditions
<p>I have a list of length 64, such as <code>first_list = [64, 27, 99, 133, 0, 41, ... ]</code>. Numbers in this are some random selection from <code>0</code> to <code>150</code> (minimum value is <code>0</code> and maximum value is <code>149</code>).</p> <p>I want to generate several other list of random number with t...
<python><arrays><python-3.x><list><random>
2023-09-27 09:07:48
3
1,581
Kadaj13
77,186,034
4,445,832
How to replace string keeping associated info in python
<p>Given an <strong>ordered</strong> list of words with associated info (or a list of tuples). I want to replace some of the strings with others but keep track of the associated info.</p> <p>Let's say that we have a simple case where our input data is two list:</p> <pre><code>words = [&quot;hello&quot;, &quot;I&quot;, ...
<python><regex>
2023-09-27 09:04:51
4
714
ivangtorre
77,185,760
7,692,855
Python mock and call assertion
<p>I am trying to write a python unit test to assert that a scoped_session .commit() is called.</p> <p>main.py</p> <pre><code>from database import DBSession def deactivate_user(user_id): db_session = DBSession() user = User(db_session).get(user_id) user.is_active = False db_session.commit() def get_ac...
<python><unit-testing><mocking><python-unittest><python-unittest.mock>
2023-09-27 08:28:38
2
1,472
user7692855
77,185,692
7,437,143
How to resolve E0611: No name 'Test_HC' in module 'test' (no-name-in-module)?
<h2>Context</h2> <p>I have a pip package called <code>something</code> with tree structure:</p> <pre><code>src/something/__main__.py src/something/__init__.py src/something/hardcoded.py src/something/bike/ride.py test/__init__.py test/bike/test_ride.py test/Test_HC.py </code></pre> <p>With a class named <code>Hardcode...
<python><pylint>
2023-09-27 08:18:09
1
2,887
a.t.
77,185,672
10,713,813
Insert image in pdf file using python
<p>I want to insert an image in a pdf using a python script. I have given a jpg as well as a png file. I want to be able to specify a page number, x and y coordinates and heigth and width of the image. Then I want the image inserted at the given point.</p> <p>I have found this question: <a href="https://stackoverflow.c...
<python><image><pdf>
2023-09-27 08:13:25
2
320
wittn
77,185,621
11,167,163
Setting an item of incompatible dtype is deprecated and will raise in a future error of pandas
<p>I have the below code which for instance work as excepted but won't work in the future:</p> <pre><code>total.name = 'New_Row' total_df = total.to_frame().T total_df.at['New_Row', 'CURRENCY'] = '' total_df.at['New_Row', 'MANDATE'] = Portfolio total_df.at['New_Row', 'COMPOSITE'] = 'GRAND TOTAL' total_df.set_index('COM...
<python><pandas>
2023-09-27 08:03:42
3
4,464
TourEiffel
77,185,610
11,932,905
Pandas: Assign same cluster id to records based on common groups in different columns
<p>I have a dataframe like this:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th style="text-align: left;">index</th> <th style="text-align: left;">A</th> <th style="text-align: left;">B</th> <th style="text-align: left;">C</th> </tr> </thead> <tbody> <tr> <td style="text-align: left;">1</t...
<python><pandas><graph><group-by><connected-components>
2023-09-27 08:01:25
1
608
Alex_Y
77,185,476
1,294,704
Why BeautifulSoup find_all not returning elements with <br> in them?
<p>Environment:</p> <ul> <li>Python 3.9.4</li> <li>beautifulsoup4==4.12.2</li> </ul> <p>Code:</p> <pre><code>from bs4 import BeautifulSoup test_content = '''&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;p&gt;123&lt;/p&gt;&lt;p&gt;123&lt;br&gt;123&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;''' bs = BeautifulSoup(test_con...
<python><python-3.x><beautifulsoup><web-crawler>
2023-09-27 07:39:09
2
801
wings
77,185,386
13,975,077
Python Rich Live not working in Intellij IDE
<p>I have the following example of Rich Live from the official examples of Rich. (<a href="https://github.com/Textualize/rich/blob/master/examples/layout.py" rel="nofollow noreferrer">layout.py</a>)</p> <p><strong>Code</strong></p> <pre><code>from datetime import datetime from time import sleep from rich.align import...
<python><intellij-idea><pycharm><rich>
2023-09-27 07:24:22
1
800
Yogesh
77,185,287
1,236,858
Pymongo: Handling SQL Injection
<p>I'm using Pymongo to do database operations and it seems that the command I'm using is being flagged as having SQL Injection vulnerability.</p> <p>Here is my original query:</p> <pre><code>e = client[db_name]['request'].find_one_and_update(filter={'_id': ObjectId(request_id)}, ...
<python><mongodb><pymongo>
2023-09-27 07:06:00
0
7,307
rcs
77,185,218
18,904,265
Is it possible to redirect a get request to another API?
<p>I want to use FastAPI as a translator/interface to a InfluxDB database. This enables me to simplify the endpoints other apps/clients need to call to.</p> <p>The main endpoints would be /preview, where you could get a small preview of the datasets you want to get, and /data, where you would get a full copy of the dat...
<python><fastapi><influxdb>
2023-09-27 06:54:08
0
465
Jan
77,184,639
2,975,438
Button to download a file with Plotly Dash
<p>I've built a Plotly Dash app that allows users to navigate through directories and download files. The files are .log files and are converted into .csv format before download.</p> <p>The issue I'm facing is with the download functionality. When I first click the download button, it downloads the previously requested...
<python><flask><download><plotly-dash>
2023-09-27 04:11:58
1
1,298
illuminato
77,184,545
2,793,602
Apply function to values in a dataframe column
<p>I have a function that calls a mapping API and returns longs and lats given unstructured address data. This works, and I can pass</p> <pre><code>address = &quot;12 &amp; 14 CHIN BEE AVENUE,, SINGAPORE 619937&quot; lat, lon = get_coordinates(api_key, address) print(lat, lon) </code></pre> <p>and get a result like <co...
<python><pandas><dataframe>
2023-09-27 03:34:03
1
457
opperman.eric
77,184,513
2,497,309
Call CDK Deploy in another AWS Account from Fargate Task
<p>I have two accounts A and B. I want to deploy a stack using CDK in Account A by running cdk synth and cdk deploy in an ECS Task in Account B.</p> <p>I created a role in account A with administrator access and granted permissions to Account B to be able to assume the role. Then the ECS task spins up in Account B and ...
<python><amazon-web-services><amazon-ecs><aws-cdk><aws-fargate>
2023-09-27 03:23:06
1
947
asm
77,184,491
11,996,266
Psycopg2: how to deal with special characters in password?
<p>I am trying to connect to a db instance, but my password has the following special characters: backslash, plus, dot, asterisk/star and at symbol. For example, 12@34\56.78*90 (regex nightmare lol)</p> <p>How do I safe pass it to the connection string? My code looks like that:</p> <pre><code>connection_string = f'user...
<python><postgresql><psycopg2>
2023-09-27 03:15:06
2
1,495
Roni Antonio
77,184,478
8,708,364
Not sure how to use Application Default Credentials
<p>I am currently working on a Flask project and I want to host it on Google Cloud App Engine. Since I want to store sessions, I came across the service named FireStore. To use that service, I need to use Google Application Credentials, which I am not sure how to use.</p> <p>My code:</p> <pre class="lang-py prettyprint...
<python><flask><google-cloud-platform><google-app-engine><google-cloud-firestore>
2023-09-27 03:10:44
2
71,788
U13-Forward
77,184,472
4,286,383
Breaking a python loop using threads
<p>I would like to have a thread that constantly monitors the status of a value in a text file, another thread that executes some code inside a loop, and I would like that when the value in the text file changes, immediately break the loop and execute an else statement regardless of which part in the loop the program i...
<python><python-3.x><multithreading><loops>
2023-09-27 03:08:41
2
471
Nau
77,184,120
6,702,598
`sam build` suddenly fails with `pip executable not found in your python environment` on Mac
<p>I'm building an aws lambda function, written in Python3.10, with <code>sam build</code>.</p> <p>After some changes (code changes, files added, modules added) - nothing fancy, my build suddenly stops working. I get the error message <code>Error: PythonPipBuilder:ResolveDependencies - pip executable not found in your...
<python><aws-lambda>
2023-09-27 00:46:20
1
3,673
DarkTrick
77,184,058
2,515,265
Save a Pandas DataFrame to a CSV file without adding extra double quotes
<p>I want to save a Pandas dataframe to a CSV file in such a way that no additional double quotes or any other characters are added to these formulas. Here is my attempt:</p> <pre><code>import pandas as pd data = { &quot;Column1&quot;: [1, 2, 3], &quot;Column2&quot;: [&quot;A&quot;, &quot;B&quot;, &quot;C&quot...
<python><pandas><dataframe><excel-formula><quoting>
2023-09-27 00:24:25
1
2,657
Javide
77,184,016
6,032,140
yaml/ruamel load and dumped out file is missing variables of same value
<ol> <li>I have a string and using ruamel to load the string and dump the file output in yaml format.</li> <li>The string contains arrays of same value.</li> <li>If its of same value it misses those value but if there is different values then it prints those values.</li> </ol> <p>Code:</p> <pre><code>import sys import ...
<python><yaml><ruamel.yaml>
2023-09-27 00:04:13
2
1,163
Vimo
77,183,906
3,553,923
Python: Robustly remove all line breaks and indentations from HTML (replacing some inside tags with spaces as the browser would do for rendering)
<p>As BeautifulSoup doesn't seem to work well with indented content and breaks inside tags (also see <a href="https://stackoverflow.com/questions/77183750/how-do-i-make-beautifulsoup-ignore-any-indents-in-original-html-when-getting-tex">How do I make BeautifulSoup ignore any indents in original HTML when getting text</...
<python><html><beautifulsoup><format>
2023-09-26 23:20:26
1
323
clel
77,183,750
3,553,923
How do I make BeautifulSoup ignore any indents in original HTML when getting text
<p>I think, I basically want the reverse of what the <code>prettify()</code> function does.</p> <p>When one has HTML code (excerpt) like:</p> <pre><code> &lt;p&gt; Test text with something in it Test text with something in it &lt;i&gt;and italic text&lt;/i&gt; inside that text. Test...
<python><html><parsing><beautifulsoup>
2023-09-26 22:27:17
3
323
clel
77,183,668
10,004,072
Can I write behavioural unit tests using "Given-When-Then" in Pytest (Python)?
<p>We currently have many unit tests in Python and we're using Pytest. Ideally I'd like to stay with Pytest as that's what the company has elected to be their testing framework of choice. I wonder if people recommend fixtures in Pytest or some other good way to do this.</p> <p>When doing a quick Google I see people usi...
<python><unit-testing><testing><pytest><acceptance-testing>
2023-09-26 22:05:28
0
1,623
Leslie Alldridge
77,183,648
8,508
Find all the ManyToManyField targets that are not connected to a ManyToManyField haver
<p>Suppose I have 2 models connected by a many to many relation</p> <pre><code>from django.db import models class Record(models.Model): name = models.CharField(max_length=64) class Batch(models.Model): records = models.ManyToManyField(Record) </code></pre> <p>Now I want to find all the Records that are not co...
<python><django><database><django-models>
2023-09-26 22:01:50
1
15,639
Matthew Scouten
77,183,618
8,372,455
Dockerfile to install scikit-learn on rasp pi hardware
<p>How to make a Dockerfile for Raspbian hardware that can install scikit-learn? I haven't had any luck with debian-slim or Alpine Linux images.</p> <pre><code># Use a base image for Raspberry Pi with Alpine Linux FROM arm32v6/alpine:3.14 # Update package repositories and install necessary dependencies RUN apk --no-ca...
<python><docker><numpy><scikit-learn><raspbian>
2023-09-26 21:55:33
1
3,564
bbartling
77,183,615
1,423,217
Tracking the results of the multiprosssing version of the for-loop
<p>I have a function that I apply sequentially on a list of objects and which returns me a score for each object as following :</p> <pre><code>def get_score(a): // do something return score objects = [obj0, obj1, obj3] results = np.zeros(len(objects)) index = 0 for i in range(len(results)): results[i]=get_s...
<python><multiprocessing>
2023-09-26 21:54:56
1
327
ZchGarinch
77,183,499
1,185,790
How can I use the Palantir Foundry REST API to get a list of datasets within a directory
<p>I need to check to see if a dataset exists within a Palantir Foundry directory, and if it doesn't exist, initiate the dataset creation process. I specifically want to look for a specified table name within the directory, and if it exists, return the dataset RID associated with that table. However, I'm having difficu...
<python><palantir-foundry><palantir-foundry-api>
2023-09-26 21:23:21
1
723
baobobs
77,183,391
382,200
Search a string's unknown text and replace it
<p>I want to search for a section of a string in a data file and replace it.</p> <p>No problem doing it if the exact text in the section of interest is known, but I seem unable to do it if the exact text is not fully known.</p> <p>The contents of the string(s) may be different (may be numbers or names or mixed).</p> <p...
<python><regex>
2023-09-26 21:01:02
1
551
headscratch
77,183,339
9,962,007
Installing torch with GPU support but without downloading 3 GB of duplicated siloed CUDA libraries?
<p>I'm trying to make CUDA containers for DNN less heavy. PyTorch goes against my efforts, as it seems to come bundled with its own siloed copy of a large subset of CUDA libraries. But what if we have them already (possibly newer) and want to install just <code>torch</code>?</p> <p>And bonus question: why cannot PyTorc...
<python><pip><pytorch><gpu>
2023-09-26 20:52:33
3
7,211
mirekphd
77,183,190
2,195,440
How `torch.einsum` API works?
<p>How <code>torch.einsum</code> API works?</p> <p>I am trying to understand how the <code>torch.einsum(&quot;ac,bc-&gt;ab&quot;,norm_max_func_embedding,norm_nl_embedding)</code> is calculating the similarity?</p> <p>I understand this is doing manipulation of tensors.</p> <p>I thikn β€œac” specifies a tensor with dimensi...
<python><pytorch><word-embedding>
2023-09-26 20:24:22
2
3,657
Exploring
77,183,185
5,676,198
How to stop my jupyter notebook to print the color ansi code with the variable output
<p>I am using <code>Jupyter notebook v2023.8.1002501831</code> with <code>VsCode v1.82.2</code>.</p> <p>Every time I attribute a value to a variable, the default output of a variable also prints the ANSI colors:</p> <p><a href="https://i.sstatic.net/TvOXY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/T...
<python><visual-studio-code><jupyter-notebook>
2023-09-26 20:23:20
1
1,061
Guilherme Parreira
77,183,132
5,503,494
unable to import azureml in vscode
<p>I've installed python 3.8, from vscode terminal I created an env and seem to have successfully installed azureml as below:</p> <pre><code>C:\Python38\python.exe -m venv tempml tempml\scripts\activate pip install azureml-core </code></pre> <p>I then go into python and type</p> <pre><code>import azureml </code></pre> ...
<python><azure><visual-studio-code><azure-devops><azureml-python-sdk>
2023-09-26 20:12:27
2
469
tezzaaa
77,182,937
9,983,652
TypeError: get_loc() got an unexpected keyword argument 'method'
<p>In pandas 2 with the following code:</p> <pre class="lang-py prettyprint-override"><code>for time in tfo_dates: dt=pd.to_datetime(time) indx_time.append(df.index.get_loc(dt,method='nearest')) </code></pre> <p>I get this error:</p> <pre><code>TypeError: get_loc() got an unexpected keyword argument 'method' </...
<python><pandas>
2023-09-26 19:35:26
3
4,338
roudan
77,182,787
5,507,389
Force type in abstract property from abstract class
<p>The following code illustrates one way to create an abstract property within an abstract base class (<code>A</code> here) in Python:</p> <pre><code>from abc import ABC, abstractmethod class A(ABC): @property @abstractmethod def my_abstract_property(self): pass class B(A): my_abstract_prop...
<python><class><abstract-class>
2023-09-26 19:04:57
0
679
glpsx
77,182,777
481,061
Paste strings into larger string in Python
<p>I have a pretty large logfile (1.3G) which is more or less tabular with spaces padding the individual fields. I also have a list of indices in that file where I would like to overwrite a field's contents with some other string. For the sake of simplicity, assume that the field is previously empty and my replacement ...
<python><replace>
2023-09-26 19:03:31
0
14,622
Felix Dombek
77,182,764
2,112,406
How to integrate C++ tests into a sckit-build pybind module
<p>I'm making a python module based on <a href="https://github.com/pybind/scikit_build_example" rel="nofollow noreferrer">the official pybind scikit build example</a>. I (and the example) have some unit tests for the python part in <code>tests</code>, that runs with <code>pytest</code>. In my case, I have some librarie...
<python><c++><unit-testing><cmake>
2023-09-26 19:01:38
0
3,203
sodiumnitrate
77,182,715
1,852,526
PyInstaller Tree Cannot find the path specified
<p>I want to include a folder and its contents within pyinstaller. I have a folder named 'etc' and it has a file named sbom.json. I am following the post mentioned <a href="https://stackoverflow.com/questions/20602727/pyinstaller-generate-exe-file-folder-in-onefile-mode/20677118#20677118">tree</a>, but I keep getting a...
<python><path><pyinstaller>
2023-09-26 18:51:39
1
1,774
nikhil
77,182,518
17,301,834
pcolormesh with alternating cell widths
<p>I would like to make a matplotlib colourmesh which is scaled irregularly to make some rows and columns wider than others.</p> <p>Keep in mind that I'm not very familiar with matplotlib, and am likely overlooking an obvious solution.</p> <p>Say I have the following code:</p> <pre><code>plt.axes().set_aspect(&quot;equ...
<python><matplotlib>
2023-09-26 18:12:41
1
459
user17301834
77,182,421
6,087,087
Does PyTorch support stride_tricks as in numpy.lib.stride_tricks.as_strided?
<p>It is possible to make cool things by changing the strides of an array in Numpy like this:</p> <pre><code>import numpy as np from numpy.lib.stride_tricks import as_strided a = np.arange(15).reshape(3,5) print(a) # [[ 0 1 2 3 4] # [ 5 6 7 8 9] # [10 11 12 13 14]] b = as_strided(a, shape=(3,3,3), strides=...
<python><arrays><numpy><pytorch><stride>
2023-09-26 17:59:34
1
499
FΔ±rat KΔ±yak
77,182,278
3,802,813
Type hints for matplotlib Axes3D
<p>I have a function that takes a matplotlib 3D axis:</p> <pre class="lang-py prettyprint-override"><code>from mpl_toolkits.mplot3d.axes3d import Axes3D def plot(ax: Axes3D): pass </code></pre> <p>I know how to add a type hint for a 2D axis. Just <code>ax: plt.Axes</code> works perfectly. However, with this <code...
<python><matplotlib><python-typing><pylance>
2023-09-26 17:37:47
0
1,231
Marcel
77,182,230
382,982
How can I use django-filter's DateTimeFromToRangeFilter with Graphene?
<p>I'm attempting to use an instance of django-filter's DateTimeFromToRangeFilter in conjunction with a custom <code>FilterSet</code>. However, this does not work when I attempt to do the following:</p> <pre><code>class CustomFilterSet(FilterSet): modified = django_filters.IsoDateTimeFromToRangeFilter() class ...
<python><django><graphql><django-filter><graphene-django>
2023-09-26 17:29:48
0
10,529
pdoherty926
77,182,223
2,100,039
Xtick Label Shift Problem with 2 Plots Overlaid
<p>I am trying to make a combined plot using seaborn boxplot and scatterplot. The problem is that my xtick labels are not aligned and I've tried many solutions. the red data values are the values that are not aligned with the boxplot xtcick labels and correspond to the LAST row in the df_concat df shown below. The trun...
<python><seaborn><axis-labels><xticks>
2023-09-26 17:28:10
0
1,366
user2100039
77,182,026
1,080,189
Type hinting Python enum staticmethod where literal types are defined
<p>In the code below, the <code>direction</code> attribute of the <code>Horizontal</code> dataclass is type hinted to only allow 3 of the 5 values from the <code>Direction</code> enum. I want to be able to return an enum value from dynamic input using the <code>from_string</code> static method which falls back to Direc...
<python><mypy><python-typing>
2023-09-26 16:55:18
1
1,626
gratz
77,181,805
5,695,336
Define an enum that is a subset of another enum
<p>My program has an <code>enum</code> called <code>Platform</code></p> <pre><code>class Platform(StrEnum): binance = auto() kraken = auto() trading_view = auto() </code></pre> <p>Now I want to define another <code>enum</code> called <code>Exchange</code> that only contains platforms that are exchanges. Som...
<python><enums>
2023-09-26 16:21:21
2
2,017
Jeffrey Chen
77,181,786
3,086,470
How to turn of spellchecking in ipywidgets Textarea?
<p>On ipywidgets version 8, I've tried to turn off spellchecking (which is a CSS attribute) like this:</p> <pre class="lang-py prettyprint-override"><code>area = ipywidgets.Textarea(rows=10, style={&quot;spellchecking&quot;: &quot;false&quot;}) </code></pre> <p>But the created widget still gets spellchecked (Chrome 116...
<python><css><ipywidgets>
2023-09-26 16:19:30
0
850
marscher
77,181,761
2,426,888
Build a python package with two independent modules where one is a git subodule
<p>I am trying to build a Python package for distribution that contains two independent modules (<code>lkh</code> and <code>tsplib95</code>), but with a non-standard directory layout.</p> <p>The two modules are contained in different repos (<a href="https://github.com/ben-hudson/pylkh" rel="nofollow noreferrer">pylkh</...
<python><pypi><python-packaging><python-poetry>
2023-09-26 16:15:00
2
794
beenjaminnn
77,181,551
3,768,871
How to generate uniform random numbers in Python close to the true mean and standard deviation?
<p>I am trying to generate uniform random numbers as much as possible close to its theoretical definition, particularly in Python. (i.e., I am familiar with the concept of Pesudo-Random Generators (PRGs) in programming languages.)</p> <p>I am using the following code for this matter (a widely known solution):</p> <pre ...
<python><math><random><probability>
2023-09-26 15:48:23
1
19,015
OmG
77,181,515
11,231,520
Python not found when trying to execute git-clang-format on Windows
<p>I am trying to set up <code>git-clang-format</code> on Windows 10. I have following programs installed:</p> <ul> <li>git</li> <li>python 3.11.5</li> <li>LLVM 16.0.4 (which includes <code>clang-format</code> and <code>git-clang-format</code>)</li> </ul> <p>Both python executable and LLVM's bin folder (containing <cod...
<python><windows><git><clang-format>
2023-09-26 15:43:48
1
509
Vincent
77,181,503
4,472,856
How to understand the output of scipy's quadratic_assignment function?
<p>I'm trying to use scipy's <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.quadratic_assignment.html" rel="nofollow noreferrer">quadratic_assignment</a> function but I can't understand how the output can describe an optimal solution. Here is a minimal example where I compare a small matri...
<python><scipy-optimize>
2023-09-26 15:41:33
1
5,185
LowPolyCorgi
77,181,404
7,257,731
How to update multiple columns of a Pandas dataframe at once
<p>Given a Pandas dataframe with columns A, B and C, I want to update A and B as the result of applying a function over C. This function has one parameter and two return values.</p> <pre><code>import pandas as pd # Create a sample dataframe df = pd.DataFrame({ 'A': [1, 2, 3], 'B': [10, 20, 30], 'C': [100, ...
<python><pandas>
2023-09-26 15:27:12
2
392
Samuel O.D.
77,181,227
711,006
ModuleNotFoundError when trying to debug a test
<p>I am trying to debug a failing test method in VS Code but when I use the <code>Debug Test</code> action from the Testing sidebar or the context menu for the test method, it fails with the following error (found in the Debug Console):</p> <pre><code>E ==================================================================...
<python><visual-studio-code><debugging><testing><python-unittest>
2023-09-26 15:04:30
1
6,784
Melebius
77,181,041
4,443,378
Trying to change the first character of every row in a pandas series
<p>I have a series list1:</p> <pre><code>1 listId 95 LaBc.defGabc 97 Kasd.defGabc 99 aaSd.defGabc 101 Basd.defGabc 103 Lasd.defGabc 105 Lasd.defGabc </code></pre> <p>I want to <code>lower()</code> only the first character of every item so it looks like:</p> <pre><code>1 listId 95 laBc...
<python><pandas>
2023-09-26 14:40:28
3
596
Mitch
77,180,927
1,145,808
python reportlab - how to test whether a particular font (core or TTF) can encode/render a given glyph in a PDF?
<p>I've seen <a href="https://stackoverflow.com/questions/69261202/how-to-determine-if-a-glyph-can-be-displayed">How to determine if a Glyph can be displayed?</a>, which doesn't seem to work for the core fonts.</p> <p><a href="https://docs.reportlab.com/reportlab/userguide/ch3_fonts/" rel="nofollow noreferrer">https://...
<python><reportlab>
2023-09-26 14:24:05
1
829
DobbyTheElf
77,180,833
5,924,264
Am I violating encapsulation by having unit test access path to sql database file and creating a connector to it?
<p>I have a python class that manages initilization, read, and writes to a sql database:</p> <pre><code>class Database { def __init__(self, path2db): # path2db is created within this constructor self._connector = # create a sqlite3 connector pointing to an input path2db def query_col1(query_sql): # exe...
<python><sql><oop><encapsulation>
2023-09-26 14:12:09
0
2,502
roulette01
77,180,768
10,071,473
Linux process defunct if started from flask
<p>I would need my flask application to manage the execution of some commands via a specific endpoint. I would also like to have a second endpoint that allows me to monitor the processes triggered by the flask application.</p> <p>I already have in my mind about how to do it, I am facing only one problem, after the proc...
<python><linux><flask><process>
2023-09-26 14:04:15
0
2,022
Matteo Pasini
77,180,626
2,437,080
Kubernetes CronJob to copy, modify and create a secret
<p>I am currently trying to debug the following setup in Kubernetes: With a Cronjob, I want to read a secret from a namespace, delete some labels in the secret and then create the new secret in another namespace. For some reason, the following code (see CronJob) does not do what it's supposed to and I can't figure out ...
<python><bash><kubernetes>
2023-09-26 13:47:19
1
336
zappa
77,180,580
2,741,091
Unable to parse string for Int64 in pd read_csv
<p>It doesn't seem as if Pandas 2.0.0 properly accounts for <code>thousands=','</code> when parsing <code>Int64</code> objects:</p> <pre><code>import io pd.read_csv(io.StringIO('''a\n22,922'''), sep='\t', dtype={'a': 'Int64'}, thousands=',') </code></pre> <p>The specific error is:</p> <pre><code>Traceback (most recent ...
<python><pandas>
2023-09-26 13:41:15
2
5,390
ifly6
77,180,480
19,251,203
Pandas get_dummies altering shape
<p>I want to one-hot encode the categorical features of my Pandas dataframe. Previously, the values stored variables of shape (60,). See code below:</p> <pre><code>ohe_features = [&quot;Gender&quot;, &quot;Married&quot;, &quot;Self_Employed&quot;] num_features = [&quot;Dependents&quot;] df = pd.get_dummies(df, columns...
<python><python-3.x><pandas><dataframe>
2023-09-26 13:28:39
1
392
user19251203
77,180,475
209,834
Symbols have mismatching columns error which loading data into vectorbt from a pandas dataframe
<p>I have downloaded historical data and stored in a csv file on disk. I am loading this csv file in a pandas dataframe. From there on, I am trying to load this dataframe into vectorbt. Here is my code</p> <pre class="lang-py prettyprint-override"><code>import vectorbt as vbt import pandas as pd prices_1m = pd.read_cs...
<python><vectorbt>
2023-09-26 13:28:07
1
8,498
Suhas
77,180,434
726,730
Can I use pyodbc or anything similar without having MS Access installed on my computer?
<p>Can I open a *.mdb Access database to display the table rows (in cmd for example) if I haven't installed Microsoft Access on my computer?</p>
<python><ms-access><driver><pyodbc>
2023-09-26 13:24:01
1
2,427
Chris P
77,179,988
2,043,397
How to animate the translation of a sphere in vispy
<p>I'm trying to visualize the translation of a sphere in Vispy without sucess.</p> <p>I have used the code from <a href="https://vispy.org/gallery/scene/sphere.html#sphx-glr-gallery-scene-sphere-py" rel="nofollow noreferrer">Vispy Documentation examples - Draw a Sphere</a> to generate the sphere and then tried to upda...
<python><animation><vispy>
2023-09-26 12:23:21
2
662
TMoover
77,179,906
305,712
Rendering a PDF from HTML that refers to another PDF as an <object> tag
<p>I have a generated HTML page that might include images or references to PDF pages. I would like to convert that HTML to PDF and include the referenced PDF files in the generated PDF using Playwright for Python.</p> <p>An example:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;h1&gt;Hello World&lt;/h1&gt; &lt;p...
<python><pdf><playwright>
2023-09-26 12:12:51
1
335
Radim Novotny
77,179,651
3,447,369
How to make a discrete colorbar for plotly.graph_objects.Heatmap?
<p>I want to visualize <a href="https://pastebin.com/HdyujvXw" rel="nofollow noreferrer">this</a> spatio-temporal data in a Plotly heatmap. A working example that includes <a href="https://pastebin.com/HdyujvXw" rel="nofollow noreferrer">this</a> data:</p> <pre><code>import matplotlib.pyplot as plt import numpy as np i...
<python><plotly><heatmap>
2023-09-26 11:34:28
0
1,490
sander
77,179,447
18,091,040
Access Hyperledger Indy Node deployed in virtual machine using local workstation
<p>I'm trying to follow <a href="https://github.com/hyperledger/indy-sdk/blob/main/docs/how-tos/write-did-and-query-verkey/README.md" rel="nofollow noreferrer">this tutorial</a> and I have a virtual machine running an Indy pool (ip: 192.168.15.177 internal net: 10.217.0.18). It is a simple docker command to run the poo...
<python><docker><ip><nat><hyperledger-indy>
2023-09-26 11:09:33
1
640
brenodacosta
77,179,247
8,329,213
Pythonic way of aggregating but without grouping
<p>I have a <code>df</code> as follows, where I wish to find of <code>Sum of orders</code> and <code>Number of unique order sizes</code>, but I don't want to compress the <code>df</code>:</p> <pre><code>list_of_lists = [['11','Berlin',2],['11','Berlin',2],['11','Berlin',3], ['22','Munich',1],['22','Mun...
<python><pandas><aggregate>
2023-09-26 10:42:45
0
7,707
cph_sto
77,179,224
4,358,785
Multiple ONNX outputs (Get Intermediate layer output for ONNX) in python
<p>How can I export model to ONNX so that I'll get intermediate layers' output as well as the layer? (I've seen a similar question that went unanswered <a href="https://stackoverflow.com/questions/69658166/get-intermediate-layer-output-for-onnx-mode">here</a>)</p> <p>Consider I have a model, <code>model</code>. The mod...
<python><deep-learning><pytorch><onnx>
2023-09-26 10:39:16
1
971
Ruslan
77,179,134
9,131,089
Loading input as a string with Langchain
<p>I've been trying to load the dynamic user queries and the answers that I receive for it into Chroma DB in langachain. I have only options to load input as documents in langchain. Is there a possibility to load input strings in langchain ?</p> <p>I have attached the function in which I'm trying to pass the query and ...
<python><openai-api><langchain><gpt-3><chromadb>
2023-09-26 10:26:57
1
431
Nuju
77,179,122
9,284,651
Check if part of the string exists in different dataframe and get this part only
<p>My DF_1 looks like below:</p> <pre><code>id x 1 eu continent hamburg 2 asia singapore 3 austrlia hedland </code></pre> <p>I have a second DF_2 that looks like below:</p> <pre><code>name germany hamburg singapore china west australia hedland </code></pre> <p>I want to check if there are similar names and get t...
<python><pandas><dataframe>
2023-09-26 10:25:15
2
403
Tmiskiewicz
77,178,959
3,416,774
How can I use gkeepapi to retrieve and print out the labels associated with my Google Keep notes?
<h1>Background</h1> <p>I am using <code>gkeepapi</code> to get the labels of my Google Keep notes:</p> <pre class="lang-py prettyprint-override"><code>import gkeepapi keep = gkeepapi.Keep() keep.login('user@gmail.com', 'password') labels = keep.labels() </code></pre> <p>I want to read the data from <code>labels</code>....
<python><google-keep-api>
2023-09-26 10:02:46
1
3,394
Ooker
77,178,957
3,243,499
How to get info of class call order in Python?
<p>How to get the classes information of <code>A</code> and <code>B</code> and the order of their invocations <code>A</code> followed by <code>B</code> in the following Python code:</p> <pre><code>class A: def __init__(self, x, y): self.x = x self.y = y def __call__(self): return self.x...
<python>
2023-09-26 10:02:41
0
3,201
user3243499
77,178,883
3,619,498
Python PDM backend complains about conflict which is not a conflict
<p>In my team, we are using PIP with PDM backend for managing our Python packages and we've run into a problem with PDM backend.</p> <p>We've managed to reproduce with the following &quot;mickey mouse&quot; example.</p> <p>Directory structure:</p> <pre><code>- package-a - pyproject.toml - package-b - pyproject.toml...
<python><pip><package><python-pdm>
2023-09-26 09:53:04
0
817
jgreen81
77,178,879
13,768,998
python wget.download() throws OSError: Address family not supported by protocol
<p>I'm trying to download a model weights file from huggingface with python's wget library. What did I run:</p> <pre><code>import wget wget.download(&quot;https://huggingface.co/h94/IP-Adapter/resolve/main/models/image_encoder/pytorch_model.bin&quot;) </code></pre> <p>what I've got:</p> <pre><code>Traceback (most recen...
<python><wget>
2023-09-26 09:52:44
0
807
Flicic Suo
77,178,497
968,861
Mysterious missing dependency in AWS Lambda docker image
<p>I have been struggling on this for a few days. I have been following this page: <a href="https://docs.aws.amazon.com/lambda/latest/dg/python-image.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/lambda/latest/dg/python-image.html</a></p> <p><strong>What do I try to accomplish?</strong></p> <p>I want to h...
<python><docker><aws-lambda><sentence-transformers>
2023-09-26 08:58:41
1
1,217
dyesdyes
77,178,489
3,104,974
Using explode() as Aggregation Function
<p>How can I <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.explode.html" rel="nofollow noreferrer">explode</a> duplicate index rows in a <a href="https://pandas.pydata.org/docs/reference/api/pandas.pivot_table.html#pandas.pivot_table" rel="nofollow noreferrer"><code>pd.pivot_table()</code></a>?...
<python><pandas><aggregate><pivot-table>
2023-09-26 08:57:12
1
6,315
ascripter
77,178,477
8,761,554
Adding a paragraph to PDF with specific coordinates size
<p>I am using python for modifying PDFs but I have a PDF template which I am trying to automatize. I am using PyPDF2 and reportlab to do so. For single sentences I am using the reportlab's drawString function. However I'd like to now create and paste a paragraph to the specific coordinates on the first page. I know tha...
<python><pdf><formatting><pypdf>
2023-09-26 08:55:46
0
341
Sam333
77,178,438
4,993,513
How to use a custom toml file path for Streamlit secrets?
<p>Assume I have a toml file which contain secrets at <code>/some/filepath/secrets.toml</code>. How do I specify this path for Streamlit to use?</p> <p>Currently, the streamlit docs mention <code>.streamlit/secrets.toml</code> as the default filepath for secrets. However, I do not find any doc which explains how to use...
<python><streamlit><toml>
2023-09-26 08:50:21
1
11,141
Dawny33
77,178,429
17,541,416
How to create new column with new names that has value from other column and keep values for the previous columns?
<p>I have the following dataframe_1 I would like to transform:</p> <pre><code> Time Not_paid Paid 0 morning 30 10 1 afternoon 60 20 2 night 90 30 </code></pre> <p>I would like to use the first column of dataframe_1 to create new columns with the others. For example, 1 col...
<python><pandas><dataframe>
2023-09-26 08:49:16
1
327
codelifevcd
77,178,406
10,755,032
How to add tags to S3 buckets from a dataframe in python
<p>I have a dataframe as follows:</p> <pre><code>bucket_name tags name1 tag1 name2 tag2 name3 tag3 </code></pre> <p>I want to use the above to insert tags into the respective s3 bucket. How can I do this using boto3?</p>
<python><amazon-web-services><boto3>
2023-09-26 08:46:48
1
1,753
Karthik Bhandary