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,330,971 | 14,753,388 | Can Django STATIC_ROOT point to path on another server? | <p>I am using Django 4.0.1 in my project, and right prior to deploying my site, I am faced with the issue of handling my static files. Due to the limit of my server, I have decided to instead serve these static files via CDN.</p>
<p>I have already configured my <code>STATIC_URL</code> option in <code>settings.py</code>... | <python><python-3.x><django> | 2023-02-03 02:41:51 | 2 | 310 | Shaobin Jiang |
75,330,933 | 4,298,178 | Folium HeatMapWithTime html file generated is blank | <p>I created a self-contained code to create a HeatMapWithTime map but it shows up as a blank file. This code is run on Jupyter and the output is a 14KB file and I've tried to open it in Chrome, Safari, Firefox but it is still blank.</p>
<pre><code>import folium
import pandas as pd
import numpy as np
from folium.plugin... | <python><heatmap><folium> | 2023-02-03 02:34:31 | 2 | 797 | maregor |
75,330,793 | 13,946,204 | How to change number of workers and threads in running process for gunicorn | <p>I want to test performance of WEB service that running inside AWS ECS service depending on number of <code>gunicorn</code> workers.</p>
<p>Entrypoint of the container is:</p>
<pre class="lang-bash prettyprint-override"><code>WORKERS=15
THREADS=15
gunicorn \
--reload \
--workers "${WORKERS}" \
--thre... | <python><gunicorn> | 2023-02-03 02:04:42 | 1 | 9,834 | rzlvmp |
75,330,709 | 4,133,188 | Projection of a 3D circle onto a 2D camera image | <p>Asked this on <a href="https://math.stackexchange.com/questions/4630540/projection-of-a-3d-circle-onto-a-2d-camera-image">math.stackexchange</a>, but no responses so trying here, hopefully the computer vision people are more able to help out.</p>
<p>Assume that I have a 3D circle with a center at <code>(c1, c2, c3)<... | <python><graphics><computer-vision><linear-algebra><projection> | 2023-02-03 01:48:00 | 1 | 771 | BeginnersMindTruly |
75,330,690 | 6,202,327 | Get FEM, save plot as PNG? | <p>I am using the python bindings for getfem, to that effect I wrote this script, following their tutorial:</p>
<pre class="lang-py prettyprint-override"><code>import getfem as gf
import numpy as np
import math
center = [0.0, 0.0]
dir = [0.0, 1.0]
radius = 1.0
angle = 0.2 * math.pi
mo = gf.MesherObject("cone&qu... | <python><image> | 2023-02-03 01:43:36 | 1 | 9,951 | Makogan |
75,330,560 | 2,159,051 | How to debug crashing C++ library loaded in python project | <p>I am attempting to figure out why calling a function in a dynamically loaded lib crashes python. I'm doing the following, I have a C++ function in a dynamic library file, which is loaded in python using ctypes. I then call the function from python:</p>
<pre><code>lib = cdll.LoadLibrary(libPath)
# Note: using c_char... | <python><c++><visual-studio><ctypes> | 2023-02-03 01:19:57 | 1 | 2,298 | BWG |
75,330,556 | 5,141,652 | python tkinter scrollable frame scroll with mousewheel | <p>I have created a scrollable frame with tkinter and would like to use the mousewheel for the scrolling, I am also switching frames as pages. Everything works as expected for page 2 however the page does not scroll with the mousewheel on page 1, the scrollbar itself works and the mousewheel event is being triggered it... | <python><tkinter> | 2023-02-03 01:19:25 | 1 | 1,037 | Chris |
75,330,484 | 418,586 | Minimize AbsEquality rather than enforce in OrTools | <p>I'm trying to solve the following using OR tools:</p>
<p>Given the following bags containing different colors of balls:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>bag</th>
<th>red</th>
<th>blue</th>
<th>green</th>
<th>black</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>10</td>
<td... | <python><or-tools><integer-programming> | 2023-02-03 01:03:03 | 1 | 564 | Chris |
75,330,311 | 7,687,981 | Python vectorize nested for loop with conditionals | <p>How can I vectorize a nested for loop containing some conditionals? I'm trying to get a list of row/column windows within a very large array. What I have below is quick for a nested loop going through all the rows and columns with a given window size but I'm wondering if there is any way to make this faster.</p>
<pr... | <python><numpy><vectorization> | 2023-02-03 00:33:05 | 1 | 815 | andrewr |
75,330,256 | 16,491,055 | How to convert 1D numpy array of tuples to 2D numpy array? | <p>I have a <code>numpy</code> array of <code>tuples</code>:</p>
<pre><code>import numpy as np
the_tuples = np.array([(1, 4), (7, 8)], dtype=[('f0', '<i4'), ('f1', '<i4')])
</code></pre>
<p>I would like to have a 2D <code>numpy</code> array instead:</p>
<pre><code>the_2Darray = np.array([[1,4],[7,8]])
</code></pr... | <python><numpy> | 2023-02-03 00:22:07 | 2 | 771 | geekygeek |
75,330,116 | 19,130,803 | Flask upload file, pass file to celery task | <p>I am uploading file using flask rest-api and flask. As the file size is large I am using celery to upload the file on server. Below is the code.</p>
<p><strong>Flask Rest API</strong></p>
<pre><code>@app.route('/upload',methods=['GET','POST'])
def upload():
... | <python><flask><celery><gunicorn> | 2023-02-02 23:51:34 | 1 | 962 | winter |
75,330,032 | 9,795,817 | Unable to start Jupyter Notebook Kernel in VS Code | <p>I am trying to run a Jupyter Notebook in VS Code. However, I'm getting the following error message whenever I try to execute a cell:</p>
<pre class="lang-none prettyprint-override"><code>Failed to start the Kernel.
Jupyter server crashed. Unable to connect.
Error code from Jupyter: 1
usage: jupyter.py [-h] [--vers... | <python><visual-studio-code><jupyter-notebook> | 2023-02-02 23:35:15 | 6 | 6,421 | Arturo Sbr |
75,329,790 | 3,380,902 | Jupyter kernel dies on SageMaker notebook instance when running join operation using pd.merge on large DataFrames | <p>I am running a large pandas merge join operation on a <code>jupyter</code> notebook running on <code>SageMaker</code> notebook instance <code>ml.t3.large</code> i.e <code>8 gb</code> of memory.</p>
<pre><code>import pandas as pd
df1 = pd.DataFrame({
'ID': [1, 2, 3],
... | <python><pandas><amazon-web-services><amazon-sagemaker> | 2023-02-02 23:00:57 | 1 | 2,022 | kms |
75,329,708 | 10,045,428 | Dash leaflet not rendering when inside a Bootstrap tab container | <p>I am trying to create a simple Dash application that includes Dash-Leaflet so that it plots some points as markers. It is apparently working as expected when no styles are applied. But I would like to create a layout with bootstrap with tabs as in this example: <a href="https://hellodash.pythonanywhere.com/" rel="no... | <python><leaflet><plotly-dash><dash-leaflet> | 2023-02-02 22:47:52 | 2 | 347 | juancar |
75,329,646 | 12,461,032 | Tensorflow dataset iterator pick a sub-sample of whole data | <p>I have a code that generates an iterator from a Tensorflow dataset. The code is this:</p>
<pre><code>@tf.function
def normalize_image(record):
out = record.copy()
out['image'] = tf.cast(out['image'], 'float32') / 255.
return out
train_it = iter(tfds.builder('mnist').as_dataset(split='train').map(normalize_im... | <python><tensorflow><machine-learning><tensorflow-datasets> | 2023-02-02 22:37:29 | 1 | 472 | m0ss |
75,329,627 | 359,730 | Intersection of a predefined protocol with a generic protocol | <p>I'm looking for a workaround to the <a href="https://github.com/python/typing/issues/213" rel="nofollow noreferrer">infamous type <code>Intersection</code> problem</a> that would apply when one of the protocols is a <code>TypeVar</code>.</p>
<p>Pseudocode:</p>
<pre class="lang-py prettyprint-override"><code>Protocol... | <python><types><type-hinting><mypy><typing> | 2023-02-02 22:35:27 | 0 | 2,220 | eigenein |
75,329,597 | 6,077,239 | Polars dataframe join_asof with(keep) null | <p><strong>Update:</strong> This issue has been resolved. <code>df.join_asof(df2, on="time", by=["a", "b"])</code> now runs without error and returns the expected result.</p>
<hr />
<p>Currently, from my expermentation, join_asof does not will cause error if there are any None(null) in eit... | <python><python-polars> | 2023-02-02 22:31:43 | 1 | 1,153 | lebesgue |
75,329,557 | 4,774,461 | How is passing a generator to Depends make the generator act like a contextmanager? | <p>I was going through a tutorial on fast api and I came across something like below</p>
<pre><code>def get_db():
try:
db = SessionLocal()
yield db
finally:
print("from finally block")
db.close()
</code></pre>
<pre><code>@app.get("/")
async def read_all(db: Se... | <python><python-3.x><fastapi> | 2023-02-02 22:27:06 | 2 | 1,578 | Halcyon Abraham Ramirez |
75,329,456 | 3,434,906 | Binary Search in Python: correct slicing | <p>Please, help me unterstand the silly question about how binary sort algorithm's works.
So, lets take input array of <code>[4, 5, 6, 7, 8, 11, 20]</code> where i'm searching for index of 6 value (see the code).
As I take it should work this way:</p>
<ol>
<li>First of all we take the pivot(middle) point of (end-start)... | <python><arrays><algorithm><sorting> | 2023-02-02 22:08:09 | 1 | 401 | Dec0de |
75,329,446 | 6,905,666 | How to decrypt an encrypted image knowing the key but not much more on the algorithm? | <p>I am downloading an image from my camera (Ezviz, model CS-BC1C) and this image is encrypted. I set the encryption key (a password) on the camera app (Android) so I know what the key is (I suppose, if the key and the password are the same thing). It looks like that the image is encrypted with AES 128 bit. That's pret... | <python><aes><pycryptodome> | 2023-02-02 22:07:10 | 0 | 367 | Songio |
75,329,391 | 7,197,249 | Not able to configure cluster settings instance type using mlflow api 2.0 to enable model serving | <p>I'm able to enable model serving by using the mlflow api 2.0 with the following code...</p>
<pre><code> instance = f'https://{workspace}.cloud.databricks.com'
headers = {'Authorization': f'Bearer {api_workflow_access_token}'}
# Enable Model Serving
import requests
url = f'{instance}/api/2.... | <python><databricks><aws-databricks> | 2023-02-02 22:00:29 | 0 | 2,947 | spies006 |
75,329,306 | 4,856,526 | How can I query the bittensor network using btcli? | <pre><code>btcli query
Enter wallet name (default): my-wallet-name
Enter hotkey name (default): my-hotkey
Enter uids to query (All): 18
</code></pre>
<p>Note that <code>my-wallet-name</code>, <code>my-hotkey</code> where actually correct names. My wallet with one of my hotkeys. And I decided to query the UID 18.</p>
... | <python> | 2023-02-02 21:50:03 | 1 | 421 | eduardogr |
75,329,235 | 12,574,341 | Python convert time string with Z at end to datetime object | <p>An API is providing a time stamp in the following format</p>
<pre class="lang-py prettyprint-override"><code>s = "2023-02-02T21:05:07.2207121Z"`
</code></pre>
<p>I'm attempting to convert it to a datetime object</p>
<pre class="lang-py prettyprint-override"><code>dt = datetime.strptime(s, "%Y-%m-%dT%H... | <python><datetime> | 2023-02-02 21:41:03 | 0 | 1,459 | Michael Moreno |
75,329,174 | 357,313 | Where does this bottom margin come from? | <p>I'm cramming lots of small line charts onto one single figure. Sometimes I am left with a relatively large bottom margin, depending on my data. This is not specific to subplots but can also happen for only one axes. An example:</p>
<pre><code>import pandas as pd
import matplotlib.pyplot as plt
df = pd.Series([1, 2,... | <python><pandas><matplotlib><plot> | 2023-02-02 21:32:50 | 1 | 8,135 | Michel de Ruiter |
75,329,012 | 6,759,459 | Why does a ValidationError 422 occur when sending a POST request to a FastAPI app through Postman? | <p>I cannot seem to send a POST request to a FastAPI app through Postman.</p>
<ul>
<li>FastAPI version 0.89.1</li>
<li>Python version 3.10.9</li>
</ul>
<pre><code>from fastapi import FastAPI
from fastapi.params import Body
from pydantic import BaseModel
app = FastAPI()
class Post(BaseModel):
title : str
conte... | <python><postman><fastapi><http-status-code-422> | 2023-02-02 21:15:54 | 1 | 926 | Ari |
75,329,005 | 13,668,802 | Python: `and` operator does not return a boolean value | <p>In Python, an empty list is considered a Falsey value</p>
<p>Therefore this is how things should work:</p>
<pre><code>>>> [] and False
False
</code></pre>
<p>But in reality, python returns an empty list.</p>
<pre><code>>>> [] and False
[]
</code></pre>
<p>Is this intended or a bug?</p>
| <python><python-3.x><list><boolean> | 2023-02-02 21:15:05 | 3 | 970 | Rage |
75,328,861 | 10,620,003 | Multiply two df in GPU (cudf) | <p>I have two dataframe in GPU. I want to multiply each element of each df.
Here is a simple version of my dataframes:</p>
<pre><code>import cudf
a = cudf.DataFrame()
a['c1'] = [1, 2]
b = cudf.DataFrame()
b['c1'] = [2, 5]
</code></pre>
<p>I want to see this output:</p>
<pre><code> c1
0 2
1 10
</code></pre>
<p>I ... | <python><dataframe><cudf> | 2023-02-02 20:56:32 | 1 | 730 | Sadcow |
75,328,769 | 10,687,615 | Extract multiple date/time values from text field into new variable columns | <p>I have dataframe - see below. This is just a snippet of the full dateframe, there are more text and date/times in each respective rows/IDS. As you can see the text before and after each date/time is random.</p>
<pre><code>ID RESULT
1 Patients Discharged Home : 12/07/2022 11:19 Bob Melciv Appt 12/0... | <python><pandas><extract> | 2023-02-02 20:47:39 | 2 | 859 | Raven |
75,328,614 | 6,197,439 | Format int as hex string in help string of Python argparse? | <p>I have seen <a href="https://stackoverflow.com/questions/5661725/format-ints-into-string-of-hex">Format ints into string of hex</a> - but I simply cannot figure out how to apply that here:</p>
<pre class="lang-py prettyprint-override"><code>import argparse
def parse_args(args):
parser = argparse.ArgumentParser(de... | <python><number-formatting> | 2023-02-02 20:30:13 | 1 | 5,938 | sdbbs |
75,328,606 | 5,568,409 | How to show different colors on a plot for values from different columns | <p>Please consider the small dataframe test:</p>
<pre><code>import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame(
[
[1, 1.0, 0.0, 0.0],
[1, 0.75, 0.25, 0.0],
[1, 0.576, 0.396, 0.028]
],
columns = ["State", "1", "... | <python><matplotlib><colors> | 2023-02-02 20:29:23 | 2 | 1,216 | Andrew |
75,328,537 | 6,560,267 | How to disable jupyter/ipython saving of intermediate (anonymous variables)? | <p>When you use Jupyter, you get these "numbered inputs & outputs" you can reference like this: <code>_3</code>. I'm the kind of guy who uses Jupyter like a nicer REPL with persistent code blocks & comments.
As time goes on, on long sessions, these kind of outputs start eating up memory, and then I ha... | <python><jupyter-notebook> | 2023-02-02 20:18:53 | 0 | 913 | Adrian |
75,328,427 | 2,117,355 | Implement Python Flash Controller Methods Generated from OpenAPI Generator | <p>I'm using <a href="https://openapi-generator.tech/docs/generators/python-flask" rel="nofollow noreferrer">OpenAPI Generator</a> to generate a Python Flask web app from an OpenAPI specification. A generated controller method looks like this:</p>
<pre><code>def doStuff(body): # noqa: E501
return 'do some magic!'... | <python><flask><openapi><openapi-generator> | 2023-02-02 20:07:22 | 0 | 5,722 | Mark |
75,328,289 | 12,470,058 | Return an element with the maximum number of occurrences in a given matrix | <p>I have written a function that takes a matrix and finds an element with the greatest number of occurrences in the matrix. If more than one such element exists, my function returns the list of all of them.</p>
<p>For example, if the input is:</p>
<pre><code>matrix = [[0, 5, 1, 1, 0],
[0, 2, 2, 2, 0],
... | <python><python-3.x> | 2023-02-02 19:52:19 | 1 | 368 | Bsh |
75,328,277 | 1,848,244 | Pandas: Concise way of applying different functions across a multiindex column | <p>I have a multi-index dataframe. I want to create a new column whose value is a function of other columns. The problem is that the function is different for a small number of levels.</p>
<p>In order to do this, I am having to manually define the calculation for every leaf level in the hierarchical dataset. This is un... | <python><pandas> | 2023-02-02 19:50:25 | 3 | 437 | user1848244 |
75,328,211 | 15,171,387 | How to get the unique values multiple columns for a unique value of another column in Pandas? | <p>I have a datframe like this:</p>
<pre><code>import pandas as pd
df = pd.DataFrame({'val':['a', 'a', 'b', 'a', 'c'], 'g_1':[0, 0, 1,0,2], 'g_2':[0, 0, 0,0,1]})
</code></pre>
<p>Now, to get the unique values of column <code>g_1</code> for all unique values of column <code>val</code>, I do something like this:</p>
<pr... | <python><pandas><group-by> | 2023-02-02 19:43:14 | 3 | 651 | armin |
75,328,144 | 3,063,547 | Error trying to import netCDF4 in python script using chaquopy with android studio | <p>I am trying to integrate python code into an Android app using Chaquopy with Android Studio.</p>
<p>The Android app is dying on import netCDF4 in the python module. I am running Android Studio on MacOS and made sure netcdf4 was installed via:</p>
<pre><code> %pip3 uninstall netcdf4
%pip3 install netcdf4
</code></p... | <python><android><netcdf><chaquopy> | 2023-02-02 19:35:06 | 0 | 853 | user3063547 |
75,328,088 | 5,346,843 | Confused about plotting interpolated 2D data with matplotlib | <p>I have some unstructured 2D data that I would like to interpolate on a unit offset grid (ie grid indices start at 1 not 0) using <code>scipy</code> and plot using <code>matplotlib</code>. The code is below</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
import scipy.interpolate
# X Y Z... | <python><matplotlib><scipy> | 2023-02-02 19:28:44 | 1 | 545 | PetGriffin |
75,327,974 | 7,984,318 | Pandas compute time duration among 3 columns and skip the none value at the same time | <p>I have a Dateframe ,you can have it ,by runnnig:</p>
<pre><code>import pandas as pd
from io import StringIO
df = """
case_id first_created last_paid submitted_time
3456 2021-01-27 2021-01-29 2021-01-26 21:34:36.566023+00:00
7891 2021-08-02 2021-09-16 2022-10-26... | <python><pandas><dataframe> | 2023-02-02 19:16:27 | 1 | 4,094 | William |
75,327,966 | 13,231,896 | How to get static map with multipolygon as an Image in python | <p>I am looking for way (maybe through an external API) to represent many polygons in an static map. The idea is giving the coordinates to that service,and that service or API must give an static map asn a png image with those polygons. Just like this:</p>
<p><a href="https://i.sstatic.net/rBOix.png" rel="nofollow nore... | <python><gis> | 2023-02-02 19:15:51 | 0 | 830 | Ernesto Ruiz |
75,327,914 | 801,902 | How to replicate what django-allauth does when it creates a user, or how to programmatically submit a form in django? | <p>I am trying to import a bunch of users from an old database into a new system, and I am running into problems when I just create users and add their email addresses. Apparently allauth does some hidden magic behind the scenes that I'm having trouble figuring out, because when one of these users logs in, I get an er... | <python><django><django-allauth> | 2023-02-02 19:11:08 | 1 | 1,452 | PoDuck |
75,327,797 | 9,983,652 | output NaN value when using apply function to a dataframe with index | <p>I am trying to use apply function to create 2 new columns. when dataframe has index, it doesn't wokr, the new columns have values of NaN. If dataframe has no index, then it works. Could you please help? Thanks</p>
<pre><code>
def calc_test(row):
a=row['col1']+row['col2']
b=row['col1']/row['col2']
retur... | <python><pandas> | 2023-02-02 18:58:41 | 2 | 4,338 | roudan |
75,327,650 | 12,323,468 | I have a list of dataframes, how do I append a dataframe to each of those in my list in Python? | <p>The following python code gives me 3 dataframes (df_apples, df_oranges, df_grapes) showing sales and price for various fruits by month. I created a list of these dfs (df_list). I have another frame (df_forecast) which I want to append to each of the frames in df_list so I can create customized projections of each ... | <python> | 2023-02-02 18:43:49 | 3 | 329 | jack homareau |
75,327,510 | 17,696,880 | Why doesn't this regex capture group stop with the set condition and continue capturing until the end of the line? | <pre class="lang-py prettyprint-override"><code>import re
input_text = "((PL_ADVB)alrededor (NOUN)(del auto rojizo, algo grande y completamente veloz)). Luego dentro del baúl rápidamente abajo de una caja por sobre ello vimos una caña." #example input
#place_reference = r"((?i:\w\s*)+)?"
#place_re... | <python><python-3.x><regex><string><regex-group> | 2023-02-02 18:31:47 | 1 | 875 | Matt095 |
75,327,441 | 17,194,313 | How to use PARSE_XML in SnowSQL where the underlying XML is "broken"? | <p>I am working with a very large collection of XML files (1m+) and for some reason most of them are "broken"</p>
<p>That is to say, running <code>CHECK_XML()</code> on them returns all sorts of errors (missing tag name after <, prematurely terminated xml, etc...)</p>
<p>Is there any way to parse this in s... | <python><xml><snowflake-cloud-data-platform> | 2023-02-02 18:23:53 | 0 | 3,075 | MYK |
75,327,429 | 8,852,498 | microservices: client service and server service (fastAPI) running as docker | <p>I need to build a small program with microservice architecture:</p>
<ol>
<li>server service (Python fast API framework)</li>
</ol>
<p>I run it with Dockerfile command:</p>
<pre><code> CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
</code... | <python><docker><microservices><client-server><fastapi> | 2023-02-02 18:22:41 | 1 | 845 | Adi Epshtain |
75,327,410 | 5,269,906 | SQLAlchemy 2.0 session.execute() BULK INSERT respecting relationships | <p>I'm trying to create a web scraping project that uploads scraped data to a database using SQLAlchemy ORM. Lets use <a href="https://quotes.toscrape.com/" rel="nofollow noreferrer">https://quotes.toscrape.com/</a> as an example</p>
<pre><code># models.py
from sqlalchemy import Column, Date, ForeignKey, Integer, Strin... | <python><sqlalchemy> | 2023-02-02 18:21:47 | 0 | 499 | Osuynonma |
75,327,384 | 13,359,498 | ValueError: ('Input data in `NumpyArrayIterator` should have rank 4. You passed an array with shape', (550, 8)) | <p>I used stratified cross-validation in my model. I have datagen, which I will use to augment the train data.
Code snippet:</p>
<pre><code>i=0
for train_index, val_index in skf.split(X_train, y_train):
X_train_fold, X_val_fold = X_train[train_index], X_train[val_index]
y_train_fold, y_val_fold = y_train[train_... | <python><tensorflow><keras><deep-learning> | 2023-02-02 18:19:50 | 0 | 578 | Rezuana Haque |
75,327,383 | 18,758,062 | SimPy: In every step, run a specific process after all the other processes has finished | <p>I am new to SimPy and need help to figure out how to do this:</p>
<p>There are multiple <code>foo</code> processes running and a <code>monitor</code> process. At every time step, is there a way to ensure that the <code>monitor</code> process runs only after the other <code>foo</code> processes have finished running ... | <python><generator><simulation><simpy> | 2023-02-02 18:19:46 | 1 | 1,623 | gameveloster |
75,327,375 | 867,889 | How to feed a dictionary as parameters to a function with a mix of positional and named arguments? | <p>Given a dictionary <code>params={'a':0, 'b':1, 'c':2, 'd':3}</code> I want to pass them to a function <code>foo</code>:</p>
<pre><code>def foo(a, b, c=None, d=None):
pass
</code></pre>
<p>Something as simple as <code>foo(**params)</code> would complain about mixing positional and named arguments.</p>
<p>There is ... | <python> | 2023-02-02 18:19:10 | 1 | 10,083 | y.selivonchyk |
75,327,334 | 9,391,359 | Split string by specific html tags with keeping tags | <p>I need to split string by specific number of tags <code>(<li>, <lu> ...)</code>. I came up with regex</p>
<p><code>pattern = <li>|<ul>|<ol>|<li>|<dl>|<dt>|<dd>|<h1>|<h2>|<h3>|<h4>|<h5>|<h6></code> and <code>re.split</code></p>
... | <python><html> | 2023-02-02 18:15:04 | 1 | 941 | Alex Nikitin |
75,327,274 | 19,053,778 | Having the same index values when pivoting a dataframe from long to wide format gives an average value | <p>Context: I'm trying to pivot a long format dataframe to a wide format dataframe, however, I'm noticing a weird pattern on the wide format dataframe. It seems that if we have repeated values for the index (in my case, a date), it's almost like it's giving me an average instead of repeating each index value and keepin... | <python><pandas> | 2023-02-02 18:08:17 | 1 | 496 | Chronicles |
75,327,185 | 2,100,039 | Reading Data from URL into a Pandas Dataframe | <p>I have a URL that I am having difficulty reading. It is uncommon in the sense that it is data that I have self-generated or in other words have created using my own inputs. I have tried with other queries to use something like this and it works fine but not in this case:</p>
<pre><code>bst = pd.read_csv('https://psl... | <python><pandas><csv><url> | 2023-02-02 18:00:07 | 2 | 1,366 | user2100039 |
75,327,154 | 282,918 | Python: separating words using space, but preserving double quotes surrounded text as single unit | <p>Let's say I have a string that looks like this:</p>
<pre><code>one two three "four five"
</code></pre>
<p>I'd like to split such that I get an array:</p>
<pre><code>['one', 'two', 'three', 'four five']
</code></pre>
<p>using <code>split</code> with <code>' '</code> will not be enough here. I have to separa... | <python> | 2023-02-02 17:57:20 | 2 | 5,534 | JasonGenX |
75,327,075 | 16,512,200 | SQL Alchemy: Convert Row Values to Column Names | <p>I've got a table with columns like this:</p>
<pre><code>DataID (Primary auto-incrementing key)
TestID (Foreign Key)
FormID (Foreign Key)
VariableName (String Type)
Data (String Type)
</code></pre>
<p>Which means the data often looks like this:</p>
<pre><code>DataID, TestID, FormID, Var... | <python><sqlalchemy> | 2023-02-02 17:49:24 | 0 | 371 | Andrew |
75,327,034 | 14,692,430 | Moderngl: Render VAO with multiple shaders | <p>I'm doing some stuff with 2D opengl rendering.</p>
<p>Is there a way to render a vertex array object but have the data be passed through multiple shaders? For example, a shader that applies a normal map to the texture, and then a shader that blurs the image. It would be very difficult and unclean to combine the two ... | <python><opengl><shader><vertex-array-object><python-moderngl> | 2023-02-02 17:45:29 | 1 | 352 | DaNubCoding |
75,327,028 | 6,454,901 | Python Falcon - Post calls are being ignored | <p>I'm trying to set up a simple reverse proxy with Falcon in Python.</p>
<p>I have:</p>
<pre><code>import falcon
import requests
class ReverseProxyResource:
def on_get(self, req, resp, text=None):
print("GET")
if(text):
destination = "[destination_url]/" + text
... | <python><falconframework><falcon> | 2023-02-02 17:44:54 | 1 | 508 | DevBot |
75,326,988 | 8,017,666 | Supervisorctl : Issuing in running supervistorctl status | <p>I am not able to run any <code>supervisorctl</code> command inside docker container like <code>stop</code>, <code>start</code>, <code>status</code>, <code>restart</code>, etc.</p>
<p>My Supervisord configuration looks like below</p>
<pre><code>abc@abc-adhocworker-c89d9667b-9lqbd:/app$ cat worker.conf
[supervisord]
... | <python><docker><supervisord> | 2023-02-02 17:40:45 | 1 | 2,946 | SRJ |
75,326,955 | 10,842,351 | How to use different RNGs in different parts of a simulation avoiding correlation? | <p>This question arises from my attempt to mix two different RNGs. I'd like to mix them choosing the best of the two according to the operations I need to carry out to achieve better performance. More concretely, the two RNGs are:</p>
<ul>
<li>The Mersenne Twister (MT19937) coming from the <a href="https://docs.python... | <python><numpy><performance><random> | 2023-02-02 17:37:07 | 1 | 665 | Tortar |
75,326,947 | 9,262,339 | Django ORM dublicate objects in queryset after order_by by foreignkey field | <p>I have encountered some unexpected sorting behaviour with objects. As soon as I sort by the related model field, I get duplicates.
A short description of the model fields</p>
<p>models.py</p>
<pre><code>class GoogleCreativeSpend(models.Model):
creative = models.ForeignKey(
'GoogleCreative',
on_de... | <python><django> | 2023-02-02 17:36:46 | 1 | 3,322 | Jekson |
75,326,861 | 1,221,310 | Initializing an empty Pydantic Dynamic model | <p>I have data coming into my FastAPI that can take any shape/form and as such I need an empty Pydantic model. I tried creating a dynamic model like this:</p>
<pre><code>DynamicModel = create_model('RandomData', random_data=(dict, ...))
</code></pre>
<p>However it requires the model to follow this structure:</p>
<pre><... | <python><pydantic> | 2023-02-02 17:30:31 | 0 | 906 | cp-stack |
75,326,752 | 13,679,903 | Time complexity of dict.fromkeys() | <p>I'm trying to get an ordered set in Python 3.8. According to this <a href="https://stackoverflow.com/a/53657523/13679903">answer</a>, I'm using <code>dict.fromkeys()</code> method to get the unique items from a list preserving the insertion order. What's the time complexity of this method? As I'm using this frequent... | <python><dictionary> | 2023-02-02 17:20:12 | 0 | 437 | Mohammad Rifat Arefin |
75,326,707 | 14,406,682 | Hide attributes from sphinx autodoc but show them in docstring | <p>I want to do two things at once:
Display the attributes of a class in its docstring, so that, for example, it will available in a Jupyter notebook when I hit Shift + Tab + Tab.</p>
<p>However, in the Sphinx output, the docs generated with the <code>.. autoclass::</code> directive contain the attributes section, whic... | <python><python-sphinx><restructuredtext><docstring> | 2023-02-02 17:15:48 | 0 | 718 | Maurycyt |
75,326,663 | 5,908,886 | Remove duplicates in multifasta, where entries are paired | <p>Hi my input looks like:</p>
<pre><code>>ref
GGTGCCCACACTAATGATGTAAAACAATTAACAGAGGCAGTGCAAA
>sample1
GGTGCCCACACTAATGATGTAAAACAATTAACAGAGGCAGTGCAAA
>ref
GGTTAGGGCCGCCTGTTGGTGGGCGGGAATCAAGCAGCATTTTGGAATTCCCTACAAT
>sample2
GGTTAGGGCCGCCTGTTGGTGGGCGGGAATCAAGCAGGTATTTGGAATTCCCTACAAT
</code></pre>
<p>The e... | <python><bash><awk> | 2023-02-02 17:11:59 | 3 | 377 | SaltedPork |
75,326,651 | 11,115,072 | How to get the last occurrance of all items on a column (pandas) | <p>Let's suppose I have a dataset like this:</p>
<pre><code>item_id | date | cat |
----------------------------
0 | 2020-01-01 | A |
0 | 2020-02-01 | B |
1 | 2020-04-01 | A |
2 | 2020-02-01 | C |
2 | 2021-01-01 | B |
</code></pre>
<p>So, I need to get the last category (co... | <python><pandas> | 2023-02-02 17:10:06 | 1 | 381 | Gabriel Caldas |
75,326,465 | 10,007,302 | Most effecient way to insert data into an existing mySQL table from a python dataframe but if column2 and column 3 contain dupes, update existing | <p>I'm relatively new to SQL and python. I'm trying to write code that will handle updates to an existing table in SQL. I've made an example below.</p>
<pre><code>id Project Company Start Date Industry
1 Zebra Apple 1/2/2022 Software
2 Charlie Tesla 2/2/2022 Automotive
3 Alpha Google 3/2/2022 ... | <python><mysql><pandas> | 2023-02-02 16:53:56 | 0 | 1,281 | novawaly |
75,326,423 | 3,521,180 | how do I pass multiple column names dynamically in pyspark? | <p>I am writing a python function that will do a leftanti join on two dataframe, and the joining condition may vary. i.e. sometime 2 DFs might have just one column as unique key for joining, and soemtime 2 DFs might have more than 1 columns to join on.</p>
<p>So, I have written the below code. Please suggest what chan... | <python><python-3.x><pyspark> | 2023-02-02 16:50:23 | 1 | 1,150 | user3521180 |
75,326,281 | 15,520,615 | Python/PySpark String Split Index on key:value pair modification | <p>The following split/index will retrieve the following the output <code>'accountv2'</code> from</p>
<pre><code>Ancestor:{'ancestorPath': '/mnt/lake/RAW/Internal/origination/dbo/accountv2/1/Year=2023/Month=2/Day=2/Time=04-09', 'dfConfig': '{"sparkConfig":{"header":"true"}}', 'fileFormat':... | <python><pyspark> | 2023-02-02 16:38:39 | 1 | 3,011 | Patterson |
75,326,238 | 1,008,794 | How to omit dependency when exporting requirements.txt using Poetry | <p>I have a Python3 Poetry project with a <code>pyproject.toml</code> file specifying the dependencies:</p>
<pre><code>[tool.poetry.dependencies]
python = "^3.10"
nltk = "^3.7"
numpy = "^1.23.4"
scipy = "^1.9.3"
scikit-learn = "^1.1.3"
joblib = "^1.2.0"
[tool... | <python><pip><python-poetry><requirements.txt> | 2023-02-02 16:35:36 | 1 | 4,931 | Rulle |
75,326,179 | 11,027,207 | import package dynamically | <p>I'd like to understand if there's better solution .
for following tree:</p>
<pre><code>|-main.py
├── app_config
│ ├── db_config.py
| |--- settings.py
</code></pre>
<p>Main.py importing class from db_config</p>
<pre><code>from app_config.db_config import DBContext
</code></pre>
<p>So in db_config.py each import o... | <python><import> | 2023-02-02 16:32:03 | 1 | 424 | AviC |
75,326,066 | 19,155,645 | Coco annotations: convert RLE to polygon segmentation | <p>I have coco style annotations (json format) with Both segmentations And bboxes.<br>
Most of the segmentations are given as list-of-lists of the pixels (polygon).</p>
<p>The problem is that some segmentations are given as a dictionary (with 'counts' and 'size' keys) that represent RLE values, and in these cases the '... | <python><machine-learning><computer-vision><annotations><image-segmentation> | 2023-02-02 16:22:04 | 1 | 512 | ArieAI |
75,326,012 | 16,688,854 | Compute and fill an array in parallel | <p>As part of a signal processing task, I am doing some computation per frequency step.</p>
<p>I have a <strong>frequencies</strong> list of <strong>length 513</strong>.</p>
<p>I have a 3D numpy array <strong>A</strong> of <strong>shape (81,81,513)</strong>, where 513 is the number of frequency points. I then have a 81... | <python><multiprocessing> | 2023-02-02 16:17:25 | 1 | 337 | Antoine101 |
75,325,992 | 8,598,605 | Python: Accelerate numpy brute force 2d image searching | <p>I have two images, where part of one image is present in another, however the position is not necessarily equal.</p>
<p><a href="https://i.sstatic.net/ZDk5u.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZDk5u.jpg" alt="First image" /></a><a href="https://i.sstatic.net/4ex7L.jpg" rel="nofollow norefe... | <python><numpy><optimization><gpu><numba> | 2023-02-02 16:15:48 | 1 | 740 | Jkind9 |
75,325,985 | 9,983,652 | ValueError: too many values to unpack when using apply to return multiple values | <p>I am using apply function to return 2 new columns, and then I got an error, not sure what is wrong? Thanks for your help.</p>
<pre><code>def calc_test(row):
a=row['col1']+row['col2']
b=row['col1']/row['col2']
return (a,b)
df_test_dict={'col1':[1,2,3,4,5],'col2':[10,20,30,40,50]}
df_test=pd.DataFrame(d... | <python><pandas> | 2023-02-02 16:14:22 | 1 | 4,338 | roudan |
75,325,959 | 472,226 | Why would sum(array) give a different result depending on the order of the | <p>Why would the order of the values yield different totals?</p>
<pre class="lang-py prettyprint-override"><code>data = (
-81.9672,
48.3607,
48.3607,
40.9836,
-40.9836,
-40.9836,
81.9672,
81.9672,
-81.9672,
40.9836,
-48.3607,
-48.3607,
)
sum_order_1 = sum(data)
sum... | <python><precision> | 2023-02-02 16:12:22 | 0 | 12,853 | Ronnis |
75,325,876 | 3,435,121 | class hidden from module dictionary | <p>I'm developing a code analysis tool for Python program.<br />
I'm using introspection techniques to navigate into program structure.<br />
Recently, I tested my tool on big packages like tkinter and matplotlib. It worked well.<br />
But I found an oddity when analyzing numpy.</p>
<pre><code>import numpy,inspect
for ... | <python><introspection> | 2023-02-02 16:05:57 | 1 | 675 | user3435121 |
75,325,828 | 15,414,616 | Python thread safe singleton stuck when used | <p>I tried to implement a thread safe singleton for my python code. I tried these 2 pieces of code but both of them get stuck when the class with the metaclass of the Singleton is being called from my unittests.</p>
<p>1 (check-lock-check):</p>
<pre><code>import functools
import threading
from typing import Callable
... | <python><multithreading><singleton> | 2023-02-02 16:02:00 | 1 | 437 | Ema Il |
75,325,514 | 1,075,653 | How can I add the currently logged in username to the access log of django.server? | <p>I'm trying to add the currently logged in username, if any, to the access log of a Django app:</p>
<pre><code>INFO [django.server:161] "GET / HTTP/1.1" 200 116181
^ username should go here
</code></pre>
<p>My main problem is how do I share the user/username between the middleware an... | <python><django><django-admin> | 2023-02-02 15:38:42 | 1 | 463 | Emil Burzo |
75,325,378 | 3,375,378 | gradio refresh interface when selecting File | <p>I'm trying to create a gradio User Interface which does the following</p>
<ol>
<li>on the left panel I have a File control, that allows the selection of a local file (eg. a .csv)</li>
<li>when a file is selected a "Process" button should be made visible</li>
<li>when the "Process" button is press... | <python><gradio> | 2023-02-02 15:28:31 | 1 | 2,598 | chrx |
75,325,367 | 293,995 | Getting the GPS position of coordinates (x,y) on a Google maps API satellite image in function of the zoom level | <p>Using yolo to detect features on satellite images Google Maps API, I get the coordinates (x,y) of each features. The reference (0, 0) is the top left corner. Yolo provides also the width and height of the bounding box. I have the GPS position of the center of the image.</p>
<p>I would like to get the GPS coordinates... | <python><google-maps-api-3><gis> | 2023-02-02 15:27:35 | 1 | 2,631 | hotips |
75,325,188 | 7,042,778 | Problem loading a function in Python to_sql | <p>I have the following code in two scripts called Playing_DB_Around.py with the following code:</p>
<pre><code>import data_base.Calc_Func as calc
import pandas as pd
df = pd.DataFrame({'Name': ['John', 'Jane', 'Jim'], 'Age': [25, 30, 35]})
db = calc.Database("example_db")
calc.Database.to_sql(df, "e... | <python><sqlite><class><sqlalchemy><pandas-to-sql> | 2023-02-02 15:12:28 | 1 | 1,511 | MCM |
75,325,121 | 13,517,174 | How do you set up a docker container that depends on multiple python libraries being installed? | <p>I am trying to create a docker container to always run mypy in the same environment. The library I want to run mypy on has multiple dependencies, so I have to install those first and have access to them as I am evaluating the library that was passed. This is what it currently looks like, in this example I am only in... | <python><docker><dockerfile><mypy> | 2023-02-02 15:06:51 | 0 | 453 | Yes |
75,325,061 | 7,376,511 | Caching an instance's method indefinitely raises pylint warning | <pre><code>class A:
@cache
def extremely_long_and_expensive_function(self) -> None:
# series of instructions that MUST access self
</code></pre>
<p>Pylint complains as follows:</p>
<blockquote>
<p>lru_cache(maxsize=None)' or 'cache' will keep all method args alive
indefinitely, including 'self'pylint... | <python><caching><memoization> | 2023-02-02 15:01:56 | 0 | 797 | Some Guy |
75,325,025 | 9,663,207 | Parsing a pandas dataframe into a nested list object | <p>Does anyone have a neat way of packing a dataframe including some columns which indicate hierarchy into a nested array?</p>
<p>Say I have the following data frame:</p>
<pre class="lang-py prettyprint-override"><code>from pandas import DataFrame
df = DataFrame(
{
"var1": [1, 2, 3, 4, 9],
... | <python><pandas><dataframe><recursion> | 2023-02-02 14:58:16 | 1 | 724 | g_t_m |
75,324,905 | 10,260,243 | Pandas groupby and then apply to_dict('records') | <p>Suppose I have the following data frame:</p>
<pre><code>df = pd.DataFrame({'a': [1,1,1,2], 'b': ['a', 'a', 'b', 'c'], 'd': [1, 2, 3, 4]})
</code></pre>
<p>And I want to end with the following dict:</p>
<pre><code>{1: [{'b':'a', 'd': 1}, {'b': 'a', 'd': 2}, {'b': 'b', 'd': 3}], 2: [{'b': 'c', 'd': 4}]}
</code></pre>
... | <python><pandas> | 2023-02-02 14:50:25 | 3 | 4,678 | Bruno Mello |
75,324,721 | 7,578,494 | python-numpy, assigning the nearest valid value of a reference array | <p>Here are toy NumPy arrays:</p>
<pre class="lang-py prettyprint-override"><code>nrow = 10
ar_label = np.arange(nrow**2).reshape(nrow, nrow)
ar_label[1:4, 1:4] = 100
ar_label[6:9, 2:5] = 200
ar_label[2:5, 6:9] = 300
ar_label = np.where(ar_label<100, np.nan, ar_label)
ar_label
array([[ nan, nan, nan, nan, nan,... | <python><numpy> | 2023-02-02 14:37:11 | 4 | 343 | hlee |
75,324,711 | 18,814,386 | Why Python import is looking package from another environment? | <p>I am using different environment (Conda) for the project (python 3.10.9). When I import libraries and packages etc, it is importing from that environment's path. But when I import streamlit-extras package, even though it is installed on the same environment, It is searching from other version (python 3.7) and theref... | <python><visual-studio><import><environment><streamlit> | 2023-02-02 14:36:40 | 1 | 394 | Ranger |
75,324,700 | 14,088,919 | Divide two columns in pivot table and plot grouped bar chart with pandas | <p>I have a dataset that looks like this:</p>
<pre><code>df = pd.DataFrame({
'Vintage': ['2016Q1','2016Q1', '2016Q2','2016Q3','2016Q4','2016Q1', '2016Q2','2016Q2','2016Q2','2016Q3','2016Q4'],
'Model': ['A','A','A','A','A','B','B','B','B','B','B',],
'Count': [1,1,1,1,1,1,1,1,1,1,1],
'Case':[0,1,1,0,1... | <python><pandas><matplotlib><group-by><pivot-table> | 2023-02-02 14:35:37 | 2 | 612 | amestrian |
75,324,641 | 10,007,302 | uhashable type:DataFrame error when trying to write DataFrame to_sql | <p>I have this code block that reads a named range from excel into a dataframe. Once I have that, I'm trying to upload it to a SQL table called projects. but I keep getting the following error:</p>
<pre><code> if key in metadata.tables:
TypeError: unhashable type: 'DataFrame
</code></pre>
<p>Any ideas? Code block be... | <python><mysql><pandas><dataframe><sqlalchemy> | 2023-02-02 14:31:38 | 0 | 1,281 | novawaly |
75,324,499 | 8,467,078 | Proper way to do a True/False/"something" argument in Python | <p>I have a function in Python which should use a keyword argument, let's call it <code>foo</code>, to decide if a certain action should be performed always (<code>foo=True</code>), never (<code>foo=False</code>) or let an algorithm make the decision (<code>foo='auto'</code>). Minimum working example would look somethi... | <python><arguments> | 2023-02-02 14:20:48 | 2 | 345 | VY_CMa |
75,324,498 | 1,040,718 | Switch python version in Ubuntu | <p>I'm using Python 3.6 installed with pyenv and apt-get. In the shell if I do <code>python3 --version</code> it shows</p>
<pre><code>python3 --version
Python 3.6.0
</code></pre>
<p>I'm using Ubuntu 20.04 ARM version, and it comes with Python 3.8 installed. However, when running a test command, it's invoking <code>/usr... | <python><python-3.x><ubuntu> | 2023-02-02 14:20:47 | 0 | 11,011 | cybertextron |
75,324,409 | 4,587,498 | NetApp ONTAP with Python netapp-ontap - create vault policy | <p>I am trying to create a custom policy using netapp-ontap python library, version 9.11.1. I can do the same using the CLI <code>snapmirror policy create</code> as show <a href="https://docs.netapp.com/us-en/ontap-cli-97/snapmirror-policy-create.html#description" rel="nofollow noreferrer">here</a> where I can specify ... | <python><netapp><ontap> | 2023-02-02 14:13:19 | 1 | 1,307 | RVid |
75,324,304 | 774,575 | Matlab Dirichlet kernel equivalent in Python? | <p>Is there an equivalent in Python for Matlab <a href="https://fr.mathworks.com/help/signal/ref/diric.html" rel="nofollow noreferrer">diric</a>? The <a href="https://en.wikipedia.org/wiki/Dirichlet_kernel" rel="nofollow noreferrer">Dirichlet kernel</a> D<sub>L</sub>(ω) is: D<sub>L</sub>(ω) = sin(ωL/2) / sin (ω/2)</p>
... | <python><signal-processing> | 2023-02-02 14:04:26 | 1 | 7,768 | mins |
75,324,275 | 4,689,991 | Generating a certificate with multiple OU fields using pyopenssl | <p>I've been using <code>pyopenssl</code> for a while now to generate certificates, specifically the subject line like so:</p>
<pre><code>from OpenSSL import crypto
cert = crypto.X509()
cert.get_subject().C = certificate_params.country
cert.get_subject().ST = certificate_params.state
cert.get_subject().L = certificat... | <python><openssl><pyopenssl> | 2023-02-02 14:01:47 | 0 | 745 | GabeL |
75,324,215 | 8,869,570 | How to tell a non-class method which child class a child object is? | <p>I'm not well versed with inheritance in python. I'm currently writing a set of child classes that inherit from a single parent class, e.g.,</p>
<pre><code>class child1(parent):
# define some stuff
class child2(parent):
# define some stuff
</code></pre>
<p>There's a separate non-class function that takes in one ... | <python><inheritance> | 2023-02-02 13:57:29 | 0 | 2,328 | 24n8 |
75,324,214 | 8,179,502 | How to initialize a parent class with a child object outside of the child's __init__ function | <p>We have two basic class.</p>
<pre><code>class A:
def __init__(self) -> None:
pass
class B(A):
def __init__(self) -> None:
print(self)
A.__init__(self)
</code></pre>
<p>When initializing B, when can see that the "self" being passed to A is an instance ... | <python> | 2023-02-02 13:57:29 | 2 | 458 | Pier-Olivier Marquis |
75,324,124 | 19,600,130 | Copy a model instance and update a filed in new copy | <p>This is my model. I want to make a copy from my model with <code>copy</code> function. and update the <code>created_time</code> to this time and eventually return the post <code>id</code>.</p>
<pre><code>from django.db import models
from django.utils import timezone
class Author(models.Model):
name = models.Ch... | <python><django><django-models> | 2023-02-02 13:49:52 | 1 | 983 | HesamHashemi |
75,324,072 | 1,325,133 | Pandas JSON Orient Autodetection | <p>I'm trying to find out if Pandas.read_json performs some level of autodetection. For example, I have the following data:</p>
<pre><code>data_records = [
{
"device": "rtr1",
"dc": "London",
"vendor": "Cisco",
},
{
... | <python><json><pandas> | 2023-02-02 13:45:13 | 4 | 16,889 | felix001 |
75,324,008 | 247,696 | American time zones like CT, give error: ZoneInfoNotFoundError: 'No time zone found with key CT' | <p>Python 3.9 introduced the <code>zoneinfo</code> module:</p>
<blockquote>
<p>The <code>zoneinfo</code> module provides a concrete time zone implementation to support the IANA time zone database as originally specified in PEP 615. By default, <code>zoneinfo</code> uses the system’s time zone data if available; if no s... | <python><datetime><timezone><zoneinfo><tzdata> | 2023-02-02 13:39:01 | 3 | 153,921 | Flimm |
75,323,974 | 143,931 | Performance difference between tf.boolean_mask and tf.gather + tf.where | <p><a href="https://www.tensorflow.org/api_docs/python/tf/boolean_mask" rel="nofollow noreferrer"><code>tf.boolean_mask</code></a> reads much nicer than then combination of <code>tf.gather</code> and <code>tf.where</code>. However, it seems to be much slower in the 1-D case:</p>
<pre><code>import tensorflow as tf
# us... | <python><performance><tensorflow> | 2023-02-02 13:35:39 | 1 | 8,472 | fuenfundachtzig |
75,323,859 | 3,337,089 | Choose a random element in each row of a 2D array but only consider the elements based on a given mask python | <p>I have a 2D array <code>data</code> and a boolean array <code>mask</code> of shapes <code>(M,N)</code>. I need to randomly pick an element in each row of <code>data</code>. However, the element I picked should be true in the given mask. Is there a way to do this without looping over every row? In every row, there ar... | <python><numpy><vectorization> | 2023-02-02 13:26:20 | 2 | 7,307 | Nagabhushan S N |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.