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 ⌀ |
|---|---|---|---|---|---|---|---|---|
75,653,285 | 4,817,370 | pytest : is it possible to disable the warnings that originate from a specific directory? | <p>Situation is as follows :</p>
<p>I am redoing all the test suites for my work and there is a LOT of warnings but not all of them I can fix.<br/>
More specifically, the project has dependencies that I cannot interfer with and cannot fix them</p>
<p>Here is an exemple :</p>
<p><code>/venv/lib/python3.9/site-packages/f... | <python><python-3.x><pytest> | 2023-03-06 16:20:31 | 1 | 2,559 | Matthieu Raynaud de Fitte |
75,653,197 | 8,543,025 | Merge "True" chunks in binary array (Binary Closing) | <p>I have a (big) boolean array and I'm looking for a way to fill <code>True</code> where it merges two sequences of <code>True</code> with minimal length.<br />
For example:</p>
<pre><code>a = np.array([True] *3 + [False] + [True] *4 + [False] *2 + [True] *2)
# a == array([ True, True, True, False, True, True, Tr... | <python><python-3.x><binary-image> | 2023-03-06 16:13:43 | 1 | 593 | Jon Nir |
75,653,149 | 8,318,946 | Django - revoke(task_id) in celery does not cancel playwright task | <p>I am trying to write Django command that will cancel existing celery task in my Django application. The idea is to use this command in APIView so user can cancel the task that is already running.</p>
<p>When running <code>python manage.py cancel_task</code> I see in terminal that task was cancelled but the status of... | <python><django><celery> | 2023-03-06 16:09:49 | 0 | 917 | Adrian |
75,653,030 | 605,356 | Python: how to avoid psutil.process_iter() 'AccessDenied' and other misc errors? | <p>In Python, why am I seeing <code>psutil.AccessDenied</code> errors/exceptions when iterating through my processes (which works just fine) and printing their command lines via <code>psutil.cmdline()</code> (which, frustratingly experiences the aforementioned Exception for the exact same process, where <code>psutil.na... | <python><command-line><process><access-denied><psutil> | 2023-03-06 15:57:13 | 1 | 2,498 | Johnny Utahh |
75,653,000 | 2,908,017 | How do I change the cursor of a control in a Python FMX GUI App? | <p>I've created an <a href="https://github.com/Embarcadero/DelphiFMX4Python" rel="nofollow noreferrer">FMX GUI App</a> and I have several components on the form. I'd like to change the default <code>Cursor</code> for them, but I'm not sure how.</p>
<p>I've tried doing the following code to change the <code>Cursor</code... | <python><user-interface><firemonkey><mouse-cursor> | 2023-03-06 15:53:19 | 2 | 4,263 | Shaun Roselt |
75,652,936 | 2,071,807 | How to unit test that a Flask app's routes are protected by authlib's ResourceProtector? | <p>I've got a Flask app with some routes protected by <a href="https://docs.authlib.org/en/latest/flask/2/resource-server.html" rel="nofollow noreferrer">authlib's ResourceProtector</a>.</p>
<p>I want to test that a route I've set up is indeed protected by a <code>authlib.integrations.flask_oauth2.ResourceProtector</co... | <python><flask> | 2023-03-06 15:46:57 | 2 | 79,775 | LondonRob |
75,652,855 | 9,471,909 | Emacs elpy : How to view a list of all (global) variables and class attributes in the current buffer? | <p>I use <code>elpy</code> in <code>emacs</code> for Python development. If I enter the command <code>C-C C-o</code> I'll be able to view all defined functions, classes and methods in the current buffer. But I don't see any of class attributes and defined (global) variables. Is there any way to have this extra informat... | <python><emacs><elpy> | 2023-03-06 15:40:09 | 1 | 1,471 | user17911 |
75,652,730 | 5,641,924 | Best practice to download blobs from Azure container | <p>I have an Azure container with thousands of blobs that each of them saves in a directory <code>id/year/month/day/hour_minute_second/file.json</code>. I want to download all <code>file.json</code> for an <code>id</code> between <code>start_date</code> and <code>end_date</code> in python. For this purpose, I use the <... | <python><azure> | 2023-03-06 15:29:39 | 1 | 642 | Mohammadreza Riahi |
75,652,727 | 346,112 | Python logging configuration like Java log4j | <p>I'm a Java developer who has transitioned to Python 3 development. I need to configure logging in my Python application, and I'd like to do it in a similar way to how I configured log4j in Java. Ideally I want my Python logging configuration file to be in YAML format. How do I do this?</p>
| <python><python-3.x><logging><configuration><log4j> | 2023-03-06 15:29:08 | 1 | 15,278 | Jim Tough |
75,652,720 | 7,179,546 | How to transform a list of lists in Python into a dictionary | <p>I have in Python an structure like this one</p>
<pre><code>example = {
['g': 'h'],
[
{'a':'b'}, {'c': 'd'},
{'a':'b'}, {'e', 'f'}
]
}
</code></pre>
<p>I want to create a dictionary that represents the information of this list considering it a graph in the sense that the info goes from le... | <python><dictionary><graph> | 2023-03-06 15:28:09 | 1 | 737 | Carabes |
75,652,633 | 11,992,601 | A phenomenon in which the cycle of a function is delayed when an error occurs in multiple infinite loop functions executed with python asyncio | <p>like the following code, I put several infinite loop asynchronous functions in one loop and run them.</p>
<pre><code>loop = asyncio.get_event_loop()
try:
loop.run_until_complete(
asyncio.gather(
get_exchange_rate(),
data_input(),
return_exceptions=T... | <python><python-asyncio><coroutine> | 2023-03-06 15:21:14 | 0 | 567 | 윤태일 |
75,652,476 | 8,845,766 | why is the output of make_password different than expected? | <p>Sorry if this is a dumb question, but I'm new to django here. I'm creating a signup flow, one that needs the users email id and password to create the user. I'm trying to hash and salt the password, before saving the salted password in the db, along with the email.</p>
<p>I'm using django's default <code>make_passwo... | <python><django> | 2023-03-06 15:07:30 | 1 | 794 | U. Watt |
75,652,474 | 2,725,103 | Python: replace a pattern in a df column with another pattern | <p>I have a dataframe as per the below:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
columns=['deal','details'],
data=[
['deal1', 'MH92h'],
['deal2', 'L97h'],
['deal3', '97.538'],
['deal4', 'LM98h'],
['deal5', 'TRD (97.612 cvr)'],
]
... | <python><pandas><regex> | 2023-03-06 15:07:22 | 1 | 1,069 | Mike |
75,652,460 | 3,914,746 | Python Sum Scores from CSV | <p>I am creating a program that is supposed to read data in a file called "Diving.csv". Each line in the file has a set of scores for each contestant in a diving competition. The program needs to find and display the highest and lowest score for each contestant. It should then find the final score for each c... | <python> | 2023-03-06 15:06:07 | 1 | 1,155 | Hexana |
75,652,326 | 2,532,203 | Celery: Spawn "sidecar" webserver process | <p>I'm trying to collect metrics from my Celery workers, which seemed simply enough, but turns out to be utterly, ridiculously hard. After lots of approaches, I'm now trying to spawn an additional process next to the Celery worker/supervisor that hosts a simple HTTP server to expose Prometheus metrics.<br />
To make th... | <python><celery><python-multiprocessing> | 2023-03-06 14:54:26 | 2 | 1,501 | Moritz Friedrich |
75,652,281 | 11,703,015 | Store a edited dataframe | <p>I am importing data from an excel file (.xls) as a DataFrame. Once the DataFrame has been imported, I manipulate it, modifying several fields and columns. For the following steps, I would like to use the modified DataFrame and not work from the beginning with the excel file.</p>
<p>How could I store the DataFrame, s... | <python><pandas><dataframe><import> | 2023-03-06 14:50:50 | 1 | 516 | nekovolta |
75,652,274 | 2,908,017 | How do I make an Edit that only accepts numbers in a Python FMX GUI App? | <p>I have a <a href="https://github.com/Embarcadero/DelphiFMX4Python" rel="nofollow noreferrer">Python FMX GUI App</a> with an <code>Edit</code>control that I want to only accept integer values with. In the past, I've done this kind of validation by overloading the KeyPress event and just removing characters that didn'... | <python><user-interface><firemonkey> | 2023-03-06 14:50:14 | 1 | 4,263 | Shaun Roselt |
75,652,221 | 2,163,392 | Find countours on a dark background | <p>Suppose, I have a dark image on a white background. For example, the image below:</p>
<p><a href="https://i.sstatic.net/CxHCc.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CxHCc.jpg" alt="enter image description here" /></a></p>
<p>With the code below, I can easily extract its countors</p>
<pre><cod... | <python><opencv><image-processing><computer-vision> | 2023-03-06 14:46:13 | 2 | 2,799 | mad |
75,652,083 | 13,742,058 | how to design a class with complicated data type which includes multiple list and dictionaries in python? | <p>I have a complicated data type in which I would like to create a class but I do not know how to design it, please help and see example data below, thank you.</p>
<pre><code>"""
complicated_data_sample1 = {
name: "test_name"
description:"test_description",
type:"test_type"... | <python><list><dictionary><class><inner-classes> | 2023-03-06 14:30:41 | 1 | 308 | fardV |
75,652,018 | 577,669 | How to annotate a dataclass to have a return value based on the initialized value? | <p>I have the following (stripped down) dataclass:</p>
<pre class="lang-py prettyprint-override"><code>from dataclasses import dataclass
from typing import Union, Type
class BaseType: ...
class PathType(BaseType): ...
class DataType(BaseType): ...
_FinalTypes = Union[PathType, DataType]
@dataclass
class InterfaceInf... | <python><python-typing> | 2023-03-06 14:25:21 | 1 | 1,069 | Steven Van Ingelgem |
75,651,703 | 468,334 | Get the (C) size of a (C) type in a Python extension | <p>I'm writing a C extension for Python and need to pass the size of a C type to the compilation. So I'll want to do</p>
<pre class="lang-py prettyprint-override"><code>extra_compile_args = ['-DSIZEOF_MYTYPE=32']
</code></pre>
<p>in my <code>setup.py</code>. My question is: how can I get the size? (32 here)</p>
<p>If ... | <python><setup.py><python-extensions> | 2023-03-06 13:55:13 | 0 | 1,120 | jjg |
75,651,587 | 12,546,311 | How to subtract one row pandas series from a multi-row pandas series? | <p>I have a pandas dataframe with 962 columns</p>
<pre><code>print(df)
ID doy WaitID Year ... 212
386 1895 193 14507 2001 ... 0.407672
389 1899 192 14511 2001 ... 0.000000
390 1900 204 14512 2001 ... 0.000000
391 1902 145 14514 2001 ... 2.251606
395 1877 204 ... | <python><pandas><dataframe><subtraction> | 2023-03-06 13:42:44 | 2 | 501 | Thomas |
75,651,425 | 18,579,739 | why catch a TimeExpired exception in python subprocess lose stdout? | <p>app.py</p>
<pre><code>import subprocess
import time
if __name__ == '__main__':
outs = ''
p = subprocess.Popen(['python3', 'app2.py'], stdout=subprocess.PIPE,
text=True)
try:
p.communicate(timeout=3)
except subprocess.TimeoutExpired:
p.kill()
... | <python><subprocess><popen> | 2023-03-06 13:25:49 | 0 | 396 | shan |
75,651,353 | 15,904,492 | Pyomo: Iterative model to reach a known value for a given variable | <p>I am new to Pyomo and I am trying to build a simple model.
It takes only one variable with known initial and final values. The solver needs to modify the value of the vafriable to reach its final value while minimizing the change between each timestep.</p>
<p>However when I run my optimization the value of my variab... | <python><optimization><pyomo> | 2023-03-06 13:18:50 | 0 | 729 | zanga |
75,651,326 | 8,182,504 | Python function minimization not changing optimization variables | <p>I need to minimize a simple function that divides two values. The optimization paramter <code>x</code> is a <code>(n,m)</code> numpy array from which I calculate a float.</p>
<pre><code># An initial value
normX0 = calculate_normX(x_start)
def objective(x) -> float:
"""Objective function "... | <python><optimization><scipy-optimize-minimize><jax> | 2023-03-06 13:16:33 | 1 | 1,324 | agentsmith |
75,651,325 | 6,357,916 | Considering numpy matrix row independent of other rows while performing softmax computation | <p>This is rather noob question. I am trying to code the neural network from scratch.
This is how I have wrote the softmax function:</p>
<pre><code>def softmax(x):
e_x = np.exp(x - np.max(x))
return e_x / e_x.sum()
</code></pre>
<p>Then I created a dummy weights matrix:</p>
<pre><code>w0 = np.random.uniform(-0... | <python><numpy><multidimensional-array><numpy-ndarray><array-broadcasting> | 2023-03-06 13:16:29 | 1 | 3,029 | MsA |
75,651,233 | 5,134,285 | Managing AppRoles using Azure SDK for python, or Microsoft Graph API | <p>I am lost in my searches, and cannot find any specific documentation regarding creating/Deleting,... App Roles.</p>
<p>My aim is to create an App Roles, preferably using python, here is my code</p>
<pre><code>import requests
from msal import ConfidentialClientApplication
# Define the Azure AD credentials and API en... | <python><azure><azure-active-directory><azure-sdk><azure-sdk-python> | 2023-03-06 13:06:16 | 1 | 1,404 | GeoCom |
75,651,183 | 15,452,168 | error in Huber regressor sklearn Error: The 'max_iter' parameter of HuberRegressor must be an int | <p>I am running a forecasting algorithm and suddenly today my algorithm is throwing an error</p>
<pre><code>sklearn.utils._param_validation.InvalidParameterError: The 'max_iter' parameter of HuberRegressor must be an int in the range [0, inf). Got 279170.46874829195 instead.
</code></pre>
<p>I have no idea what went w... | <python><scikit-learn><regression><linear-regression><forecasting> | 2023-03-06 13:00:51 | 1 | 570 | sdave |
75,651,079 | 1,014,747 | Is it wise to have if logic inside a python catch block? | <p>Consider the following method that checks if a parameter contains a valid UUID string and generates a new one if it isn't and if the option is set:</p>
<pre><code>def validate_uuid(val, generate):
try:
uuid.UUID(str(val))
return val
except ValueError:
if generate:
return s... | <python><try-catch><catch-block> | 2023-03-06 12:51:04 | 1 | 603 | b0neval |
75,650,973 | 10,450,923 | msgraph client to communicate with OneDrive | <p>How to properly use msgraph-sdk and does it even work as expected?</p>
<pre><code>import asyncio
from azure.identity.aio import EnvironmentCredential
from kiota_authentication_azure.azure_identity_authentication_provider import AzureIdentityAuthenticationProvider
from msgraph import GraphRequestAdapter
from msgraph ... | <python><microsoft-graph-api> | 2023-03-06 12:40:46 | 0 | 371 | Rostislav Aleev |
75,650,953 | 13,854,431 | group_by id and timestamp (timestamp threshold 45 minutes) in polars | <p>I have a polars dataframe with a 'col1' column and a 'col2' column.
Now I want to groupby the two columns and to create a new column. I have the following example data:</p>
<pre><code>data = {
"col1": [1, 1, 1,1,1,1,1,1,1,1,1,1, 2, 2,2,2,2,2,2,2,2,2,2],
"col2": [
"2022-05-25T... | <python><group-by><python-polars> | 2023-03-06 12:38:54 | 1 | 457 | Herwini |
75,650,950 | 15,042,008 | Generate equation for one variable in terms of others | <p>I have a particular data set where there are 3 different functions with 3 different variables:</p>
<pre><code>x = 1
strLen_x = int(3**x + 0.25*(-3*(-1)**x + 3**x + 6)) # Function 1
y = 2
strLen_y = 2*y # Function 2
z = 3
strLen_z = 3*(z + 1 + (z//4)) # Function 3
# Expecting Function 4 in terms of 1, 2, and 3
</code... | <python><python-3.x><function><math><sequence> | 2023-03-06 12:38:39 | 1 | 1,219 | The Myth |
75,650,925 | 12,976,010 | How is that pandas is faster than pure C in the groupby operation? | <p>I have an nparray of <em>x,y</em> pairs with shape <code>(n,2)</code>, and knowing for certain that for each <em>x</em> there are multiple values of <em>y</em> , I wanted to calculate the average value of <em>y</em> for each unique <em>x</em>. It occurred to me that this needed a <code>groupby</code> operation follo... | <python><c><pandas><performance><ctypes> | 2023-03-06 12:35:33 | 1 | 838 | ARK1375 |
75,650,879 | 4,373,805 | Pivot a column to multiple columns based on regex pattern | <p>There are 33 columns in my dataframe -</p>
<p><code>Description_1_1, Description_2_1, Description_3_1,Description_1_2, Description_2_2, Description_3_2</code> etc.</p>
<p>I need to make 11 columns based out a pattern -
First word should be description and it should end with a number</p>
<pre><code>Description_1
Desc... | <python><pandas> | 2023-03-06 12:31:04 | 1 | 468 | Ezio |
75,650,841 | 15,800,270 | How to train or fine-tune GPT-2 / GPT-J model for generative question answering? | <p>I am new at using Huggingface models. Though I have some basic understanding of its Model, Tokenizers and Training.</p>
<p>I am looking for a way to leverage the generative models like GPT-2, and GPT-J from the Huggingface community and tune them for the question <strong>Closed Generative question answering</strong>... | <python><machine-learning><nlp><huggingface-transformers><gpt-2> | 2023-03-06 12:27:08 | 1 | 610 | Aayush Shah |
75,650,572 | 5,342,009 | Stripe Subscription adding same card twice | <p>I have implemented Stripe Subscription with the following steps :</p>
<ol>
<li><p>Add card via Stripe Elements using stripe.PaymentMethod.attach :</p>
<pre><code> stripe_customer = stripe.Customer.retrieve(str(customer.stripe_customer_id))
payment_methods_list = stripe.PaymentMethod.list(custo... | <python><django><stripe-payments> | 2023-03-06 11:56:14 | 0 | 1,312 | london_utku |
75,650,569 | 5,270,403 | Unittesting DRF Serializer validators one by one | <p>We have an example Serializer class we'd like to test:</p>
<pre><code>from rest_framework import serializers
class MySerializer(serializers.Serializer):
fieldA = serializers.CharField()
fieldB = serializers.CharField()
def validate_fieldA(self,AVal):
if len(AVal) < 3:
raise seriali... | <python><django><rest> | 2023-03-06 11:55:51 | 1 | 1,031 | AlanKalane |
75,650,507 | 16,389,095 | Kivy MD: How to get the selected item from an uix.list / OneLineAvatarIconListItem | <p>I'm quite new in Kivy. I developed a simple UI in Python/KivyMD. It displays a list of items: each of them has a checkbox that allows the user to select that item. The object that displays this list is inherited from <em>kivymd.uix.list</em>. I would like to get the selected item/items of this list. Here is the code... | <python><user-interface><kivy><kivy-language><kivymd> | 2023-03-06 11:49:11 | 1 | 421 | eljamba |
75,649,960 | 4,432,671 | How do I compare arbitrarily nested numpy ndarrays? | <p>Leaving aside if this is a good idea or not, how can I compare two nested arrays in numpy?</p>
<pre><code>>>> a
array([[array([0, 0]), array([0, 1])],
[array([1, 0]), array([1, 1])]], dtype=object)
>>> b
array([[array([0, 0]), array([0, 1])],
[array([1, 0]), array([1, 1])]], dtype=ob... | <python><numpy> | 2023-03-06 10:56:26 | 0 | 3,737 | xpqz |
75,649,944 | 7,568,316 | Regex find until word of end of block | <p>I'm analyzing router logs and found a solution to find blocks of text, but now I'm facing a problem that the end of the text block might not be present. I'll explain.
This is a sample of a stripped log.</p>
<pre><code>POBL026# show run vpn 0
interface ge0/4
no shutdown
!
interface ge0/4.1
description "TLO... | <python><regex> | 2023-03-06 10:55:33 | 1 | 755 | Harry Leboeuf |
75,649,848 | 2,592,835 | predicting data bug with keras | <p>Hi im trying to build a model in keras that can predict some data based on training values.
I've seen this work succesfully all over the internet but my example code doesn't work:</p>
<pre><code>from keras.models import Sequential
from keras.layers import Dense, Activation
import numpy as np
model = Sequential()
m... | <python><keras><deep-learning> | 2023-03-06 10:45:16 | 1 | 1,627 | willmac |
75,649,804 | 8,713,442 | Create dictionary of each row in polars Dataframe | <p>Lets assume we have below given dataframe. Now for each row I need to create dictionary and pass it to UDF for some logic processing.Is there a way to achieve this using either polars or pyspark dataframe ?</p>
<p><a href="https://i.sstatic.net/OuLTu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/OuL... | <python><apache-spark><python-polars> | 2023-03-06 10:41:33 | 2 | 464 | pbh |
75,649,695 | 584,239 | how to make collectd python plugin to use python3 instead of python2 to execute the script | <p>I have enable python collectd plugin. My python script requires python3 syntax. When the script executes it is using python2.7 hence my script fails. How can I force the plugin to use python3 instead of python2.</p>
| <python><collectd> | 2023-03-06 10:29:27 | 1 | 9,691 | kumar |
75,649,542 | 11,251,938 | colormap not returning the expected color for value | <p>I'm experiencing some problems with matplotlib colormap.
I've set up this example code to reproduce my problem.</p>
<pre><code>%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib import style
from matplotlib import colors
import pandas as pd
import numpy as np
st... | <python><matplotlib><colormap> | 2023-03-06 10:15:38 | 1 | 929 | Zeno Dalla Valle |
75,649,540 | 12,932,447 | Pydantic root_validator unexpected behaviour | <p>I have a file <code>test.py</code> like this:</p>
<pre class="lang-py prettyprint-override"><code>from pydantic import root_validator
from sqlmodel import SQLModel
from typing import List
from devtools import debug
class Base(SQLModel):
@root_validator(pre=True)
def validate(cls, values):
debug(va... | <python><validation><pydantic><sqlmodel> | 2023-03-06 10:15:32 | 1 | 875 | ychiucco |
75,649,406 | 14,555,505 | Matplotlib plot one line, multiple colours, *multiple* segments | <p>Let's say I had some random time-series data:</p>
<pre class="lang-py prettyprint-override"><code>y = np.random.random(100) - 0.5
x = np.array(range(len(y)))
plt.plot(
x,
y
)
</code></pre>
<p><a href="https://i.sstatic.net/ETgMx.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ETgMx.png" alt="1... | <python><matplotlib><plot> | 2023-03-06 10:00:27 | 2 | 1,163 | beyarkay |
75,649,339 | 19,920,392 | Sending form data from react to flask server | <p>I am trying to submit a form and send the form data to a flask server from React.
It seems like POST is working fine. However, when I try to access to the form in the flask server, it returns <code>ImmutableMultiDict([])</code>.</p>
<p>Here are my codes:<br />
<strong>register.js</strong></p>
<pre><code>async functi... | <javascript><python><flask> | 2023-03-06 09:54:09 | 2 | 327 | gtj520 |
75,649,286 | 11,572,712 | Ariadne-GraphQL - ModuleNotFoundError: No module named 'graphql.pyutils.undefined' | <p>I am trying to import several libraries:</p>
<pre><code>from ariadne import load_schema_from_path, make_executable_schema, \
graphql_sync, snake_case_fallback_resolvers, ObjectType
</code></pre>
<p>But when running this I get this Error:</p>
<pre><code>ModuleNotFoundError: No module named 'graphql.pyutils.undefi... | <python><flask><graphql><ariadne-graphql> | 2023-03-06 09:46:44 | 2 | 1,508 | Tobitor |
75,649,130 | 5,423,080 | Get minimum of SortedKeyList with a condition on an object attribute | <p>I have a <code>SortedKeyList</code> of objects sorted by timestamp, the objects also have another attribute, the ID.</p>
<p>I was trying to get the earliest element of the list based on the ID.</p>
<p>This is a code example:</p>
<pre><code>import numpy as np
import sortedcontainers
class Point:
def __init__(sel... | <python><python-3.x><numpy><sortedcontainers> | 2023-03-06 09:31:43 | 2 | 412 | cicciodevoto |
75,649,108 | 7,118,663 | How can I translate a curl command to Python request? | <p>Following <a href="https://shopify.dev/docs/apps/online-store/media/products#images-post-request" rel="nofollow noreferrer">this Shopify tutorial</a>, I'm trying to upload an image to Shopify. A subtask is to translate this curl command to a python request. The file is uploaded by users and I pass the file variable ... | <python><django><curl><shopify><shopify-api> | 2023-03-06 09:30:00 | 2 | 932 | Benny Chan |
75,649,103 | 5,675,325 | Override test settings from a file | <p>For context, when one wants to change settings in a test (<a href="https://stackoverflow.com/q/48042132/5675325">yes, it's ok to change it there</a>), we can use <a href="https://docs.djangoproject.com/en/4.1/topics/testing/tools/#django.test.override_settings" rel="nofollow noreferrer">override_settings()</a> or <a... | <python><django><django-testing><django-settings> | 2023-03-06 09:29:25 | 1 | 15,859 | Tiago Peres |
75,649,082 | 616,349 | "invalid server address" when connecting to LDAP server with ldap3 | <p>I have the following python code that connects to our LDAP servers (multiple LDAP servers behind a load balancer).</p>
<pre class="lang-py prettyprint-override"><code>ldap_server = Server(host=LDAP_server_IP, port=636, use_ssl=True, get_info=ALL)
</code></pre>
<p>It keeps on failing with the following error message:... | <python><python-3.x><ssl><ldap> | 2023-03-06 09:28:16 | 1 | 2,195 | E. Jaep |
75,649,038 | 7,327,257 | Training difference between LightGBM API and Sklearn API | <p>I'm trying to train a LGBClassifier for multiclass task. I tried first working directly with LightGBM API and set the model and training as follows:</p>
<p><strong>LightGBM API</strong></p>
<pre><code>train_data = lgb.Dataset(X_train, (y_train-1))
test_data = lgb.Dataset(X_test, (y_test-1))
params = {}
params['learn... | <python><machine-learning><scikit-learn><multiclass-classification><lightgbm> | 2023-03-06 09:24:30 | 3 | 357 | M. Merida-Floriano |
75,649,009 | 11,017,797 | Cannot build sphinx autodocumentation with Django via GitLab (docker) pipeline | <p>this problem might be quite specific.</p>
<h3>My setup</h3>
<p>This is my project structure. It's a Django project.</p>
<pre><code>├── docs
│ ├── build
│ │ ├── doctrees
│ │ └── html
│ ├── Makefile
│ └── source
│ ├── code
│ ├── conf.py
│ ├── contributing.md
│ ├── index.rst
│ ... | <python><django><gitlab><python-sphinx><gitlab-ci-runner> | 2023-03-06 09:20:24 | 1 | 324 | kerfuffle |
75,648,889 | 15,112,321 | tf keras autokeras with early stopping returns empty history | <p>I am trying different models for the same dataset, being autokeras.ImageClassifier one of them.
First I go for</p>
<pre><code>img_size = (100,120,3)
train_dataset = get_dataset(x_train, y_train, img_size[:-1], 128)
valid_dataset = get_dataset(x_valid, y_valid, img_size[:-1], 128)
test_dataset = get_dataset(x_test, y... | <python><tensorflow><keras><early-stopping><auto-keras> | 2023-03-06 09:07:38 | 1 | 305 | Videgain |
75,648,660 | 16,971,617 | Counting unique pixel value of an image | <p>I would like to count the number of unique pixel values and filter out those number more than a threshold and save it in a dict.</p>
<pre class="lang-py prettyprint-override"><code># Assume an image is read as a numpy array
np.random.seed(seed=777)
s = np.random.randint(low=0, high = 255, size=(100, 100, 3))
print(s... | <python><numpy> | 2023-03-06 08:40:56 | 3 | 539 | user16971617 |
75,648,656 | 12,579,308 | Getting upper case keyboard entries from OpenCV HighGUI in Linux Environment and Python? | <p>I'm currently working on a project that involves OpenCV HighGUI for reading and displaying images in a Linux environment. I need to be able to capture keyboard entries, including upper case letters, from the user while running the HighGUI window.</p>
<p>As an example, I like to get ASCII of 'A'(i.e 65) but I always ... | <python><opencv> | 2023-03-06 08:40:40 | 0 | 341 | Oguz Hanoglu |
75,648,441 | 15,222,211 | Python CiscoConfParse. How to get full block by command in middle? | <p>I need to get full config of block by some command in middle.
In the following example, I got an incomplete block where more indented children 'ip 10.2.2.1' were missing.</p>
<pre><code>from ciscoconfparse import CiscoConfParse
from pprint import pprint
config = """
hostname switch
interface Vlan2
... | <python><cisco><ciscoconfparse> | 2023-03-06 08:12:52 | 2 | 814 | pyjedy |
75,648,372 | 17,124,619 | SQL concurrency overflows for larger tables | <p>I have a simple concurrency script that uses Oracle for the main database. I'm listening into SQL with <code>python-oracledb</code> and have used individual threads to open up a database connection. However, I have recognised that this is very slow by comparison for larger tables. For example, for table with a table... | <python><sql><oracle-database><multithreading><python-oracledb> | 2023-03-06 08:04:31 | 2 | 309 | Emil11 |
75,648,347 | 13,647,125 | Finding minimum iterative | <pre><code>sales_data = {
'order_number': [1001, 1002, 1003, 1004, 1005],
'order_date': ['2022-02-01', '2022-02-03', '2022-02-07', '2022-02-10', '2022-02-14']
}
sales_data = pd.DataFrame(sales_data)
capacity_data = {
'date': pd.date_range(start='2022-02-01', end='2022-02-28', freq='D'),
'capacity': [0... | <python><loops><optimization> | 2023-03-06 08:01:02 | 2 | 755 | onhalu |
75,648,232 | 17,267,064 | Is there a method of reading a Google Sheet via Python without having to share sheet to service account? | <p>I am new to using Google Cloud Platform and its Developer Console. Here, I am working on a project wherein I have to automate data transfer from google sheets to SQL Server daily using Task Scheduler. Here, I came across an approach which requires me to share Google Sheet to a service account to read data from it in... | <python><google-sheets><gspread> | 2023-03-06 07:44:19 | 1 | 346 | Mohit Aswani |
75,648,221 | 19,106,705 | Upsampling 4d tensor in pytorch | <p>I created a 4D tensor of the following size. (B, C, H, W)</p>
<p>And I want to reshape this tensor to the following size. (B, C, 2H, 2W)</p>
<p>Each value expands into 4 values, but only the elements in the original tensor that have an index corresponding to a value in the index tensor remain identical to the origin... | <python><pytorch><tensor> | 2023-03-06 07:42:16 | 1 | 870 | core_not_dumped |
75,648,159 | 4,473,615 | raise KeyError(key) KeyError: python matplotlib bar chart key error | <p>I have below data frame, on which am creating a chart:</p>
<p><a href="https://i.sstatic.net/aaoja.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/aaoja.png" alt="enter image description here" /></a></p>
<p>The expectation is to create as below which is in Excel:</p>
<p><a href="https://i.sstatic.net/... | <python><pandas><matplotlib> | 2023-03-06 07:34:24 | 1 | 5,241 | Jim Macaulay |
75,648,150 | 3,735,871 | Pyspark- how to reformat column names from schema description | <p>I'm trying to get the column names of a table and only extract the last part after <code>_</code> For example for column name <code>a_col_name1</code>, I'd like to keep <code>name1</code></p>
<p>Below is the code I tried, and the part doesn't work. Could someone please help with this? Please let me know if I could e... | <python><string><list><apache-spark><pyspark> | 2023-03-06 07:32:45 | 1 | 367 | user3735871 |
75,648,132 | 139,150 | OpenAI GPT-3 API: Why do I get only partial completion? Why is the completion cut off? | <p>I tried the following code but got only partial results like</p>
<pre><code>[{"light_id": 0, "color
</code></pre>
<p>I was expecting the full JSON as suggested on this page:</p>
<p><a href="https://medium.com/@richardhayes777/using-chatgpt-to-control-hue-lights-37729959d94f" rel="nofollow noreferrer">... | <python><openai-api><gpt-3> | 2023-03-06 07:29:41 | 2 | 32,554 | shantanuo |
75,648,108 | 1,635,523 | QCheckBox stateChanged not triggered reliably | <p>Here is a Qt riddle: PythonQt. Win10. Within Slicer 3d (I am hoping, that this is not the issue).</p>
<ul>
<li>Defined a QCheckBox in the QtDesigner.</li>
<li>Said: <code>ui.checkBox.connect('stateChanged(int)', _on_checkBox)</code></li>
</ul>
<p>The callback:</p>
<pre class="lang-py prettyprint-override"><code>def ... | <python><qt> | 2023-03-06 07:26:54 | 1 | 1,061 | Markus-Hermann |
75,648,044 | 2,827,181 | I would like to use list[int] parameters for input and output, and for internal variable of a function. But I cannot declare them as Python hints | <p>While many examples succeed in using hints to describe the items carried by a list, I'm stumbling in their declarations.</p>
<p>I'm willing to manipulate (receive, return, create internally) lists of integers.<br />
Accordingly, I'm using <code>list[int]</code> to mention them.</p>
<p>But my code fails with the mess... | <python><arrays><type-hinting> | 2023-03-06 07:18:11 | 1 | 3,561 | Marc Le Bihan |
75,647,830 | 9,798,210 | How to download the folders from gcs bucket to local using python? | <p>I have a model and other folders in the gcs bucket where I need to download into my local. I have the service account of that gcs bucket as well.</p>
<p><strong>gs bucket: gs://test_bucket/11100/e324vn241c9e4c4/artifacts</strong></p>
<p>Below is the code I am using to download the folder</p>
<pre><code>from google.c... | <python><google-cloud-platform><google-bucket> | 2023-03-06 06:50:30 | 1 | 1,835 | merkle |
75,647,682 | 15,260,108 | How can i resolve flake8 "unused import" error for pytest fixture imported from another module | <p>I wrote pytest fixture in fixtures.py file and using it in my main_test.py . But I am getting this error in flake8: <strong>F401 'utils_test.backup_path' imported but unused</strong> for this code:</p>
<pre><code>@pytest.fixture
def backup_path():
...
</code></pre>
<pre><code>from fixtures import backup_path
d... | <python><pytest><flake8> | 2023-03-06 06:30:11 | 1 | 400 | Diyorbek |
75,647,669 | 584,239 | In amazon linux 2 how to set defalut python to python 3 | <p>In Amazon linx 2 currently command <code>python</code> points to python2. How do I set so that for all profile and command uses python3 when python command is called?
Currently i am editing <code>~/.bashrc</code> and adding <code>alias python=python3</code>. But I what it to be default across the system.</p>
| <python><python-3.x><amazon-ec2> | 2023-03-06 06:28:15 | 1 | 9,691 | kumar |
75,647,581 | 5,405,813 | Reading 7 segment digits of weighing controller | <p>i am trying to read the 7-segment display of a industrial weighing machine. as there is no serial out port for the machine i have to note down the weight manually. the idea is to use python-computer vision to capture the weight and store it in text file. the image is as shown <a href="https://i.sstatic.net/Cf8ko.jpg... | <python><opencv> | 2023-03-06 06:16:08 | 1 | 455 | bipin_s |
75,647,442 | 1,080,517 | Firestore collection documents accessible directly but not with stream() | <p>I am using simple <code>Firestore</code> database with chats collection inside which each chat document has collection of message documents. If I want to access specific message I can do following request</p>
<pre><code>msg_ref = self.db.collection('chats').document(chat_id).collection('messages').document(msg_id)
<... | <python><google-cloud-firestore> | 2023-03-06 05:51:10 | 1 | 2,713 | sebap123 |
75,647,409 | 3,682,549 | Extracting info from customer requests using python regex | <p>I have customer request log data as below: (showing one request as an example</p>
<pre><code>req=['"Software not available on Software Center, when tried to raise AHO for required software it opens Software Center with error as 'This Software is not available for you'... | <python><regex> | 2023-03-06 05:44:40 | 2 | 1,121 | Nishant |
75,647,387 | 1,652,954 | How to set max number of concurrent files to be opened for parallelized operations in .py file | <p>in the .py file, it contains flask webservices and that .py file contains mutltiple parallelized code. so, each time i want to run the .py file using the commnds mentioned in the code section mentioned below, i have to spcify the number of the concurrent opened files
via the following command:</p>
<pre><code>ulimit ... | <python><flask> | 2023-03-06 05:41:07 | 1 | 11,564 | Amrmsmb |
75,647,373 | 16,971,617 | Replace a pixel value in an image (numpy) to the closest color in a dict | <p>I have an image with 4 channels rgba but I only want to compute the difference of rgb of each pixel and replace it with the closest color in a dict.</p>
<pre><code>myMap = {
'a': ([255, 27, 255, 255]),
'b': ([255, 255, 27, 255]),
'c': ([255, 27, 27, 255]),
}
</code></pre>
<p>Let this be my array,</p>
<pr... | <python><numpy><opencv><optimization> | 2023-03-06 05:38:34 | 1 | 539 | user16971617 |
75,647,325 | 5,252,492 | Neural Network: Detect multiple digits from an image | <p>I have a neural network that detects single digits from an image of a 6 digit display (A digital clock with hours, minutes and seconds).</p>
<p>I've trained it on a picture database of 10k images of the clock (tagged with eg- 14:45:02 corresponding to the clock) using most of the techniques mentioned in this youtube... | <python><opencv><image-processing><neural-network> | 2023-03-06 05:27:32 | 1 | 6,145 | azazelspeaks |
75,647,305 | 7,585,973 | Can we convert from text to existing header and URL that available in search engine using pandas | <p>Here's my input</p>
<pre><code>app
fix
jd_id
zalora
leomaster
</code></pre>
<p>Here's my expected output</p>
<pre><code>app header url
fix Fix.com | Your Source for Genuine Parts & DIY Repair Help https://www.fix.com/
jd_id ... | <python><pandas><dataframe><automation><google-api> | 2023-03-06 05:23:27 | 1 | 7,445 | Nabih Bawazir |
75,647,177 | 15,247,669 | django rest framework giving psycopg2 Error | <p>End developers, I am a FE dev having trouble with setting up BE. I need to connect django project with my FE which uses React.js. I have installed all the required stuff and finally when I ran <code>make runserver</code>, it's giving me this error</p>
<pre><code>raise ImproperlyConfigured("Error loading psycopg... | <python><django><postgresql><psycopg2> | 2023-03-06 04:56:36 | 2 | 744 | Nyi Nyi Hmue Aung |
75,646,773 | 3,575,018 | Preserving long single line string as is when round-triping in ruamel | <p>In the below code, I'm trying to write a load and write a YAML string back to ensure that it retains the spacing as is.</p>
<pre><code>import ruamel.yaml
yaml_str = """\
long_single_line_text: Hello, there. This is nothing but a long single line text which is more that a 100 characters long
"&qu... | <python><yaml><ruamel.yaml> | 2023-03-06 03:13:05 | 1 | 1,621 | thebenman |
75,646,742 | 7,734,318 | Reshape matrix before matrix multiplication | <p>I have a snippet of the <code>forward</code> step of "Transformer Neural Network" using Pytorch.</p>
<ul>
<li>Source: <a href="https://github.com/pbloem/former/blob/master/former/transformers.py" rel="nofollow noreferrer">https://github.com/pbloem/former/blob/master/former/transformers.py</a></li>
<li>Simp... | <python><performance><pytorch><matrix-multiplication><transformer-model> | 2023-03-06 03:05:31 | 1 | 319 | Tín Tr. |
75,646,546 | 1,230,724 | Combine by-integer and by-boolean numpy slicing | <p>I'm looking for a way to combine two index arrays <code>b</code> and <code>i</code> (one of type boolean, one of type integer) to slice another array <code>x</code>.</p>
<pre><code>x = np.array([5.5, 6.6, 3.3, 7.7, 8.8])
i = np.array([1, 4])
b = np.array([True, True, False, False, False])
</code></pre>
<p>The result... | <python><arrays><numpy><numpy-slicing> | 2023-03-06 02:13:17 | 1 | 8,252 | orange |
75,646,317 | 2,985,049 | pytorch: Only divide values greater than certain value | <p>I'm trying to divide one tensor by another in torch, but only when the values of the denominator exceed a certain threshold.</p>
<p>This implementation works, but won't compile in torchdynamo.</p>
<pre class="lang-py prettyprint-override"><code>wsq_ola = wsq_ola.to(wav).expand_as(wav).clone()
min_mask = wsq_ola.abs(... | <python><pytorch> | 2023-03-06 00:59:44 | 1 | 7,189 | Luke |
75,646,258 | 11,703,015 | Using contains operator to add new columns | <p>I have a DataFrame imported from an excel file, we can say expenses of different type. This DataFrame has a column called 'CONCEPT'. I would like to add two new columns depending on the type of expense. To do so, I identify "key words" in the concept. For instance></p>
<pre><code>import pandas as pd
di... | <python><pandas><dataframe><contains> | 2023-03-06 00:42:13 | 1 | 516 | nekovolta |
75,646,247 | 9,291,340 | Is set.remove() causing a big slowdown in my code? | <p>This is a solution to a <a href="https://leetcode.com/problems/jump-game-iv/description/" rel="nofollow noreferrer">leetcode problem</a>. The problem is solved, but I am struggling to understand some weird behavior which is probably python specific. The issue is with the two lines that have a comment.</p>
<p><code>g... | <python><python-3.x> | 2023-03-06 00:37:35 | 1 | 528 | Mustafa |
75,646,178 | 726,730 | How can I make a python package (setuptools) and publish in pypi.org? | <p><a href="https://stackoverflow.com/questions/67127591/install-python-shout-module-in-windows-10-python-version-3-9/67177448#67177448">In this link</a> i make a py script and an exe file while trying to make a Windows OS python-shout module.</p>
<p>The question now is how can i make a .whl file and publish it to gith... | <python><python-packaging> | 2023-03-06 00:16:43 | 1 | 2,427 | Chris P |
75,646,032 | 12,688,015 | Issue with the dequeue function in the custom class | <p>I am building a RingBuffer class for my module. However, I am facing some issues with the dequeue function. When I enqueue/dequeue integers, everything is fine. When I enqueue a list, the first dequeue operation returns an empty list instead of the actual values. When I enqueue a string, the first dequeue operation ... | <python><c><cpython><pyobject> | 2023-03-05 23:37:39 | 1 | 742 | sekomer |
75,646,031 | 11,703,015 | Sort dataframe by dates | <p>I am importing an excel file in which a column is a date in the format dd/mm/yyyy.</p>
<p>When I import it from the excel file, I think it is understood as a string. I need to sort the whole DataFrame by date, so I perform this code:
import pandas as pd</p>
<pre><code>import pandas as pd
dictionary = {
"... | <python><pandas><dataframe><xls> | 2023-03-05 23:37:09 | 3 | 516 | nekovolta |
75,645,812 | 272,023 | How do I copy bytes to/from SharedMemory into BytesIO? | <p>I am creating a <a href="https://docs.python.org/3/library/multiprocessing.shared_memory.html#multiprocessing.shared_memory.SharedMemory" rel="nofollow noreferrer"><code>SharedMemory</code> object</a>, where data is being written to it in an I/O bound process for subsequent processing by a separate compute-bound pro... | <python><shared-memory><bytesio> | 2023-03-05 22:46:01 | 1 | 12,131 | John |
75,645,762 | 5,637,851 | Cannot Import Models In Django | <p>I am trying to import my models file into my api.py file but, I get this error:</p>
<pre><code>> from dashboard.models import Customer, Lines, Devices
> ModuleNotFoundError: No module named 'dashboard'
</code></pre>
<p>My apps.py is:</p>
<pre><code>from django.apps import AppConfig
class DashboardConfig(AppC... | <python><django><django-models> | 2023-03-05 22:31:14 | 2 | 800 | Doing Things Occasionally |
75,645,700 | 3,802,177 | How do i query a DynamoDB and get all rows where "col3" exists & not 0/null (boto3) | <p>This is my DynamoDB table via serverless framework, added a secondary column index for "aaa_id":</p>
<pre class="lang-yaml prettyprint-override"><code> Devices:
Type: AWS::DynamoDB::Table
Properties:
TableName: Devices
BillingMode: PAY_PER_REQUEST
AttributeDefinitions... | <python><aws-lambda><amazon-dynamodb><boto3><serverless-framework> | 2023-03-05 22:19:31 | 1 | 5,946 | Imnotapotato |
75,645,492 | 308,827 | Specify a list of columns to move ot the end of a pandas dataframe | <p>I want to select multiple columns and move them to the end of the dataframe. E.g. current dataframe is:</p>
<pre><code>index a b c
1 2 3 4
2 3 4 5
</code></pre>
<p>How can I specify a list l = ['a', 'b'] and use that to specify that those two columns be moved to the end of the dataframe result... | <python><pandas> | 2023-03-05 21:33:49 | 3 | 22,341 | user308827 |
75,645,321 | 16,797,805 | python & sqlite - Bind parameters when multiple columns with same name are present | <p>I have the following update query:</p>
<pre><code>UPDATE table1 SET name = ?, surname = ?, birth_date = ?, sex = ? WHERE name = ? AND surname = ?
</code></pre>
<p>I'm running this query through the <code>sqlite3</code> python package, and specifically using this method:</p>
<pre><code> def _connect_and_execute(qu... | <python><sqlite> | 2023-03-05 21:01:59 | 1 | 857 | mattiatantardini |
75,645,297 | 2,607,447 | Django - gettext_lazy not working in string interpolation/concatenation (inside list) | <p>I have a dictionary of items with multiple properties.</p>
<pre><code>from django.utils.translation import (
gettext_lazy as _,
)
{"item1": {
"labels": [
_("label1"),
"this is" + _("translatethis") + " ... | <python><django><gettext><django-i18n> | 2023-03-05 20:56:30 | 1 | 18,885 | Milano |
75,645,292 | 2,550,810 | Duplicate tick sets of tick marks with loglog plot | <p>I would like customized tick marks for a loglog plot in Matplotlib. But in some cases (although not all), the default tick marks chosen by the loglog plot are not overwritten by my custom tick marks. Instead, both sets of tick marks show up in the plot.</p>
<p>In the following, I use <code>xticks</code> to get cust... | <python><matplotlib> | 2023-03-05 20:55:42 | 1 | 1,610 | Donna |
75,645,065 | 7,437,143 | Error: Untyped decorator (@typeguard) makes function "add_two" untyped [misc] | <h2>Context</h2>
<p>While using <a href="https://github.com/agronholm/typeguard/issues/60" rel="nofollow noreferrer">typeguard</a> on a project with <code>mypy</code>, I've encountered the error:</p>
<pre><code>src/pythontemplate/adder.py:6: error: Untyped decorator makes function "add_two" untyped [misc]
</... | <python><mypy><typing><typeguards> | 2023-03-05 20:13:30 | 1 | 2,887 | a.t. |
75,645,059 | 10,162,229 | error: (-215:Assertion failed) (npoints = prevPtsMat.checkVector(2, CV_32F, true)) >= 0 in function 'calc' | <p><a href="https://github.com/prouast/heartbeat" rel="nofollow noreferrer">I'm trying out this git</a> and I get this error below</p>
<pre><code>terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.5.1) ../modules/video/src/lkpyramid.cpp:1257: error: (-215:Assertion failed) (npoints = pr... | <python><python-3.x><opencv><raspberry-pi><raspberry-pi3> | 2023-03-05 20:12:40 | 0 | 303 | Gordon Freeman |
75,644,789 | 2,103,394 | Type hint the "with" value of a context manager | <p>I am looking to create some interfaces for extending a concise SQL library to use different SQL databases using a plugin/bridge pattern. I modeled this on sqlite3 since that is packaged with Python, and I used a context manager that connects to the sqlite3 database file on <code>__init__</code> and returns the curso... | <python><python-typing> | 2023-03-05 19:25:28 | 1 | 1,216 | Jonathan Voss |
75,644,713 | 1,110,044 | How to access the subgraph added as node in networkx graph? | <p>Let's say I have such a graph:</p>
<pre class="lang-py prettyprint-override"><code>G = nx.Graph()
G.add_edges_from([(12, 8), (12, 11), (11, 8), (11, 7), (8, 1), (8, 9), (8, 13), (7, 0), (7, 6), (0, 1), (0, 2), (6, 2), (6, 5), (5, 3), (3, 2), (3, 4), (1, 4), (4, 9), (4, 10), (10, 14), (10, 13), (14, 15), (13, 15), (1... | <python><networkx> | 2023-03-05 19:14:11 | 1 | 1,478 | eawer |
75,644,654 | 6,032,140 | YAML / ruamel output formatting. Are there any other knobs? | <p>I have the following python string dictionary and am using ruamel to dump it out as yaml file.</p>
<pre><code> import sys
import json
import ruamel.yaml
dit = "'{p_d: '{a:3, what:3.6864e-05, s:lion, vec_mode:'{2.5, -2.9, 3.4, 5.6, -8.9, -5.67, 2, 2, 2, 2, 5.4, 2, 2, 6.545, 2, 2}, sst:'{c:-20, b... | <python><yaml><ruamel.yaml> | 2023-03-05 19:01:33 | 1 | 1,163 | Vimo |
75,644,557 | 11,004,423 | numpy get indexes of connected array values | <p>I have a 1d numpy array that looks like this:</p>
<pre class="lang-py prettyprint-override"><code>a = np.array([1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1])
</code></pre>
<p>Is there a way to get the indexes of start and end of each cluster of values. So basically I would get this:</p>
<pre class="lang-py prettypri... | <python><arrays><numpy><split> | 2023-03-05 18:45:32 | 0 | 1,117 | astroboy |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.