QuestionId int64 74.8M 79.8M | UserId int64 56 29.4M | QuestionTitle stringlengths 15 150 | QuestionBody stringlengths 40 40.3k | Tags stringlengths 8 101 | CreationDate stringdate 2022-12-10 09:42:47 2025-11-01 19:08:18 | AnswerCount int64 0 44 | UserExpertiseLevel int64 301 888k | UserDisplayName stringlengths 3 30 β |
|---|---|---|---|---|---|---|---|---|
77,400,886 | 9,599,508 | Python CustomTkinter CTKButton change of state not taking effect? | <p>I am writing an app with CustomTkinter. I have created a collapsible frame with a button to collapse and uncollapse the frame. But I need to be able to disable this button. I wrote a function <code>disable_uncollapse</code> to do this but the button remains clickable.</p>
<pre><code>import tkinter
import customtkin... | <python><tkinter><customtkinter> | 2023-11-01 07:04:36 | 1 | 302 | Mr. T |
77,400,589 | 1,866,775 | What is the reason for MultiHeadAttention having a different call convention than Attention and AdditiveAttention? | <p><code>Attention</code> and <code>AdditiveAttention</code> <a href="https://github.com/keras-team/keras/blob/68f9af408a1734704746f7e6fa9cfede0d6879d8/keras/layers/attention/base_dense_attention.py#L160" rel="nofollow noreferrer">are called with their input tensors in a list</a>. (same as <code>Add</code>, <code>Avera... | <python><tensorflow><keras><attention-model><multihead-attention> | 2023-11-01 05:47:10 | 0 | 11,227 | Tobias Hermann |
77,400,502 | 6,301,394 | DuckDB export / import for a subset of tables | <p>Exporting and importing of all tables works great. I would like to select only a subset of tables for export. I can do COPY but that does not include the load.sql and schema.sql command files for neat importing.</p>
| <python><sql><duckdb> | 2023-11-01 05:20:04 | 1 | 2,613 | misantroop |
77,400,073 | 7,766,024 | Specifying known_first_party and src_path still causes Isort to group my own module with third party imports | <p>The directory structure of my project is as follows:</p>
<pre><code>.
βββ Home/
βββ project/
βββ data/
β βββ dataset.py
β βββ data_utils.py
βββ src/
β βββ main.py
βββ .pre-commit-config.yaml
βββ .isort.cfg
</code></pre>
<p>I also have a <code>.env</co... | <python><isort> | 2023-11-01 02:46:35 | 0 | 3,460 | Sean |
77,399,743 | 159,072 | Splitting a data set for CNN | <p>Suppose, I have a tensor <code>tfDataSet</code> as follows:</p>
<pre><code>data3d = [
[[7.042 9.118 0. 1. 1. 1. 1. 1. 0. 0. 1. ]
[5.781 5.488 7.47 0. 0. 0. 0. 1. 1. 0. 0. ]
[5.399 5.166 6.452 0. 0. 0. 0. 0. 1. 0. 0. ]
[5.373 4.... | <python><arrays><tensorflow><conv-neural-network> | 2023-11-01 00:31:01 | 1 | 17,446 | user366312 |
77,399,698 | 688,624 | Python "setuptools" build with C++ files in higher directory | <p>I am struggling to compile an extension module.</p>
<p>My C++ files are in a higher directory than my "setup.py"/etc. files. This is because the Python extension is a binding of a C++ library, and so is hierarchically subordinate<sup>[1]</sup>. This use-case, I should think, is basic and common.</p>
<p>I... | <python><setuptools><pybind11> | 2023-11-01 00:15:16 | 0 | 15,517 | geometrian |
77,399,617 | 10,487,817 | Unable to write a dataframe to SQL Server as a table using SQL Alchemy, connection is established but cannot write a new table to the database | <p>I can connect to SQL Server using SQLAlchemy, but I am not able to write the data frame to the database as a table.</p>
<p>I am getting the below error:</p>
<pre><code>try:
SqlServerEngine = pyodbc.connect(driver='{ODBC Driver 17 for SQL Server}',
host=server_name,
... | <python><sql-server><sqlalchemy> | 2023-10-31 23:45:16 | 0 | 363 | cyrus24 |
77,399,592 | 3,936,601 | 'Set like' behaviour of dict.items() for non hashable values | <p><a href="https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects" rel="nofollow noreferrer">https://docs.python.org/3/library/stdtypes.html#dictionary-view-objects</a></p>
<p>The documentation says:</p>
<blockquote>
<p>If all values are hashable, so that (key, value) pairs are unique and hashable, th... | <python><dictionary><set> | 2023-10-31 23:36:32 | 1 | 1,739 | Evan Benn |
77,399,310 | 11,855,904 | How to Override Django ManyRelatedManager Methods and Enforce Validations | <p>I have the following two models that have a Many-to-Many (m2m) relationship. I want to implement validation rules when creating a relationship, particularly when the <code>Field</code> object is controlled.</p>
<pre class="lang-py prettyprint-override"><code>class Category(models.Model):
name = models.CharField(... | <python><django><django-models><many-to-many><manyrelatedmanager> | 2023-10-31 22:05:28 | 0 | 392 | cy23 |
77,399,227 | 9,165,040 | What are the best ways to optimize this mongo query? | <p>I inherited a mongo query that I've been tasked to put into a GCP cloud function. The cloud function is getting a mongo timeout when it hits this query. When running locally, it takes quite a while as well ~ 40 seconds - but it does finish. I could use help in 2 ways here;</p>
<ol>
<li>Does my prognosis about why th... | <python><mongodb><google-cloud-functions><data-pipeline> | 2023-10-31 21:44:01 | 1 | 518 | cDub |
77,399,168 | 3,220,769 | Signal.alarm not raising while other function is executing | <p>I have a Lambda function which does some querying to a database using the <code>teradatasql</code> library. I have a 15 minute timeout on my Lambda, but I want to make sure to throw an exception before hitting that timeout to let users know their query timed out. Here's the basic idea:</p>
<pre><code>import signal
i... | <python><amazon-web-services><aws-lambda><signals> | 2023-10-31 21:29:49 | 1 | 3,327 | TomNash |
77,399,029 | 10,016,018 | Create table and view in the same migration in SQLAlchemy | <p>I'm trying to create a table and a view based on this table in a SQLAlchemy/alembic/PostgreSQL environment, with <code>alembic revision --autogenerate</code>. I could properly setup things so that alembic identifies the table and the view to be created, following the structure proposed <a href="https://stackoverflow... | <python><sqlalchemy><orm><alembic><sqlalchemy-migrate> | 2023-10-31 20:54:26 | 1 | 982 | Danilo Filippo |
77,399,006 | 15,456,681 | Why are np.empty((1,), dtype=np.bool_) or global arrays slow as default arguments in numba? | <p>I was writing a function in numba which requires an optional argument to be an array of any dtype, and was experimenting with putting a default array directly in the function definition, and noticed that using <code>np.empty</code> or a global array was ~80x slower than using <code>array</code> or <code>zeros</code>... | <python><numpy><performance><numba> | 2023-10-31 20:48:18 | 0 | 3,592 | Nin17 |
77,398,956 | 3,584,765 | How to pass a parameter of a lambda functon to another function which accepts the lambda function as parameter | <p>I am using a function (more specifically <em>optim.lr_scheduler.LambdaLR</em> from torch) where a Lambda function is passed as parameter.</p>
<pre><code>from torch import optim
lambda1 = lambda epoch: epoch /10
optimizer = optim.SGD(model.parameters(), lr=0.1)
scheduler = optim.lr_scheduler.LambdaLR(optimizer, lr_l... | <python><lambda> | 2023-10-31 20:36:51 | 1 | 5,743 | Eypros |
77,398,915 | 14,751,691 | Python pandas - want to use values in both cols hitting road block | <p>Trying to use both values of T and V from a 2 column text file (iterating over all rows) to pass to other functions</p>
<p><strong>SourceFile</strong></p>
<pre><code>T1|V1
T2|V2
T3|V3
</code></pre>
<p><strong>Output</strong></p>
<pre><code>T1:1 V1
Name: T1, dtype: object
T2:1 V2
Name: T1, dtype: object
T3:1 ... | <python><pandas><dataframe><loops> | 2023-10-31 20:30:12 | 0 | 411 | irnerd |
77,398,903 | 5,522,303 | boto3: Get version ID and support callbacks on object upload | <p>I would like to upload a file to S3 with a progress callback as it uploads, and also get the version ID of the object I just uploaded.</p>
<p><a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3/client/put_object.html" rel="nofollow noreferrer"><code>client.put_object</code></a> ret... | <python><boto3> | 2023-10-31 20:28:49 | 1 | 7,404 | Kevin |
77,398,891 | 7,994,685 | Langchain: Why does langchain agent return the action input instead of running it? | <p>I'm working with a Langchain agent.</p>
<p>I'm running into a phenomenon: After small talk with the chatbot where the user provides it with parameters to executes a function (set as a tool), instead of running the function, it returns to the user the action input instead.</p>
<p>Any ideas why this might be happening... | <python><langchain> | 2023-10-31 20:26:26 | 1 | 1,328 | Sharif Amlani |
77,398,737 | 29,347 | How can I get pandas read_csv converters to set the type on parsing? | <p>Given a CSV like:</p>
<pre><code>foo,geo,bar
1,{"country": "SG"},{}
2,{"country": "US"},{"id": "1234"}
</code></pre>
<p>I want to parse the JSON into a specific type, not just <code>object</code>. My type:</p>
<pre class="lang-py prettyprint-override"><code... | <python><pandas> | 2023-10-31 19:53:23 | 0 | 37,295 | Kit Sunde |
77,398,627 | 5,091,720 | Pandas worksheet.add_table AttributeError: 'int' object has no attribute 'lower' | <p>I created a function to format several dataframes the same way placing them into the same excel workbook.</p>
<p>The error is:</p>
<pre><code>Traceback (most recent call last):
File "f:\...\weather_WPC.py", line 282, in < module > frame_to_excel(writer, exl = NS_parts, df=dfsp)
File "f:\...\df_t... | <python><pandas><excel><dataframe> | 2023-10-31 19:30:46 | 1 | 2,363 | Shane S |
77,398,493 | 3,649,629 | Where is an inputShape in tf.keras.layers.Conv2D()? | <p>I am writing a simple CNN model for classic digit recognition task. Part of my code looks like this:</p>
<pre><code>model = tf.keras.models.Sequential()
image_width = 28
image_height = 28
image_channels = 1
model.add(layers.Conv2D(
8,
5,
inputShape = [image_width, image_height, image_channels],
stri... | <python><tensorflow><keras><deep-learning> | 2023-10-31 19:02:53 | 1 | 7,089 | Gleichmut |
77,398,449 | 4,830,062 | Unit Test Imported Modules when A Global Function Call will Fail | <p>I am trying to mock a session created in a test by an import. I have two files:</p>
<p>/lib/module.py</p>
<pre><code>import boto3
session = boto3.session()
</code></pre>
<p>/tests/test.py</p>
<pre><code>from lib.module import test_func
test_function():
assert test_func()
</code></pre>
<p>My testing environment ... | <python><unit-testing><testing><python-import> | 2023-10-31 18:54:06 | 1 | 489 | J_Heads |
77,398,366 | 1,044,604 | How can I find the python client library for a gcloud command? | <p>To write a Python script to collect various details about all projects deployed in the organization, how can we find which shared-vpc host project/network is being used?</p>
<p>There's a <strong>gcloud</strong> command that provides details</p>
<pre class="lang-bash prettyprint-override"><code>gcloud compute shared-... | <python><google-cloud-platform><gcloud><client-library> | 2023-10-31 18:38:58 | 1 | 877 | codeangler |
77,398,362 | 10,377,244 | Polars - Windows function with condition | <p>Given this DataFrame.</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
df = pl.DataFrame(
{'id':['1']*3 + ['2']*3,
'actions': [0,1,2, 0, 1, 2],
'campaign_name': [None,None, '2', '1', '2', None] ,
'event_time': [1,2,3,0,1,2],
'session_id':['session_1']*6}
)
</code></pre... | <python><dataframe><window-functions><python-polars> | 2023-10-31 18:38:16 | 1 | 1,127 | MPA |
77,398,225 | 1,072,625 | Google Cloud Compute Python Library package naming confusion | <p>In the Google Compute Python library we seem to have 2 packages - screenshot
<a href="https://i.sstatic.net/UXLHV.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/UXLHV.png" alt="GCP Python Client GitHub" /></a>.</p>
<p>When importing the various modules should we refer to <code>compute</code> or <code... | <python><google-cloud-platform><google-cloud-compute-engine> | 2023-10-31 18:10:47 | 0 | 316 | Neeraj |
77,398,137 | 471,136 | Adding qfrm fails | <p>I am trying to run this simple piece of code (implement Excel's <code>YIELD()</code> using <code>qfrm</code> library) in Python using <code>poetry</code>:</p>
<pre class="lang-py prettyprint-override"><code>from qfrm import Bond
def excel_yield(price, par, rate, years, freq):
return Bond(par=par, T=years, freq... | <python><python-poetry> | 2023-10-31 17:52:58 | 1 | 33,697 | pathikrit |
77,398,093 | 10,243,689 | QML application does not receive signals from python backend | <p>I have tried a minimal example of using Python as the backend for the QML application. But weirdly, the signals from the backend have not been received in the QML application.</p>
<p>The QML code is as below:</p>
<pre><code>import QtQuick 2.15
import QtQuick.Window 2.15
Window {
id: mainWindow
width: 640
... | <python><qt><qml> | 2023-10-31 17:45:37 | 0 | 621 | AMIR REZA SADEQI |
77,397,891 | 5,001,448 | Linearly interpolating in L*a*b* space yields negative RGB values? Is RGB's embedding within L*a*b* non-convex? | <p>I am trying to linearly interpolate between colors in CIELAB space starting out and retrieving colors in a linear RGB space.</p>
<p>My workflow is the following:</p>
<ol>
<li>Take 2 colors in linear RGB, let's say (1,0,0) and (0,0,1).</li>
<li>Convert those to XYZ space. I am using <a href="https://en.wikipedia.org/... | <python><colors><rgb><color-space><cielab> | 2023-10-31 17:11:38 | 1 | 2,123 | JMC |
77,397,854 | 4,309,334 | python change group to each folder in a tree | <p>I have a directory structure as this:</p>
<p><code>/app/<app_name>/server/logs</code></p>
<p>I need to give <code>user_a</code> access read-only to logs and all the files</p>
<p>I created user_a with a group <code>group_a</code> and I now have to change the group to each folder leading to <code>logs</code> to ... | <python> | 2023-10-31 17:03:33 | 1 | 319 | danidar |
77,397,723 | 8,030,794 | How to find max value with shift and condition? | <p>I have <code>Dataframe</code> like this:</p>
<pre><code>Index A
0 3
1 2
2 5
3 4
4 1
5 2
6 7
7 3
8 1
</code></pre>
<p>And i need to go with the shift, taking 5 pieces and so that the maximum is in the center of them.</p>
<p>Result:</p>
<pre><code>Index A Res
0 3 0
1 2 ... | <python><pandas> | 2023-10-31 16:40:05 | 1 | 465 | Fresto |
77,397,697 | 11,621,983 | OpenCV ArUco marker detection | <p>I am attempting to detect an ArUco marker on my image, but OpenCV is not detecting the marker. I believe it may potentially be because of low resolution, but I'm not sure.</p>
<p>I used <a href="https://chev.me/arucogen/" rel="nofollow noreferrer">this tool</a> to generate a 4x4 ID.</p>
<p>The following is my code:<... | <python><opencv><aruco> | 2023-10-31 16:37:51 | 1 | 382 | unfestive chicken |
77,397,644 | 1,636,598 | How to filter a DataFrame to only include categories that are linked to specific values? | <p>I have a CSV dataset that looks like this:</p>
<pre><code>country,year,happiness
A,2008,3.72
A,2009,4.4
A,2011,3.83
B,2009,5.49
B,2010,5.27
B,2011,5.87
B,2012,5.51
C,2010,5.46
C,2011,5.32
D,2009,6.42
D,2010,6.44
D,2011,6.78
</code></pre>
<p>My goal is to filter it to <strong>only include countries that have the year... | <python><pandas><dataframe> | 2023-10-31 16:29:13 | 6 | 6,120 | Kevin Markham |
77,397,507 | 7,055,769 | swagger not working after deploying to vercel | <p>When deploying my code I see this under the /docs endpoint (swagger)</p>
<p><a href="https://i.sstatic.net/Xcvu7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Xcvu7.png" alt="enter image description here" /></a></p>
<p><a href="https://python-django-project.vercel.app/docs" rel="nofollow noreferrer"... | <python><django><django-rest-framework><swagger><vercel> | 2023-10-31 16:08:14 | 1 | 5,089 | Alex Ironside |
77,397,466 | 7,318,488 | Polars Python select based on dtype pl.list | <p>Hi I want to select those cols of a polars df that are of the dtype <a href="https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.List.html" rel="nofollow noreferrer">list</a>.<br />
Selecting by dtypes works ususally fine with <code>df.select(pl.col(pl.Utf8))</code>.</p>
<p>However for the type list... | <python><python-polars><data-wrangling> | 2023-10-31 16:02:07 | 1 | 1,840 | BjΓΆrn |
77,397,374 | 2,725,810 | Using index better than sequential scan when every hundredth row is needed, but only with explicit list of values | <p>I have a table (under RDS Postgres v. 15.4 instance <code>db.m7g.large</code>):</p>
<pre class="lang-sql prettyprint-override"><code>CREATE TABLE MyTable (
content_id integer,
part integer,
vector "char"[]
);
</code></pre>
<p>There is a B-Tree index on <code>content_id</code>. My data consist... | <python><postgresql><query-optimization><amazon-rds><database-indexes> | 2023-10-31 15:50:09 | 2 | 8,211 | AlwaysLearning |
77,397,234 | 8,030,746 | How to get multiple elements of text from one div with BeautifulSoup? | <p>I'm using Beautiful Soup, together with Flask, to scrape and show elements on a page. However, I'm having some trouble understanding what I need to do to get multiple items from a single div, and how to write it in a for loop, to show up properly in a HTML file. I'll explain it much better with code.</p>
<p>This is ... | <python><flask><web-scraping><beautifulsoup> | 2023-10-31 15:31:46 | 1 | 851 | hemoglobin |
77,397,199 | 7,421,654 | No module named 'opentelemetry' in chromadb | <p>I have hosted chroma db in aws using docker it was working fine and there was no changes made in the code no redeployment done, I am getting this error.</p>
<pre><code>ModuleNotFoundError: No module named 'opentelemetry'
</code></pre>
| <python><chromadb> | 2023-10-31 15:26:06 | 0 | 1,493 | Mohamed Anser Ali |
77,397,181 | 14,643,315 | Can't exit the script when using 'keyboard' package in Python | <p>Here is my code:</p>
<pre><code>import keyboard
def onEsc(e):
if e.event_type == keyboard.KEY_DOWN and e.name == 'esc':
print("Goodbye")
exit(1)
keyboard.on_press_key('esc', onEsc)
while True:
None
</code></pre>
<p>I get this weird error - when pressing 'esc', it prints but does... | <python> | 2023-10-31 15:23:29 | 0 | 453 | sadcat_1 |
77,397,174 | 1,314,159 | Data structure for a CSV file using OpenAI and LangChains CSVLoader | <p>OK this maybe a stupid question but I can't find an answer anywhere. I am trying to load a csv file into an openAI application that will use that US Cancer Related data. I am trying to determine the "best" data structure for doing queries. What I mean is:</p>
<p>Is it better to have each item in a separ... | <python><openai-api><langchain> | 2023-10-31 15:22:51 | 2 | 1,517 | Bill |
77,396,807 | 10,557,442 | Discrepancies in PySpark DataFrame Results When Using Window Functions and Filters | <p>When I do certain types of transformations on a dataframe that involve window functions with filters I am getting the wrong results. Here is a minimal example of the results I get with my code:</p>
<pre class="lang-py prettyprint-override"><code>from pyspark.sql import SparkSession
import pyspark.sql.functions as f
... | <python><apache-spark><pyspark><partitioning> | 2023-10-31 14:33:42 | 0 | 544 | Dani |
77,396,626 | 1,172,907 | How to mark rgb colors on a colorwheel in python? | <p>Given <code>(255,0,255)</code>, how can I output a colorwheel where this value is marked?</p>
<p><a href="https://i.sstatic.net/oTyIW.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/oTyIWm.png" alt="enter image description here" /></a></p>
| <python><colors> | 2023-10-31 14:06:46 | 1 | 605 | jjk |
77,396,596 | 9,443,671 | How can I playback audio as it's being streamed to a file? | <p>I'm using <a href="https://github.com/rany2/edge-tts/tree/master" rel="nofollow noreferrer">edge-TTS</a> (text-to-speech software) that streams audio to a file as its being generated. Is there a way to do some processing and then playback this audio as soon as it gets generated and not when it finishes? I'm not too ... | <python><file><streaming><text-to-speech><audio-streaming> | 2023-10-31 14:01:50 | 0 | 687 | skidjoe |
77,396,472 | 10,863,083 | Check if column values are consecutive in SQL and assign them a row_number | <p>I have the next table :</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Device_id</th>
<th>Code</th>
<th>SESSION_ID</th>
<th>row_nb</th>
</tr>
</thead>
<tbody>
<tr>
<td>MD50</td>
<td>XSC547</td>
<td>7</td>
<td>450</td>
</tr>
<tr>
<td>MD51</td>
<td>LM678</td>
<td>7</td>
<td>451</td>
</tr>... | <python><sql><snowflake-cloud-data-platform> | 2023-10-31 13:46:04 | 3 | 417 | baddy |
77,396,453 | 11,038,017 | sending POST, getting GET in Tornado | <p>I have a question. I am using tornado web server. I have a main handler which gets a request, pre-procceses it, creates a new request, and sends it further to the worker. The code of sending a pre-processed new request further to the worker looks like this:</p>
<pre><code> async def send_reworked_request(self, pr... | <python><request><tornado> | 2023-10-31 13:43:54 | 0 | 333 | Irina KΓ€rkkΓ€nen |
77,396,451 | 7,895,331 | VSCode: Python virtual environments not automatically activating in integrated terminal | <p>I recently installed VSCode and noticed that the Python virtual environments are not automatically activating when I open the integrated terminal.</p>
<p>From the information available within VSCode in this link:</p>
<p><a href="https://github.com/microsoft/vscode-python/wiki/Activate-Environments-in-Terminal-Using-... | <python><visual-studio-code> | 2023-10-31 13:43:24 | 3 | 601 | Rafael Zanzoori |
77,396,335 | 2,307,570 | What is the fastest way to remove multiple elements from a set, just based on their properties? (E.g. remove all negative numbers.) | <p>In the following example all negative numbers are removed from the set.<br>
But first I have to create the subset of negative numbers.<br>
This does not seem like the most efficient way to achieve this.</p>
<pre class="lang-py prettyprint-override"><code>my_set = {-100, -5, 0, 123, 3000}
my_set.difference_update({e ... | <python><arrays><set><binary-matrix> | 2023-10-31 13:27:59 | 1 | 1,209 | Watchduck |
77,396,200 | 4,192,366 | Make @intrinsic return a tuple | <p>I'm trying to implement a <code>(uint64 a)*(uint64 b)->(uint64 higher,uint64 lower)</code> function in numba. This was what I got fighting all night. There are really few examples online about this:</p>
<pre><code>import numpy as np
from llvmlite import ir
from numba import njit, types
from numba.extending import... | <python><numpy><llvm><numba> | 2023-10-31 13:11:43 | 2 | 1,760 | ZisIsNotZis |
77,396,198 | 5,919,632 | how to auto format E501 line too long (89 > 88 characters) in pre-commit? | <p>I have below .pre-commit-config.yaml file.</p>
<pre><code>default_language_version:
python: python3.10
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-byte-order-marker
... | <python><pre-commit><python-black><ruff> | 2023-10-31 13:11:29 | 2 | 647 | Akash Pagar |
77,396,096 | 2,817,520 | How to configure Flask-Babel to work with blueprints | <p>I have a Flask app with many blueprints. Each blueprint is a python package. Now how can I have translations alongside each package?</p>
| <python><flask> | 2023-10-31 12:58:10 | 1 | 860 | Dante |
77,396,021 | 264,136 | SSH to server and from there SCP to another server | <p>I want to SSH to a Linux server and from there, do a SCP copy to one ESXI server. Both need username and password.</p>
<ol>
<li><p>Connect to Linux box:</p>
<pre><code>ssh_linux = paramiko.SSHClient()
ssh_linux.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_linux.connect(linux_host, username=linux_user, p... | <python><ssh><paramiko><scp><openssh> | 2023-10-31 12:45:41 | 1 | 5,538 | Akshay J |
77,395,818 | 6,338,996 | FileNotFoundError for a file that is certainly there when running a command from a python script | <p>I need to perform consecutive concatenations of FITS files (or one big concatenation of all of them) and, since doing them by hand is a terrible idea (around 200 files). I am using Python to write a script and then I run it in a WSL/UNIX terminal using <code>python3 code.py</code> on the command line.</p>
<p>The scr... | <python><awk><terminal><subprocess> | 2023-10-31 12:17:39 | 1 | 573 | condosz |
77,395,742 | 5,170,800 | Filtering rows of dataframe based on quintiles | <p>I created a dataframe using the following code. I am triong to create a new dataframe that contains only rows from the original dataframe that are less than or greater than Q1 or Q4 for each PP.</p>
<p>I tried <code>filtered_df = df[df['Hours per action'].lt(first_quartile) | df['Hours per action'].gt(fourth_quartil... | <python><pandas><dataframe> | 2023-10-31 12:07:18 | 1 | 581 | Britt |
77,395,533 | 2,552,108 | Secondary Axis Range from 0 to None in Update Layout Not Working | <p>I have a data of total sales and total invoices (rows) per Year. I want to plot them in a bar and line chart. I successfully made the chart with plotly.</p>
<p>However I am having problem in adjusting the secondary yaxis to start from 0 and not automatically set by plotly.</p>
<pre><code>fig = make_subplots(specs=[[... | <python><plotly> | 2023-10-31 11:33:56 | 1 | 1,170 | user2552108 |
77,395,425 | 5,437,090 | Flatten SciPy lil_matrix without converting to dense to avoid memory error | <p>Given:</p>
<pre><code>import numpy as np
import scipy
print(np.__version__, scipy.__version__) # numpy: 1.23.5 scipy: 1.11.3
</code></pre>
<p>I would like to flatten or squeeze my sliced array without converting it to dense in order to avoid memory error:</p>
<pre><code>mtx=scipy.sparse.lil_matrix((int(2e8), int(4e9... | <python><scipy><sparse-matrix><flatten> | 2023-10-31 11:18:48 | 2 | 1,621 | farid |
77,395,177 | 1,734,097 | How to set value to a session state in streamlits? | <p>i'm new to streamlit and i tried to create a budgeting apps in Streamlit.
i have the following functions:</p>
<pre><code>#the purpose of this function are:
# create a st.number_input
# store its value in sessions
def input_number(labelnya,session_name,value=None,help=None,format='%g'):
valuenya = st.number_input... | <python><streamlit> | 2023-10-31 10:38:53 | 2 | 1,099 | Cignitor |
77,395,129 | 276,193 | No module named 'pybind11' when using poetry | <p>Used pybind11 in the past without issue pulled in as a submodule and used via cmake. Now working on another project that uses poetry, and so wanted to make everything poetry-centric.</p>
<p>Trying to build this simple example project <a href="https://github.com/octavifs/poetry-pybind11-integration" rel="nofollow nor... | <python><python-poetry><pybind11><python-extensions> | 2023-10-31 10:33:11 | 1 | 16,283 | learnvst |
77,395,017 | 12,133,068 | Dask DataFrame: write multiple CSV by column | <p>I have a Dask DataFrame with a column <code>"file"</code>. I want to write each line of the dataframe to a CSV whose path is given by the <code>"file"</code> column.</p>
<p>For instance, on the example below, the row indices 0, 1, 2, and 4 should be written to the file <code>a.csv</code> ; while ... | <python><dask><dask-dataframe> | 2023-10-31 10:14:07 | 0 | 334 | Quentin BLAMPEY |
77,395,009 | 8,241,568 | Stacked bars in subplots with plotly | <p>I have the code below but I am now trying to have the two subplots in a 2 rows, 1 column format (so one subplot underneath the other). Unfortunately, when I try to do this, I end up have my bar plot with bars not being stacked anymore. Is there a way to to this with plotly?</p>
<pre><code>import plotly.graph_objects... | <python><plotly> | 2023-10-31 10:13:25 | 1 | 1,257 | Liky |
77,394,929 | 3,104,974 | Convert pyspark.sql.column.Column to numpy array | <p>I'm new to pyspark and don't yet have a full overview of the avl. methods. I want to get <em>unique values of a single column</em> of a pyspark dataframe. This approach doesn't work:</p>
<pre><code>F.array_distinct(my_spark_df.my_column).???
</code></pre>
<p>Whatever <code>???</code>-function I try to apply to the c... | <python><python-3.x><pyspark><apache-spark-sql> | 2023-10-31 10:01:52 | 2 | 6,315 | ascripter |
77,394,812 | 1,678,780 | Awaiting request.json() in FastAPI hangs forever | <p>I added the exception handling as given here (<a href="https://github.com/tiangolo/fastapi/discussions/6678" rel="noreferrer">https://github.com/tiangolo/fastapi/discussions/6678</a>) to my code but I want to print the complete request body to see the complete content. However, when I await the <code>request.json()<... | <python><fastapi><freeze><starlette><exceptionhandler> | 2023-10-31 09:46:01 | 1 | 1,216 | GenError |
77,394,744 | 9,860,033 | How to directly extract fields of a nested dict using itemgetter in Python? | <p>I'm using python's itemgetter from the operator module.</p>
<p>This piece of code works perfectly fine:</p>
<pre><code>from operator import itemgetter
example_dict = {
"field1": 1,
"field2": 2,
"nestedDict": {
"subfield1": 3
}
}
field1, field2, nest... | <python><json><dictionary> | 2023-10-31 09:33:47 | 1 | 1,134 | waykiki |
77,394,717 | 1,219,593 | python read yaml file with variable substitution | <p>I use the yaml library to read yaml files, and it works great. My only issue is with the variable substitution.</p>
<p>For instance, here is a simple example of yaml file I want to read:</p>
<pre><code>queues:
mail-queue-name: mail-app-test
mail-dlq-name: ${queues.mail-queue-name}-dlq
</code></pre>
<p>(just ... | <python><yaml> | 2023-10-31 09:29:07 | 1 | 314 | Peppe |
77,394,642 | 12,242,085 | How to fill NaN values in 3 columns based on group of values in 2 other columns and stay untouchd values in rest cols in Data Frame in Python Pandas? | <p>I have Data Frame in Python Pandas like below:</p>
<pre><code>data = [
(1, None, None, None, '2023-01-10', None, None),
(1, None, None, None, '2023-01-10', 1, 0),
(1, 9, 0, 0.55, '2023-01-10', 15, None),
(2, None, None, None, '2023-11-22', 2, 1),
(2, 88, 1, 0.68, '2023-11-22', 103, 8)
]
df = pd.... | <python><pandas><dataframe><date> | 2023-10-31 09:17:28 | 2 | 2,350 | dingaro |
77,394,442 | 12,242,085 | How to fill NaN values in 3 columns based on group of values in 2 other columns in Data Frame in Python Pandas? | <p>I have Data Frame in Python Pandas like below:</p>
<pre><code>data = [
(1, None, None, None, '2023-01-10'),
(1, None, None, None, '2023-01-10'),
(1, 9, 0, 0.55, '2023-01-10'),
(2, None, None, None, '2023-11-22'),
(2, 88, 1, 0.68, '2023-11-22')
]
df = pd.DataFrame(data, columns=['id', 'col1', 'co... | <python><pandas><dataframe><date> | 2023-10-31 08:46:01 | 3 | 2,350 | dingaro |
77,394,432 | 6,021,482 | Microsoft Build Tools for Python openAI | <p>I am installing open ai python library as</p>
<p>pip install openai</p>
<p>It was throwing an error that Microsoft build tools are required. I've installed it by following <a href="https://stackoverflow.com/questions/64261546/how-to-solve-error-microsoft-visual-c-14-0-or-greater-is-required-when-inst">StackOverflow ... | <python><visual-c++><openai-api><visual-studio-2017-build-tools> | 2023-10-31 08:44:39 | 1 | 377 | Azeem112 |
77,394,187 | 12,224,591 | Insert Scrollbar into child ListBox? | <p>I'm attempting to insert a <code>Scrollbar</code> object into a <code>ListBox</code> object, when the <code>ListBox</code> object is a child of an existing window using Python's Tkinter library.</p>
<p>The vast majority of the Tkinter <code>Scrollbar</code> tutorials out there (<a href="https://www.tutorialspoint.co... | <python><tkinter> | 2023-10-31 08:06:39 | 3 | 705 | Runsva |
77,394,182 | 22,629,028 | Mojo (Mac) using wrong python lib | <p>As most Mac users, I have two separate versions of python on my machine: The one installed by Apple (version 3.9 in <code>/usr/bin</code>) and one installed via Homebrew (version 3.11 in <code>/opt/homebrew/bin</code>).</p>
<p>I've put the latter first in path and, sure enough,</p>
<pre class="lang-bash prettyprint-... | <python><modular><mojolang> | 2023-10-31 08:06:12 | 1 | 2,212 | volkerschulz |
77,394,180 | 6,002,424 | Can't seem to find a proper way of splitting a huge (really huge) video into 1 hour chunks without any loss in quality | <p>I have backed up a video from Milestone system in mkv format. It's a ~106 hours-video with 37 GB size. I have searched for way to split into one-hour chunks without any quality loss. However, I am facing two problems:</p>
<ol>
<li>A python code with <code>subprocess</code> has produced videos in arbitrary lengths su... | <python><windows><video><ffmpeg> | 2023-10-31 08:06:01 | 0 | 1,510 | bit_scientist |
77,393,960 | 5,368,083 | JSON dumping a dictionary where some values are PyDantic models | <p>Assume a dictionary with an arbitrary structure, where some values are native Python objects and others are instances of PyDantic's <code>BaseModel</code> subclasses</p>
<p>e.g.</p>
<pre class="lang-py prettyprint-override"><code>my_dict = {"key1": "value1",
"key2": {"ke... | <python><json><dictionary><pydantic> | 2023-10-31 07:26:33 | 1 | 12,767 | bluesummers |
77,393,783 | 13,238,846 | Python app running correctly on local environment but not on Azure | <p>I have deployed python web app for teams and deployed it to azure and It giving me following error. The libraries that I'm using with web app version are same. When I checking the error log following errors were there. I cannot figure out what causing this issue. Everything is similar in both versions.The local ver... | <python><azure-web-app-service><microsoft-teams><langchain> | 2023-10-31 06:56:31 | 1 | 427 | Axen_Rangs |
77,393,662 | 13,086,128 | Change mode for plotly.express | <p>I have a bunch of plotly plots. I am giving example from the plotly site.</p>
<p>I want to plot all of them in dark mode.
I have to manually enter <code>template="plotly_dark"</code> for each plot.</p>
<p>How can I change the default setting of my display so that I do not have to manually enter <code>templ... | <python><plotly> | 2023-10-31 06:31:17 | 1 | 30,560 | Talha Tayyab |
77,393,610 | 12,242,085 | How to create additional rows for each combination of values in 2 columns based on data in third column in Data Frame in Python Pandas? | <p>I have Data Frame in Python Pandas like below:</p>
<pre><code>data = [
(1, '2023-10-10', '2023-09-25', 1, 20, 11),
(1, '2023-10-10', '2023-10-04', 0, 10, 10),
(1, '2023-05-05', '2023-05-01', 0, 10, None),
(2, '2023-02-13', '2023-02-10', 0, 25, 10),
(2, '2023-02-13', '2023-02-02', None, 12, None)
... | <python><pandas><dataframe><date> | 2023-10-31 06:18:32 | 2 | 2,350 | dingaro |
77,393,443 | 12,519,954 | how to run multiple lambda function locally with docker | <p>I have multiple lambda python functions. Which is related to each other. Suppose I have a main lambda function. from that main lambda function, I have to go to different lambda functions based on the condition.</p>
<p>I have dockerized the main lambda function like below.</p>
<p>Dockerfile</p>
<pre><code>FROM public... | <python><amazon-web-services><docker><amazon-s3><aws-lambda> | 2023-10-31 05:32:42 | 1 | 308 | Mahfujul Hasan |
77,393,415 | 7,279,111 | How to add a new route to the existing Flask app | <p>I am newbie with Flask and trying to add a new route to <a href="https://github.com/Sanster/lama-cleaner/blob/0b3a9a68a296a3c4fc993bd904b7df6792c34579/lama_cleaner/server.py" rel="nofollow noreferrer">Lama Clearner</a>.</p>
<p>Existing routes work perfectly in my localhost but I added the below code</p>
<pre><code>@... | <python><flask><custom-error-pages> | 2023-10-31 05:25:42 | 1 | 547 | KingHodor |
77,393,344 | 2,153,235 | Back-ticks in DataFrame.colRegex? | <p>For PySpark, I find back-ticks enclosing regular expressions for
<code>DataFrame.colRegex()</code>
<a href="https://sparkbyexamples.com/pyspark/select-columns-from-pyspark-dataframe" rel="nofollow noreferrer">here</a>,
<a href="https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.Dat... | <python><regex><apache-spark><pyspark> | 2023-10-31 05:05:19 | 1 | 1,265 | user2153235 |
77,393,316 | 8,253,860 | Is vars() a correct hash function for python classes? | <p>I need to implement <code>__eq__</code> and <code>__hash__</code> function in order to allow <code>lru_cache</code> decorator in some instance function of the class. This class is supposed to be used as a base class for many downstream classes, so I've added these functions:</p>
<p>This seems to work syntactically f... | <python><caching><hash> | 2023-10-31 04:57:22 | 1 | 667 | Ayush Chaurasia |
77,393,250 | 15,320,579 | Python Flask API cannot handle multiple requests | <p>I have created a Python Flask API which basically accepts <code>POST</code> requests containing <strong>PDF documents</strong>, performs <strong>OCR</strong> on them and then runs a couple <strong>Deep Learning</strong> models on the text extracted.</p>
<p>I am using <strong>Multi threading</strong> in the <strong>O... | <python><python-3.x><flask><concurrency><flask-restful> | 2023-10-31 04:39:29 | 0 | 787 | spectre |
77,393,110 | 7,789,281 | Best way to host multiple pytorch model files for inference? | <h2>Context:</h2>
<ul>
<li>I'm working with an end to end deep learning TTS framework (you give it text input it gives you a wav object back)</li>
<li>I've created a FastAPI endpoint in a docker container that uses the TTS framework to do inference</li>
<li>My frontend client will hit this FastAPI endpoint to do infere... | <python><deep-learning><pytorch><devops><mlops> | 2023-10-31 04:00:13 | 0 | 417 | Drew Scatterday |
77,392,937 | 1,755,083 | Fastest way to create a dataframe from a dict of lists | <p>I have a case where I have my initial data-structure as:</p>
<pre><code>import datetime
data = {
'col1': [1,2,3,4],
'col2': ['a', 'b', 'c', 'd'],
'col3': [datetime.datetime.now() for _ in range(4)],
'col4': [[1], [2,3], [4,5,6], [7,8,9,19]],
}
</code></pre>
<p>I want to create a pandas data frame out of ... | <python><pandas><dataframe><numpy><performance> | 2023-10-31 02:53:25 | 0 | 3,357 | AbdealiLoKo |
77,392,813 | 377,022 | How do I make interacting updates? | <p>The <a href="https://plotly.com/python/dropdowns/" rel="nofollow noreferrer">Plotly Documentation on Dropdowns</a> contains the following example:</p>
<pre class="lang-py prettyprint-override"><code>import plotly.graph_objects as go
import pandas as pd
# Load dataset
df = pd.read_csv(
"https://raw.githubu... | <python><plotly> | 2023-10-31 02:17:18 | 1 | 6,168 | Jason Gross |
77,392,792 | 4,898,202 | Is there a way to interpolate variables into a python string WITHOUT using the print function? | <p>Every example I have seen of Python string variable interpolation uses the <code>print</code> function.</p>
<p>For example:</p>
<pre class="lang-py prettyprint-override"><code>num = 6
# str.format method
print("number is {}".format(num))
# % placeholders
print("number is %s"%(num))
# named .fo... | <python><string><variables><format><string-interpolation> | 2023-10-31 02:11:28 | 2 | 1,784 | skeetastax |
77,392,603 | 480,118 | slice numpy/pandas array based on a None value in one of the array/columns | <p>i have the following code where im trying to slice/transform a data array into multiple Dataframes, then concat those dataframes together</p>
<pre><code>import pandas as pd, numpy as np
arr=[['id', 'aaa', 'bbb', None, 'ccc', None, None],
['period', 'd', 'd', None, 'd', Non... | <python><pandas><numpy> | 2023-10-31 00:57:58 | 1 | 6,184 | mike01010 |
77,392,594 | 11,922,765 | Python dataframe split a string column into many | <p>The data I import comes in irregular fashion.</p>
<pre><code>df =
# following data all in one column
1 CABATT CAR BATTERY VOLTAGE -10.0 200.0
2 CPTEMP CAR DAS PANEL TEMP C -10.0 200.0
3 CAPTMA CAR PANEL A TEMP C -10.0 200.0
205 SPPT4P SPEED INPUT 4 CYCLINDER 0.0 32000.0
# Slicing the first three di... | <python><pandas><regex><dataframe> | 2023-10-31 00:53:13 | 1 | 4,702 | Mainland |
77,392,339 | 308,827 | Select top n groups in pandas dataframe | <p>I have the following dataframe:</p>
<pre><code> Country Crop Harvest Year Area (ha)
Afghanistan Maize 2019 94910
Afghanistan Maize 2020 140498
Afghanistan Maize 2021 92144
Afghanistan Winter Wheat 2019 2334000
Afghanistan Winter Wheat 2020 2668000
Afghanistan Winter Wheat 2021 ... | <python><pandas> | 2023-10-30 23:09:53 | 2 | 22,341 | user308827 |
77,392,334 | 4,898,202 | How do I call multiple python functions by reference to operate on a variable so that I can change the sequence of function calls easily? | <p>I want to create a 'function pipeline', like a factory.</p>
<p>Let's say I have the following functions:</p>
<pre class="lang-py prettyprint-override"><code>def func1(var):
var = # do something with var
return var
def func2(var):
var = # do something else with var
return var
def func3(var):
var... | <python><function><sequence><pass-by-reference><call> | 2023-10-30 23:08:06 | 2 | 1,784 | skeetastax |
77,392,321 | 9,986,939 | Running Python 3.6 on Airflow | <p>Feels like this is a bit of a rookie question, but I figured I'd ask anyway.</p>
<p>I have some homegrown packages that are stuck on python 3.6 and I want to update Airflow, which runs them. This means I'm stuck on the highest version of Airflow that supports 3.6 right? Can I work around this using an env or somethi... | <python><airflow> | 2023-10-30 23:05:38 | 0 | 407 | Robert Riley |
77,392,037 | 4,001,750 | Issue while using map_partitions in dask with a power function on pandas table with list elements | <p>I am having the following code in python developed using the Dask framework:</p>
<pre><code># Create a Pandas DataFrame
df = pd.DataFrame({
'A': [[1], [2], [3], [4], [5]],
'B': [[6], [7], [8], [9], [10]]
})
# Convert the Pandas DataFrame to a Dask DataFrame
ddf = dd.from_pandas(df, npartitions=2)
def my_fu... | <python><dask> | 2023-10-30 21:45:30 | 1 | 720 | naseefo |
77,392,010 | 7,743,076 | How to fill a form outside a <form> with selenium? | <p>I'm trying to fill in a form. Here's my code:</p>
<pre class="lang-py prettyprint-override"><code>from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support i... | <python><html><selenium-webdriver><firefox> | 2023-10-30 21:40:58 | 1 | 532 | Huzaifa |
77,391,992 | 9,983,652 | how to split the string wtih brackets? | <p>I'd like to splitt the below string into something like this
<code>'180-240','0-100','100-200','0-110','200-240','0-120'</code></p>
<pre><code>a='(180-240,0-100),(100-200,0-110),(200-240,0-120)'
a
'(180-240,0-100),(100-200,0-110),(200-240,0-120)'
</code></pre>
<p>After the below split, it is still one element of st... | <python> | 2023-10-30 21:36:56 | 1 | 4,338 | roudan |
77,391,988 | 2,205,916 | How do I break up a large for-loop in Python into multiple files? | <p>In actuality, I have hundreds of lines in a for-loop. It is very painful to edit these hundreds of lines. But let's examine the following, related toy code snippet:</p>
<pre><code>from datetime import datetime, timedelta, timezone
import pytz
import time
central_timezone = pytz.timezone('US/Central') # define the E... | <python> | 2023-10-30 21:36:31 | 1 | 3,476 | user2205916 |
77,391,933 | 272,023 | Is it possible to get Kerberos logging using gssapi inside secure context? | <p>I am using <a href="https://github.com/pythongssapi/python-gssapi" rel="nofollow noreferrer"><code>gssapi</code></a> to create a Flask server that is protected by Kerberos authentication. I am wanting to debug some Kerberos errors I am seeing and hence I would like to turn on debug logging by means of the <a href="h... | <python><kerberos><gssapi> | 2023-10-30 21:25:15 | 0 | 12,131 | John |
77,391,843 | 4,643,092 | Searching for values in large dataframe with unnamed columns | <p>I have a dataframe with ~300 columns in the following format:</p>
<pre><code>| Column1 | Column2 | Column3 | Column5
| ------------| -------------- |-----------|----------
| Color=Blue | Location=USA | Name=Steve| N/A
| Location=USA| ID=123 | Name=Randy| Color=Purple
| ID=987 | Name=Gary... | <python><pandas><dataframe> | 2023-10-30 21:06:32 | 3 | 323 | NRH |
77,391,828 | 8,171,079 | Overload binary operators to support right application | <p>I'm trying to make a class <code>A</code> that supports both multiplication between two instances of <code>A</code> and scalar multiplication.</p>
<p>I currently have the following implementation for the <code>__mul__</code> method:</p>
<pre class="lang-py prettyprint-override"><code>class A:
def __init__(self, ... | <python> | 2023-10-30 21:02:02 | 1 | 377 | user8171079 |
77,391,785 | 6,734,243 | How to add a reference in a Sphinx custom directive? | <p>I'm creating a custom directive to display the list of all the available components in pydata-sphinx theme. I try to avoid using the raw directive so I'm building a custom one to remain compatible with the other builders.</p>
<p>Here is the important part of the code:</p>
<pre class="lang-py prettyprint-override"><c... | <python><python-sphinx><docutils> | 2023-10-30 20:53:39 | 1 | 2,670 | Pierrick Rambaud |
77,391,664 | 9,983,172 | matplotlib.path.contains_points inconsistent behavior | <p>I have been using <code>matplotlib.path.contains_points()</code> method without any figures or plots. I am getting inconsistent results depending on the path. In the following example, a simple square path works, but a longer path from an ellipse does not:</p>
<pre><code>import numpy as np
from skimage.draw import e... | <python><matplotlib> | 2023-10-30 20:30:58 | 1 | 480 | J B |
77,391,636 | 7,055,769 | program gets stuck when sending email via gmail | <p>I have the following python function:</p>
<pre><code>import smtplib, ssl
port = 465 # For SSL
password = "valid password"
context = ssl.create_default_context()
def sendEmail(to_email, subject, content):
from_email = "valid_email@zaliczenie.pl"
message = (f"Tresc zadania: {conte... | <python><django><django-rest-framework><smtplib> | 2023-10-30 20:24:34 | 0 | 5,089 | Alex Ironside |
77,391,595 | 5,392,289 | two copies of source code being checked by flake8 in CI/CD pipeline | <p>When I run <code>flake8 .</code>, it runs on two copies of my source code:</p>
<pre><code>./build/lib/smartx/smartpressing/frlo/silver/tagenriched.py:14:13: E225 missing whitespace around operator
./smartx/smartpressing/frlo/silver/tagenriched.py:14:13: E225 missing whitespace around operator
</code></pre>
<p>And be... | <python><python-3.x><continuous-integration><setuptools> | 2023-10-30 20:16:01 | 1 | 1,305 | Oliver Angelil |
77,391,573 | 11,305,741 | Why is `db.query(Order).get(order_id)` behaving as O(n) and not O(log(n))? - SQLAlchemy and Python | <p>We have this service, with the method <code>get_order</code>, which for some reason increases linearly with the quantity of orders:</p>
<pre class="lang-py prettyprint-override"><code>from nameko.events import EventDispatcher
from nameko.rpc import rpc
from nameko_sqlalchemy import DatabaseSession
from orders.excep... | <python><sqlalchemy><orm> | 2023-10-30 20:11:41 | 0 | 627 | BuddhiLW |
77,391,524 | 1,609,514 | Why is df.dtypes.isin not giving expected results when passed a list of strings? | <p>I want to check that all the dtypes of a dataframe are contained in a subset of dtypes which I specify.</p>
<p>I thought this might be a good way to do that but getting unexpected results:</p>
<pre><code>import pandas as pd
df = pd.DataFrame({'A': [1., 2., 3.], 'B': [100, 101, 102], 'C': ['a', 'b', 'c']})
assert df.... | <python><pandas><dtype> | 2023-10-30 20:02:09 | 0 | 11,755 | Bill |
77,391,325 | 14,385,099 | Interpreting special case of 'x for x in ...' loop in python | <p>I have a question about the code chunk below:</p>
<pre><code>for i, name in enumerate([x[:-3] for x in dm_cov.columns[:10]]):
stats['beta'][i].write(f'../data/{sub}_beta_{name}.nii.gz')
</code></pre>
<p>Is it accurate to say that the above code chunk is functionally equivalent to the code chunk below?</p>
<pre><... | <python> | 2023-10-30 19:22:13 | 3 | 753 | jo_ |
77,391,204 | 11,628,437 | Pandas `merge_asof` generating error - ValueError: left keys must be sorted | <p>I have the following dataframes that I'd like to merge using <code>merge_asof</code> -</p>
<pre><code>import pandas as pd
data_0 = {'setting':[0,0,0,0,1,1,1,2,2,2,2,2,2],
'values': [0, 1, 2, 3, 0, 1, 2, 0,1,2,3, 5,6]
}
df_0 = pd.DataFrame(data_0)
print(df_0)
</code></pre>
<pre><code> setting ... | <python><pandas><dataframe> | 2023-10-30 18:55:29 | 1 | 1,851 | desert_ranger |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.