QuestionId
int64
74.8M
79.8M
UserId
int64
56
29.4M
QuestionTitle
stringlengths
15
150
QuestionBody
stringlengths
40
40.3k
Tags
stringlengths
8
101
CreationDate
stringdate
2022-12-10 09:42:47
2025-11-01 19:08:18
AnswerCount
int64
0
44
UserExpertiseLevel
int64
301
888k
UserDisplayName
stringlengths
3
30
76,142,428
17,353,489
Unexpected uint64 behaviour 0xFFFF'FFFF'FFFF'FFFF - 1 = 0?
<p>Consider the following brief numpy session showcasing <code>uint64</code> data type</p> <pre><code>import numpy as np a = np.zeros(1,np.uint64) a # array([0], dtype=uint64) a[0] -= 1 a # array([18446744073709551615], dtype=uint64) # this is 0xffff ffff ffff ffff, as expected a[0] -= 1 a # array([0], dtype=uin...
<python><numpy><uint64>
2023-04-30 16:50:29
5
533
Albert.Lang
76,142,366
9,983,652
ModuleNotFoundError: No module named 'dash_extensions.callback'
<p>since I am using anaconda, so I installed dash_extensions using below command instead of pip.</p> <p>conda install -c conda-forge dash-extensions</p> <p><a href="https://anaconda.org/conda-forge/dash-extensions" rel="nofollow noreferrer">https://anaconda.org/conda-forge/dash-extensions</a></p> <p>I can import dash_e...
<python><plotly-dash>
2023-04-30 16:36:10
0
4,338
roudan
76,142,338
16,527,606
When I recreate machine learning model in flask api, the server shuts down without any warning
<pre><code>from flask import Blueprint, request, current_app as app from project_app.modules import ml_tool, pickle_tool adminBp = Blueprint('admin', __name__, url_prefix='/admin') @adminBp.route('/refresh', methods=['POST']) def refresh(): body = request.get_json() df_nonTest, df_test = ml_tool.get_spl...
<python><machine-learning><flask>
2023-04-30 16:30:34
0
537
niddddddfier
76,142,305
17,507,202
How to create function that translates an array of 0 and 1s into a float?
<p>I am trying to create a function that takes an array as argument, the array represents number but in Binary, I want this function to return a number.</p> <p>I can translate any number into Binary, however I can't figure out how to get float number from Binary.</p> <p>For example 4.8 is [0, 1, 0, 0, 1, 1, 0, 0], but ...
<python><python-3.x><floating-point><binary><binary-data>
2023-04-30 16:22:54
1
335
mitas1c
76,142,253
181,098
Flask / Bootstrap not showing image
<p>I have this python flask bootstrap function:</p> <pre><code># Index page (main page) @app.route('/') def index(): return render_template('test.html') </code></pre> <p>And my run code:</p> <pre><code>if __name__ == '__main__': app.run(debug=True) </code></pre> <p>Of course the default folder will be under the...
<python><flask><flask-bootstrap>
2023-04-30 16:09:32
1
3,367
Hein du Plessis
76,141,978
8,849,755
Cannot build scipy from source
<p>I am following the steps specified <a href="https://scipy.github.io/devdocs/dev/dev_quickstart.html" rel="nofollow noreferrer">here</a> under the <em>pip+venv</em> tab. I was able to create the virtual environment and install all the python level dependencies, but then when I navigate into <code>/wherever/I/cloned/s...
<python><build><scipy>
2023-04-30 15:10:37
1
3,245
user171780
76,141,615
6,819,038
How to reconnect / retrieve realtime session of previous jupyter notebook session?
<p>I have so much data to process and that takes a lot of time. Closing the tab of jupyter session disconnects the existing realtime session and output, so I can't retrieve previous realtime result. Example: I want to get <code>tqdm</code> progress shown again after I reopen the closed tab of jupyter. I want to retrie...
<python><websocket><jupyter-notebook>
2023-04-30 13:55:22
0
653
adib-enc
76,141,506
1,152,915
Simplifying weighted moving average calculation
<pre><code>accs = pd.DataFrame({'v': values[start_index:], 'w': weights[start_index:]})\ .rolling(window=window_len, min_periods=1, method='table').apply(weighted_mean, engine='numba', raw=True)\ .v.to_numpy()[a:b] # after .apply() we get df back with all columns being set to the same resulting sequence...
<python><pandas>
2023-04-30 13:28:46
0
8,926
clime
76,141,435
13,438,431
Use SSL self-signed certificate to connect to ScyllaDB (cassandra) node on Windows?
<p>I've generated a self-signed cert using <a href="https://docs.scylladb.com/stable/operating-scylla/security/generate-certificate.html" rel="nofollow noreferrer">this scylla tutorial</a>. Started a scylladb node, everything's fine and dandy.</p> <p>Now it's time to connect clients. Here's the script:</p> <pre><code>f...
<python><ssl><cassandra><scylla><datastax-python-driver>
2023-04-30 13:09:42
1
2,104
winwin
76,141,399
1,581,090
How to fix python logging error "TypeError: setLevel() missing 1 required positional argument: 'level'"?
<p>I am trying to use a simple logger in python (3.9.6) to log out to the terminal and to format the logging with some timestamp etc. as follows (following <a href="https://sematext.com/blog/python-logging/" rel="nofollow noreferrer">this example</a>):</p> <pre><code>import logging logger = logging.getLogger(&quot;__ma...
<python>
2023-04-30 13:01:12
2
45,023
Alex
76,140,943
675,011
How to connect a Python gRPC stub to a Go gRPC server in the same process
<p>I have a Python app that loads Go code through a shared library. I want to call a gRPC server in the Go part from the Python part of the application. I could make the Go server listen on a TCP socket, but I want to avoid the overhead of TCP, want to avoid the use of sockets (as I will be creating and destroying many...
<python><go><grpc><grpc-python><grpc-go>
2023-04-30 11:14:39
0
877
Remko
76,140,909
6,198,659
IFC: Add Unit (IfcUnit) to IfcPropertySingleValue
<p>A python script produces an IFC-file wherein the following line appears several times:</p> <pre><code>PropertySingleValueWriter = ifcfile.createIfcPropertySingleValue(&quot;{}&quot;.format(V), &quot;{}&quot;.format(k), ifcfile.create_entity(&quot;IfcText&quot;, str((val[&quot;{}&quot;.format(k)]))), None) </code></p...
<python><scripting><ifc>
2023-04-30 11:07:42
1
522
stonebe
76,140,839
16,383,578
Regex to find sequences of two given characters that alternate
<p>I have written a small program to convert IPv6 addresses to <code>int</code>s and back, and I have managed to beat built-in <code>ipaddress.IPv6Address</code> in terms of performance.</p> <pre class="lang-py prettyprint-override"><code>import re MAX_IPV6 = 2**128-1 DIGITS = set(&quot;0123456789abcdef&quot;) def pa...
<python><python-3.x><regex>
2023-04-30 10:48:35
2
3,930
Ξένη Γήινος
76,140,609
10,327,984
error while training the generator in a text to image gan model
<p>I am trying to train a gan model which takes text embeddings and transforms them into an image due to a lack of resources I loaded the generator in GPU and discriminator in CPU. and I deleted every variable I do not further need in the training loop and then cleared the memory. this is my train function :</p> <pre><...
<python><pytorch><generative-adversarial-network>
2023-04-30 09:56:17
1
622
Mohamed Amine
76,140,411
14,459,677
Calculating specific cells based on cell condition
<p>I have:</p> <p>EXCEL 1:</p> <pre><code>NAME Year ACTIVITY AMOUNT AA 1 CC 140 AA 1 CC 150 AA 1 DD 80 </code></pre> <p>My desired output is:</p> <pre><code>NAME ACTIVITY YEAR TOTAL AMOUNT AA CC 1 290 AA DD 1 8...
<python><pandas><excel><if-statement>
2023-04-30 09:06:55
1
433
kiwi_kimchi
76,140,300
7,371,707
How to limit the memory usage of python program so that it can trun to swap memory firstly?
<p>I am running a python program that has a large CPU memory consumption. I have limited real CPU memory (32G), but the swap memory is large enough (128G). Can I limit the python program to use less real memory (like up to 4G) and it turns to swap for more?</p> <p>I am working on Ubuntu 20.04 with python 3.8. Thanks!</...
<python><ubuntu><memory>
2023-04-30 08:43:16
1
1,029
ToughMind
76,139,962
2,889,716
Celery stucks at pending
<p>This is my code: <code>celery_app.py</code></p> <pre class="lang-py prettyprint-override"><code>from celery import Celery app = Celery( 'tasks', # app name broker='redis://localhost:6379/0', # broker URL backend='redis://localhost:6379/1', # backend URL include=['tasks'] # list of task modules ) i...
<python><celery>
2023-04-30 07:05:20
0
4,899
ehsan shirzadi
76,139,913
10,569,922
Plotly Scatter Plot Gap in categorical y-axis
<p>I cant find in <a href="https://plotly.com/python/reference/" rel="nofollow noreferrer">reference</a> Plotly Python, information that I need. Here my code:</p> <pre><code>fig_scatter = px.scatter(df_lv, x='frame', y='username', color='label_name', symbol='label_name', title=f'{task_option}'...
<python><plotly><visualization>
2023-04-30 06:51:32
1
521
TeoK
76,139,892
11,099,842
How to use a PDF map with plotly?
<p>I want the parameter that allows me to update the layout with a PDF map instead of an open-street-map for <code>plotly.express.scatter_mapbox</code>.</p> <p>I've searched through the documentation of Plotly, and searched online but I couldn't find the answer.</p> <p>Line within comments below is the one that I want ...
<python><plotly><gis>
2023-04-30 06:45:35
1
891
Al-Baraa El-Hag
76,139,800
6,455,731
How to dynamically assign a function signature?
<p>I would like to create a decorator for dynamically assigning function signatures to decorated functions, something like this:</p> <pre><code>import inspect signature = inspect.Signature([ inspect.Parameter('x', kind=inspect.Parameter.KEYWORD_ONLY, default=None), inspect.Parameter('y', kind=inspect.Parameter...
<python><functional-programming><signature>
2023-04-30 06:14:19
2
964
lupl
76,139,521
11,198,558
How can I format number in plotly Indicator?
<p>I'm now plotting <code>go.Indicator</code> and face a problem with the number format. Specifically, my code is as below</p> <pre><code>fig.add_trace( go.Indicator( mode = &quot;delta&quot;, value = df[df.columns[2]].values[-1], domain = {'row': 1, 'column':...
<python><plotly>
2023-04-30 04:18:16
1
981
ShanN
76,139,511
18,758,062
SSH using Python Paramiko: How to detect SSH Server responding with string on successful connection
<p>When I connect to my Ubuntu server via SSH using the terminal, it sometimes return a certain string then closes the connection.</p> <pre><code>$ ssh hello@my.server.com -i ~/.ssh/id_ed25519 container not found Connection to 123.10.10.231 closed. Connection to my.server.com closed. </code></pre> <p>Using <code>parami...
<python><python-3.x><ssh><paramiko>
2023-04-30 04:14:52
2
1,623
gameveloster
76,139,482
11,901,732
Find pairs of words in dictionary in Python
<p>I want to find pairs of words in a file called <code>dictionary.txt</code> based on given strings of <strong>distinct</strong> letters such as <code>GRIHWSNYP</code>.</p> <p><code>dictionary.txt</code> looks like this:</p> <pre><code>AARHUS AARON ABABA ABACK ABAFT ABANDON ABANDONED ABANDONING ABANDONMENT ABANDONS AB...
<python><list><algorithm><tuples>
2023-04-30 04:04:15
1
5,315
nilsinelabore
76,139,185
5,049,813
How to compare two Pandas Dataframes with text, numerical, and None values
<p>I have two dataframes <code>df1</code> and <code>df2</code> that both contain text and numerical data in addition to <code>None</code>s as well. However, <code>df1</code> has integer numbers, and <code>df2</code> has float numbers.</p> <p>I've tried comparing their equality with <code>df1.equals(df2)</code>, but thi...
<python><pandas><dataframe><equality>
2023-04-30 01:26:47
2
5,220
Pro Q
76,139,175
17,741,308
Visual Studio Code Debug Python Redirecting Input from Text File in Virtual Environment
<p>I am following the code mentioned in <a href="https://stackoverflow.com/questions/65165574/debugging-a-python-file-in-vs-code-with-input-text-file">debugging a python file in vs code with input text file</a>. To get my error:</p> <ol> <li>Create a new virtual pip virtual environment.</li> <li>Create a new folder cal...
<python><python-3.x><visual-studio-code><debugging>
2023-04-30 01:23:54
1
364
温泽海
76,139,171
7,599,062
Secure Password Storage in Flask-based RESTful API using Python
<p>I am building a Flask-based RESTful API in Python, and I need to securely store and encrypt user passwords for authentication. Currently, I am using a simple hashing algorithm to hash passwords with a salt, but I'm not sure if this is secure enough.</p> <p>Here is an example of my current implementation for password...
<python><security><flask><restful-authentication>
2023-04-30 01:22:53
1
543
SyntaxNavigator
76,139,126
13,849,446
Selenium cannot send keys to google map input selenium
<p>I am trying to send keys to google maps to perform search, but Google Maps only accepts keys when the browser screen is in focus. I have tried input_box click, maximizing the window, action chain, and scrolling into view. The following is the code.</p> <pre class="lang-py prettyprint-override"><code>import time from...
<python><python-3.x><selenium-webdriver><selenium-chromedriver>
2023-04-30 00:59:24
1
1,146
farhan jatt
76,139,012
12,369,606
Pandas groupby, keep most common value but drop if tie
<p>This is directly based off of the question <a href="https://stackoverflow.com/questions/15222754/groupby-pandas-dataframe-and-select-most-common-value/74900139#comment134266608_74900139">GroupBy pandas DataFrame and select most common value</a>. My goal is to groupby one column, and keep the value that occurs most o...
<python><pandas><group-by>
2023-04-30 00:05:38
1
504
keenan
76,138,816
2,647,447
How to remove "Python" from tk menu?
<p>I am trying to build a simple Python desktop application using tkinter. I want to have &quot;Release&quot; and &quot;Module&quot; in my dropdown menu. The issue is, there is always an extra menu -&quot;Python&quot; in it. How do I remove that? (My code is below):</p> <pre><code>root = Tk() myLabel =Label(root, text...
<python><tkinter>
2023-04-29 22:53:33
1
449
PChao
76,138,764
44,330
Since timezone info is deprecated by numpy.datetime64 constructor, what's the right way to convert ISO 8601 datestrings?
<p>I have a timeseries with a large number of ISO 8601 datestrings and would like to convert to <code>numpy.datetime64</code>. But I get a warning:</p> <pre><code>&gt;&gt;&gt; import numpy as np &gt;&gt;&gt; t=np.datetime64('2022-05-01T00:00:00-07:00') &lt;stdin&gt;:1: DeprecationWarning: parsing timezone aware datetim...
<python><numpy>
2023-04-29 22:38:19
3
190,447
Jason S
76,138,703
1,039,860
issues with regular expressions in python
<p>I am trying to replace a string with another</p> <p>I have two strings I am looping over:</p> <pre class="lang-none prettyprint-override"><code>1: &quot;I have a sentence with this_is_a_test in it.&quot; 2: &quot;I have another sentance with this_is_a_test_also in it&quot;. </code></pre> <p>I want to replace <code>...
<python><regex>
2023-04-29 22:20:04
0
1,116
jordanthompson
76,138,612
9,297,170
Django SearchRank not taking full text search operators into account
<p>I'm trying to add a new endpoint that does full-text search with <code>AND, OR, NOT</code> operators and also tolerates typos with <code>TriagramSimilarity</code>.</p> <p>I came across this question: <a href="https://stackoverflow.com/questions/37859960/combine-trigram-with-ranked-searching-in-django-1-10">Combine t...
<python><django><postgresql><django-rest-framework><full-text-search>
2023-04-29 21:52:53
2
580
Gerardo Sabetta
76,138,498
5,306,861
Understand why opencv's KNearest gives these results
<p>Below is the code I run in Python, when <code>K</code> = <code>1</code>, the output looks correct, But why when <code>K</code> = <code>3</code> the result is <code>4</code> and not <code>5</code>, then there is a row that matches exactly what we were looking for?</p> <pre><code>import cv2 as cv import numpy as np t...
<python><opencv><machine-learning><knn>
2023-04-29 21:26:23
0
1,839
codeDom
76,138,360
5,370,631
combine multiple rows in pyspark dataframe into one along with aggregation
<p>I have the below df with 2 rows which I want to combine into one row.</p> <pre><code>+--------------------+--------------------+----+--------------------+--------------------+---------------+-------+-----------+-------------+-------------+-------------+-------------+-------------+----------------------+-------------...
<python><apache-spark><pyspark><apache-spark-sql>
2023-04-29 20:53:26
1
1,572
Shibu
76,138,342
525,913
Twitter login with Playwright
<p>I'm new to Playwright, and I can't figure out how to get this working. I can enter my userID just fine, but then can't find the right code to click on the &quot;Next&quot; button. Here's one (of many) things I tried:</p> <pre><code>from playwright_stealth import stealth_async from playwright.sync_api import sync_pla...
<python><authentication><twitter><playwright-python>
2023-04-29 20:47:48
1
2,347
ViennaMike
76,138,267
15,900,832
Read/write data over Raspberry Pi Pico USB cable
<p>How can I read/write data to Raspberry Pi Pico using Python/MicroPython over the USB connection?</p>
<python><micropython><raspberry-pi-pico>
2023-04-29 20:26:14
1
633
basil_man
76,138,236
6,447,399
_ctypes not install when trying to import pandas
<p>I have read many questions online about trying to solve this issue but none of the solutions seemed to work for me.</p> <p>I get this error:</p> <pre><code>(venv) matt@localhost:~/Downloads/Python-3.11.3&gt; python3 Python 3.11.3 (main, Apr 29 2023, 22:07:31) [GCC 7.5.0] on linux Type &quot;help&quot;, &quot;copyrig...
<python><ctypes>
2023-04-29 20:17:56
1
7,189
user113156
76,138,199
9,064,615
Loading Pytorch weights results in poor performance compared to training
<p>I'm currently messing around PPO reinforcement learning with <a href="https://www.youtube.com/watch?v=hlv79rcHws0" rel="nofollow noreferrer">this video</a> (Github code located <a href="https://github.com/philtabor/Youtube-Code-Repository/tree/master/ReinforcementLearning/PolicyGradient/PPO/torch" rel="nofollow nore...
<python><pytorch>
2023-04-29 20:08:00
1
608
explodingfilms101
76,137,989
13,403,510
Getting value error while enc.transform, where enc is OneHotEncoder(sparse_output=False), in pandas
<p>I have a timeseries dataset name temp which has 4 columns; Date, Minutes, Issues, Reason no.</p> <p>in which:</p> <pre><code>temp['REASON NO'].value_counts() </code></pre> <p>shows this output:</p> <pre><code>R13 158 R14 123 R4 101 R7 81 R2 40 R3 35 R5 31 R8 11 R15 9 R12 ...
<python><pandas><numpy><lstm>
2023-04-29 19:15:48
1
1,066
def __init__
76,137,936
895,544
Too many open files when run an external script with multiprocessing
<pre class="lang-py prettyprint-override"><code>def func(item, protein, ncpu): output = None item_id = item.id output_fname = tempfile.mkstemp(suffix='_output.json', text=True)[1] input_fname = tempfile.mkstemp(suffix='_input.pdbqt', text=True)[1] # &lt;-- error occurs here try: with o...
<python><multiprocessing>
2023-04-29 19:02:58
1
4,143
DrDom
76,137,930
14,790,056
Cumsum of previous values if conditions are met after groupby
<p>I have unbalanced panel. Basically, someone will increase liquidity before decreasing that liquidity fully. I have groups (NF_TOKEN_ID). I want to first <code>groupby</code> and whenever <code>ACTION</code> is <code>DECREASE_LIQUIDITY</code> i want to replace the zero value with all the funds that have been withdraw...
<python><pandas><dataframe>
2023-04-29 19:01:22
1
654
Olive
76,137,774
964,235
Loading .npy file takes over 30x longer if RAM usage is high
<p>Here is my RAM usage when loading a .npy file, deleting it with del, calling gc.collect, then loading it again. It behaves as expected and takes about 2.5 seconds.<br /> <a href="https://i.sstatic.net/s4RRQ.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/s4RRQ.jpg" alt="enter image description here" /...
<python><numpy><memory><memory-management><ram>
2023-04-29 18:25:53
1
1,293
Frobot
76,137,381
9,079,461
AttributeError: window object has no attribute tk
<p>I have a tinker program with multiple windows.</p> <p>Code :</p> <pre><code>import tkinter as tk from tkinter import * class window(Toplevel): def __init__(self, master=None): self.master=master self.title(&quot;Add Customer Record&quot;) window= tk.Tk() window.geometry(&quot;500x...
<python><python-3.x><tkinter>
2023-04-29 16:55:44
3
887
Khilesh Chauhan
76,137,292
16,655,290
Attempting to edit a Sqlite entry with Flask-SqlAlchemy but receive an error
<p>When trying to edit a row, on submit I get this error:</p> <p>sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) Error binding parameter 1: type 'StringField' is not supported [SQL: UPDATE blog_post SET title=?, subtitle=?, body=?, author=?, img_url=? WHERE blog_post.id = ?] [parameters: (&lt;wtforms.fields...
<python><sqlite><flask-sqlalchemy><flask-wtforms>
2023-04-29 16:31:48
1
351
Daikyu
76,137,221
3,166,177
Dask converts list of tuples to list of list from pandas
<p>I recently came across an issue that Dask converts list of tuples to list of listfrom pandas while applying a function on a groupby after converting a Pandas dataframe to Dask dataframe. Below is a small reproducible example:</p> <pre><code>abc = [[(&quot;a&quot;, 1), (&quot;b&quot;, 2)], [(&quot;a&quot;, 1), (&quot...
<python><pandas><dask><dask-dataframe>
2023-04-29 16:17:54
1
352
jsanjayce
76,137,208
9,134,545
Python attrs nested objects convertes
<p>I'm using <code>attrs</code> lib to parse my configuration file, and I'm looking for a better way to parse nested data objects.</p> <p>Example :</p> <pre><code>from attrs import define, field, validators from typing import Dict class HoconParser: @classmethod def from_hocon(cls, file_path): from pyh...
<python><python-attrs>
2023-04-29 16:13:46
1
892
Fragan
76,137,199
10,307,576
Copy and subdivide object without original also being subdivided
<p>I wrote a .py script where I attempt to make two copies of a selected object, one with 1 subdivision and another with 2 subidivions. I ran this script on a plane and it resulted in three planes total, however they all ended up with 3 subdivisions. I think it's because they are all selected during the subdivision cal...
<python><blender>
2023-04-29 16:12:13
1
2,160
Bugbeeb
76,137,008
2,473,022
Python class constructor docstring with __new__ or metaclass
<p><a href="https://stackoverflow.com/questions/37019744/is-there-a-consensus-on-what-should-be-documented-in-the-class-and-init-docs">Previous</a> <a href="https://stackoverflow.com/questions/54189661/docstring-in-class-or-init-constructor">users</a> have asked whether to put the constructor docstring under the <code>...
<python><docstring><pep>
2023-04-29 15:25:16
0
1,664
Moobie
76,137,007
13,119,730
Fast API - Gunicorn vs Uvicorn
<p>Im developing Fast API application which is doing a lot of I/O operations per single request. The request are handled synchronously.</p> <p>Whats the difference between serving the application using:</p> <ul> <li>uvicorn <code>uvicorn main:app --workers 4</code></li> <li>gunicorn - <code>gunicorn main:app --workers ...
<python><fastapi><gunicorn><uvicorn>
2023-04-29 15:24:45
1
387
Jakub Zilinek
76,136,697
7,179,546
Set AppDynamics integration with Python
<p>I'm trying to set up my Python application to send data to AppDynamics. I have the AppDynamics controller up and running and on my local my application works, but no data is found on AppDynamics</p> <p>I've been told to use this repo as a template (and I can confirm it works, sending data to the AppDynamics instance...
<python><dockerfile><appdynamics>
2023-04-29 14:16:27
1
737
Carabes
76,136,612
8,769,985
set axes ticks on double log plot
<p>In a double logarithmic plot with matplotlib, I would like to have axes ticks at given points, and with &quot;standard&quot; label (no scientific notation).</p> <p>This code does not produce the desired output</p> <pre><code>import matplotlib.pyplot as plt plt.errorbar(x = [1, 2, 4, 8, 10], y = [1, 1/2...
<python><matplotlib>
2023-04-29 13:59:46
1
7,617
francesco
76,136,551
1,159,488
How to use Python pwn tools to resolve a side channel case study
<p>I work on class exercice that involves on find a password on a remote server. The goal is to use the Python pwn library.</p> <p>When I access to the server with a <code>nc IP port</code> I have :</p> <blockquote> <p>[0000014075] Initializing the exercice...<br /> [0001678255] Looking for a door...<br /> [0001990325...
<python><reverse-engineering><netcat><pwntools><server-side-attacks>
2023-04-29 13:46:29
0
629
Julien
76,136,494
8,189,936
How to scrape a page that doesn't load unless you click the pagination button
<p>I am trying to scrape a website with Python BeautifulSoup. The website is paginated. The scaping works until page 201. For page 201, the URL returns a 404 if you copy it, and paste it in your browser, and hit enter. However, if you click the pagination button, it loads.</p> <p>How do I handle this kind of scenario?<...
<python><web-scraping><beautifulsoup>
2023-04-29 13:30:33
1
1,631
David Essien
76,136,469
11,065,874
How to allow hyphen (-) in query parameter name using FastAPI?
<p>I have a simple application below:</p> <pre class="lang-py prettyprint-override"><code>from typing import Annotated import uvicorn from fastapi import FastAPI, Query, Depends from pydantic import BaseModel app = FastAPI() class Input(BaseModel): a: Annotated[str, Query(..., alias=&quot;your_name&quot;)] @a...
<python><query-string><fastapi><pydantic>
2023-04-29 13:25:40
1
2,555
Amin Ba
76,136,446
1,124,262
python logging with joblib returns empty
<p>When I try to log to a file from multithreaded loop, I just get empty file.</p> <p>Minimal program to illustrate the issue is following:</p> <pre><code>import logging import time from joblib import Parallel, delayed def worker(index): time.sleep(0.5) logging.info('Hi from myfunc {}'.format(index)) time....
<python><python-logging><joblib>
2023-04-29 13:18:11
1
1,794
Mehmet Fide
76,136,190
7,789,649
is there a way to specify what should be in a list when passed as a parameter?
<p>I am learning python. I have a function:</p> <pre><code>def saveQuotesAndData(self,filename:str, items:list): </code></pre> <p>but I want my VS Code intellisense to know what items[i] will be, so i can write the function with auto complete, and not manually type properties of items[i].</p> <p>for example if I want t...
<python><python-3.x><list><python-typing>
2023-04-29 12:21:45
2
344
Luke
76,136,148
8,849,755
plotly's line_group analog in seaborn
<p>The function <a href="https://plotly.com/python-api-reference/generated/plotly.express.line.html" rel="nofollow noreferrer"><code>plotly.express.line</code></a> has an argument that is <code>line_group</code> which allows to specify one column to determine each individual line. I am looking to replicate this behavio...
<python><plotly><seaborn>
2023-04-29 12:07:52
1
3,245
user171780
76,136,083
63,621
Return value object in FastAPI
<p>I'd like to work with this Python class as a value object that serialises to/from <code>str</code>, with FastAPI:</p> <pre class="lang-py prettyprint-override"><code> class KsuidPrefixed: &quot;&quot;&quot;Class with two fields: a Ksuid and the prefix. Uses the PREFIX_SEPARATOR to separate the prefix from the Ks...
<python><fastapi>
2023-04-29 11:52:57
0
9,985
Henrik
76,135,980
1,228,333
Selenium, after open Chrome signed with my account, the python script doesn't seem getting executed
<p>I'm running a simple script which accesses to a page and clicks on a button, but looks like Selenium loses the focus or kind of. This is happening after I set the option to open the browser (Chrome) being signed with my account (since I need one extension to be available, and logged in)</p> <pre><code>from selenium ...
<python><google-chrome><selenium-webdriver>
2023-04-29 11:30:02
0
3,161
Donovant
76,135,912
12,968,928
How to define a new arithmetic operation in Python
<p>How to define a new arithmetic operation in python</p> <p>Suppose I want to have operator <code>?</code> such that <code>A?B</code> will result in <code>A</code> to power of <code>1/B</code></p> <p>So the statement below would be true</p> <p><code>A?B == A**(1/B)</code></p> <p>for instance in R I can achieve it as f...
<python>
2023-04-29 11:16:18
2
1,511
Macosso
76,135,606
5,542,049
What is the benefit of using curried/currying function in Functional programming?
<p>If you consider <code>inner_multiply</code> as an initializer of <code>multiply</code>, shouldn't you make them loosely coupled and DI the initializer (or any other way) especially if you require multiple initializers? Or am I misunderstanding the basic concept of curried function in FP?</p> <pre><code>def inner_mul...
<python><dependency-injection><functional-programming><solid-principles><currying>
2023-04-29 10:07:03
1
845
Tando
76,135,553
5,719,294
Ansible-Lint warning for custom module argument exception
<p>I have a custom module to manage Keycloak realms. That module takes a long list of arguments including a sub-dictionary for smtp_server:</p> <pre class="lang-py prettyprint-override"><code> def keycloak_argument_spec(): return dict( auth_keycloak_url=dict(type='str', aliases=['url'], required=True), auth_c...
<python><ansible-module><ansible-lint>
2023-04-29 09:50:50
0
1,034
TRW
76,135,497
9,452,512
Manim: Animating row of matrix
<p>I would like to animate a Latex array like this one</p> <pre class="lang-latex prettyprint-override"><code>\begin{matrix} A &amp; B&amp; C \\ A &amp; B&amp; D \\ A &amp; B&amp; F \\ A &amp; KASHDAKSJHD&amp; F \end{matrix} </code></pre> <p>such that manim starts with the first row, transforms it into the second row ...
<python><manim>
2023-04-29 09:34:13
1
1,473
Uwe.Schneider
76,135,304
19,186,611
Celery dockerfile
<p>I'm using Django and celery together in an app(or container) but I want to separate celery in another app(or container). I am not sure how should I do this because my tasks are in the Django app. so how should I set celery parameters in order to access tasks?</p>
<python><django><celery>
2023-04-29 08:47:01
1
433
lornejad
76,135,235
2,998,077
Convert image captured from online MJPG streamer by CV2, to Pillow format
<p>From an image that captured from an online MJPG streamer by CV2, I want to count its colors by Pillow.</p> <p>What I tried:</p> <pre><code>import cv2 from PIL import Image url = &quot;http://link-to-the-online-MJPG-streamer/mjpg/video.mjpg&quot; cap = cv2.VideoCapture(url) ret, original_image = cap.read() img_cv2...
<python><numpy><opencv><image-processing><python-imaging-library>
2023-04-29 08:26:11
1
9,496
Mark K
76,134,772
12,715,723
Tensorflow Keras TypeError: Eager execution of tf.constant with unsupported shape
<p>My goal is to do <code>Conv2d</code> to an array with a custom shape and custom kernel with this code:</p> <pre class="lang-py prettyprint-override"><code>import tensorflow as tf import numpy as np import sys tf.compat.v1.enable_eager_execution() # kernel kernel_array = np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]]) k...
<python><numpy><tensorflow><keras><conv-neural-network>
2023-04-29 06:04:19
1
2,037
Jordy
76,134,758
5,034,651
Docker: issue when using entrypoint+cmd but not when using just cmd
<p>I want to preface this by saying this is not a <a href="https://stackoverflow.com/questions/21553353/what-is-the-difference-between-cmd-and-entrypoint-in-a-dockerfile">general question</a> about the difference between cmd and entrypoint+cmd. I thought I understood the general difference and how to use them but I enc...
<python><docker>
2023-04-29 06:00:23
1
616
Ken Myers
76,134,704
14,581,828
How to connect to the active session of mainframe from Python
<p>How to connect to the active session in mainframe from Python -</p> <pre class="lang-py prettyprint-override"><code>import win32com.client passport = win32com.client.Dispatch(&quot;PASSPORT.Session&quot;) session = passport.ActiveSession if session.connected(): print(&quot;Session active&quot;) else: print...
<python><win32com><mainframe>
2023-04-29 05:44:38
1
551
Sabbha
76,134,340
4,107,349
Including additional data in Django DRF serializer response that doesn't need to be repeated every entry?
<p>Our Django project sends GeoFeatureModelSerializer responses and we want to include an additional value in this response for JS to access. We figured out how to do this in serializers.py:</p> <pre class="lang-py prettyprint-override"><code>from rest_framework_gis import serializers as gis_serializers from rest_frame...
<python><json><django><django-rest-framework><django-rest-framework-gis>
2023-04-29 03:04:01
3
1,148
Chris Dixon
76,134,265
4,175,822
How can I type hint a dictionary where the key is a specific tuple and the value is known?
<p>How can I type hint a dictionary where the key is a specific tuple and the value is known?</p> <p>For example I want to type hint a dict like this:</p> <pre><code>class A: pass class B: pass class_map: = { (str,): A (int,): B } some_cls = class_map[(str,)] </code></pre> <p>The use case will be to ...
<python><python-typing><typeddict>
2023-04-29 02:26:46
1
2,821
spacether
76,134,210
11,065,874
how to create pydantic model with dynamic keys on the nested dictionary?
<p>I have this data structure for which I need to create a pydantic model.</p> <pre><code>a = { &quot;name&quot;: &quot;dummy&quot;, &quot;countries&quot;: { &quot;us&quot;: { &quot;newyork&quot;: { &quot;address&quot;: &quot;dummy address&quot; }, &qu...
<python><pydantic>
2023-04-29 02:05:54
1
2,555
Amin Ba
76,134,147
2,909,897
How do you work around deprecated PRETTYPRINT_REGULAR Flask setting?
<p>The <a href="https://flask.palletsprojects.com/en/2.2.x/changes/#version-2-2-0" rel="nofollow noreferrer"><em>Version 2.2.0</em></a> Flask release notes mention that <em>PRETTYPRINT_REGULAR</em> setting is deprecated; however, there isn't an explanation for what to do instead. The Flask changelog links to <a href="h...
<python><flask>
2023-04-29 01:33:33
1
8,105
mbigras
76,134,060
2,056,201
Getting an Array from Flask to React
<p>I am trying to move this JSON list from Flask to my react app, but I dont understand the complex syntax</p> <p>In Flask I have</p> <pre><code>@app.route('/data') def get_time(): result_t = [] for k in range(1, 6): result_t.append(str(sensor.value)) return jsonify(result_t) </code></pre> <p>I can...
<javascript><python><html><reactjs><flask>
2023-04-29 00:51:28
1
3,706
Mich
76,133,729
12,011,589
Planet not following orbit in Solar System Simulation
<p>I'm trying to simulate a solar system, but the planets don't seem to follow the orbit, instead, the distance between a planet and the sun increases. I can't figure out what's wrong with this code. Here is an MRE.</p> <pre class="lang-py prettyprint-override"><code>import numpy as np import matplotlib.pyplot as plt ...
<python><astronomy><astroquery>
2023-04-28 22:51:28
1
913
O_o
76,133,727
3,943,600
column names are dropped when converting a df from pandas to PySpark
<p>I have a json file in below format.</p> <pre><code>{ &quot;fd&quot;: &quot;Bank Account&quot;, &quot;appVar&quot;: [], &quot;varMode&quot;: &quot;AABH&quot;, &quot;occurred&quot;: [ { &quot;occurredTimes&quot;: 3, &quot;sys&quot;: [ { &quot;varTyp&quot;: &quot;Conf Param&quo...
<python><pandas><dataframe><apache-spark><pyspark>
2023-04-28 22:50:59
1
2,676
codebot
76,133,499
13,231,537
Numpy method to get max value of numpy array for multiple ranges
<p>I want to get the maximum and minimum value from a numpy array over multiple ranges. I found <a href="https://stackoverflow.com/questions/35253716/pythonic-way-for-partwise-max-in-a-numpy-array">this</a> solution for getting only the maximum over multiple ranges when the ranges are uniform. However, my ranges are no...
<python><numpy>
2023-04-28 21:54:31
1
858
nikost
76,133,461
3,324,136
Lambda boto3 python - error - ClientError: An error occurred (404) when calling the HeadObject operation: Not Found
<p>I have a Lambda function <code>Lambda1</code> that runs Transcribe on a file, saves it to an s3 bucket and returns a dictionary (which has the location of the srt file created) that is passed out of one Lambda1 and to Lambda2 as a destination.</p> <p>Lambda2 then is supposed to form a download object so I can then r...
<python><amazon-web-services><amazon-s3><aws-lambda>
2023-04-28 21:42:57
0
417
user3324136
76,133,399
600,360
Python object factory repeats constructor arguments multiple times
<p>In writing a python object factory, I'm running into a <em>lot</em> of parameter repetition in the constructors. It feels wrong, like there is a better way to use this pattern. I'm not sure if I should be replacing the parameters with <code>**kwargs</code> or if there is a different design pattern that is more suite...
<python><oop><design-patterns><factory-pattern>
2023-04-28 21:30:59
2
3,599
Mort
76,133,397
5,583,772
How to get a mean of a list of columns in a polars dataframe
<p>I want to get the average of a list of columns within a polars dataframe, but am getting stuck. For example:</p> <pre><code>df = pl.DataFrame({ 'a':[1,2,3], 'b':[4,5,6], 'c':[7,8,9] }) cols_to_mean = ['a','c'] </code></pre> <p>This works:</p> <pre><code>df.select(pl.col(cols_to_mean)) </code></pre> <p>...
<python><dataframe><python-polars>
2023-04-28 21:30:51
2
556
Paul Fleming
76,133,320
13,629,335
Implementing Tcl bgerror in python
<p>This is a follow up question from <a href="https://stackoverflow.com/q/74732580/13629335">this one</a> where it is suggested to implement the <a href="https://www.tcl.tk/man/tcl/TclCmd/bgerror.html" rel="nofollow noreferrer"><code>bgerror</code></a> to actually get a response to what went wrong in the background. Ho...
<python><tkinter><tcl><tk-toolkit>
2023-04-28 21:15:24
2
8,142
Thingamabobs
76,133,293
19,369,393
What collection to use that is able to track and remove an object from it in constant time in python?
<p>I need a collection of elements the only purpose of which is to store elements for futher enumeration, so the elements don't have to be ordered/indexes in any way. But a simple list is not enough, because I may need to remove any element from the collection, and I need to do it in constant time. <code>deque</code> o...
<python><collections><linked-list>
2023-04-28 21:08:31
2
365
g00dds
76,133,139
19,039,483
Custom Decorator over Dash CallBack
<p>I am trying to understand if it is possible to use dash callback with custom decorators. Basic Dash App:</p> <pre><code>from dash import Dash, html, dcc, callback, Output, Input import plotly.express as px import pandas as pd df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapminder_unfil...
<python><python-3.x><plotly-dash>
2023-04-28 20:39:42
1
315
Thoughtful_monkey
76,133,124
680,268
do not assign default values when creating model from dict in pydantic
<p>I have a pydantic model with optional fields that have default values. I use this model to generate a JSON schema for another tool, so it can know the default values to apply if it chooses to assign a field.</p> <pre><code>class MyModel(BaseModel): my_field: Optional[str] = None my_other_field: Optional[str...
<python><pydantic>
2023-04-28 20:37:12
1
10,382
Stealth Rabbi
76,133,090
8,863,779
HuggingChat API?
<p>I am trying to access HuggingChat using requests in Python but I am getting a response code of 500 for some reason. What I have so far is something like this:</p> <pre><code>hf_url = &quot;https://huggingface.co/chat&quot; resp = session.post(hf_url + f&quot;/conversation/{self.now_conversation}&quot;, json=req_json...
<python><chatbot><huggingface>
2023-04-28 20:31:06
1
1,515
Parth Shah
76,133,040
2,735,009
pool.map() not working on more than 2 CPUs
<p>I have the following piece of code:</p> <pre><code>import sentence_transformers import multiprocessing from tqdm import tqdm from multiprocessing import Pool import numpy as np embedding_model = sentence_transformers.SentenceTransformer('sentence-transformers/all-mpnet-base-v2') data = [[100227, 7382501.0, 'view',...
<python><python-3.x><multithreading><multiprocessing><mapreduce>
2023-04-28 20:21:40
1
4,797
Patthebug
76,132,901
468,455
Python to convert data to a png file
<p>We have an intranet/knowledge base site that has an API. I can use that API to pull assets from the backend. That worked as expected... except... I'm not sure what format the return is in. The file is a png file, and it has the png chunks listed like IHDR but can I just convert this (see below) to base64 and push it...
<python><python-imaging-library><png>
2023-04-28 19:57:06
1
6,396
PruitIgoe
76,132,861
1,418,326
How to get value mapping from sklearn Leave One Out encoder?
<p>I am using the <code>LeaveOneOutEncoder</code> from <a href="https://contrib.scikit-learn.org/category_encoders/leaveoneout.html" rel="nofollow noreferrer">category_encoders</a>. I am able to encode my data.</p> <p>How to get a map of the original value and looe_value pair?</p> <p>Original:</p> <div class="s-table-c...
<python><scikit-learn><leave-one-out>
2023-04-28 19:50:21
0
1,707
topcan5
76,132,667
1,202,863
Consolidating tuples as a dict based on condition
<p>input :</p> <pre><code>x = ( (1,&quot;A&quot;, 10),(1,&quot;B&quot;, 10),(1,&quot;B&quot;, 10),(1,&quot;C&quot;, 10),(1,&quot;C&quot;, 10),(1,&quot;B&quot;, 10),(1,&quot;A&quot;, 10),(1,&quot;A&quot;, 10),(1,&quot;C&quot;, 10),(1,&quot;B&quot;, 10)) </code></pre> <p>Expected Output:</p> <pre><code>{'A': [(1, 'A', 10...
<python><list><dictionary><tuples><generator>
2023-04-28 19:20:26
1
586
Pankaj Singh
76,132,614
8,401,294
Class attributes as dictionary is not reseting on new instance in Python
<p>First example:</p> <pre><code>class StatsCourseBuilder(): test = 0 novoA = StatsCourseBuilder() novoA.test += 1 novoA.test += 1 novoB = StatsCourseBuilder() print(novoB) novoB.test += 1 </code></pre> <p>Second example:</p> <pre><code>class StatsCourseBuilder(): test = {'name' : 0} novoA = StatsCourseBuild...
<python><oop>
2023-04-28 19:12:30
0
365
José Victor
76,132,050
3,380,902
AttributeError: module 'pyspark.dbutils' has no attribute 'fs'
<p><code>AttributeError</code> when attempting to transfer files from <code>dbfs</code> filestore in DataBricks to a local directory.</p> <pre><code>import pyspark.dbutils as pdbutils pdbutils.fs.cp(&quot;/dbfs/Data/file1.csv&quot;, &quot;/Users/Downloads/&quot;) Traceback (most recent call last): File &quot;/datab...
<python><databricks>
2023-04-28 17:43:48
0
2,022
kms
76,132,035
1,212,596
boto3 get_secret_value not working with ARN
<p><a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/secretsmanager/client/get_secret_value.html" rel="nofollow noreferrer">https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/secretsmanager/client/get_secret_value.html</a></p> <blockquote> <p>SecretId (string) –...
<python><amazon-web-services><boto3>
2023-04-28 17:42:14
4
84,149
Paul Draper
76,132,019
5,858,752
Overriding a method definition with a method from another class?
<pre><code>class test: def func(self): print(5) class test1: def testing(self, t): t.func = self.another_func def another_func(self): print(6) t = test() t1 = test1() t1.testing(t) # now t.func() uses test1's another_func and prints 6 t.func() </code></pre> <p>This is a simple example I came up with...
<python><python-class>
2023-04-28 17:39:43
0
699
h8n2
76,131,865
11,653,374
Numerically check the gradient is a linear operator
<p>Given the following two snippets of code, the first one is designed to iterate over each MNIST sample individually, calculate the loss and find the individual gradients. At the end, all the individual gradients are added and divided by the length of the training dataset to calculate the full gradient (batch). In the...
<python><pytorch>
2023-04-28 17:17:27
0
728
Saeed
76,131,842
1,076,493
Python requests module slow due to high number of internal function calls
<p>On one of my machines the Python module <code>requests</code> is extremely slow, seemingly due to a very high number of internal function calls. What could lead to such an issue?</p> <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; import sys, cProfile, requests, urllib3 &gt;&gt;&gt; sys.version '3.10.6 ...
<python><python-requests><.netrc>
2023-04-28 17:14:30
1
10,332
timss
76,131,670
8,942,319
Python, how to ensure object is garbage collected?
<p>I have an api client instance needed for some work. I'll need to run several iterations of this work with a change in target directories each iteration.</p> <p>Simple example. Obviously, the work we're doing is not just printing the client properties.</p> <pre><code>while x &lt; y: SUB_DIR = f&quot;dir_{x}&quot...
<python><azure><garbage-collection><azure-data-lake-gen2>
2023-04-28 16:49:40
1
913
sam
76,131,622
5,091,720
Itsdangerous security - TypeError: unsupported operand type(s) for +: 'int' and 'bytes'
<p>I am using Python 3.9 and itsdangerous 2.1.2. I was testing things in the terminal and it does not appear to be working. This is my first experience with itsdangerous so maybe I don't understand it.</p> <p>I want to get a token that can be emailed for when the user clicks on [forgot password].</p> <p>My code in term...
<python><itsdangerous>
2023-04-28 16:41:22
2
2,363
Shane S
76,131,401
17,176,270
Django form error "this field is required" after HTMX request
<p>I'm using HTMX lib to send the requests with Django. The issue is that after succeed htmx request with <code>project_form</code> swapped <code>project_detail_form</code> comes with &quot;this field is required&quot;. What am I doing wrong?</p> <p>This is my views.py:</p> <pre><code>def index(request): &quot;&quo...
<python><django><python-requests><django-forms><htmx>
2023-04-28 16:09:31
1
780
Vitalii Mytenko
76,131,280
5,252,492
Python Scipy: Force Least Squares to use Positive Integer Values when minimizing
<p>I'm able to create an minimal solution for a weight multiplication problem below using the <code>scipy.optimize.lsq_linear</code>.</p> <pre><code>Actual = [x,y,z] * [i,j,k] Difference = Expected - Actual Difference is sent to the Least Squares Minimizer </code></pre> <p><a href="https://docs.scipy.org/doc/scipy/refe...
<python><scipy><least-squares>
2023-04-28 15:52:59
0
6,145
azazelspeaks
76,131,271
13,391,350
Add blank rows to transposed dataframe
<p>Goal: Insert blank rows in between rows.</p> <pre class="lang-py prettyprint-override"><code>df = pd.DataFrame( { 'revenue_month': ['Jan', 'Feb', 'Mar'], 'new_invoice_net': [1000, 2000, 3000], 'new_accrual': [500, 1000, 1500], 'tax': [100, 200, 300], 'total_new_invoice_gro...
<python><pandas>
2023-04-28 15:52:05
1
747
Luc
76,131,267
7,133,523
numpy seems to produce strange eignvectors
<p>I am doing linear algebra (calculating eignvestors) in python using one of Gilbert Strang's books. In his books the matrix A is given as shown below.</p> <p><a href="https://i.sstatic.net/8iTi7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8iTi7.png" alt="enter image description here" /></a></p> <p>...
<python><numpy><linear-algebra>
2023-04-28 15:51:34
1
319
Johny