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,668,665 | 522,209 | Run a hook in one plugin out of many, in Pluggy | <p>I'm using <a href="https://github.com/pytest-dev/pluggy" rel="nofollow noreferrer">Pluggy</a> and I would like to run a hook in one of the plugins.</p>
<p>Having this code:</p>
<pre><code>import pluggy
import myspec
import impl1
import impl2
pm = pluggy.PluginManager("my-project-name")
pm.add_hookspecs(my... | <python><plugins> | 2023-03-08 01:25:15 | 0 | 896 | Helgi Borg |
75,668,574 | 11,116,696 | how to run parallel processing Pyomo? | <p><strong>Background</strong></p>
<p>I am trying to solve a MILP problem using pyomo with a 'cbc' solver. the optimisation problem is being run over time series data and is very large (3005 rows, 3011 columns (2010 with objective) and 15998 elements)</p>
<p><strong>What I am attempting to do</strong></p>
<p>I've read ... | <python><optimization><parallel-processing><pyomo> | 2023-03-08 01:05:28 | 1 | 601 | Bobby Heyer |
75,668,544 | 178,315 | Curl fails with SSL errors 56 and 35 when talking to a HTTPS Python web server | <p>I have setup my own HTTPS server using Python:</p>
<pre><code>from http.server import HTTPServer, BaseHTTPRequestHandler
import ssl
class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
self.wfile.write(b'Hello, secure world!... | <python><ssl><curl> | 2023-03-08 00:58:08 | 1 | 6,134 | Sergiy Belozorov |
75,668,478 | 751,231 | Yapf wanting a linebreak and tabbing when it shouldn't | <p>I'm having an issue with yapf behaving differently on my local machine and on a jenkins pipeline build.</p>
<p>This is my line:</p>
<pre><code>groups = thing.func(
*[iter(people)] * constants.MAX_PEOPLE_PER_CREATE)
</code></pre>
<p>That yapf keeps telling me is wrong (and failing, causing the whole build to fail... | <python><yapf> | 2023-03-08 00:38:57 | 0 | 603 | Rev Tyler |
75,668,436 | 19,113,780 | Django docker: docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed | <p>I want to deploy my django project with docker and uwsgi on windows 11, but get some errors.</p>
<pre><code>docker build . -t djangohw
docker run -it --rm djangohw -p 8080:80
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container proce... | <python><django><docker> | 2023-03-08 00:29:17 | 1 | 317 | zhaozk |
75,668,412 | 3,453,768 | Regex search string with partial matches allowed | <p>Suppose I have a search pattern like <code>^FOO.B.A.R</code>, and I want to check whether a string matches the full search pattern, <em>but</em>, if the string is shorter than the search pattern, it's allowed to match only part of it.</p>
<p>That is:</p>
<ul>
<li>If the string is 1 character long, it must match <cod... | <python><regex> | 2023-03-08 00:24:34 | 1 | 2,397 | LarrySnyder610 |
75,668,312 | 2,774,885 | how does PySerial manage multiple processes/clients accessing the same device at the same time? (context management maybe?) | <p>I've got a couple of IOT-type toys (power meter, specifically) that provide an RS485 interface for configuration and monitoring. With a basic USB<->RS485 bridge I'm able to communicate with the device, read the output data and have it respond to basic commands... all well and good.</p>
<p>the script is a supe... | <python><pyserial><contextmanager> | 2023-03-08 00:02:44 | 1 | 1,028 | ljwobker |
75,668,267 | 2,487,330 | Filter by multiple items in lists? | <p>Given a DataFrame with a list column and a list of items not in the data frame:</p>
<pre class="lang-py prettyprint-override"><code>df = pl.DataFrame({
"sets": [
[1, 2, 3],
[4],
[9, 10],
[2, 12],
[6, 6, 1],
[2, 0, 1],
[1, 1, 4],
[2, 7, 2],... | <python><python-polars> | 2023-03-07 23:54:38 | 3 | 645 | Brian |
75,668,255 | 18,032,104 | How to reduce Pycharm memory usage? | <p>Recently I got working to something that needs a lot of memory while using Pycharm. How should I possibly reduce the memory to about 550MB? My current is 1198MB. (I'm using <strong>Windows 10</strong>, <strong>Pycharm Community Edition 2022.2.4</strong>)</p>
| <python><pycharm> | 2023-03-07 23:51:26 | 1 | 314 | CPP_is_no_STANDARD |
75,668,153 | 1,867,985 | matplotlib: 3 channel binary RGB image only shows black | <p>I have three 2D datasets that I'm trying to plot as an RGB image using <code>matplotlib</code>. I thought this would be quite straightforward but I'm finding it very frustrating.</p>
<p>Here's the bit of code I'm currently using:</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.ax... | <python><matplotlib><visualization><imshow> | 2023-03-07 23:32:48 | 1 | 325 | realityChemist |
75,668,091 | 6,379,197 | pandas to access text file | <p>I am using pandas to access a file whose content is as follows:</p>
<pre><code>English Word anger anticipation disgust fear joy negative positive sadness surprise trust Bengali Word
aback 0 0 0 0 0 0 0 0 0 0 বিস্মিত
abacus 0 0 0 0 0 0 0 0 0 1 অ্যাবাকা... | <python><pandas><google-colaboratory><text-files> | 2023-03-07 23:20:20 | 1 | 2,230 | Sultan Ahmed |
75,668,067 | 17,696,880 | How to iterate over a list of lists and update one of the sublists with content from previous iterations under certain conditions? | <pre class="lang-py prettyprint-override"><code>prev_names_elements = [] # keep track of names from previous iterations
for idx, i in enumerate(["1", "2", "3", "4"]):
if (i == "1"): i_list = [['Luciana', 'María', 'Lucy'], ['jugando'], [], ['2023_-_03_-_07(19:00... | <python><python-3.x><string><list><for-loop> | 2023-03-07 23:17:02 | 1 | 875 | Matt095 |
75,668,066 | 2,392,192 | Yield in parent function in Python? | <p>I have a music library in Python that involves a system of clocks. Currently, they are implemented with different threads that use Events and Locks, etc. to keep everything synchronized. But the truth is, I want it to be effectively single-threaded.</p>
<p>The current syntax for the clocks is that you can fork funct... | <python><macros><yield> | 2023-03-07 23:16:55 | 2 | 563 | MarcTheSpark |
75,667,980 | 1,072,830 | Connecting to SharePoint using Azure app authentication and Python | <p>I created a self signed certificate and uploaded it to an Azure app registration, similar to what I've done with a dozen or so other apps. I'm attempting to connect to my SharePoint site with Python's office365 library, which is not something I have a lot of experience with and it shows.</p>
<pre><code>from office36... | <python><office365><sharepoint-online> | 2023-03-07 22:59:39 | 1 | 6,622 | Robbert |
75,667,964 | 10,976,654 | Matplotlib how to overlay probability density function onto baseline plot | <p>I want to overlay a probability distribution on a baseline graph. An MRE is below, and then the desired outcome is shown below by just copying/rotating/squeezing the plots in PowerPoint as an example.</p>
<pre><code># Import python libraries
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
... | <python><matplotlib> | 2023-03-07 22:56:04 | 1 | 3,476 | a11 |
75,667,862 | 1,506,145 | Save and load a Grayscale WebP image in PIL | <p>I'm trying to save and load a grayscale image in PIL:</p>
<pre><code>import numpy as np
from PIL import Image, ImageOps
o = np.random.rand(100,100)*255
o = o.astype('uint8')
im = Image.fromarray((o))
im.save('test.webp', lossless=True)
im = Image.open(r"test.webp")
a = np.asarray(im)
a.shape
</code></pre>
... | <python><python-imaging-library> | 2023-03-07 22:38:14 | 0 | 5,316 | user1506145 |
75,667,853 | 21,113,865 | Can you preemptively provide password input to a python program? | <p>I am running python on a linux machine and have a simple program that will prompt the user for input multiple times.</p>
<p>i.e.</p>
<pre><code>import getpass
try:
p1 = getpass.getpass()
except Exception as error:
print('ERROR', error)
try:
p2 = getpass.getpass()
except Exception as error:
print('... | <python><passwords> | 2023-03-07 22:37:15 | 0 | 319 | user21113865 |
75,667,657 | 6,734,243 | how to dynamically change indentation in a multiline string? | <p>I'm using docstrings to document my code with Sphinx. I recently started to use <a href="https://beta.ruff.rs/docs/" rel="nofollow noreferrer">ruff</a> to lint my code and It is by default applying D212 instead of D213. The only difference being that the first line of the docstring (short description) must start on ... | <python><docstring> | 2023-03-07 22:09:00 | 2 | 2,670 | Pierrick Rambaud |
75,667,613 | 1,133,224 | Switched from WSGI to ASGI for Django Channels and now CircleCI throws "corrupted double-linked list" even though tests pass | <p>I've been working on a project which requires WebSockets. The platform is built with Django and was running the WSGI server <code>gunicorn</code>. We decided to implement WebSockets using Django Channels.</p>
<p>I set everything up including switching from <code>gunicorn</code> to the ASGI server <code>daphne</code>... | <python><django><pytest><circleci><django-channels> | 2023-03-07 22:03:46 | 1 | 905 | TWGerard |
75,667,596 | 3,460,486 | Python Django: Inline edit and sub-total automatic | <p>I have a simple application for forecasting hours in projects for team members. The 'view' mode:
<a href="https://i.sstatic.net/r0Tta.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/r0Tta.png" alt="enter image description here" /></a></p>
<p>For the "edit" mode I have this interface:
<a href... | <python><django><forms><inline-editing> | 2023-03-07 22:02:23 | 0 | 493 | user3460486 |
75,667,535 | 18,192,997 | Create product in printful using API - Python | <p>I am trying to a create a product using the Printful api and python. I was able to create a product on there website (a basic) hoodie, and I wanted to try and create the same hoddie using python.</p>
<p>Here is the documentation I am using: <a href="https://developers.printful.com/docs/#operation/createSyncProduct" ... | <python><json><python-requests> | 2023-03-07 21:55:12 | 1 | 537 | PythonKiddieScripterX |
75,667,527 | 6,165,007 | Numpy vectorization and algorithmic complexity | <p>I have read many times about <em>vectorized</em> code in <code>numpy</code>. I know for a fact that a python for loop can be ~100x times slower than an equivalent <code>numpy</code> operation. However, I thought that the power of <code>numpy</code> <em>vectorization</em> was beyond a mere translation of a for loop f... | <python><numpy><machine-learning><blas> | 2023-03-07 21:54:20 | 1 | 339 | Jaime Arboleda Castilla |
75,667,349 | 7,479,376 | pydantic schema to postgres db | <p>I am trying to insert a pydantic schema (as json) to a postgres database using sqlalchemy. As you can see below I have defined a <code>JSONB</code> field to host the schema.</p>
<pre><code>from sqlalchemy import Column, Integer, String, JSON
from sqlalchemy.orm import declarative_base
from pydantic import BaseModel,... | <python><sqlalchemy><pydantic> | 2023-03-07 21:31:24 | 1 | 3,353 | Galuoises |
75,667,320 | 220,997 | Connecting Python SQLAlchemy to Redshift Connector with SAML Okta | <p>Looking for a way to write some python code to connect to Redshift using my okta MFA credentials. I'm able to connect using login/pw but need to use Okta SAML 2FA. Using sqlalchemy, so I can load into a Pandas dataframe and do some analysis.</p>
<p>There's a redshift connector driver I'm trying to use.
<a href="http... | <python><sqlalchemy><amazon-redshift> | 2023-03-07 21:27:33 | 1 | 6,282 | Gabe |
75,667,301 | 150,684 | python click custom shell completion for command | <p>I have a click application which is running just fine currently.</p>
<p>We want to introduce a new command called <code>api</code> which will dynamically reach into our python sdk and extract sdk methods that can be invoked to interact with our platform. There are 100s of sdk methods and it doesn't make sense to exp... | <python><python-click> | 2023-03-07 21:25:49 | 1 | 2,642 | thomas |
75,667,251 | 11,594,202 | Get bytes of downloaded file in playwright (example in python) | <p>I am using playwright in python to automate some tasks. At the end, I want to download a file and save it to my cloud storage.</p>
<p>For this, I need to get the bytes of the downloaded file, so I cant post/put these bytes to my cloud api.</p>
<p>I used the very straightforward download method in playwright, as such... | <python><playwright><webautomation> | 2023-03-07 21:17:54 | 2 | 920 | Jeroen Vermunt |
75,667,232 | 1,330,719 | Defining VSCode's python interpreter in a monorepo using poetry's in-project virtualenvs | <p>I have a folder I open in VSCode that is a monorepo. One of the folders inside it is a python service.</p>
<p>This python service uses poetry with <code>in-project</code> virtualenvs configured. This means that I want my interpreter path to be <code>./python-service/.venv</code>.</p>
<p>Unfortunately, VSCode does no... | <python><visual-studio-code> | 2023-03-07 21:15:18 | 2 | 1,269 | rbhalla |
75,667,225 | 243,031 | How to get latest version of not installed package using pip? | <p>I want to know, for a package which is not installed in my virtual environment, what is the latest version available.</p>
<p>For example, if I had to install <code>requests</code> library, I would want to know the version before installation.</p>
<p>I considered <code>pip search</code> but that was deprecated in Pyt... | <python><pip> | 2023-03-07 21:14:30 | 3 | 21,411 | NPatel |
75,667,087 | 14,697,000 | Why is my python dictionary updating when it is not supposed to (conditions are not being met)? | <p>I am trying to update a dictionary with data I am obtaining from sorting methods. I am obtaining the time it takes for a certain algorithm to finish, I am also counting how many swaps and how many comparisons the algorithm is making. After my sorting function returns the values I want to update a dictionary and I am... | <python><list><dictionary><for-loop><nested-loops> | 2023-03-07 20:56:10 | 0 | 460 | How why e |
75,667,042 | 5,072,010 | PuLP optimization running (essentially) infinitely despite never improving the answer? | <p>I have a python script which solves the following optimization:</p>
<pre><code>from pulp import *
import matplotlib.pyplot as plt
rates = {'h': {'level_pay_rate': 0.1425, 'on_demand': 0.2}, 'x': {'level_pay_rate': 0.0129, 'on_demand': 0.0162}, 'ak': {'level_pay_rate': 0.3642, 'on_demand': 0.448}, 'ao': {'level_pay... | <python><optimization><pulp> | 2023-03-07 20:50:16 | 2 | 1,459 | Runeaway3 |
75,666,879 | 2,226,029 | List executables that are in $PATH without knowing their locations | <p>Is there a way to (glob-like) list executables that match a certain pattern without knowing their actual locations? For example, let's say I have multiple versions of GCC installed: <code>gcc-10</code>, <code>gcc-11</code> and <code>gcc-12</code>, then I need the pattern <code>gcc-*</code> to yield something like <c... | <python> | 2023-03-07 20:29:03 | 2 | 2,043 | thomas_f |
75,666,795 | 4,261,613 | Multiply Numpy n x 2 array by n x 1 array | <p>Assuming I have a Numpy n x 2 array <code>y</code>: <code>array([[1, 1], [2, 3], [1, 4], ...])</code> and a Numpy n x 1 array <code>x</code>: <code>array([2, 4, 5, ...])</code>, how can I efficiently obtain the following result, n x 2 array: <code>array([2, 2], [8, 12], [5, 20], ...])</code>, where each element (arr... | <python><arrays><numpy><multiplication> | 2023-03-07 20:19:59 | 1 | 3,746 | Mikhail |
75,666,714 | 4,392,566 | gspread list_spreadsheet_files not getting files in subfolders given a folder_id | <p>This used to work in getting all Google Sheets in all sub-folders given a top folder ID:</p>
<pre><code>import gspread
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'creds_path/creds.json'... | <python><directory><google-drive-api><gspread> | 2023-03-07 20:08:13 | 1 | 3,733 | Dance Party |
75,666,604 | 3,943,868 | What does this double dot slicing mean in numpy? | <pre><code>my_array[:, 0::2] = np.sin(A)
my_array[:, 1::2] = np.cos(B)
</code></pre>
<p>If my_array is a two dimension array, what does this code do? In particular, what does :: do?</p>
| <python><numpy> | 2023-03-07 19:53:38 | 0 | 7,909 | marlon |
75,666,497 | 2,328,273 | st_ino from os.stat in Python gets unexpectedly altered if output to a file | <p>I have tried to research this to see if it is expected behavior or not but I haven't found anything. Maybe I'm not using the right search terms. I use os.stat in Python and capture file attributes but I have noticed some strange behavior with st_ino. I am using Python 3.10 in Linux. I've noticed when I output st_ino... | <python><integer> | 2023-03-07 19:40:24 | 1 | 1,010 | user2328273 |
75,666,449 | 16,629,677 | DataLoader default_collate found "NoneType" | <p>I have a dataset directory that has hundreds of subdirectories, each subdirectory's name is a UUID. Inside each subdirectory, there are four files: an image (<code>png</code>), a <code>html</code>, a <code>json</code>, and a <code>txt</code> file.</p>
<p>The image, html, and txt form the sample, and the json contain... | <python><pytorch><pytorch-dataloader> | 2023-03-07 19:35:24 | 1 | 343 | Tharsalys |
75,666,445 | 15,724,084 | python selenium does not go to right page with scraper | <p>I have a scraper in python which with help of selenium goes to URL <code>www.apartments.com</code> then I enter (input) some location but it, with help of <code>method of selenium .click()</code> press search button but it only goes by default page which <code>chicago, il</code>.</p>
<p>here is code;</p>
<pre><code>... | <python><python-3.x><selenium-webdriver><web-scraping> | 2023-03-07 19:34:36 | 1 | 741 | xlmaster |
75,666,408 | 523,612 | How can I collect the results of a repeated calculation in a list, dictionary etc. (or make a copy of a list with each element modified)? | <p><sub>There are a great many existing Q&A on Stack Overflow on this general theme, but they are all either poor quality (typically, implied from a beginner's debugging problem) or miss the mark in some other way (generally by being insufficiently general). There are at least two extremely common ways to get the n... | <python><iteration><list-comprehension> | 2023-03-07 19:30:09 | 3 | 61,352 | Karl Knechtel |
75,666,211 | 5,900,093 | Stop logging parameters for django background tasks? | <p>I'm using <a href="https://django-background-tasks.readthedocs.io/en/latest/" rel="nofollow noreferrer">Django Background Tasks</a> in my app for a task that requires user authentication. To create the task, I use a command like:</p>
<pre><code>my_cool_task(pks, request.POST.get('username'), request.POST.get('passwo... | <python><django> | 2023-03-07 19:08:06 | 1 | 2,068 | Evan |
75,666,062 | 6,658,422 | Discrete date values for x-axis in seaborn.objects plot | <p>I am trying to prepare a bar plot using <code>seaborn.objects</code> with time series data where the x-axis ticks and labels are only on the dates that really appear in the data.</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
import seaborn.objects as so
df1 = pd.DataFrame({'date': pd.to_dat... | <python><pandas><seaborn><seaborn-objects> | 2023-03-07 18:51:07 | 1 | 2,350 | divingTobi |
75,665,559 | 10,200,497 | Finding first occurrence of even numbers | <p>This is my dataframe:</p>
<pre><code>df = pd.DataFrame(
{
'a': [20, 21, 333, 55, 444, 1000, 900, 44,100, 200, 100],
'b': [2, 2, 2, 4, 4, 4, 4, 3, 2, 2, 6]
}
)
</code></pre>
<p>And this is the output that I want:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th></th... | <python><pandas> | 2023-03-07 17:50:57 | 2 | 2,679 | AmirX |
75,665,549 | 1,506,850 | how to iteratively extend pd.dataframe avoiding list overallocation? | <p>I often do</p>
<pre><code>df_collection = []
for iteration in iterations:
df_this_iteration = computational_step(*many_other_iteration_specific_params...)
df_collection.append(df_this_iteration)
df_collection = pd.concat(df_collection,axis=0)
</code></pre>
<p>when <code>iterations</code> and/or <code>df_th... | <python><pandas><memory> | 2023-03-07 17:49:52 | 1 | 5,397 | 00__00__00 |
75,665,464 | 272,023 | How to I write an S3 object to SharedMemory using boto3? | <p>How do I write the contents of an S3 object into <a href="https://docs.python.org/3/library/multiprocessing.shared_memory.html#multiprocessing.shared_memory.SharedMemory" rel="nofollow noreferrer">SharedMemory</a>?</p>
<pre><code>MB=100
mem = SharedMemory(create=True, size=MB*2**20)
response = s3_client.get_object(B... | <python><amazon-web-services><amazon-s3><boto3> | 2023-03-07 17:40:28 | 2 | 12,131 | John |
75,665,392 | 14,912,118 | Getting Bad Magic Number while Decrypting the file | <p>Here i am encrypting the file using below code using python and i am getting the encrypted file as expected.</p>
<pre><code>from Crypto.Cipher import AES
import base64
def pad(s):
return s + b"\0" * (AES.block_size - len(s) % AES.block_size)
def encrypt_file(input_path, output_path, key):
with op... | <python><encryption><openssl><aes> | 2023-03-07 17:33:59 | 1 | 427 | Sharma |
75,665,344 | 3,486,773 | How to make every other row a column using row below as the value in Pandas? | <p>I have a pandas dataframe that looks like this:</p>
<pre><code> df = pd.DataFrame.from_dict({'type': {4: 'Second Product',
5: 'table',
6: 'First Product',
7: 'chair',
8: 'Second Product',
9: 'desk',
10: 'First Product',
11: 'chair'},
'id': {4: 'cust1',
5: 'cust1',
6: 'cust1',
7: 'cust1',
8: '... | <python><pandas><dataframe> | 2023-03-07 17:29:04 | 3 | 1,278 | user3486773 |
75,665,264 | 832,490 | Cannot access member "safe_search_detection" for type "ImageAnnotatorClient" | <p>I have this line:</p>
<pre><code>from google.cloud.vision import ImageAnnotatorClient
vision = ImageAnnotatorClient()
vision.safe_search_detection(image).safe_search_annotation.adult
</code></pre>
<p>After enabling type checking on Pylance I'm getting the error:</p>
<blockquote>
<p>Cannot access member "safe_... | <python><google-cloud-vision> | 2023-03-07 17:20:52 | 1 | 1,009 | Rodrigo |
75,665,076 | 12,131,472 | How to use pd.json_normalize to retrieve the data I need | <p>I have this JSON list in Python:</p>
<pre class="lang-json prettyprint-override"><code>[{'id': 'TC2-FFA',
'shortCode': 'TC2-FFA',
'dataSet': {'datumPrecision': 2,
'id': 'TC2_37',
'shortCode': 'TC2_37',
'shortDescription': 'Clean Continent to US Atlantic coast',
'displayGroup': 'BCTI',
'datumUnit':... | <python><json><pandas><json-normalize> | 2023-03-07 17:04:44 | 2 | 447 | neutralname |
75,665,021 | 12,474,157 | Airflow v2.3.4: Make all tasks in a DAG run at the same time | <p>How can a define the parameters for airflow KubernetesPodOperator make all tasks in a DAG run at the same time.</p>
<p>In my image below you can see that some tasks are in grey "scheduled", I want them to run all at the same time green, also make it NOT possible to run the same task more than once at a tim... | <python><airflow><airflow-2.x><airflow-taskflow> | 2023-03-07 16:58:43 | 1 | 1,720 | The Dan |
75,664,836 | 955,273 | Crash when attempting to return a pybind11::array_t from c++ to python | <p>I have created the following example library:</p>
<pre class="lang-cpp prettyprint-override"><code>#include <vector>
#include <cstdint>
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
namespace py = pybind11;
struct Foo
{
using UintArr = py::array_t<std::uint64_t, py::arra... | <python><c++><numpy><pybind11> | 2023-03-07 16:43:03 | 1 | 28,956 | Steve Lorimer |
75,664,740 | 12,814,680 | lists comparing with nested values | <p>I have a list of objects, that among other attributes have an attribute named "id"</p>
<pre><code>
listA = [{"id":"5","age":"44"},{"id":"8","age":"34"},{"id":"15","age":"84"}]
</code></p... | <python> | 2023-03-07 16:34:53 | 4 | 499 | JK2018 |
75,664,725 | 364,966 | Installing PIP Package connectorx on Docker? | <p>I'm developing a Lambda using Docker. I had this in requirements.txt:</p>
<blockquote>
<p>connectorx</p>
</blockquote>
<p>I ran <code>docker-compose build</code> and got:</p>
<blockquote>
<p>Exception: connectorx is not installed. Please run <code>pip install connectorx>=0.3.1</code>.</p>
</blockquote>
<p>I updat... | <python><docker><docker-build> | 2023-03-07 16:33:25 | 0 | 5,154 | VikR |
75,664,720 | 14,608,529 | How to generate heartbeat sounds in Python given beats per minute? | <p>I'm looking to pass in an integer beats per minute (bpm) variable value (e.g. 62) into a function in Python that outputs the accompanying heartbeat noises (i.e. 62 heart beat sounds in a minute).</p>
<p>I can't find any libraries that can help with this and Google searching leads me to only find the reverse (i.e. ca... | <python><python-3.x><file><audio><libraries> | 2023-03-07 16:33:11 | 1 | 792 | Ricardo Francois |
75,664,665 | 7,776,781 | Typing a function dynamically using a subset of a ParamSpec | <p>I have a decorator that should be used to test certain things prior to the function that it decorates is being called, and if the checks fail just raise an exception. The decorator itself takes callables as input, and these callables will accepts a subset of the parameters from the function that it decorates.</p>
<p... | <python><python-typing> | 2023-03-07 16:27:50 | 0 | 619 | Fredrik Nilsson |
75,664,548 | 8,231,763 | how to solve scipy importerror | <p>I have run into a problem while importing Scipy.</p>
<p>My OS is windows 10 enterprise. I have installed the latest Anaconda package (2022-10 64bit) in Jan of 2023. Everything was fine. And today I found I have trouble to run some code I created a few weeks ago. The problem is with SciPy. For example, with</p>
<pre>... | <python><scipy><anaconda><pywin32> | 2023-03-07 16:18:33 | 0 | 325 | Shu Pan |
75,664,530 | 6,751,456 | is average of total and the sum of average of group distribution the same | <p>I have a query that calculates the total sessions and total number of crashed sessions.</p>
<pre><code>SELECT COUNT(*) count,
SUM(cast((CAST((session.platform = 1 AND session.iscrashed) OR
(session.platform = 2 AND session.iscrashed) AS int)) as int)) total_crashed
FROM session
WHERE appid = '4ef36d'
AND (... | <python><sql><average><aggregation><weighted-average> | 2023-03-07 16:17:13 | 0 | 4,161 | Azima |
75,664,524 | 10,271,487 | Pandas MultiIndex updating with derived values | <p>I am tryng to update a MultiIndex frame with derived data.</p>
<p>My multiframe is a time series where 'Vehicle_ID' and 'Frame_ID' are the levels of index and I iterate through each Vehicle_ID in order and compute exponential weighted avgs to clean the data and try to merge the additional columns to the original Mul... | <python><pandas> | 2023-03-07 16:16:40 | 1 | 309 | evan |
75,664,522 | 3,581,217 | Mask xarray Dataset on one dimension | <p>I have an xarray dataset with variables with dimensions <code>(time, x, y)</code> or <code>(x, y)</code>. I addition, I have an array with bools the same size as the <code>time</code> dimension, which I would like to use to filter my dataset. I can't get that working.</p>
<p>Simple example that does work (all variab... | <python><python-xarray> | 2023-03-07 16:16:34 | 1 | 10,354 | Bart |
75,664,519 | 4,934,150 | Malicious Macro Detected when trying to run Python-Script from Excel-VBA | <p>I want to run a simple PythonScript using the below VBA:</p>
<pre><code>Sub RunPythonScrip()
Set objShell = VBA.CreateObject("Wscript.shell")
PythonExePath = """C:\Users\user1\AppData\Local\Programs\Python\Python311\python.exe"""
PythonScriptPath = """C:\Users... | <python><vba> | 2023-03-07 16:15:58 | 1 | 5,543 | Michi |
75,664,404 | 14,045,537 | How to extract hex color codes from a colormap | <p>From the below <code>branca</code> colormap</p>
<pre><code>import branca
color_map = branca.colormap.linear.PuRd_09.scale(0, 250)
colormap = color_map.to_step(index=[0, 10, 20, 50, 70, 90, 120, 200])
</code></pre>
<p><a href="https://i.sstatic.net/BK80u.png" rel="nofollow noreferrer"><img src="https://i.sstatic.ne... | <python><matplotlib><visualization><colormap> | 2023-03-07 16:06:18 | 2 | 3,025 | Ailurophile |
75,664,343 | 10,866,873 | Tkinter child widgets don't trigger <Leave> on parent | <p>When the mouse moves from a parent widget into a child widget and the parent has a <code><Leave></code> binding the event is never triggered due to the mouse not actually leaving the bounds of the parent. It is also the same for <code><Enter></code> when the mouse outside the child widget yet remains in ... | <python><tkinter> | 2023-03-07 16:00:46 | 2 | 426 | Scott Paterson |
75,664,331 | 12,596,824 | Using assign operator on already updated dataframe through method chaining | <p>I have a dataframe like so:</p>
<pre><code>pid name kids_count
10 tom 2
21 bill 0
22 peter NaT
81 jen 4
20 jerry 1
</code></pre>
<p>I do the following method chaining to create an ID column but it takes two lines:</p>
<pre><code>person_data = (person_data
.dropna()
... | <python><pandas> | 2023-03-07 15:59:53 | 2 | 1,937 | Eisen |
75,664,275 | 7,593,853 | What hook language should I use for local pre-commit hooks written in Python? | <p>I’m working on a <a href="https://pre-commit.com/#repository-local-hooks" rel="nofollow noreferrer">local pre-commit hook</a> written in Python. At first, I saw <a href="https://pre-commit.com/#python" rel="nofollow noreferrer">this quote from the pre-commit documentation</a>:</p>
<blockquote>
<h3>python</h3>
<p>The... | <python><pre-commit.com> | 2023-03-07 15:55:00 | 1 | 646 | Ginger Jesus |
75,664,227 | 20,443,528 | How to implement SQL ORDER BY like functionality if the first parameter is a function call in python? | <p>I have a list of objects like this</p>
<pre><code>time_slots = [
<TimeSlot: number: 1, capacity: 4, advance: 10, from: 02:00:00, till: 08:00:00>,
<TimeSlot: number: 2, capacity: 3, advance: 17, from: 01:00:00, till: 04:00:00>,
<TimeSlot: number: 3, capacity: 3, advance: 17, from: 01:00:00, till: 04:00... | <python><sorting><datetime> | 2023-03-07 15:51:02 | 2 | 331 | Anshul Gupta |
75,664,220 | 13,986,997 | Is there a way to do vlookup using python? | <p>Lets say I have two dataframes df1 and df2 and I need to do vlookup on name and give out names which are matching.</p>
<pre><code>import pandas as pd
import numpy as np
df1 = pd.DataFrame({
'name': ['A', 'B', 'C', 'D'],
'val1': [5, 6, 7, 8],
'val2': [1, 2, 3, 4],
})
df2 = pd.DataFrame({
'name': ['B... | <python><pandas> | 2023-03-07 15:50:06 | 2 | 413 | Akilesh |
75,664,217 | 12,065,403 | How to update custom package version? | <p>I am trying to create a python package that I can reuse in other projects. I did follow this tutorial: <a href="https://towardsdatascience.com/create-your-custom-python-package-that-you-can-pip-install-from-your-git-repository-f90465867893" rel="nofollow noreferrer">Create Your Custom, private Python Package That Yo... | <python><git><pipenv><python-packaging> | 2023-03-07 15:50:01 | 1 | 1,288 | Vince M |
75,664,215 | 7,987,987 | Sum together list of F expressions | <p>Is there a way to specify (in an annotation or aggregation) that a sequence of <code>F</code> expressions should be summed together without manually typing out <code>F("first_prop") + F("second_prop") + ...</code>?</p>
<p>I want something similar to how python's <code>sum()</code> function allows... | <python><django><django-models><django-aggregation> | 2023-03-07 15:49:52 | 1 | 936 | Uche Ozoemena |
75,664,160 | 1,107,474 | How to pass the index of the iterable when using multiprocessing pool | <p>I would like to call a function <code>task()</code> in parallel <code>N</code> times. The function accepts two arguments, one is an array and the second is an index to write the return result in to the array:</p>
<pre><code>def task(arr, index):
arr[index] = "some result to return"
</code></pre>
<p>To ... | <python> | 2023-03-07 15:45:16 | 1 | 17,534 | intrigued_66 |
75,664,091 | 15,613,309 | How to determine if tkinter Toplevel widget exists.? | <p>I have a need to destroy a <code>Toplevel</code> widget if it already exists before creating it. I've researched this and every response I can find here and elsewhere suggest using <code>winfo_exists</code>; however, the following code demonstrates that doesn't work. It fails with the error: object has no attribut... | <python><tkinter> | 2023-03-07 15:40:18 | 1 | 501 | Pragmatic_Lee |
75,664,060 | 980,151 | Why does Mypy report a subset of JSON as invalid? | <p>I have a base class that returns a JSON type. I then have subclasses that return more specific types that should I think be valid JSON types, but Mypy reports an error:</p>
<pre><code>error: Return type "List[Dict[str, JSON]]" of "return_json" incompatible with return type "JSON" in sup... | <python><mypy><python-typing> | 2023-03-07 15:37:31 | 1 | 2,569 | wrgrs |
75,664,029 | 6,240,756 | Powershell: se variable in command | <p>I'm facing a basic and stupid problem on Windows PowerShell. I'm almost sure it has already been answered somewhere but I can't find something working for me.</p>
<p>I simply would like to use a variable inside a command in PowerShell:</p>
<pre><code>$VENV_DIR='C:\venv\'
python -m venv $VENV_DIR
$VENV_DIR\Scripts\py... | <python><powershell> | 2023-03-07 15:34:57 | 1 | 2,005 | iAmoric |
75,663,995 | 5,387,991 | Polars: Addressing "The predicate passed to 'LazyFrame.filter' expanded to multiple expressions" | <p>From Polars 0.16.11 the following filter statement raises an exception with the following error message:</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
df = pl.DataFrame({'lag1':[0,1,None],'lag2':[0,None,2]})
df.filter(pl.col('^lag.*$').is_not_null())
ComputeError: The predicate passed to '... | <python><python-polars> | 2023-03-07 15:31:47 | 3 | 934 | braaannigan |
75,663,969 | 7,012,917 | Compute percentage change by increasing window size up to period | <p>Say I have this series</p>
<pre><code>s = pd.Series([90, 91, 85, 95])
</code></pre>
<p>If I compute the <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.pct_change.html" rel="nofollow noreferrer">percentage change</a> with a period of 2 I get</p>
<pre><code>s.pct_change(periods=2)
0 Na... | <python><pandas><dataframe><percentage> | 2023-03-07 15:29:31 | 1 | 1,080 | Nermin |
75,663,813 | 8,580,652 | Python regular expression: search from right to left by delimiter, then search from right to left in the left part of the delimiter | <p>Example:</p>
<pre><code>aaa_bbb_ /xyz=uvw,ccc=height:18y,weight:1xb,ddd=19d
</code></pre>
<p>The end goal is to parse it into a dictionary:</p>
<pre><code>{'aaa_bbb_ /xyz':'uvw','ccc':'height:18y,weight:1xb','ddd':19d}
</code></pre>
<p>The rule is:</p>
<blockquote>
<p>search for "=" from the right, split b... | <python><regex> | 2023-03-07 15:16:03 | 1 | 398 | John |
75,663,721 | 5,568,409 | How to label the kernel density estimate in histplot | <p>I am plotting a histogram using <code>seaborn</code>, along with a KDE curve and a Gaussian fit, but the instruction <code>label = "KDE fit"</code> in <code>sns.histplot</code> is inappropriately displayed in color, as it seems to refer to the whole histogram... Is there a way to specifically label the KDE... | <python><python-3.x><seaborn><histogram><kernel-density> | 2023-03-07 15:07:55 | 1 | 1,216 | Andrew |
75,663,717 | 9,162,193 | CVAT REST API to upload files | <p>I am able to create a Task in an existing project in CVAT using the below code, but I am unable to upload files, even if I try to reference this link here: <a href="https://github.com/opencv/cvat/issues/4704" rel="nofollow noreferrer">https://github.com/opencv/cvat/issues/4704</a></p>
<p>Any advice would be greatly ... | <python><rest><cvat> | 2023-03-07 15:07:22 | 1 | 1,339 | yl_low |
75,663,683 | 20,443,528 | How to implement SQL ORDER BY like funtionality in python? | <p>I have a list of objects like this</p>
<pre><code>time_slots = ['<TimeSlot: capacity: 1, number: 5>',
'<TimeSlot: Room: capacity: 3, number: 2>',
'<TimeSlot: capacity: 4, number: 1>',
'<TimeSlot: capacity: 4, number: 6>',
'<TimeSlot: capacity: 4, number: 1>',
'<TimeSlot: capacit... | <python><sorting> | 2023-03-07 15:04:26 | 2 | 331 | Anshul Gupta |
75,663,680 | 8,512,262 | Can I force the tkinter.Text widget to wrap lines on the "space" character as well as words? | <p>Below is an example tkinter app with a <code>Text</code> field which wraps to the next line on long words, as expected. The issue, however, is that <em>spaces</em> don't wrap to the next line in the same way. I am able to enter as many spaces as I like prior to the start of a new word and a line wrap won't occur. On... | <python><tkinter><text><word-wrap> | 2023-03-07 15:04:10 | 1 | 7,190 | JRiggles |
75,663,669 | 2,302,244 | Change the content of a ttkbootstrap ScrolledFrame | <p>How do I replace the content of a <code>ttkbootstrap ScrolledFrame</code>?</p>
<p>I have built the scrolled frame with this snippet:</p>
<pre class="lang-py prettyprint-override"><code> for ndx, t in enumerate(sorted(tw, key=lambda x: x.created_at, reverse=True)):
print(t.created_at)
c... | <python><tkinter><ttkbootstrap> | 2023-03-07 15:03:27 | 2 | 935 | user2302244 |
75,663,384 | 12,193,952 | How to log Python code memory consumption? | <h3>Question</h3>
<p>Hi, I am runnin' a <strong>Docker</strong> container with a <strong>Python</strong> application inside. The code performs some computing tasks and I would like to monitor it's memory consumption using logs (<em>so I can see how different parts of the calculations perform</em>). I do not need any ch... | <python><docker><memory> | 2023-03-07 14:41:02 | 2 | 873 | FN_ |
75,663,294 | 20,959,773 | Find and click disabled element in Selenium Python | <h2>I'm working on automating a website and I'm encountering a problem with finding a single button.</h2>
<p>The issue stands that the website, has made a button I want to find and click by Selenium disabled by default, meaning selenium cannot find it by the xpath selector. I have concluded that the button has an even... | <javascript><python><html><selenium-webdriver> | 2023-03-07 14:31:24 | 1 | 347 | RifloSnake |
75,663,283 | 12,596,824 | Duplicating every row in dataframe N times where N is random | <p>I have a data set like so:</p>
<p><strong>Input:</strong></p>
<pre><code>id name
1 tim
2 jim
3 john
4 bill
</code></pre>
<p>I want to duplicate each row in my data set randomly anywhere from 0 - 5 times.</p>
<p>So my final data set might look something like this:</p>
<p><strong>Output:</strong></p>
<pre><code>id... | <python><pandas> | 2023-03-07 14:30:11 | 1 | 1,937 | Eisen |
75,663,162 | 2,135,504 | How to execute code only when executed as a VSCode Jupyter code cell? | <p>I often develop notebooks using <a href="https://code.visualstudio.com/docs/python/jupyter-support-py#_jupyter-code-cells" rel="nofollow noreferrer">VSCode jupyter code cells</a> like the one below and execute them via <code>python script.py</code> in tmux. The problem is that currently I don't have a function for <... | <python><visual-studio-code><jupyter-notebook> | 2023-03-07 14:18:23 | 1 | 2,749 | gebbissimo |
75,663,109 | 10,755,448 | Launch a program in vscode only if a certain condition is satisfied, e.g. the filename matches. (using launch.json) | <p>I am trying to write a <code>launch.json</code> config to run a python program called <code>myProg</code>. By design, <code>myProg</code> needs to be run from a folder containing a file named <code>myInput.py</code>; My workflow is that I open <code>myInput.py</code>, put some breakpoints there, and launch <code>myP... | <python><visual-studio-code> | 2023-03-07 14:14:14 | 3 | 507 | KMot |
75,663,011 | 1,367,097 | How to include both ends of a pandas date_range() | <p>From a pair of dates, I would like to create a list of dates at monthly frequency, including the months of both dates indicated.</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
import datetime
# Option 1
pd.date_range(datetime(2022, 1, 13),datetime(2022, 4, 5), freq='M', inclusive='both')
# ... | <python><pandas><datetime> | 2023-03-07 14:05:08 | 2 | 2,042 | Simon |
75,662,912 | 6,444,472 | Using `functools.partial` with variable-length arguments in python | <p>I have the following function with using *args, and a lambda function:</p>
<pre class="lang-py prettyprint-override"><code>def draw_figures(picture: Picture, *figures: Figure):
# draws the figures on the picture
...
figures = [figure1, figure2, figure3]
draw_fun = lambda new_picture: draw_figures(new_pictu... | <python><lambda><functools> | 2023-03-07 13:56:35 | 1 | 327 | ledermauss |
75,662,904 | 726,730 | python-shout *** buffer overflow detected ***: terminated | <p>script:</p>
<pre class="lang-py prettyprint-override"><code>import shout
s = shout.Shout()
print("Using libshout version %s" % shout.version())
s.audio_info = {shout.SHOUT_AI_BITRATE:'128', shout.SHOUT_AI_SAMPLERATE:'44800', shout.SHOUT_AI_CHANNELS:'2'}
s.name = 'Test radio connection'
s.url = 'http://l... | <python><buffer-overflow><icecast> | 2023-03-07 13:56:12 | 0 | 2,427 | Chris P |
75,662,883 | 2,749,397 | 2D array, check which rows are equal to a 1D array | <p>I have an array, <code>N</code> rows and <code>2</code> columns,</p>
<pre><code>arr = np.arange(200, dtype=int).reshape(-1,2)
</code></pre>
<p>and you know that <code>arr[50]</code> is <code>[100, 101]</code>, but I don't know that, so I write</p>
<pre><code>guess = np.array((100, 101), dtype=int)
arr == guess
</cod... | <python><arrays><numpy> | 2023-03-07 13:54:53 | 1 | 25,436 | gboffi |
75,662,882 | 6,281,366 | Python: getting the list of wifi interfaces in linux | <p>Whats the most simple way to get the list of current wifi interfaces?
i guess i can just run a shell command and extract if from there, but i wonder if theres a simpler way.</p>
| <python><linux> | 2023-03-07 13:54:53 | 3 | 827 | tamirg |
75,662,696 | 145,400 | How to infer type (for mypy & IDE) from a marshmallow schema? | <p>I have not asked a Python question in years! Exciting. This is largely an ecosystem question. Consider this snippet:</p>
<pre class="lang-py prettyprint-override"><code>try:
result = schema.load(data)
except marshmallow.ValidationError as exc:
sys.exit(f'schema validation failed: {exc}')
</code></pre>
<p>wit... | <python><types><mypy><pydantic><marshmallow> | 2023-03-07 13:37:33 | 1 | 36,314 | Dr. Jan-Philip Gehrcke |
75,662,649 | 14,697,000 | My python dictionary is not updating properly | <p>I am working on a project where I want to capture some data from different types of sorting algorithms and I planned on doing this by saving all the data into a dictionary and then converting that dictionary into a pandas data frame and eventually exporting it as a csv file.</p>
<p>The problem now is that I am updat... | <python><sorting><for-loop><global-variables><nested-loops> | 2023-03-07 13:33:25 | 1 | 460 | How why e |
75,662,625 | 8,665,962 | Understanding the subtle difference in calculating percentile | <p>When calculating the percentile using <code>numpy</code>, I see some authors use:</p>
<pre><code>Q1, Q3 = np.percentile(X, [25, 75])
</code></pre>
<p>which is clear to me. However, I also see others use:</p>
<pre><code>loss = np.percentile(X, 4)
</code></pre>
<p>I presume 4 implies dividing the 100 into 4 percentile... | <python><numpy><percentile> | 2023-03-07 13:31:17 | 1 | 574 | Dave |
75,662,623 | 12,946,401 | Understanding how to output multiclass segmentation using UNet in Pytorch | <p>So I have been learning about UNets and I managed to get the binary classification UNet model to work using some <a href="https://github.com/nikhilroxtomar/Retina-Blood-Vessel-Segmentation-in-PyTorch" rel="nofollow noreferrer">github examples</a>. However, I am now trying to figure out how this translates to multicl... | <python><pytorch><conv-neural-network><unet-neural-network> | 2023-03-07 13:31:11 | 1 | 939 | Jeff Boker |
75,662,358 | 14,093,555 | create 2 dimension array in C, and every cell with 512 bit size | <p>I want to create 2d arrays, with dimension of 2 by M, and any cell in the array will have 512 bit. I was think to create something like this:</p>
<pre class="lang-c prettyprint-override"><code>#define M 1024
typedef struct {
unsigned char public_key[2][M];
unsigned char private_key[2][M];
} key_pair
void k... | <python><c> | 2023-03-07 13:05:18 | 1 | 757 | hch |
75,662,333 | 12,965,658 | Type cast data types using pandas | <p>I have a file which has all datatypes as string. I want to type cast the data.</p>
<pre><code>for s3_file in keys:
analytics_df = pd.read_csv(s3_file, encoding="utf8")
analytics_df = analytics_df.juice.astype(float).fillna(0.0)
print(analytics_df.dtypes)
</code></pre>
<p>I am getting these erro... | <python><python-3.x><pandas><dataframe> | 2023-03-07 13:03:14 | 0 | 909 | Avenger |
75,662,319 | 15,724,084 | python selenium add value to attribute named value | <p>I want to add with python selenium framework, to input tag's <code>value</code> attribute equals let's say <code>New York, NY</code>. I guess I need for it, like <code>driver.execute_script("arguments[0].setAttribute('value',arguments[1])",element, value)</code> but do not know how to use it. Any kind of s... | <python><python-3.x><selenium-webdriver><web-scraping><css-selectors> | 2023-03-07 13:01:40 | 1 | 741 | xlmaster |
75,662,229 | 7,379,587 | Connect to postgresql database without a password | <p>I have no problem connecting to a PostgreSQL database locally on a server without a password on the commandline i.e., <code>$ psql -d dname</code> takes me straight into the database <code>dname</code> with no errors and no prompts for passwords etc. However, when I try to connect in Python (still locally on the ser... | <python><postgresql><sqlalchemy><psycopg2> | 2023-03-07 12:53:18 | 0 | 899 | ojunk |
75,662,227 | 14,494,483 | how to jitter the scatter plot on px.imshow heatmap in python plotly | <p>I have a risk matrix made using plotly's heatmap, and I have overlayed scatter points on the heatmap to show as each individual project. My question is if I have 2 projects that are in the same box, how to jitter the points so they can both fit in the box without overlaying onto each other? For example, I have <code... | <python><plotly><heatmap> | 2023-03-07 12:53:10 | 1 | 474 | Subaru Spirit |
75,662,122 | 3,189,219 | Proper pg8000 + SQLAlchemy Setup for Google Cloud Function | <p>my apologies in advance as I see there are a bunch of answers that are close to what I need, but no cigar - I'm a C# developer mostly, but am stuck on what should be basic boilerplate setup.</p>
<p>I need a small PostGRE SQL client for relatively basic queries (basic set or non-complex selects), but I want to re-use... | <python><postgresql><sqlalchemy><google-cloud-functions><pg8000> | 2023-03-07 12:43:04 | 0 | 369 | Xsjado |
75,661,970 | 15,751,564 | Reshaping torch tensor | <p>I have a torch of shape <code>(1,3,8)</code>. I want to increase the first dimension to <code>n</code>, resulting in the final tensor of shape <code>(n,3,8)</code>. I want to pad zeroes of that shape. Here is what I worked on:</p>
<pre><code>n = 5
a = torch.randn(1,3,8) # Random (1,3,8) tensor
b = torch.cat((a,torch... | <python><python-3.x><pytorch> | 2023-03-07 12:27:03 | 2 | 1,398 | darth baba |
75,661,851 | 11,197,301 | add a row to an empty array in python | <p>I would lie to add an array to an empty array in numpy.
Basically I would like to do the following:</p>
<pre><code>AA = np.array([])
for i in range(0,3):
#
BB = np.random.rand(3)
CC = np.vstack((AA, BB))
</code></pre>
<p>However, I get the following error:</p>
<pre><code>all the input array dimension... | <python><arrays><is-empty><vstack> | 2023-03-07 12:15:09 | 2 | 623 | diedro |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.