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 ⌀ |
|---|---|---|---|---|---|---|---|---|
78,648,819 | 20,920,790 | How to change Airflow docker image? | <p>I got working Airflow image.</p>
<p>But I need add new Python library to Airflow.</p>
<p>I got "/opt/beget/airflow/docker-compose.yml".
<a href="https://i.sstatic.net/ZLfzdJ1m.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZLfzdJ1m.png" alt="enter image description here" /></a></p>
<p>I cre... | <python><docker><airflow> | 2024-06-20 17:05:31 | 1 | 402 | John Doe |
78,648,677 | 10,164,669 | How to apply the color of a styled `Labelframe` to its label text also | <p>The following code:</p>
<pre><code>from tkinter import *
from tkinter.ttk import *
root = Tk()
root['bg'] = 'yellow'
root.title("Styled Labelframe")
root.geometry("250x150")
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
Style().configure('my.TLabelframe', background='red')
fram... | <python><tkinter> | 2024-06-20 16:29:38 | 1 | 607 | FedKad |
78,648,595 | 7,378,537 | What is the benefit of letting FastAPI handle SQLAlchemy's session vs the provided context manager? | <p>I am doing a POC on FastAPI with a Controller-Service-Repository architecture. Service and Repository are classes, with dependency injection done in the <code>__init__</code> function like so:</p>
<p>(This is the architecture, above my paygrade)</p>
<pre><code>Class MyService(IService):
def __init__(self, reposi... | <python><sqlalchemy><fastapi> | 2024-06-20 16:10:15 | 1 | 755 | Yeile |
78,648,574 | 4,126,652 | Python singleton pattern with type hints | <p>I have been trying to use the Singleton pattern in Python with proper type hints.</p>
<p>Here is my attempt</p>
<pre class="lang-py prettyprint-override"><code>from typing import Any, TypeVar, override
T = TypeVar('T', bound='SingletonBase')
class Singleton(type):
_instances: dict[type[T], T] = {} # type va... | <python><python-typing><pyright> | 2024-06-20 16:03:51 | 1 | 3,263 | Vikash Balasubramanian |
78,648,564 | 3,048,243 | How to Groupby and assign Series Values to each row? | <p>I have the following data-frame (read from a csv file):</p>
<pre><code> my_df:
my_date my_id values key factor
1/1/2024 _One 123 key1 .56
1/7/2024 _One 567 key1 .75
1/14/2024 _One 100 key1 .81
1/14/2024 _One 100 key2 .44
1/1/2024 _Two ... | <python><dataframe> | 2024-06-20 16:01:23 | 1 | 4,202 | 5122014009 |
78,648,465 | 6,930,340 | Replace column level values with tuple in Pandas dataframe | <pre><code>import pandas as pd
arrays = [["array_0", "array_0"], ["col1", "col2"]]
col_idx = pd.MultiIndex.from_arrays(arrays, names=["level_0", "level_1"])
df = pd.DataFrame(data=[[1,2],[3,4],[5,6]], columns=col_idx)
print(df)
level_0 array_0
leve... | <python><pandas> | 2024-06-20 15:41:59 | 2 | 5,167 | Andi |
78,648,443 | 545,591 | How to get python 2d numpy arrays of shape 2x2 from 4 1d arrays | <p>Suppose I have 4 component arrays of size 6 (e.g., denoting 6 spatial locations in a grid):</p>
<p><code>Sxx = array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])</code></p>
<p><code>Sxy = array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6])</code></p>
<p>Then assume <code>Syx = Sxy</code>, and</p>
<p><code>Syy = array([1.1, 2.1, 3.1, 4.1, 5.1,... | <python><arrays><numpy> | 2024-06-20 15:37:12 | 1 | 1,356 | squashed.bugaboo |
78,648,426 | 20,804,255 | Skip lines with JSON document that cause "ValueError: Unexpected character found when decoding object value" in pd.read_json(..., lines=True) | <p>Consider a document <code>btc_transactions.json</code> that contains the following data:</p>
<pre><code>
{"txid":"00a5b60bf38d0605a7ed65c557722e42c1637e1dade80e37b7fc73cea3b67d9b","consensus_time":"2013-07-14T07:07:24.000000000Z","tx_position":"1058687963627546&... | <python><json><pandas><dataframe><jsonparser> | 2024-06-20 15:33:59 | 1 | 315 | TLeitzbach |
78,648,362 | 7,227,146 | Match punctuation sign or end of a line | <p>I want to improve the NLTK sentence tokenizer. Unfortunately, it doesn't work too well when the text doesn't leave any whitespace between the period and the next sentence.</p>
<pre><code>from nltk.tokenize import sent_tokenize
text = "I love you.i hate you.I understand. i comprehend. i have 3.5 lines.I am bore... | <python><regex> | 2024-06-20 15:17:18 | 2 | 679 | zest16 |
78,648,039 | 5,551,849 | Check for existing data before writing to database | <p>When writing time series data from a <code>pandas</code> dataframe to an InfluxDB bucket, to check whether a specific row of data already exists in the bucket (and thus prevent data from being written again).</p>
<p>Format of the time series data that exists in the pandas dataframe (sample):</p>
<pre><code>epoch,ope... | <python><database><time-series><influxdb> | 2024-06-20 14:18:53 | 1 | 743 | p.luck |
78,647,959 | 3,965,828 | GCP Cloud Function worker timeout | <p>I have a Google Cloud Function, 1st gen, for which I've set the Timeout value to 540 seconds (9 minutes), the maximum allowed for a 1st gen function. This is a python function that executes a Dataform workflow, then polls the execution every 5 seconds for the execution's status.</p>
<p>Starting two days ago, the fun... | <python><google-cloud-platform><google-cloud-functions><timeout> | 2024-06-20 14:06:04 | 0 | 2,631 | Jeffrey Van Laethem |
78,647,917 | 11,328,614 | Python unittest.mock, wrap instance method, turn mock on/off | <p>I would like to write an unit test for an instance method of a class under test containing some simple logic but calling another more complicated instance method.</p>
<p>I would like to wrap the complicated instance method in a mock.
Additionally, it should be possible to forwards calls to the original method via th... | <python><python-3.x><unit-testing><class-method><instance-methods> | 2024-06-20 13:55:46 | 0 | 1,132 | Wör Du Schnaffzig |
78,647,821 | 1,031,191 | How to save django db data in the middle of a playwright test? | <p>I'm having trouble figuring out how to call the "sync" <code>create_user()</code>.</p>
<p>Error message:</p>
<pre><code>django.core.exceptions.SynchronousOnlyOperation:
You cannot call this from an async context - use a thread or sync_to_async.
</code></pre>
<p>However, when I use sync_to_async, it cannot... | <python><python-3.x><django><playwright> | 2024-06-20 13:36:36 | 2 | 12,634 | Barney Szabolcs |
78,647,624 | 5,562,431 | Can Python's input be terminated with another key? | <p>I am writing an interactive CLI and just thought about giving the user a different way of confirming an input.
So, usually I would use python's <code>input()</code>.
With that a user would submit input by pressing <kbd>Enter</kbd>.</p>
<p>Would it be possible to let a user submit input by pressing e.g. <kbd>Tab</kbd... | <python><input><command-line-interface> | 2024-06-20 12:58:35 | 0 | 894 | mRcSchwering |
78,647,552 | 17,672,187 | Using pyenv python inplace of system default | <p>I am on archlinux and trying to run krita scripter (built-in python console) with a pyenv python version. The system default python version is 3.12, however the script I am running uses python libraries that require version 3.11.</p>
<p>Here is what I have tried so far.</p>
<ol>
<li><code>pyenv init</code>, checked ... | <python><pyqt><pyqt5><archlinux><pyenv> | 2024-06-20 12:44:40 | 0 | 691 | Loma Harshana |
78,647,145 | 4,100,282 | Inconsistent covariance estimates from sklearn.covariance.MinCovDet vs numpy.cov | <p>I would expect that when considering a large sample from a bivariate Gaussian population, covariance estimates from <code>sklearn.covariance.MinCovDet</code> should be equivalent to those from <code>numpy.cov</code> ? Yet when I test this using the following code, I get systematically smaller variance estimates usin... | <python><scikit-learn> | 2024-06-20 11:19:16 | 1 | 305 | Mathieu |
78,647,069 | 1,367,722 | Extracting SQL JOIN condition column names not working with Antlr using Python | <p>The code below is my attempt to identify join relationships between tables in a Oracle database.</p>
<p>The idea is to build a map of joins to help identify implicit FK relationships.</p>
<p>In the code below I use the PlSqlParserListener to walk the parse tree.</p>
<p>In the <code>Join_on_partContext</code> handler... | <python><join><antlr4> | 2024-06-20 11:02:33 | 0 | 4,034 | TenG |
78,646,926 | 13,942,929 | How can I use enum in CPP and connect it with Cython? | <p>In CPP folder, I have <code>MyWork.h</code> and <code>MyWork.cpp</code>. In Cython folder, I have <code>MyWork.pxd</code> and <code>MyWork.pyx</code>.</p>
<p>Now I want to use enum in CPP and then connect it in Cython as follow</p>
<p>[MyWork.h]</p>
<pre><code>enum Task {
REGULAR,
DEV,
MARKETING
};
clas... | <python><c++><enums><cython><cythonize> | 2024-06-20 10:32:21 | 1 | 3,779 | Punreach Rany |
78,646,747 | 1,051,765 | Wrong shape at fully connected layer: mat1 and mat2 shapes cannot be multiplied | <p>I have the following model. It is training well. The shapes of my splits are:</p>
<ul>
<li>X_train (98, 1, 40, 844)</li>
<li>X_val (21, 1, 40, 844)</li>
<li>X_test (21, 1, 40, 844)</li>
</ul>
<p>However, I am getting the following error at <code>x = F.relu(self.fc1(x))</code> in <code>forward</code>. When I attempt ... | <python><pytorch><neural-network><fast-ai> | 2024-06-20 09:53:10 | 1 | 1,369 | Carlos Vega |
78,646,723 | 14,982,219 | How to lock table row with SQLAlchemy ORM after commit? | <p>I am working with SQLalchemy orm. I add a register using <code>session.add(object)</code> and then I commit it with <code>session.commit()</code>.<br />
After commit I continue working on the orm object so I need to lock it so other processes can't edit the object. I need the same behaviour as <code>session.query.wi... | <python><postgresql><sqlalchemy> | 2024-06-20 09:50:39 | 1 | 381 | vll1990 |
78,646,608 | 1,804,490 | Estimating the size of data when loaded from parquet file into an arrow table | <p>I have a pyarrow table with a large amount of columns (>2000). For 1000 rows, it takes about 20M RAM. For many columns, there’s a single value over all the rows. When I save it to a parquet file, the size of the resulting file on storage is ~4MB.</p>
<p>Now, when looking on the <code>total_compressed_size</code> ... | <python><parquet><pyarrow> | 2024-06-20 09:29:48 | 1 | 591 | urim |
78,646,484 | 1,867,328 | Combining two Pandas dataframe with unequal number of columns (superset) | <p>I have below code:</p>
<pre><code>import pandas as pd
df1 = pd.DataFrame({'a':[1,2,3],'y':[7,8,9]})
df2 = pd.DataFrame({'b':[10,11,12],'x':[13,14,15],'y':[16,17,18]})
pd.DataFrame(np.vstack([df1, df2]), columns=df1.columns)
</code></pre>
<p>Above code generates error. I expect that final dataframe will be all column... | <python><pandas><dataframe> | 2024-06-20 09:03:41 | 1 | 3,832 | Bogaso |
78,646,440 | 5,334,903 | Inner function as callback not called | <p>So I've got some classes that allow me to upload file-like or IO objects to Azure Blob Storage.</p>
<p>My problem here is that I want to pass a callback during the export of those objects, and this callback needs to do multiple things (hence call a higher method).</p>
<p>Here is the code:</p>
<pre><code>from azure.s... | <python><azure-blob-storage> | 2024-06-20 08:55:29 | 1 | 955 | Bloodbee |
78,646,329 | 261,006 | Provide multiple languages via Odoo RPC call | <p>I would like to write multiple languages to a <code>ir.ui.view</code> Object's <code>arch_db</code> field.</p>
<p>However, if I provide a dict/json value with languages as keys and HTML as values (<code>{"de_DE"=><german-html>, "en_US"=><american-html>}</code>), validation will ... | <python><go><odoo><rpc><odoo-17> | 2024-06-20 08:30:31 | 1 | 2,561 | Jasper |
78,646,170 | 9,112,151 | Supply only payload schema for FastAPI endpoint without actual validation by Pydantic | <p>I need to supply only payload schema for API endpoint without any <code>Pydantic</code> validation. I'm using:</p>
<ul>
<li><code>FastAPI==0.110.1</code></li>
<li><code>Pydantic v2</code></li>
</ul>
<pre class="lang-py prettyprint-override"><code>from typing import Literal, Annotated
import uvicorn
from fastapi... | <python><fastapi><openapi><pydantic><pydantic-v2> | 2024-06-20 07:55:48 | 1 | 1,019 | Альберт Александров |
78,646,082 | 9,425,034 | get spectrum value with numpy only | <p>I want to do a kind of frequency monitoring program, using rtl-sdr wrapper in python and numpy. This program must run in console mode, no graphic interface. I do not want to have a dependency with matplotlib or scipy, so I'm looking for a pure python and numpy solution.</p>
<p>I know how to read data from the rtl-sd... | <python><numpy><fft><spectrogram><pyrtlsdr> | 2024-06-20 07:36:18 | 1 | 744 | JayMore |
78,645,930 | 10,200,497 | How can I find the first row after a number of duplicated rows? | <p>My DataFrame is:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
{
'x': ['a', 'a', 'a','b', 'b','c', 'c', 'c',],
'y': list(range(8))
}
)
</code></pre>
<p>And this is the expected output. I want to create column <code>z</code>:</p>
<pre><code> x y z
0 a 0 NaN
1 a 1 NaN
2... | <python><pandas><dataframe> | 2024-06-20 07:00:59 | 2 | 2,679 | AmirX |
78,645,886 | 2,919,585 | Replacement for legacy scipy.interpolate.interp1d for piecewise linear interpolation with extrapolation | <p>The documentation for <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html" rel="nofollow noreferrer"><code>scipy.interpolate.interp1d</code></a> tells me</p>
<blockquote>
<p>This class is considered legacy and will no longer receive updates. This could also mean it will be r... | <python><numpy><scipy><interpolation><extrapolation> | 2024-06-20 06:48:43 | 1 | 571 | schtandard |
78,645,873 | 3,760,519 | How do I declare a numpy array to be 1 dimensional of arbitrary length? | <p>I am working on a python code base and the team has decided to make everything statically typed.
I want to declare a numpy array of floats to be one dimension, with arbitrary length.
I currently have the following:</p>
<pre><code>float64 = np.dtype[np.float64]
floats = np.ndarray[Any, float64]
</code></pre>
<p>What ... | <python><numpy><python-typing> | 2024-06-20 06:45:49 | 3 | 2,406 | Chechy Levas |
78,645,751 | 471,376 | discover which package installed a Python script entry point? | <p><em><strong>tl;dr</strong></em> how do I discover which package installed a script entry point under <code>Scripts</code> directory?</p>
<p>Given a Python environment at path <code>Python</code>, it has a scripts entry points directory at <code>Python/Scripts</code>. For script <code>Python/Scripts/foo.py</code>, ho... | <python><pip><setuptools> | 2024-06-20 06:10:39 | 1 | 7,289 | JamesThomasMoon |
78,645,711 | 2,604,247 | Is Polars Guaranteed to Maintain Order After Deduplicating Over a Column? | <h6>The Code</h6>
<pre class="lang-py prettyprint-override"><code>import polars as pl
...
# Sort by date, then pick the first row for each UID (earliest date)
sample_frame=sample_frame.sort(by=DATE_COL).unique(subset=UID_COL, keep='first')
</code></pre>
<h6>Question</h6>
<p>I expected the resulting frame after the abov... | <python><sorting><duplicates><python-polars> | 2024-06-20 05:58:36 | 1 | 1,720 | Della |
78,645,618 | 739,809 | How Can I Optimize Machine Translation Model Training to Overcome GPU Memory Overflow Issues? | <p>I'm trying to train a fairly standard machine translation transformer model using PyTorch. It's based on the "Attention is All You Need" paper. When I ran it on my PC with standard hyperparameters and a batch size of 128 segments (pairs of source and target language sentences), it worked fine but was slow,... | <python><memory-management><gpu><machine-translation> | 2024-06-20 05:22:55 | 0 | 2,537 | dsb |
78,645,414 | 2,057,516 | 1 out of many calls to overridden django `Model.save()` generates a pylint `unexpected-keyword-arg` error - how do I satisfy it? | <p>I implemented and have been using this model (super)class I created for years, and it is completely stable on an active site. I just made a small minor tweak to some completely unrelated portion of its code, and checked my work (on my machine) with the latest superlinter. Our CI tests on github currently use an ol... | <python><django><pylint> | 2024-06-20 03:49:12 | 0 | 1,225 | hepcat72 |
78,645,312 | 2,264,738 | Python requests get call getting in to unlimited waiting, where curl succeeds | <p>In our legacy application we use Python2.6 with <strong>requests 2.9.1</strong> for making API requests.
There a strange behavior is noticed with Python requests library that is, it gets in to unlimited wait where <strong>curl</strong> requests succeeds</p>
<pre><code>curl https://url # getting 200 response
</code><... | <python><http><python-requests><centos6><python-2.6> | 2024-06-20 02:54:34 | 0 | 334 | user2264738 |
78,645,168 | 19,276,472 | Handling sync vs async with scrapy + Playwright | <p>I'm using scrapy with Playwright to load a Google Jobs search results page. Playwright is needed to be able to load the page in a browser setting, then to click on different jobs to reveal the details of the job.</p>
<p>Example URL I want to extract information from: <a href="https://www.google.com/search?q=product+... | <python><scrapy><playwright> | 2024-06-20 01:33:55 | 1 | 720 | Allen Y |
78,645,106 | 7,563,454 | Get distance from a point to the nearest box | <p>I have a 3D space where positions are stored as tuples, eg: <code>(2, 0.5, -4)</code>. If I want to know the distance between two points I just do <code>dist = (abs(x1 -x2), abs(y1 - y2), abs(z1 - z2))</code> and if I want a radius <code>distf = (dist[0] + dist[1] + dist[2]) / 3</code>. Now I have boxes each defined... | <python><math><3d> | 2024-06-20 00:50:35 | 1 | 1,161 | MirceaKitsune |
78,644,937 | 1,498,830 | How can I ensure some code is run even if a test suite is aborted? | <p>I have a Behave test suite that starts by spinning up my application in a Docker container. I've added some code using <a href="https://docs.python.org/3/library/atexit.html" rel="nofollow noreferrer"><code>atexit</code></a> to ensure that the container is stopped and removed when the suite exits 'normally':</p>
<pr... | <python><python-behave> | 2024-06-19 23:01:55 | 0 | 2,962 | spierepf |
78,644,927 | 539,490 | "pre-import" python dependencies in docker image | <p>I am building a Python 3.10 Docker image in an Ubuntu-latest GitHub action that is uploaded (by serverless.com CLI) to form an AWS lambda. It has many Python dependencies. With a clean install of the dependencies on my local Mac, it can take 20 seconds to import the main source file (calc.py). Similarly, when the... | <python><docker><aws-lambda><python-import><digital-ocean> | 2024-06-19 22:56:08 | 0 | 29,009 | AJP |
78,644,909 | 147,507 | UPDATE + SubQuery with conditions in SQLAlchemy 2.0 not being rendered | <p>I'm trying to update a table with info from some other rows from the same table. However, I cannot get SQLAlchemy to generate the proper SQL. It always ends up with a <code>WHERE false</code> clause in the subquery, which nullifies the effect.</p>
<p>I have tried several approaches, and this one seems the most corre... | <python><sql><postgresql><sqlalchemy> | 2024-06-19 22:48:04 | 1 | 7,898 | Alpha |
78,644,814 | 9,781,768 | Robot Framework is Automatically closing the browser | <p>I am new to Robot and have this simple code from a tutorial. The code is supposed open chrome and visit the login page of this website. It does that, however, it closes the browser automatically. I've tried to debug by adding the params <code>options=add_experimental_option("detach",${True})</code> after c... | <python><testing><robotframework> | 2024-06-19 22:05:37 | 1 | 784 | User9123 |
78,644,760 | 3,486,684 | `xarray`: setting `drop=True` when filtering a `Dataset` causes `IndexError: dimension coordinate conflicts between indexed and indexing objects` | <p>Some preliminary setup:</p>
<pre class="lang-py prettyprint-override"><code>import xarray as xr
import numpy as np
xr.set_options(display_style="text")
</code></pre>
<pre><code><xarray.core.options.set_options at 0x7f3777111e50>
</code></pre>
<p>Suppose that I have <code>label</code>s which are comp... | <python><python-xarray> | 2024-06-19 21:43:12 | 1 | 4,654 | bzm3r |
78,644,650 | 412,137 | GitHub Actions Workflow with Poetry Failing: "Backend subprocess exited when trying to invoke build_wheel" | <p>I'm encountering an issue with my GitHub Actions workflow that uses Poetry for dependency management. The workflow has been working fine until recently, but now it fails during the virtual environment creation and package installation steps. The error log is as follows:</p>
<pre><code>[virtualenv] create virtual env... | <python><github-actions><ubuntu-22.04> | 2024-06-19 21:03:01 | 0 | 2,767 | Nadav |
78,644,484 | 1,867,328 | Formatting month to the single digit with pandas | <p>I have below code</p>
<pre><code>import pandas as pd
pd.to_datetime(['8/23/1999']).strftime("%m/%d/%Y").astype('str')
</code></pre>
<p>This generates <code>08/23/1999</code></p>
<p>However I want to get <code>8/23/1999</code></p>
<p>Is there any specific formatting to be used for this case?</p>
| <python><pandas> | 2024-06-19 20:18:23 | 1 | 3,832 | Bogaso |
78,644,422 | 11,608,962 | Persistent MySQL connection issues with FastAPI deployed on DigitalOcean and Azure | <p>I have deployed a FastAPI application on DigitalOcean droplets and Azure App Service, with MySQL databases hosted on DigitalOcean and Azure respectively. Despite several attempts to mitigate the issue, I am consistently facing database connection problems, resulting in errors like:</p>
<pre><code>2024-06-06T07:27:13... | <python><mysql><azure><sqlalchemy><fastapi> | 2024-06-19 19:59:11 | 2 | 1,427 | Amit Pathak |
78,644,359 | 3,325,401 | How to make statsmodels' ANOVA result match R's ANOVA result | <p>The following question is sort of a concrete adaptation of a post on <a href="https://stats.stackexchange.com/questions/10182/intraclass-correlation-coefficient-vs-f-test-one-way-anova/11732#11732">StatsExchange</a>.</p>
<p>The following R script runs just fine:</p>
<pre class="lang-r prettyprint-override"><code>lib... | <python><r><dataframe><statsmodels><anova> | 2024-06-19 19:41:10 | 2 | 2,767 | hobscrk777 |
78,644,353 | 6,622,697 | Using SQLAlchemy metadata to get info about actual database vs the definition | <p>I want to use the Metadata object to get information about my definitions (i.e., my Model objects) as well as going out to the actual database. But no matter what I try, it always uses the defined information and not what's in the database.</p>
<p>Here's what I have:</p>
<pre><code>engine = create_engine('...')
c... | <python><sqlalchemy> | 2024-06-19 19:39:21 | 1 | 1,348 | Peter Kronenberg |
78,644,255 | 1,867,328 | Failed to convert the pandas datetime object to another format | <p>I tried to convert a <code>python</code> datetime object to another format as below</p>
<pre><code>import pandas as pd
pd.to_datetime(['1/1/1900']).dt.strftime('%Y-%m')
</code></pre>
<p>However above code generates error.</p>
<p>Could you please tell me what would be the right approach</p>
| <python><pandas> | 2024-06-19 19:07:22 | 1 | 3,832 | Bogaso |
78,644,027 | 1,867,328 | Managing date column with different format | <p>I am trying to convert a <code>pandas</code> dataframe column which is in text format but represents date in mix format to a proper date format. Below is one such example,</p>
<pre><code>import pandas as pd
pd.to_datetime(['0-Jan-00', '8/23/1999'])
</code></pre>
<p>Above code generates error.</p>
<p>Is there any met... | <python><pandas> | 2024-06-19 18:03:00 | 2 | 3,832 | Bogaso |
78,643,864 | 7,236,133 | Check the existence of records in the elastic search vector store | <p>I have such entries in my elasticsearch index:
<a href="https://i.sstatic.net/8MsCz7zT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8MsCz7zT.png" alt="enter image description here" /></a></p>
<p>It's unstructured data, in this case the content of a PDF that was split into chunks, then a LangChain d... | <python><elasticsearch><langchain><vectorstore> | 2024-06-19 17:18:29 | 1 | 679 | zbeedatm |
78,643,804 | 4,659,442 | TypeError using pandas read_sql_query() with dtype=UNIQUEIDENTIFIER | <p>I'm trying to use Pandas' <code>read_sql_query()</code>, specifying a <code>dtype</code> of <code>UNIQUEIDENTIFIER</code> for one of the columns:</p>
<pre class="lang-py prettyprint-override"><code>import os
import urllib
import pandas as pd
from sqlalchemy import create_engine, engine, exc
from sqlalchemy.dialects... | <python><sql-server><pandas> | 2024-06-19 17:06:03 | 0 | 727 | philipnye |
78,643,652 | 3,903,479 | Render HTML to pdf and append images | <p>I'm writing a python script that can read html from stdin and render it to a file (with css, though my example code omits that), along with attaching any trailing image paths on the command. Using the <a href="https://py-pdf.github.io/fpdf2/CombineWithPdfrw.html#adding-a-page-to-an-existing-pdf" rel="nofollow norefe... | <python><pdf><pdf-generation> | 2024-06-19 16:23:03 | 0 | 1,942 | GammaGames |
78,643,575 | 13,187,876 | Control where Source Code for Azure ML Command gets Uploaded | <p>I'm working in a notebook in Azure Machine Learning Studio and I'm using the following code block to instantiate a job using the <a href="https://learn.microsoft.com/en-us/python/api/azure-ai-ml/azure.ai.ml?view=azure-python#azure-ai-ml-command" rel="nofollow noreferrer">command function</a>.</p>
<pre><code>from azu... | <python><azure><machine-learning><command><azure-machine-learning-service> | 2024-06-19 16:06:28 | 1 | 773 | Matt_Haythornthwaite |
78,643,538 | 2,066,855 | Upgrading to Stable Diffusion 3 from 2-1 on mac | <p>I'm upgrading my stable diffusion from 2-1 to stable-diffusion-3-medium-diffusers</p>
<p>Here is my code which is working for version 2-1</p>
<pre><code># source venv/bin/activate
from diffusers import DiffusionPipeline
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1")
pipe = p... | <python><macos><machine-learning><stable-diffusion><metal-performance-shaders> | 2024-06-19 15:58:26 | 1 | 1,902 | lando2319 |
78,643,391 | 11,400,815 | Adding conditional variable in gekko leads to no solution | <p>I'm using gekko to optimize a certain function. When I use a dummy objective function like <code>m.Obj(0)</code> just to test for feasibility, the solver is able to find a feasible solution. However, when I add in my main objective function (commented out below), the solver fails to find a solution. Here's is some f... | <python><optimization><gekko> | 2024-06-19 15:25:46 | 1 | 315 | jim |
78,643,168 | 15,648,409 | Parse Google BQ SQL queries and get all tables referenced | <p>In a console Google Cloud project I have several datasets with tables/views in them, so most of them have the query from which they came. I am trying to parse every single one of them to get their table dependencies. With "table dependencies" I mean the tables next to their FROM statements or JOIN statemen... | <python><sql><google-bigquery><sql-parser> | 2024-06-19 14:38:11 | 2 | 431 | Zoi K. |
78,643,131 | 1,616,528 | HDF Error when reading a NetCDF file as part of tests | <p>My code saves and analyzes data in NetCDF4 format. I have no problem whatsoever with the analysis.
However, when I run unit tests in <code>tox</code> I get a ton of HDF and OS errors, e.g.:
<a href="https://github.com/StingraySoftware/HENDRICS/actions/runs/9580442835/job/26417155244?pr=164" rel="nofollow noreferrer"... | <python><pytest><hdf5><netcdf4><tox> | 2024-06-19 14:31:58 | 1 | 329 | matteo |
78,643,122 | 4,498,251 | pandas df.dtypes does not identify timestamps data type correctly...? | <p>Edit: I don't see this as a duplicate of the question marked right now. The issue there is about loc and "memory allocation" (how the data is being presented) while in this question it seems to be about mixing different timezones (what the data actually is)...</p>
<p>I have the following pandas dataframe a... | <python><pandas><timestamp> | 2024-06-19 14:30:39 | 0 | 1,023 | Fabian Werner |
78,643,121 | 11,756,186 | Share Python object between blocks in Simulink | <p>I have created a class in Python. In my application this class is a kind of lookup table.</p>
<p>Here is a sample class to illustrate the topic :</p>
<pre><code>class ExampleClass:
def __init__(self, var1):
self.prop1 = var1
def get_property(self):
return self.prop1
</code></pre>
<p>Matlab ... | <python><matlab><simulink> | 2024-06-19 14:30:28 | 1 | 681 | Arthur |
78,643,088 | 1,088,979 | Pylance in VSCODE Jupiter Notebooks cannot resolve modules | <p>I am working with VSCODE Jupiter Notebooks and Pylance cannot resolve some of the modules that I know they have been successfully loaded into my virtual environment.</p>
<p>Below is an screenshot:</p>
<p><a href="https://i.sstatic.net/EyVfaLZP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/EyVfaLZP.p... | <python><visual-studio-code><jupyter-notebook><pylance> | 2024-06-19 14:21:22 | 0 | 9,584 | Allan Xu |
78,643,081 | 3,572,950 | How to group by and aggregate Int field and array[int] fields? | <p>So, lets say I've got some table with 2 fields - <code>first_col</code> is <code>int</code> and <code>second_col</code> is <code>array[int]</code>:</p>
<pre><code>from sqlalchemy import (
Table,
select,
Integer,
)
from sqlalchemy.dialects.postgresql import ARRAY
some_table = Table(
"some_tabl... | <python><postgresql><sqlalchemy> | 2024-06-19 14:20:06 | 1 | 1,438 | Alexey |
78,643,077 | 20,920,790 | How to make stop/contunie task in Airflow? | <p>I'm trying to make Airflow dag to update database.
If I get no mistakes while get data from API I need to insert data to database.
If there's any errors - I need send errors messages.</p>
<p>So I need add check length of errors dict.<a href="https://i.sstatic.net/OuESHU18.png" rel="nofollow noreferrer"><img src="htt... | <python><airflow> | 2024-06-19 14:18:40 | 1 | 402 | John Doe |
78,642,905 | 13,728,700 | Mean over two consecutive elements of array | <p>I would like to compute the mean of two consecutive elements of a python array, such that the length of the final array has the length equal to that of the original array minus one (so something like <code>np.diff</code>, but with the mean instead of the difference).</p>
<p>So if I have an array</p>
<pre><code>a = [... | <python><arrays><numpy><mean> | 2024-06-19 13:48:33 | 1 | 306 | BlackPhoenix |
78,642,653 | 315,168 | Discrete Real dimension spacing in scikit-optimize | <p>Let's say I am searching over a dimension:</p>
<pre class="lang-py prettyprint-override"><code>from skopt import space
search_space = [
space.Real(1, 10, name="my_scale")
]
</code></pre>
<p>How can I make this Real number to be searched with discrete steps? E.g. 0.25. Because in my case, calculating d... | <python><mathematical-optimization><scikits><scikit-optimize> | 2024-06-19 12:57:31 | 0 | 84,872 | Mikko Ohtamaa |
78,642,650 | 9,072,753 | How to type hint a function that parallelize multiple functions and return their results? | <p>Link to mypy: <a href="https://mypy-play.net/?mypy=latest&python=3.12&gist=a4da5db5bfbdf1e6bddce442286cc843" rel="nofollow noreferrer">https://mypy-play.net/?mypy=latest&python=3.12&gist=a4da5db5bfbdf1e6bddce442286cc843</a></p>
<p>More often than not, I find myself connecting to multiple APIs and the... | <python><python-typing> | 2024-06-19 12:57:26 | 1 | 145,478 | KamilCuk |
78,642,622 | 584,532 | How to start a replication with psycopg3? | <p>How can I start the replication with psycopg3? Or is this only supported by psycopg2 so far?</p>
<p>In psycopg2, one would create a connection with <code>connection_factory = psycopg2.extras.LogicalReplicationConnection</code> and then call <code>start_replication</code> on a cursor. Is there a similar connection fa... | <python><postgresql><psycopg3> | 2024-06-19 12:50:41 | 1 | 2,643 | nrainer |
78,642,527 | 11,714,087 | Python package dependecy upgrade from requirements.txt | <p>I have a Python application with ~70 packages in requirements.txt file.</p>
<p>It was running fine, but suddenly <code>snowfalke-connector-python==2.7.3</code> and <code>schemachange==3.4.2</code> started installing numpy==2.0.0 while they were installing numpy==1.26.4 a day before, but from today they are installin... | <python><numpy><pip><numpy-2.x> | 2024-06-19 12:30:01 | 1 | 377 | palamuGuy |
78,642,391 | 8,973,620 | Inconsistent graphs with Altair despite same package version | <p>I am working on creating graphs using Altair in different environments with different package sets. Despite ensuring the Altair version is consistent across these environments, I am observing significant differences in the graphs generated. Strangely, one set of graphs closely resembles those generated using Pandas ... | <python><graph><altair> | 2024-06-19 12:02:50 | 1 | 18,110 | Mykola Zotko |
78,642,383 | 508,907 | python, Typer: disable printing of elements such as the traceback and locals | <p>I am using <a href="https://typer.tiangolo.com/" rel="nofollow noreferrer">Typer</a> and it looks pretty cool.</p>
<p>However in a particular case, I want to hide some details for being print. In particular consider a case like</p>
<pre class="lang-py prettyprint-override"><code>import typer
app = typer.Typer()
@ap... | <python><typer> | 2024-06-19 12:01:50 | 1 | 14,360 | ntg |
78,642,298 | 8,964,393 | Check following element in list in pandas dataframe | <p>I have created the following pandas dataframe</p>
<pre><code>import pandas as pd
import numpy as np
ds = {
'col1' :
[
['U', 'U', 'U', 'U', 'U', 1, 0, 0, 0, 'U','U', None],
[6, 5, 4, 3, 2],
[0, 0, 0, 'U', 'U'],
[0, 1, 'U', 'U', 'U'],
... | <python><pandas><dataframe><list> | 2024-06-19 11:46:36 | 5 | 1,762 | Giampaolo Levorato |
78,642,191 | 4,435,175 | How to write a dataframe to BigQuery and overwrite partition instead of the table? | <p>I need to write a polars dataframe into a BigQuery table. The table is partioned by date.</p>
<p>When I need to run a backfilling script I iterate over a date range, get the data from some source (API in this case), convert it into a dataframe, manipulate a bit and write it into the BQ table.</p>
<p>But instead of o... | <python><dataframe><google-bigquery><python-polars> | 2024-06-19 11:20:54 | 1 | 2,980 | Vega |
78,642,079 | 2,736,559 | How to properly calculate PSD plot (Power Spectrum Density Plot) for images in order to remove periodic noise? | <p>I'm trying to remove periodic noise from an image using PSDP, I had some success, but I'm not sure if what I'm doing is 100% correct.<br />
This is basically a kind of follow up to this <a href="https://www.youtube.com/watch?v=s2K1JfNR7Sc" rel="nofollow noreferrer">video lecture</a> which discusses this very subject... | <python><numpy><opencv><computer-vision><fft> | 2024-06-19 10:55:06 | 1 | 26,332 | Hossein |
78,642,075 | 8,501,483 | How to disable gperftool profiling in python | <p>I want to do CPU profiling with <code>gperftools</code> by setting <code>LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libprofiler.so.0 CPUPROFILE=/tmp/myprofile.out</code>.</p>
<p>It works fine on purely C++ environment, but gperftools doesn't work with python, which generates an empty file.</p>
<p>In my environment, the ca... | <python><c++><gperftools> | 2024-06-19 10:53:46 | 0 | 604 | Tinyden |
78,641,487 | 5,731,861 | Problem with numpy: pip install numpy "Requirement already satisfied: numpy" | <p>when working with numpy I have found this problem, that submodules or packages installed in a virtual environment don't recognize the numpy.</p>
<pre><code>(venv) D:\felipe\work\ml\mnist>pip install numpy
Requirement already satisfied: numpy in d:\felipe\work\ml\mnist\venv\lib\site-packages (2.0.0)
</code></pre>
... | <python><numpy> | 2024-06-19 09:00:15 | 1 | 2,257 | Felipe Valdes |
78,641,299 | 5,061,637 | How to deal with binary extensions (.pyd files) and binary scripts (.exe files) in a Python wheel file? | <p>I’ve made a binary Python extension using C++ with the help of PyBind11.
This extension come with a “binary script” which is a regular executable file.</p>
<p>Now I’m struggling with the creation of a wheel file to distribute it.</p>
<p>Using pyproject.toml and setuptools backend, I’m able to create wheel file to in... | <python><setuptools><python-wheel> | 2024-06-19 08:22:11 | 0 | 1,182 | Aurelien |
78,641,200 | 1,107,595 | Initiate copy but exit without waiting for it to finish | <p>I'm using boto3 to copy a large object from one bucket to another (3.5 GiB), I'm using the following code:</p>
<pre><code>boto3.client('s3').copy_object(Bucket=dst_bucket, Key=filepath, CopySource={'Bucket': src_bucket, 'Key': filepath})
</code></pre>
<p>It works fine, but it takes ~4-5 minute, I don't want to wait... | <python><amazon-web-services><amazon-s3><boto3> | 2024-06-19 08:00:40 | 2 | 2,538 | BlueMagma |
78,641,150 | 13,086,128 | A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.0 | <p>I installed numpy 2.0.0</p>
<p><a href="https://i.sstatic.net/4aB0aWDL.png" rel="noreferrer"><img src="https://i.sstatic.net/4aB0aWDL.png" alt="enter image description here" /></a></p>
<pre><code>pip install numpy==2.0.0
import numpy as np
np.__version__
#2.0.0
</code></pre>
<p>then I installed:</p>
<pre><code>pip ... | <python><python-3.x><numpy><pip><numpy-2.x> | 2024-06-19 07:49:51 | 3 | 30,560 | Talha Tayyab |
78,641,125 | 1,082,349 | Scipy sparse solve prints: dgstrf info | <p>The following code</p>
<pre><code>from scipy.linalg.sparse import solve as spsolve
foo = spsolve(AMatrixT, dist)
</code></pre>
<p>prints into stdout</p>
<pre><code>dgstrf info 10200
</code></pre>
<p>And if I inspect <code>foo</code>, it's all <code>NaN</code>. The shape of <code>dist</code> happens to be (10200, 1).... | <python><numpy><scipy> | 2024-06-19 07:45:28 | 1 | 16,698 | FooBar |
78,640,937 | 16,521,194 | Update Swagger when dynamically adding FastAPI endpoints | <p>I would like to update the Swagger when adding a new endpoint dynamically.</p>
<p>To dynamically add endpoints, I am using the <a href="https://stackoverflow.com/a/74035526/16521194">accepted answer</a> to <a href="https://stackoverflow.com/q/70783994">Reload routes in FastAPI during runtime</a>.
This looks like the... | <python><swagger><fastapi> | 2024-06-19 06:56:23 | 0 | 1,183 | GregoirePelegrin |
78,640,606 | 22,407,544 | Why is my Django app running out of memory after switching to Gunicorn? | <p>I got the following error when trying to run a ML/AI app in Django/Docker. The app allows a user to upload audio files which are then transcribed. I started getting the following error after switching to Gunicorn. I understand it is due to memory allocation limitations, but I am not sure how to fix it. The error is ... | <python><django><docker> | 2024-06-19 05:11:44 | 0 | 359 | tthheemmaannii |
78,640,325 | 801,967 | Can not install pandas in python 3.9 | <p>I am using python 3.9 with Spark.</p>
<pre><code>python --version
Python 3.9.0
</code></pre>
<p>When I install pandas with</p>
<pre><code>pip install pandas
</code></pre>
<p>I got the following error</p>
<pre><code>Collecting pandas
Using cached pandas-2.2.2.tar.gz (4.4 MB)
Installing build dependencies ... done... | <python><pandas><pip><pyproject.toml> | 2024-06-19 02:58:01 | 1 | 341 | ferrito |
78,640,299 | 14,250,641 | Dataframe Expansion: Generating Genomic Positions +/- 250 Nucleotides | <p>I have a df that looks like (with 300k more rows of other genomic coordinates):</p>
<pre><code> chromosome start end
chr1 11859 11879
</code></pre>
<p>I want to expand the df such that for each row, it will include every position of the given coordinate centered around 250 nucleotides on ea... | <python><pandas><dataframe><numpy><bioinformatics> | 2024-06-19 02:44:25 | 1 | 514 | youtube |
78,640,245 | 2,328,154 | Snowflake SQLAlchemy - Dynamically created column with Timestamp? | <p>This is a follow-up question to my previous one.</p>
<p><a href="https://stackoverflow.com/questions/78614458/snowflake-sqlalchemy-create-table-with-timestamp/78623238#78623238">Snowflake SQLAlchemy - Create table with Timestamp?</a></p>
<p>I am dynamically creating columns and I have this schema.</p>
<p>I need the ... | <python><json><sqlalchemy><snowflake-cloud-data-platform> | 2024-06-19 02:16:06 | 1 | 421 | MountainBiker |
78,640,035 | 3,156,085 | Are `None` and `type(None)` really equivalent for type analysis? | <p>According to the <a href="https://peps.python.org/pep-0484/#using-none" rel="nofollow noreferrer">PEP 484's "Using None" part</a>:</p>
<blockquote>
<p>When used in a type hint, the expression <code>None</code> is considered equivalent to <code>type(None)</code>.</p>
</blockquote>
<p>However, I encountered ... | <python><python-typing> | 2024-06-19 00:00:58 | 2 | 15,848 | vmonteco |
78,639,873 | 3,486,684 | Keeping a "pointer" to the of the "parent array" from which a "derived array" was produced? | <p>(Aside: my question is equally applicable to <code>numpy</code> structured arrays and non-structured arrays.)</p>
<p>Suppose I have a numpy <a href="https://numpy.org/doc/stable/user/basics.rec.html" rel="nofollow noreferrer">structured array</a> with the <code>dtype</code>:</p>
<pre class="lang-py prettyprint-overr... | <python><numpy><numpy-slicing> | 2024-06-18 22:34:39 | 0 | 4,654 | bzm3r |
78,639,645 | 1,946,418 | Python/Powershell combo - make pwsh load even faster | <p>My main programming is done within Python, and want to invoke custom Powershell cmdlets I wrote. Added my <code>.psm1</code> file to the <code>$PSModulePath</code>, and my cmdlets are always loaded.</p>
<p>And I <code>-NoProfile</code>, and <code>-NoLogo</code> to invoke <code>pwsh</code> cmd a little bit faster. So... | <python><powershell><powershell-core> | 2024-06-18 21:01:23 | 1 | 1,120 | scorpion35 |
78,639,642 | 4,752,738 | python requests: ValueError: Timeout value connect was <object object at 0x7c6b5e484a80>, but it must be an int, float or None | <p>I updated <code>google-cloud-bigquery</code> from version <code>3.11.4</code> to <code>3.12.0</code>.
requests and urllib3 are pined.</p>
<pre><code>requests==2.31.0
requests-futures==1.0.1
requests_pkcs12==1.21
urllib3==1.26.18
</code></pre>
<p>Sometimes I get this error and don't understand why:</p>
<pre><code> F... | <python><google-bigquery><python-requests><urllib3> | 2024-06-18 20:59:59 | 0 | 943 | idan ahal |
78,639,630 | 8,510,149 | Scalable approach instead of apply in python | <p>I use apply to loop the rows and get the column names of feat1, feat2 or feat3 if they are equal to 1 and scored is equal to 0. The column names are then inserted into a new feature called reason.</p>
<p>This solution doesn't scale to larger dataset. I'm looking for faster approach. How can I do that?</p>
<pre><code... | <python><pandas><numpy> | 2024-06-18 20:56:50 | 3 | 1,255 | Henri |
78,639,591 | 2,280,641 | gitlab-ce does not show test coverage on the project badged, always 'unkown' | <p>I'm trying to make the <code>coverage</code> badged work on gitlab-ce, but no success so far.</p>
<p>My badge still unknown:</p>
<p><a href="https://i.sstatic.net/Jp74VRT2.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Jp74VRT2.png" alt="enter image description here" /></a></p>
<p>The badged configur... | <python><gitlab><continuous-integration><code-coverage><gitlab-ce> | 2024-06-18 20:46:52 | 0 | 523 | DPalharini |
78,639,491 | 21,152,416 | How to shutdown resources using dependency_injector | <p>I'm using <a href="https://python-dependency-injector.ets-labs.org/index.html" rel="nofollow noreferrer">dependency_injector</a> to manage DI. I don't understand how to release my resources using this library.</p>
<p>I found <a href="https://python-dependency-injector.ets-labs.org/index.html" rel="nofollow noreferre... | <python><dependency-injection> | 2024-06-18 20:18:32 | 1 | 1,197 | Victor Egiazarian |
78,639,455 | 3,486,684 | How to install a local folder as a package using `conda`? (yet another relative imports question) | <h1>High Level problem</h1>
<p>I experiment with/test the Python code I am writing in "playground scripts".</p>
<p>Usually I don't keep these playground scripts around, but recently I have been finding some value in saving them for longer term use. So I decided to create a separate</p>
<h1>Problem Setup</h1>
... | <python><conda><jupyter><python-packaging> | 2024-06-18 20:07:24 | 1 | 4,654 | bzm3r |
78,639,402 | 3,705,854 | Capturing stdout from InteractiveConsole.compile | <p>I have the following code:</p>
<pre><code>from code import InteractiveConsole
from io import StringIO
from contextlib import redirect_stdout
cons = InteractiveConsole()
code = cons.compile("2")
f = StringIO()
with redirect_stdout(f):
exec(code)
s = f.getvalue()
print("-" * 20)
print(s)
</cod... | <python><stdout> | 2024-06-18 19:52:47 | 0 | 349 | JKS |
78,639,348 | 9,191,338 | Is it possible to skip initialization of __main__ module in Python multiprocessing? | <p>It is common in python multiprocessing to use <code>if __name__ == "__main__"</code>. However, if I know my child process does not need anything from <code>__main__</code> module, can I remove this part? e.g.</p>
<pre class="lang-py prettyprint-override"><code># test_child.py
from multiprocessing import Pr... | <python><multiprocessing> | 2024-06-18 19:40:43 | 3 | 2,492 | youkaichao |
78,639,247 | 4,823,526 | How to get the values of a dictionary type from a parquet file using pyarrow? | <p>I have a parquet file which I am reading with pyarrow.</p>
<pre><code>In [83]: pq.read_schema('dummy_file.parquet').field('dummy_column').type
Out[83]: DictionaryType(dictionary<values=string, indices=int32, ordered=0>)
</code></pre>
<p>It says it is a column of dictionary type which is similar to a sql enum o... | <python><pandas><dictionary><parquet><pyarrow> | 2024-06-18 19:15:17 | 1 | 462 | In78 |
78,639,203 | 2,862,945 | How to plot a simple line with mayavi? | <p>Apparently, I do not understand how to plot a simple line with mayavi. According to the <a href="http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html#mayavi.mlab.plot3d" rel="nofollow noreferrer">docs</a>, I should use <code>mlab.plot3d</code>, where the first three arguments <code>x</code>, <code... | <python><draw><mayavi><mayavi.mlab> | 2024-06-18 19:04:26 | 1 | 2,029 | Alf |
78,639,151 | 1,275,942 | Preserving typing/typechecking while extending function with many arguments | <p>I want to subclass/wrap subprocess.Popen. However, it has a lot of arguments. The usual ways to solve this, as far as I'm aware, are 1. "biting the bullet":</p>
<pre class="lang-py prettyprint-override"><code>class MyPopen1(subprocess.Popen):
def __init__(self, myarg1, myarg2, bufsize=-1, executable=No... | <python><python-typing> | 2024-06-18 18:47:38 | 2 | 899 | Kaia |
78,638,998 | 11,092,636 | Radix sort slower than expected compared to standard sort | <p>I've implemented two versions of radix sort (the version that allows sorting integers whose values go up to n² where n is the size of the list to sort) in Python for benchmarking against the standard sort (Timsort). I'm using PyPy for a fairer comparison.</p>
<p>Surprisingly my radix sort implementation, even withou... | <python><algorithm><sorting><complexity-theory><pypy> | 2024-06-18 18:07:51 | 1 | 720 | FluidMechanics Potential Flows |
78,638,972 | 13,135,901 | Remove all duplicate rows except first and last in pandas | <p>I have a signal log with a lot of redundant data that I parse with pandas. To remove all duplicate rows besides first and last I use following code:</p>
<pre><code>>>> df = pd.DataFrame(
{
"A": [1, 2, 3, 4, 5, 6, 7, 8, 9],
"B": [0, 0, 0, 0, 1, 1, 1, 2, 3],
}
)
>... | <python><pandas><dataframe> | 2024-06-18 17:58:20 | 2 | 491 | Viktor |
78,638,748 | 9,357,484 | Unable to change the default version of Python in the virtual environment | <p>I want to create a virtual environment with Python version 3.9. I am using Windows11 operating system. I found various python version in the folder C:\Users\user1\AppData\Local\Programs\Python. The python versions are as follows
<a href="https://i.sstatic.net/TMM1BbpJ.png" rel="nofollow noreferrer"><img src="https:/... | <python><python-venv> | 2024-06-18 16:54:54 | 1 | 3,446 | Encipher |
78,638,695 | 6,622,697 | How to use separate model files with SQLAlchemy | <p>There are many questions about this and I tried various combinations, but can't get this to work. I want to be able to separate my model files into separate files.</p>
<p>I have the following structure</p>
<pre><code>app.py
db
Database.py
models
__init__.py
City.py
Meteo.py
</code></pre>
<p>... | <python><sqlalchemy> | 2024-06-18 16:43:53 | 1 | 1,348 | Peter Kronenberg |
78,638,694 | 1,943,571 | How to test a Pydantic BaseModel with MagicMock spec and wraps | <p>Given this example in Python 3.8, using Pydantic v2:</p>
<pre><code>from pydantic import BaseModel
import pytest
from unittest.mock import MagicMock
class MyClass(BaseModel):
a: str = '123'
# the actual implementation has many intertwined attributes
# and methods that I'd like to test
@pytest.fixture(... | <python><pytest><python-unittest.mock><pydantic-v2> | 2024-06-18 16:43:30 | 3 | 2,702 | Remolten |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.