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,893,691 | 3,498,864 | Capture integer in string and use it as part of regular expression | <p>I've got a string:</p>
<pre><code>s = ".,-2gg,,,-2gg,-2gg,,,-2gg,,,,,,,,t,-2gg,,,,,,-2gg,t,,-1gtt,,,,,,,,,-1gt,-3ggg"
</code></pre>
<p>and a regular expression I'm using</p>
<pre><code>import re
delre = re.compile('-[0-9]+[ACGTNacgtn]+') #this is almost correct
print (delre.findall(s))
</code></pre>
<p>Thi... | <python><regex><dna-sequence> | 2024-08-20 17:18:15 | 2 | 3,719 | Ryan |
78,893,523 | 8,079,870 | Why does mypy not infer types with torch.nn.functional.linear? | <p>I am trying to use mypy for some PyTorch code, and am perplexed why mypy gives an error here:</p>
<pre><code>from torch import FloatTensor
from torch.nn.functional import linear
def foo(x: FloatTensor, y: FloatTensor) -> FloatTensor:
return linear(x, y)
</code></pre>
<p>mypy outputs:</p>
<pre><code>error: In... | <python><pytorch><python-typing><mypy> | 2024-08-20 16:27:17 | 0 | 1,612 | Grayscale |
78,893,444 | 567,059 | Translate a python string such as 'a.b.c=v' into a dictionary | <p>How can I read a 'key=value' strings such as <code>['foo=bar', 'a.b.c=ddd']</code> and translate them in to a dictionary? The dictionary should either be updated if the key already exists, or have the new key added if it doesn't.</p>
<p>The example given in the paragraph above should translate to the following...</p... | <python><dictionary> | 2024-08-20 16:08:38 | 2 | 12,277 | David Gard |
78,893,412 | 10,128,864 | Python .txt to .xlsx Conversion Chunking and Indexing Issue | <p>I have a chunking and/or indexing issue with my python code where I am trying to convert a text script into an xlsx file. The problem is that xlsx files have a hard limit for the number of rows you can have:</p>
<pre><code>Traceback (most recent call last):
File "/Users/rbarrett/Git/Cleanup/yourPeople3/conver... | <python><pandas><xlsx><txt><file-conversion> | 2024-08-20 15:59:58 | 1 | 869 | R. Barrett |
78,893,397 | 20,591,261 | Use PCA with Python Polars | <p>I'm trying to use PCA (from the scikit-learn library) with Polars. I'm following this <a href="https://www.kaggle.com/code/farzadnekouei/customer-segmentation-recommendation-system#Step-9-%7C-K-Means-Clustering" rel="nofollow noreferrer">Kaggle notebook</a>, which uses Pandas, where they set an index for clustering.... | <python><scikit-learn><python-polars> | 2024-08-20 15:56:30 | 0 | 1,195 | Simon |
78,893,299 | 2,287,458 | Polars Dataframe full-join (outer) on multiple columns without suffix | <p>I have this code:</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
df1 = pl.DataFrame({
'type': ['A', 'O', 'B', 'O'],
'origin': ['EU', 'US', 'US', 'EU'],
'qty1': [343,11,22,-5]
})
df2 = pl.DataFrame({
'type': ['A', 'O', 'B', 'S'],
'origin': ['EU', 'US', 'US', 'AS'],... | <python><dataframe><join><merge><python-polars> | 2024-08-20 15:33:20 | 1 | 3,591 | Phil-ZXX |
78,892,982 | 2,664,134 | plotly.py Box Select extremely slow on first call on second and higher traces | <p>Running plotly 5.23.0 from Jupyter lab 4.2.4 on Mac.</p>
<p>Drawing 3 traces of 111_000 points each, with "lines" only.</p>
<p>When drawing a Box Select rectangle over the first trace (trace 0), the kernel is busy for less than 1 second and then is available again. When drawing Box Select again over the fi... | <python><plotly><jupyter-lab> | 2024-08-20 14:26:03 | 0 | 392 | peter_v |
78,892,697 | 10,053,485 | Preserving an immutable variable required at a higher scope while an error is raised | <p>I have set up a worker application in Python. As part of this worker, I always require a <code>new_process_time</code> to be defined in the return, such that the external queue can handle it properly.</p>
<p>Sometimes a severe error type may occur, which should abort the handling of this iteration entirely. This is ... | <python> | 2024-08-20 13:20:45 | 1 | 408 | Floriancitt |
78,892,568 | 2,287,458 | Polars split column and get n-th (or last) element | <p>I have the following code and output.</p>
<p><strong>Code.</strong></p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
df = pl.DataFrame({
'type': ['A', 'O', 'B', 'O'],
'id': ['CASH', 'ORB.A123', 'CHECK', 'OTC.BV32']
})
df.with_columns(sub_id=pl.when(pl.col('type') == 'O').then(pl.co... | <python><dataframe><split><python-polars> | 2024-08-20 12:54:52 | 1 | 3,591 | Phil-ZXX |
78,892,301 | 962,190 | Condition in pytest fixture depending on some test-suite results | <p>Imagine the following test-suite:</p>
<pre class="lang-py prettyprint-override"><code>import pytest
@pytest.fixture(scope="session")
def global_resource():
yield
if ...:
print("output generated by this resource.")
def test_foo():
assert False
def test_bar(global_resource... | <python><pytest><fixtures> | 2024-08-20 11:56:35 | 1 | 20,675 | Arne |
78,892,162 | 5,413,581 | Different solution using scikit-learn and cvxpy | <p>I am trying to code a logistic regression model using the CVXPY library. The code I have written so far "works" in the sense that it can be executed, it does not yield any error message and provides a solution. However, this solution does not match the solution provided by the scikit-learn implementation o... | <python><scikit-learn><logistic-regression><cvxpy> | 2024-08-20 11:21:51 | 0 | 769 | Γlvaro MΓ©ndez Civieta |
78,892,136 | 4,050,510 | Advice on how to speed up jax compilation times? | <p>I want to implement the Legendre approximation of <a href="https://papers.nips.cc/paper_files/paper/2023/hash/ee860a9fa65a55a335754c557a5211de-Abstract-Conference.html" rel="nofollow noreferrer">Dahlke&Pacheco 2020</a> to compute the entropy of a Gaussian Mixture Model.</p>
<p>I want to incorporate this into som... | <python><jit><jax> | 2024-08-20 11:14:53 | 0 | 4,934 | LudvigH |
78,892,056 | 18,769,241 | How to disable the warning message for g4f version deprecation? | <p>I am using this code to get my response out of the model :</p>
<pre><code>from g4f.client import Client
client = Client()
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hello"}],
)
</code></pre>
<p>T... | <python><warnings><openai-api> | 2024-08-20 11:01:49 | 1 | 571 | Sam |
78,892,021 | 26,843,912 | Websocket connecting only after the ayncio finish the background task | <p>I have a process route in my fast api server :-</p>
<pre class="lang-py prettyprint-override"><code>@router.post("/process")
async def handle_options(data: Dict[str, Any]):
#.... other code
asyncio.create_task(editing(videoId, values, videoWidth, videoHeight, fps, userData))
return {'The editing star... | <python><multithreading><websocket><python-asyncio><fastapi> | 2024-08-20 10:52:55 | 1 | 323 | Zaid |
78,891,908 | 5,346,843 | Plot annotations clipped by plt.savefig | <p>I am plotting sunrise and sunset times using code adapted from the<br />
matplotlib <a href="https://matplotlib.org/stable/gallery/color/colormap_reference.html#sphx-glr-gallery-color-colormap-reference-py" rel="nofollow noreferrer">colormap examples</a></p>
<p>The code is below:</p>
<pre><code>import datetime
impor... | <python><numpy><matplotlib> | 2024-08-20 10:28:15 | 1 | 545 | PetGriffin |
78,891,820 | 1,348,691 | How do I understand grouped[l].size()? | <p>I try to understand the following code <code>grouped[l].size()</code> as in:</p>
<pre><code>f = 10
n = 250
np.random.seed(100)
x = np.random.randint(0,2,(n,f))
y = np.random.randint(0,2,n)
fcols = [f'f{_}' for _ in range(f)]
data = pd.DataFrame(x, columns = fcols)
data['l'] = y
grouped = data.groupby(list(data.colum... | <python><pandas><numpy> | 2024-08-20 10:07:56 | 1 | 4,869 | Tiina |
78,891,775 | 2,292,490 | Search in CSV and add value if found correct value in another CSV | <p>I have 2 CSV that look like this:</p>
<p><code>input.csv</code>:</p>
<div class="s-table-container"><table class="s-table">
<thead>
<tr>
<th>id</th>
<th>sku</th>
<th>costs_production</th>
</tr>
</thead>
<tbody>
<tr>
<td>12</td>
<td>h01</td>
<td></td>
</tr>
<tr>
<td>13</td>
<td>h02</td>
<td></td>
</tr>
</tbody>
</tab... | <python><csv> | 2024-08-20 09:58:46 | 3 | 571 | Bill Bronson |
78,891,590 | 6,546,694 | python package installation via pip gives: ERROR: Could not install packages due to an OSError: [Errno 28] No space left on device | <p>I am trying to install <code>FlagEmbeddings</code> (<a href="https://github.com/FlagOpen/FlagEmbedding" rel="nofollow noreferrer">https://github.com/FlagOpen/FlagEmbedding</a>)
like so:</p>
<pre><code>git clone https://github.com/FlagOpen/FlagEmbedding.git
cd FlagEmbedding
pip install -e .
</code></pre>
<p>I am runn... | <python><azure><pip><azure-storage><disk> | 2024-08-20 09:20:44 | 1 | 5,871 | figs_and_nuts |
78,891,481 | 5,269,892 | Pandas string replace with regex argument for non-regex replacements | <p>Suppose I have a dataframe in which I want to replace a non-regex substring consisting only of characters (i.e. a-z, A-Z) and/or digits (i.e. 0-9) via <a href="https://pandas.pydata.org/docs/reference/api/pandas.Series.str.replace.html" rel="nofollow noreferrer">pd.Series.str.replace</a>. The docs state that this fu... | <python><pandas><replace> | 2024-08-20 08:56:09 | 3 | 1,314 | silence_of_the_lambdas |
78,891,473 | 243,755 | How to include the project root folder into PYTHONPATH when running python script in sub folder | <p>Here's my project structure</p>
<pre><code>- folder_1
- folder_2
- file1.py
- file2.py
- folder_3
- file3.py
</code></pre>
<p>Now I use this command to run file1.py</p>
<pre><code>python folder_1/folder_2/file1.py
</code></pre>
<p>But what I found is that python put <code>folder_1/... | <python><pythonpath> | 2024-08-20 08:54:39 | 1 | 29,674 | zjffdu |
78,891,025 | 19,356,117 | Why invoking a python program in another python program will make aboriginal program slower? | <p>In my tool <a href="https://github.com/iHeadWater/hydrotopo" rel="nofollow noreferrer"><code>hydrotopo</code></a>, when I run <code>find_edge_nodes</code> to find topological relations for about 100,000 linestrings, it only costs about 10 seconds; but in code below, <code>find_edge_nodes</code> will cost about 30min... | <python><pytest><shapely> | 2024-08-20 07:04:02 | 1 | 1,115 | forestbat |
78,890,898 | 19,616,641 | Displaying gazebo realsense image using ROS, depth image looks weird and having different size from the raw | <p>Trying to display images captured by realsense in my gazebo simulation onto an opencv window. But the depth image is showing colorful despite rviz showing black and white. And the raw and depth image from the same cam have different size despite not resizing. I want the simulation to have the same output as the real... | <python><ros><realsense><gazebo-simu><rviz> | 2024-08-20 06:28:43 | 1 | 421 | brian2lee |
78,890,711 | 1,176,573 | Bar chart not updated when button is selected for a plotly python graph | <p>Below plotly code renders bar graph with buttons to select either <code>stack</code> or <code>group</code> style. But chart does not updates style when a selection is made on button. How do I fix this:</p>
<pre><code>fig1 = go.Figure()
x = temp_df.index
y1 = temp_df['Sales'].astype(float) # Sales Column
y2 = temp_... | <python><plotly> | 2024-08-20 05:16:01 | 1 | 1,536 | RSW |
78,890,700 | 1,447,953 | Bokeh simple data selection slider without python or javascript callback? | <p>Is it possible to do simple dynamic selection of data with a slider in Bokeh without a custom Python callback? Here is what I can do using a callback, but it would need a Bokeh server to work in exported html:</p>
<pre><code>import numpy as np
import pandas as pd
import ipywidgets as widgets
from bokeh.io import sho... | <python><jupyter-notebook><bokeh> | 2024-08-20 05:11:42 | 1 | 2,974 | Ben Farmer |
78,890,489 | 2,604,247 | Dataframes with Common Lazy Ancestor Means Repeated Computation? | <h4>Dependency DAG</h4>
<p><a href="https://i.sstatic.net/wiB44IpY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wiB44IpY.png" alt="enter image description here" /></a></p>
<h6>Description</h6>
<p>Pretty straight forward, basically, I am reading some parquet files from disk using polars which are the s... | <python><dataframe><lazy-evaluation><python-polars><directed-acyclic-graphs> | 2024-08-20 03:17:11 | 2 | 1,720 | Della |
78,890,441 | 1,431,690 | wordcloud with 2 background colors | <p>I generated this on wordcloud.com using one of the "themes".</p>
<p><img src="https://i.sstatic.net/51lNzsZH.png" alt="enter image description here" /></p>
<p>I'd like to be able to do this with the python wordcloud library, but so far all I can achieve is a single background color (so all black, not grey ... | <python><numpy><matplotlib><imshow><word-cloud> | 2024-08-20 02:49:45 | 1 | 688 | nettie |
78,890,438 | 2,966,723 | Creating a mutable substitute for `int` and other imutable types | <p>I have a parameter, <code>N</code> that shows up in some python-based simulations. There are several things that will be set to be equal to <code>N</code>. The code relies on packages that will run things expecting <code>N</code> to be an integer. (I have other parameters that are floats, but let's focus on the i... | <python><class> | 2024-08-20 02:47:11 | 2 | 24,012 | Joel |
78,890,167 | 1,732,418 | How could the content of pip install and PyPI download be different? is pip broken? | <p>Today I tried to install the latest pymavlink package:</p>
<p><a href="https://pypi.org/project/pymavlink/" rel="nofollow noreferrer">https://pypi.org/project/pymavlink/</a></p>
<pre><code>pip install pymavlink
Collecting pymavlink
Using cached pymavlink-2.4.41-py3-none-any.whl.metadata (6.2 kB)
Requirement alread... | <python><pip><pypi> | 2024-08-20 00:05:38 | 1 | 3,992 | tribbloid |
78,890,076 | 2,362,671 | how to configure basedpyright to work with numpy.typing | <p><code>basedpyright</code> can't resolve a simple <code>import numpy.typing</code>. What should I add to my configuration to get it to work?</p>
<p>For instance, if I have a file <code>a.py</code> with a single line:</p>
<pre><code>import numpy.typing as npt
</code></pre>
<p>I get this error when running <code>basedp... | <python><numpy><python-typing><pyright> | 2024-08-19 23:16:40 | 1 | 1,700 | Come Raczy |
78,889,983 | 23,626,926 | argparse option to create a mapping | <p>C compilers have the <code>-D</code> switch to define a preprocessor constant at compilation time. It is called like <code>-D name=value</code>, or <code>-D name</code> and <code>value</code> defaults to 1.</p>
<p>Can a similar thing be done with python argparse? That is, can you create an option that meets these cr... | <python><dictionary><argparse> | 2024-08-19 22:36:34 | 2 | 360 | dragoncoder047 |
78,889,834 | 1,739,681 | Use VS Code breakpoints with pantsbuild tests | <p>I have the following setup: Python project + pantsbuild + vscode.</p>
<p>I would like to add <a href="https://code.visualstudio.com/docs/editor/debugging#_breakpoints" rel="nofollow noreferrer">VS Code breakpoints</a> in my unit tests (unittest) while using the <code>pants test</code> command. I can already set brea... | <python><visual-studio-code><python-unittest><pants><debugpy> | 2024-08-19 21:23:18 | 1 | 305 | julianofischer |
78,889,767 | 20,591,261 | Polars chain multiple operations on select() with values_counts() | <p>I'm working with a Polars dataframe and I want to perform a series of operations using the <code>.select()</code> method. However, I'm facing problems when I try to apply <code>value_counts()</code> followed by <code>unnest()</code> to get separate columns instead of a <code>struct</code> column.</p>
<p>If I just u... | <python><dataframe><python-polars> | 2024-08-19 21:02:48 | 3 | 1,195 | Simon |
78,889,666 | 810,815 | Python package sumy throwing errors in Jupyter notebook | <p>I am trying to use sumy to summarize text but keep getting weird issues. I am using the following code in my Jupyter Notebook.</p>
<pre><code>import nltk
nltk.download('punkt')
nltk.download('punkt_tab')
import sumy
from sumy.parsers.plaintext import PlaintextParser
from sumy.nlp.tokenizers import Tokenizer
from ... | <python> | 2024-08-19 20:26:55 | 2 | 9,764 | john doe |
78,889,556 | 6,930,340 | Create date_range with predefined number of periods in polars | <p>When I create a date range in pandas, I often use the <code>periods</code> argument. Something like this:</p>
<pre class="lang-py prettyprint-override"><code>pd.date_range(start='1/1/2018', periods=8)
</code></pre>
<pre><code>DatetimeIndex(['2018-01-01', '2018-01-02', '2018-01-03', '2018-01-04',
'2018... | <python><python-polars> | 2024-08-19 19:55:22 | 1 | 5,167 | Andi |
78,889,546 | 7,685,367 | PyCharm Pro 2024.1.1 - Not stopping on all breakpoints | <p>I am using Pycharm Professional Ver 2024.1.1, in Windows 11, and it is not stopping on breakpoints defined in called/sub functions when 'stepping over' with F8. To recreate this simply use the sample code created with a new PyCharm project:</p>
<pre><code>1 def print_hi(name):
2 print(f'Hi, {name}') # Pre... | <python><pycharm> | 2024-08-19 19:50:40 | 0 | 1,057 | vscoder |
78,889,486 | 22,062,869 | Preserving DataFrame subclass type during pandas groupby().aggregate() | <p>I'm subclassing <code>pandas DataFrame</code> in a project of mine. Most <code>pandas</code> operations preserve the subclass type, but <code>df.groupby().agg()</code> does not. Is this a bug? Is there a known workaround?</p>
<pre><code>import pandas as pd
class MySeries(pd.Series):
pass
class MyDataFrame(pd.D... | <python><pandas><dataframe><group-by><subclass> | 2024-08-19 19:30:00 | 2 | 395 | rasputin |
78,889,374 | 1,631,414 | How do I write a regex to capture a block of text up to a blank line? | <p>I'm trying to capture a block of text from a linux command that's delimited by a blank line. However, I'm having trouble with the regex matching past the first line.</p>
<p>So the output might look like this where the blocks are of variable length.
What should the regex be to match past the first line and to match ... | <python><regex><blank-line><less-unix> | 2024-08-19 18:52:57 | 1 | 6,100 | Classified |
78,889,365 | 11,065,874 | how to make sub-shell env variable available in the main shell python console? | <p>I open a python console and run</p>
<pre><code>>>> import os
>>> os.system("export aaa=123")
>>> os.environ["aaa"]
</code></pre>
<p>I see a key error. Why is that?
How can I preserve the env variables across the entire process?</p>
<p>note that this is not the right ans... | <python><linux><bash><shell><sh> | 2024-08-19 18:50:43 | 4 | 2,555 | Amin Ba |
78,889,355 | 2,036,035 | git filter repo, can't find python on windows, despite it being in the path and being able to run python from cmd | <p>Similar to this, but not the same issue (all the steps prior were followed, python is provably on path) <a href="https://stackoverflow.com/q/65626875/">git filter repo - Python was not found - but it's installed</a></p>
<p>Basically I try to run git filter-repo, and while the <em>script</em> is recgonized, pytho... | <python><windows><git><path><git-filter-repo> | 2024-08-19 18:47:22 | 1 | 5,356 | Krupip |
78,889,292 | 2,397,542 | Azure Python SDK - how can I know the latest API version for a resource ID? | <p>I'm using the python Azure SDK, and for things like subnets, ipConfiguration objects will have a generic resource ID for the attached device - sometimes it's a NIC, or a PEP or something else. I know I can use the azure-mgmt-resources.ResourceManagementClient to get a generic resource object for one of these, BUT it... | <python><azure><azure-sdk-python> | 2024-08-19 18:23:44 | 1 | 832 | AnotherHowie |
78,889,184 | 2,516,862 | numpy polynomial roots incorrect compared to Matlab? | <p>I would like to figure out the roots of the polynomial <code>x^2 - 800x + 160000</code>, which has a multiple root of 400.</p>
<p>In Matlab, if I type <code>roots([1 -800 160000)</code>, I correctly get <code>ans = 400.0000, 400.0000</code> whereas numpy <code>np.roots([1, -800, 160000])</code> gives me <code>array(... | <python><numpy><polynomials> | 2024-08-19 17:53:14 | 2 | 1,420 | Gary Allen |
78,889,157 | 7,166,834 | Functioning of rate limiter for API requests | <p>I am trying to limit my API calls based on the below limit rates. To achieve this am trying to use <code>ratelimit</code> from python.</p>
<ul>
<li>Per second: 25 requests</li>
<li>Per minute: 250 requests</li>
<li>Per 30 minutes: 1,000 requests</li>
</ul>
<p>I am able to use the per second limit based on rate limit... | <python><rate-limiting> | 2024-08-19 17:43:33 | 1 | 1,460 | pylearner |
78,889,140 | 4,265,321 | transform DeviceArray into Array for jax | <p>I have a <code>.pkl</code> file I downloaded from a public GitHub repository and when I read it using <code>pickle.load</code>, i.e. using</p>
<pre class="lang-py prettyprint-override"><code>with open('filename.pkl'), 'rb') as f:
file_content = pickle.load(f)
</code></pre>
<p>I get the following error</p>
<... | <python><jax> | 2024-08-19 17:37:43 | 1 | 1,343 | johnhenry |
78,889,116 | 9,112,151 | How to select only related model? | <p>I need to select only <code>Phone.user</code> when selecting <code>Phone model</code>:</p>
<pre><code>from sqlalchemy import ForeignKey, select
from sqlalchemy import create_engine
from sqlalchemy.orm import DeclarativeBase, Session, relationship, joinedload
from sqlalchemy.orm import Mapped
from sqlalchemy.orm impo... | <python><sql><sqlite><sqlalchemy> | 2024-08-19 17:28:09 | 1 | 1,019 | ΠΠ»ΡΠ±Π΅ΡΡ ΠΠ»Π΅ΠΊΡΠ°Π½Π΄ΡΠΎΠ² |
78,889,055 | 6,141,238 | In Python, why does preallocation of a numpy array fail to limit its printed precision? | <p>Here is a minimal example:</p>
<pre><code>import numpy as np
np.set_printoptions(linewidth=1000, precision=3)
# First attempt fails to limit the printed precision of x
x = np.array([None])
x[0] = 1/3
print(x)
# Second attempt succeeds
x = [None]
x[0] = 1/3
x = np.array(x)
print(x)
</code></pre>
<p>Running this scr... | <python><numpy><printing><precision><numpy-ndarray> | 2024-08-19 17:03:55 | 1 | 427 | SapereAude |
78,889,013 | 14,271,847 | pywintypes.com_error when using getCellValue in SAP GUI Scripting with Python | <p>I'm working on a Python script that interacts with SAP GUI using the win32com.client module. My goal is to retrieve a specific cell value from a table within SAP. However, I'm encountering an error when I attempt to use the getCellValue method. Below is the traceback:</p>
<pre><code>Traceback (most recent call last)... | <python><com><win32com><sap-gui> | 2024-08-19 16:50:28 | 1 | 429 | sysOut |
78,888,948 | 251,589 | How to get `mypy` to raise errors/warnings about using the `typing` package instead of built in types | <p>Currently I have a bunch of code that does this:</p>
<pre class="lang-py prettyprint-override"><code>from typing import Dict
foo: Dict[str, str] = []
</code></pre>
<p>In Python 3.9+, it is preferable to use the built-in types (<a href="https://mypy.readthedocs.io/en/stable/builtin_types.html#generic-types" rel="nofo... | <python><python-typing><mypy> | 2024-08-19 16:35:55 | 1 | 27,385 | sixtyfootersdude |
78,888,863 | 11,598,948 | Compute the number of unique combinations while excluding those containing missing values | <p>I'd like to count the number of unique values when combining several columns at once. My idea so far was to use <code>pl.struct(...).n_unique()</code>, which works fine when I consider missing values as a unique value:</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
df = pl.DataFrame({
... | <python><python-polars> | 2024-08-19 16:11:30 | 1 | 8,865 | bretauv |
78,888,851 | 2,110,874 | Parsing string to datetime using pandas | <p>I am trying to parse a string to datetime using pandas but I am getting the following error:</p>
<pre><code>ValueError: Cannot parse both %Z and %z
</code></pre>
<p>My date string is:</p>
<pre><code>ds = '03.01.2021 23:00:00.000 GMT+0100'
</code></pre>
<p>and the conversion I'm trying is as follow:</p>
<pre><code>fo... | <python><pandas><datetime><timezone> | 2024-08-19 16:08:16 | 1 | 419 | FELIPE_RIBAS |
78,888,776 | 17,721,722 | How to Dynamically Determine the Repartition Count for Loading Large CSV Files into PostgreSQL Using PySpark? | <p>I need to load 5 million records from a CSV file into a PostgreSQL table as quickly as possible using PySpark. The performance and speed of the operation are critical for me. I often run my code from either my PC or a server, and I suspect the optimal repartition count might differ depending on the environment.</p>
... | <python><postgresql><dataframe><apache-spark><pyspark> | 2024-08-19 15:49:46 | 0 | 501 | Purushottam Nawale |
78,888,734 | 1,052,628 | Get more than 1000 records from Matillion Task History API | <p>I am using <a href="https://docs.matillion.com/metl/docs/2972278/#get-history" rel="nofollow noreferrer">Matillion Task History API</a> to fetch the history of tasks that have been running in the Matillion ETL instance. Task history results are subject to a limit of 1,000 records for a single task run. I was looking... | <python><etl><monitoring><matillion> | 2024-08-19 15:39:48 | 1 | 636 | Rafiul Sabbir |
78,888,711 | 5,058,384 | cleanup_tokenization_spaces issue in Flux running in ComfyUI | <p>I'm getting the issue below with Flux in ComfyUI and it points to this bug (<a href="https://discuss.huggingface.co/t/cleaup-tokenization-spaces-error/102749" rel="nofollow noreferrer">https://discuss.huggingface.co/t/cleaup-tokenization-spaces-error/102749</a>). What is the solution to resolve it? Do I set the clea... | <python><huggingface-transformers><huggingface-tokenizers> | 2024-08-19 15:33:47 | 2 | 966 | garrettlynchirl |
78,888,680 | 11,028,689 | ValueError: Number of classes does not match size of target_names for a confusion matrix | <p>I have this code which produces a Value error.</p>
<pre><code>y = df['weather type']
# y is an array with the 11 unique values 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
# and of an 'object' type:
array([10, 10, 10, ..., 10, 10, 9])
# Encode the target variable (weather type) to numeric values -
# not sure if I should hav... | <python><xgboost><confusion-matrix> | 2024-08-19 15:26:01 | 1 | 1,299 | Bluetail |
78,888,658 | 1,654,229 | Pydantic validation issue on discriminated union field from JSON in DB | <p>I have a JSON field (form_config) in Postgres table which contains form field structure. This is the value in that table.</p>
<pre><code>[
{
'label': 'Age',
'type': 'number',
'required': True,
'min': 0,
'max': None
},
{
'label': 'Name',
'type': 'text',
'required': True,
'min... | <python><fastapi><pydantic> | 2024-08-19 15:23:02 | 1 | 1,534 | Ouroboros |
78,888,584 | 6,930,340 | Compute difference between dates and convert into weeks/months/years in polars dataframe | <p>I have a <code>pl.DataFrame</code> with a <code>start_date</code> and <code>end_date</code> column. I need to compute the difference between those two columns and add new columns representing the result in <code>days</code>, <code>weeks</code>, <code>months</code> and <code>years</code>.</p>
<p>I would be fine to ge... | <python><python-polars> | 2024-08-19 15:10:24 | 1 | 5,167 | Andi |
78,888,562 | 11,037,602 | Page loads with Playwright, but fails with scrapy-playwright | <h2>TL,DR;</h2>
<p>When page is loaded by headless <code>playwright</code> + proxy it works perfectly, every time.
When page is loaded by <code>scrapy-playwright</code>, also headless and same proxy, it raises Timeout errors and the HTML content of the page object is as JS was disabled. Other domains work with <code>sc... | <python><scrapy><playwright><playwright-python><scrapy-playwright> | 2024-08-19 15:04:58 | 0 | 2,081 | Justcurious |
78,888,513 | 769,922 | Converting a subset of the dataframe into another dataframe | <p>I have a pandas dataframe that looks like so</p>
<pre><code>Index Key 2010-01 2010-02 2010-03 ... 2020-12
A/B/C foo 0.23 0.44 0 2.1
A/B/C bar 0.43 0.12 0.23 1.2
A/B/C baz 0.25 0.23 0.2 2.5
P/Q/R ... | <python><pandas><dataframe> | 2024-08-19 14:56:11 | 2 | 1,037 | Serendipity |
78,888,416 | 4,764,604 | Problem installing PyTorch 1.9.0 on Windows 10 x64 with Python 3.8 using pip | <p>I'm trying to install PyTorch 1.9.0 on my Windows 10 64-bit system with Python 3.8, but pip can't find the proper distribution. When I try to install it using the command:</p>
<pre><code>pip3 install torch torchvision torchaudio
</code></pre>
<p>I get the following error:</p>
<pre><code>ERROR: Could not find a versi... | <python><python-3.x><pytorch><pip><windows-10> | 2024-08-19 14:33:08 | 1 | 3,396 | Revolucion for Monica |
78,888,407 | 3,247,006 | Is `CPU times` of `%time` the total of User CPU time and System CPU time in IPython? | <p>Running the code with the <a href="https://ipython.readthedocs.io/en/stable/interactive/magics.html#built-in-magic-commands" rel="nofollow noreferrer">magic command</a> <a href="https://ipython.readthedocs.io/en/stable/interactive/magics.html" rel="nofollow noreferrer">%time</a> in IPython got <code>CPU times</code>... | <python><time><ipython><cpu-time><magic-command> | 2024-08-19 14:30:10 | 1 | 42,516 | Super Kai - Kazuya Ito |
78,888,400 | 3,556,110 | How do I override django.db.backends logging to work when DEBUG=False? | <p>In django's LOGGING configuration for the builtin <a href="https://docs.djangoproject.com/en/5.1/ref/logging/#django-db-backends" rel="nofollow noreferrer">django.db.backends</a> it states that:
"For performance reasons, SQL logging is only enabled when settings.DEBUG is set to True, regardless of the logging l... | <python><django><database><logging> | 2024-08-19 14:28:22 | 2 | 5,582 | thclark |
78,888,382 | 12,257,924 | How to use ChatOpenAI with LM Studio for LLMs? (Langchain) | <p>I want to use ChatOpenAI from <code>langchain-openai</code> package to communicate with my local LM Studio server on Ubuntu 22.</p>
<p>I followed docs and came up with this - which is a standard way:</p>
<pre class="lang-py prettyprint-override"><code>from langchain_openai import ChatOpenAI
from dotenv import load_d... | <python><openai-api><langchain><agent> | 2024-08-19 14:25:17 | 2 | 639 | Karol |
78,888,343 | 26,843,912 | Watch for file changes and send the data through websocket | <p>I have an endpoint in my python fast api and whenver the frontend connects to it, I want to listen for changes on a specific file stored in the temporary directory of the system. I am using watch dog, but I am not able to make it work it, its just not sending any message on changes :-</p>
<pre class="lang-py prettyp... | <python><fastapi><python-watchdog> | 2024-08-19 14:15:17 | 1 | 323 | Zaid |
78,888,041 | 4,435,175 | Cast multiple columns with Unix epoch to Datetime | <p>I have a dataframe with multiple columns containing unix epochs.
In my example I only use 2 of 13 columns I have. I'd like to cast all those columns to a datetime with UTC timezone in a single call to <code>with_columns()</code>.</p>
<pre class="lang-py prettyprint-override"><code>df = pl.from_repr("""... | <python><datetime><casting><python-polars><epoch> | 2024-08-19 13:05:41 | 1 | 2,980 | Vega |
78,887,911 | 3,906,713 | Is there an efficient way to sum over numpy splits | <p>I would like to split array into chunks, sum the values in each chunk, and return the result as another array. The chunks can have different sizes. This can be naively done by using <a href="https://numpy.org/doc/stable/reference/generated/numpy.split.html" rel="nofollow noreferrer">numpy split</a> function like thi... | <python><numpy><split> | 2024-08-19 12:28:54 | 2 | 908 | Aleksejs Fomins |
78,887,797 | 5,013,037 | How to log a request in FastAPI when an exception occurs which is handled inside submodule? | <p>Imagine I have a FastAPI backend application exposing the following test endpoint:</p>
<pre><code>@router.post("/my_test")
async def post_my_test(request: Request):
a = do_stuff(request.var1)
b = do_different_stuff(request.var2)
return a + b
</code></pre>
<p>Inside my <code>do_stuff()</code> an... | <python><exception><logging><fastapi><uvicorn> | 2024-08-19 12:02:39 | 1 | 364 | fragant |
78,887,694 | 16,527,170 | Compare Columns in DF & drop rows if Dates are matching between Columns | <p>I have df as below. If Column <code>Buy Exit Date</code> is having Date (YYYY/MM/DD) matching with Column <code>Buy Date</code> having Date (YYYY/MM/DD) in next row, then drop the <code>Buy Date</code> row from its matching condition.</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
data = {
... | <python><pandas><dataframe><date> | 2024-08-19 11:37:41 | 1 | 1,077 | Divyank |
78,887,684 | 11,790,979 | Pytest can't find imports from tested modules | <p>I am trying to test a package with the following structure:</p>
<pre><code>.
βββ src\
βββ--myproject\
β βββ __init__.py
β βββ module1.py
β βββ module2.py
β βββ main.py
βββ-tests\
βββtest_simple.py
βββtest_module1.py
</code></pre>
<p>I am running with a virtualenv.</p>
<pre><code>#test_simple.py
def ... | <python><pytest> | 2024-08-19 11:34:29 | 0 | 713 | nos codemos |
78,887,664 | 16,723,655 | Jupyter notebook Nbextensions shows only spinning reload circle | <p>I installed WSL Ubuntu 22.04.3 LTS.</p>
<p>I had not any problem with Nbextensions before I reinstall jupyter notebook.</p>
<p>I totally reinstalled Ubuntu (WSL Ubuntu) and jupyter notebook (See below code).</p>
<pre><code>pip install notebook==6.1.5
</code></pre>
<p>Then, I entered below code as before.</p>
<pre><c... | <python><jupyter-notebook><jupyter-contrib-nbextensions> | 2024-08-19 11:29:38 | 1 | 403 | MCPMH |
78,887,406 | 5,786,649 | Is it possible to use the override syntax with structured configs in Hydra? | <p>The Hydra docs on <a href="https://hydra.cc/docs/patterns/configuring_experiments/" rel="nofollow noreferrer">configuring experiments</a> explains how to use overrides in standard, file-base configs. Is it possible to use overrides in Structured Configs? A minimum example:</p>
<pre class="lang-py prettyprint-overrid... | <python><fb-hydra><omegaconf> | 2024-08-19 10:20:13 | 1 | 543 | Lukas |
78,887,327 | 1,251,570 | Pandas without sqlite3 | <p>There is a transitive dependency of <code>Pandas</code> on <code>sqlite3</code> via <code>SqlAlchemy</code>. Hence, if you don't have <code>sqlite3</code> installed on Linux or Windows, <code>Pandas</code> won't run. It will show this error.</p>
<blockquote>
<p>ModuleNotFoundError: No module named β_sqlite3β</p>
</b... | <python><pandas><sqlite><sqlite3-python> | 2024-08-19 10:00:07 | 1 | 1,622 | Barun |
78,887,320 | 13,314,132 | Streamlit crashing when using ydata_profiling | <p>I am using Streamlit to visualize my <code>ydata_profiling</code> report.
However when I am selecting a work_order to generate a profile report it keeps on crashing without any error message.
Attached screenshot:
<a href="https://i.sstatic.net/As3RzJ8J.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/A... | <python><mongodb><streamlit><pandas-profiling> | 2024-08-19 09:59:05 | 1 | 655 | Daremitsu |
78,887,297 | 6,525,347 | Unable to install PYPI Package from Sonatype-Nexus in Docker container: "No matching distribution found" | <p>I have a hosted PyPI Sonatype Nexus Repository named pypi, where I store several packages, including <code>pillow</code>.</p>
<p>On my local machine, I can install <code>pillow</code> without any issues from the self-hosted pypi using the following command:</p>
<pre><code>pip install pillow --trusted-host {HOST_NAME... | <python><docker><nexus><pypi><nexus3> | 2024-08-19 09:52:38 | 1 | 1,146 | thelearner |
78,887,265 | 2,123,706 | import filename as fn fails in python 3.11 | <p>I have a scheduled task that runs a python script.</p>
<p>The python script imports a bunch of functions from another python script held in the same directory.</p>
<pre><code>- dir
- script.py
- functions.py
</code></pre>
<p>I call <code>functions.py</code> with:</p>
<pre><code>import functions as paxf
</code>... | <python><import> | 2024-08-19 09:40:56 | 1 | 3,810 | frank |
78,886,970 | 893,254 | How to add Anaconda Prompt option to Windows Terminal? | <p>How can I add an Anaconda Prompt option to <a href="https://apps.microsoft.com/detail/9n0dx20hk701?hl=en-US&gl=US" rel="nofollow noreferrer">Windows Terminal</a>?</p>
<p>I have installed Anaconda Navigator. I do not have any other Python distributions installed. This is a Windows 11 system, but the same informat... | <python><windows><anaconda><windows-terminal> | 2024-08-19 08:23:00 | 1 | 18,579 | user2138149 |
78,886,889 | 4,513,726 | use an iterface to replace characterization factors of an lca object with Brightway | <p>I am trying to change the characterization factors specifying new values using a datapackage, but I am facing some unexpected problems. For example if I do</p>
<pre class="lang-py prettyprint-override"><code>import bw2data as bd
import bw_processing as bwp
import numpy as np
import bw2calc as bc
mobility_db = bd.Da... | <python><brightway> | 2024-08-19 07:58:57 | 2 | 1,646 | mfastudillo |
78,886,886 | 17,795,398 | How to align two x-axes (twiny) in matplotlib? | <p>I have written this code to plot two curves. I want to show the same <code>y</code> value for two <code>x</code> values (<code>x</code> values are related by some non-linear relation). The function that describes <code>y</code> can be written as a function of any of them, that is why I want to show both dependencies... | <python><matplotlib> | 2024-08-19 07:58:39 | 1 | 472 | Abel GutiΓ©rrez |
78,886,753 | 1,176,573 | Bar chart plot shows linearly increasing data | <p>Using Python <code>plotly</code>, the charted data shows linearly increasing data, but is not correct.
Also, the first data point (i.e. <code>5585</code>) is rendered as empty bar.
How do I fix these?</p>
<pre class="lang-py prettyprint-override"><code>import plotly.graph_objects as go
fig = go.Figure()
x = df_quat... | <python><plotly> | 2024-08-19 07:26:33 | 3 | 1,536 | RSW |
78,886,736 | 2,386,605 | PyCharm can work with setup.py but not pyproject.toml | <p>I have a package <code>my_lib</code> and want to use it in another repo in pycharm.</p>
<p>When I have my <code>setup.py</code> file</p>
<pre><code>from setuptools import setup, find_packages
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setup(
... | <python><pycharm> | 2024-08-19 07:22:02 | 1 | 879 | tobias |
78,886,486 | 1,668,622 | In Micropython, how can I guarantee asynchronous tasks being shut down? | <p><strong>Note</strong>: despite I'm beginning my question with a <code>microdot</code> example, this is just because I've first observed the later described behavior with an attempt to re-start a <code>microdot</code> server after aborting a running async script with CTRL-C. Chances are that a solution to my problem ... | <python><python-asyncio><micropython> | 2024-08-19 06:07:41 | 1 | 9,958 | frans |
78,886,414 | 6,843,153 | How to switch to another page with a button click in streamlit | <p>I have the following <strong>streamlit</strong> button:</p>
<pre><code> def _render_settings_button(self, column):
with column.container():
st.button(
":material/settings: Settings",
key="settings_button",
use_container_width=... | <python><streamlit> | 2024-08-19 05:34:33 | 2 | 5,505 | HuLu ViCa |
78,886,330 | 5,799,033 | In Python, I want a list (or something) to pop its last member when I return from a function | <p>This works, but is it the best way? Performance is not a concern. It just seems clunky and error-prone to do the pop manually.</p>
<p>I want to access all parts of the list in the called functions, but I don't want to know about them from the caller.</p>
<pre><code>def outer():
myList = ['outer']
middle(myLi... | <python><list> | 2024-08-19 04:54:36 | 2 | 321 | Tamias |
78,886,325 | 14,458,028 | How can I use a field of Foreign key (User Model) as the upload destination of FileField? | <p>I have a Files model which has the User Model as Foreign key, I want to use the user's username as the name of the folder to which the files of the particular user will be uploaded. How can I achieve this?</p>
<p>I tried creating a getter function but that is not working.</p>
<p>Files Model:</p>
<pre><code>class Fil... | <python><django-models><foreign-keys><django-file-upload> | 2024-08-19 04:52:10 | 1 | 799 | Khushal |
78,886,217 | 11,716,727 | Facing a problem with running a Federated Learning code | <p>I am trying to run the code in the following link <a href="https://github.com/shaoxiongji/federated-learning" rel="nofollow noreferrer">shaoxiongji/federated-learning</a> using the following steps:</p>
<p><strong>1- Clone the Repository:</strong></p>
<pre><code>git clone https://github.com/shaoxiongji/federated-lear... | <python><federated-learning> | 2024-08-19 03:45:06 | 0 | 709 | SH_IQ |
78,886,125 | 7,483,211 | VSCode Python extension loading forever, saying βReactivating terminalsβ | <p>After updating VS code to v1.92, the Python extension consistently fails to launch, indefinitely showing a spinner next to βReactivating terminalsβ¦β on the status bar.</p>
<p>Selecting <code>OUTPUT > Python</code> reveals the error <code>Failed to resolve env "/mnt/data-linux/miniconda3"</code>.</p>
<p>... | <python><visual-studio-code> | 2024-08-19 02:31:16 | 11 | 10,272 | Cornelius Roemer |
78,886,121 | 10,054,520 | Using MIME to send myself a text and last two characters of body is missing | <p>I have a job setup to run daily that will send me a text reminder. The reminder is sent to me successfully, but not matter what I use for my "message" the last two characters are cut off.</p>
<pre class="lang-py prettyprint-override"><code>import smtplib
from email.mime.text import MIMEText
from email.mim... | <python><python-3.x><email><text> | 2024-08-19 02:29:56 | 0 | 337 | MyNameHere |
78,886,008 | 20,591,261 | Handling Multiple Operations on DataFrame Columns with Polars | <p>I'm trying to select all columns of a DataFrame and perform multiple operations on each column using Polars. For example, I discovered that I can use the following code to count non-null values in each column:</p>
<pre><code>df.select(pl.col("*").is_not_null().sum()
</code></pre>
<p>However, when I attempt... | <python><dataframe><python-polars><unpivot> | 2024-08-19 01:02:05 | 2 | 1,195 | Simon |
78,885,709 | 342,095 | Connect to Google Photos API from Google Colab | <p>I made a Google Cloud Project and Enabled Google Photos API and OAuth 2.0.</p>
<p>In Google Colab, the <code>authenticate()</code> brings up a popup asking for permissions of Google Drive. If I provide client_secret.json instead I get other kind of errors including inability to start a server, scopes and other permi... | <python><google-colaboratory><google-photos> | 2024-08-18 21:28:06 | 2 | 7,920 | SMUsamaShah |
78,885,619 | 10,416,012 | How to transform or unpack *args types for typing variadics | <p>I want to annotate a function that combines several iterators or generators into one, the case for two iterators is trivial:</p>
<pre><code>def merge_two_iterators[T, H](
gen1: Iterator[T],
gen2: Iterator[H]
) -> Iterator[tuple[T, H]]: ...
</code></pre>
<p>But I can't make the arbitrary number of iterator... | <python><generics><python-typing><variadic-functions> | 2024-08-18 20:38:07 | 1 | 2,235 | Ziur Olpa |
78,885,549 | 7,846,884 | snakemake InputFunctionException in rule KeyError | <p>I'm running snakemake pipeline but i get KeyError: when i added longphase_phase rule. i seem not to find how to debug it. The longphase_phase rule uses as input a) each bam file from the samples in yaml file, b)modcallfile vcf file from <code>rule longphase_modcall</code> c)snpFile from <code>rule call_snps_indels</... | <python><snakemake> | 2024-08-18 20:01:12 | 1 | 473 | sahuno |
78,885,044 | 810,815 | Unable to import nltk in Jupyter Notebook | <p>I have a Jupyter Notebook. I installed ntlk using the following line of code:</p>
<pre><code>!pip install nltk
</code></pre>
<p>I get the following output:</p>
<pre><code>Requirement already satisfied: nltk in ./env/lib/python3.12/site-packages (3.9)
Requirement already satisfied: click in ./env/lib/python3.12/site-... | <python><machine-learning><jupyter-notebook><nltk> | 2024-08-18 15:53:05 | 1 | 9,764 | john doe |
78,884,897 | 16,869,946 | Python function with variable number of arguments *arg | <p>I have a function in python that takes the form <code>f(t1, t2, t3, *theta)</code>. And I would like to define a new function <code>g(t1, t3, *theta)</code> defined by</p>
<p><a href="https://i.sstatic.net/Lqz3xLdr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Lqz3xLdr.png" alt="enter image descript... | <python><list><function><tuples> | 2024-08-18 14:53:47 | 2 | 592 | Ishigami |
78,884,856 | 2,276,054 | CP-SAT | OR-Tools: at most one of two different arrays (OR-ed). How to declare constraint? | <p>I have two arrays of model variables - <code>arr1</code> and <code>arr2</code>. I would like to declare a constraint that would <strong>forbid</strong> a situation when there is at least 1 <code>true</code> in <code>arr1</code> <strong>AND</strong> at least 1 <code>true</code> in <code>arr2</code>. (There can be mul... | <python><or-tools><cp-sat> | 2024-08-18 14:32:55 | 2 | 681 | Leszek Pachura |
78,884,763 | 2,955,541 | Repeated Permutation of Powers | <p>Let's say I have two radix/base values <code>x</code> and <code>y</code> (both are floats, not ints) and I need to quickly generate all combinations of:</p>
<p>[x<sup>n</sup>y<sup>0</sup>, x<sup>n-1</sup>y, x<sup>n-2</sup>y<sup>2</sup>, ..., x<sup>2</sup>y<sup>n-2</sup>, x<sup>1</sup>y<sup>n-1</sup>, x<sup>0</sup>y<... | <python><algorithm><numpy> | 2024-08-18 13:47:18 | 3 | 6,989 | slaw |
78,884,741 | 17,860,557 | cannot create python virtual environment with Ubuntu on windows partitions | <p>I have Pop!_OS dualbooted with Windows. I can create python virtual environments without any problems in anywhere in my linux file system. But, when I try to create one (with <code>python -m venv venv</code>) in windows partitions (not drive C:, any other) which are mounted and then used on linux, I get this error:<... | <python><virtualenv><virtual-environment> | 2024-08-18 13:35:41 | 0 | 349 | ParsaAi |
78,884,667 | 11,565,514 | Send variable to Django crispy forms | <p>I have 2 HTML pages <code>choose_type.html</code> and <code>post_form.html</code>. On <code>choose_type.html</code>:</p>
<pre><code>{% extends "blog/base.html" %}
{% load pagination_extras %}
{% block content %}
<body>
<div class="row">
<div clas... | <python><html><django><django-crispy-forms> | 2024-08-18 13:07:47 | 2 | 373 | MarkoZg |
78,884,650 | 2,444,661 | Receiving streaming server response chunk by chunk | <p>I have a rest api which streams data in chunks. Each chunk is a list of 100 records.</p>
<p>In javascipt I use fetch API and it receives one chunk at a time.</p>
<p>But I am not able to have same behaviour in python. I have following code:</p>
<pre><code>response = requests.get(url, stream=True)
response.raise_for_s... | <python> | 2024-08-18 12:59:05 | 2 | 7,726 | Mandroid |
78,884,633 | 8,935,725 | Django ORM efficient way for annotating True on first occurrences of field | <p>I have a situation where we have some logic that sorts a patient_journey queryset (table) by some heuristics. A patient_journey has a FK to a patient.</p>
<p>I now need an efficient way of setting True for the first occurrence of a <code>patient_journey</code> for a given <code>patient</code>, false otherwise.</p>
<... | <python><django><postgresql><django-orm> | 2024-08-18 12:50:03 | 1 | 755 | Octavio del Ser |
78,884,572 | 1,339,626 | Installing Pyhton package from local directory error | <p>When installing a Python package a colleague sent as a directory (with <code>setup.py</code>), I'm getting:</p>
<pre class="lang-bash prettyprint-override"><code>LookupError: setuptools-scm was unable to detect version for '/home/michael/Downloads/inversion/s2shores'.
Make sure you're either building fro... | <python><package><setup.py> | 2024-08-18 12:21:21 | 0 | 1,020 | Michael Dorman |
78,884,560 | 7,483,211 | Install arbitrary extra dependencies into environment used by a pipx installed tool | <p>I've installed <code>codespell</code> using pipx:</p>
<pre><code>pipx install codespell
</code></pre>
<p>and I would like to use the <code>chardet</code> option. However, <code>chardet</code> does not come with <code>codespell</code> by default so <code>codespell</code> errors.</p>
<p>How do I add <code>chardet</cod... | <python><pip><pipx> | 2024-08-18 12:15:50 | 1 | 10,272 | Cornelius Roemer |
78,884,485 | 2,846,038 | Plotly line series animation: draw line continously instead of in steps? | <p>I'm trying to produce an animated chart that will draw a couple of time-based line series smoothly over time.</p>
<p>I've managed to animate the line series using <code>graph_objects</code>. However, instead of having the lines being smoothly drawn from point to point by interpolating the gaps between frames, they'r... | <python><animation><plotly><line><smoothing> | 2024-08-18 11:38:08 | 0 | 325 | VMX |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.