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,300,378 | 7,188,807 | How can I get a specific color from a .png picture with OpenCV and Python | <p>I want to check if a PNG-image contains a specific color.</p>
<p>I use <a href="https://www.geeksforgeeks.org/color-identification-in-images-using-python-opencv/" rel="nofollow noreferrer">this tutorial</a></p>
<p>This is the image:</p>
<p><a href="https://i.sstatic.net/pQld0.png" rel="nofollow noreferrer"><img src=... | <python><opencv><image-processing> | 2024-04-09 18:13:01 | 1 | 533 | Tommy |
78,300,315 | 8,894,131 | Custom dropout in PyTorch? | <p>I’m looking to implement a custom dropout in PyTorch — in the sense that I’d like to pass a mask of some sort, and have the corresponding neurons be “dropped out”, rather than dropping out random neurons with a specific probability. Something like:</p>
<pre><code>Nn.Dropout(inputs, mask = [0, 1, 0, …]
</code></pre>
... | <python><deep-learning><pytorch><neural-network> | 2024-04-09 17:57:32 | 1 | 1,532 | SSBakh |
78,300,233 | 3,906,786 | Can't load plugin: sqlalchemy.dialects:netezza.nzpy | <p>I have some worries with using <code>nzalchemy</code> together with <code>SQLAlchemy</code>. I tried using version 1.4.52 and the latest 2.0 version, but the failure remains always the same.
Whenever I try to connect to some Netezza database I always get the error message <code>sqlalchemy.exc.NoSuchModuleError: Can'... | <python><python-3.x><sqlalchemy><netezza> | 2024-04-09 17:41:00 | 1 | 983 | brillenheini |
78,300,197 | 1,802,483 | Can't connect to kafka docker container from another docker container: Kafka:3.7? | <p>This question is quite similar to <a href="https://stackoverflow.com/questions/58188820/cant-connect-to-kafka-docker-container-from-another-docker-container">this one</a> here, yet I still can't figure out why the following <code>docker-compose.yml</code>, <a href="https://github.com/apache/kafka/blob/trunk/docker/e... | <python><docker><apache-kafka> | 2024-04-09 17:31:10 | 1 | 705 | Ellery Leung |
78,300,187 | 3,388,962 | How to display a matplotlib figure in a Jupyter notebook with transparent background? | <p>While it is possible to render a figure inline with transparent background in a Jupyter console, I cannot set the figure background to transparent in a Jupyter notebook.</p>
<p>Why? Any ideas?</p>
<p>See below for a minimal reproducible example.</p>
<hr />
<p>Code to create a transparent matplotlib figure</p>
<pre c... | <python><matplotlib><jupyter-notebook><background><jupyter> | 2024-04-09 17:28:23 | 1 | 9,959 | normanius |
78,300,173 | 11,697,371 | How to work with Enum correclty in SQLAlchemy | <p>What should I do in order to make SQLAlchemy use the value of an Enum instead the name?</p>
<p>I have the following scenario:</p>
<pre><code>class ReportStatus(enum.Enum):
PENDING = 'pending'
PROCESSING = 'processing'
DONE = 'done'
ERROR = 'error'
class Report(Base):
id = sqlalchemy.Column(sqlalchemy.UU... | <python><sqlalchemy><fastapi> | 2024-04-09 17:25:12 | 1 | 630 | Felipe Endlich |
78,299,678 | 1,667,018 | Optional argument type annotation | <p>If we want a function that takes an optional argument <code>x</code>, we'll commonly do this:</p>
<pre class="lang-py prettyprint-override"><code>def f(x: int | None = None) -> None:
if x is None:
print("No value was given.")
else:
print(f"{x=}")
</code></pre>
<p>Simple... | <python><python-typing> | 2024-04-09 15:46:39 | 1 | 3,815 | Vedran Šego |
78,299,658 | 1,110,328 | Display JSON data or a dictionary so thats it's collapsable in a Python Jupyter Notebook | <p>Is it possible to display JSON data or a dictionary so it's collapsable and interactive (HTML display) within a Python Jupyter Notebook?</p>
| <python><json><dictionary><jupyter-notebook> | 2024-04-09 15:44:48 | 1 | 1,691 | joshlk |
78,299,639 | 12,133,068 | PyTorch Lightning inference after each epoch | <p>I'm using pytorch lightning, and, after each epoch, I'm running inference on a small dataset to produce a figure that I monitor with weight & biases.</p>
<p>I thought the natural way to do that was to use a Callback with a <code>on_train_epoch_end</code> method that generates the plot. The latter method needs to... | <python><pytorch><pytorch-lightning> | 2024-04-09 15:41:27 | 2 | 334 | Quentin BLAMPEY |
78,299,862 | 2,573,309 | How to resolve python modules in another folder in workspace | <p>I am trying to figure out if its possible to configure VS Code in such a way that I have multiple repos loaded in a workspace and I want to have the editor with a file loaded from one folder able to resolve and provide assistance for python files in another folder.</p>
<p>in a single workspace I have:</p>
<pre><cod... | <python><visual-studio-code> | 2024-04-09 14:57:03 | 0 | 2,174 | LhasaDad |
78,299,332 | 8,792,159 | Create bash script that calls a python script which takes in positional arguments, named arguments and flags | <p>I would like to create a bash-script that calls a python script. The python script accepts both positional arguments, named arguments and boolean flags. The idea is that the bash script passes whatever the users provides over to the python script.</p>
<p>Take this python script <code>example.py</code> as an example:... | <python><bash><command-line-interface><parameter-passing><command-line-arguments> | 2024-04-09 14:51:45 | 1 | 1,317 | Johannes Wiesner |
78,299,328 | 23,260,297 | Pivot dataframe into two seperate tables | <p>I have found a similar question, but I haven't found a solution that works for my case.</p>
<p>I have a dataframe looks like this:</p>
<pre><code>ID Counterparty Date Commodity Deal Price Total
-- ------------ ----- -------- ----- ----- ------
1 party1 04/03/2024 Oi... | <python><pandas> | 2024-04-09 14:50:48 | 0 | 2,185 | iBeMeltin |
78,299,167 | 13,046,093 | Is there a way to extract text from python datacompy comparison result? | <p>I am using datacompy to compare all columns from two dataframe. My goal is to extract the column(s) name with unmatched values.</p>
<p>In the below example, I used inventory_id as a join column to compare df1 and df2. One column shows unmatched value, which is 'indinv_vari_ware_uid'. This is a simple example, in rea... | <python><pandas><string> | 2024-04-09 14:24:12 | 1 | 460 | user032020 |
78,299,122 | 9,302,146 | ModuleNotFoundError: No module named 'airflow.providers.microsoft' in Airflow v2.9.0 | <p>I have been trying to update an airflow docker image from Airflow v2.2 (Python 3.9) to Airflow v2.9 (Python 3.11). After updating, I get the following errors when trying to run the docker container.</p>
<pre><code>ModuleNotFoundError: No module named 'airflow.providers.microsoft'
</code></pre>
<p>Here is the complet... | <python><azure><docker><airflow> | 2024-04-09 14:17:07 | 2 | 429 | Abe Brandsma |
78,298,982 | 984,621 | Scrapy - download images to a freshly created folder that has ID of just saved record in DB | <p>I found similar questions on SO, but I was not able to piece it together to make it work.</p>
<p>I am scraping data from a website where are also images. My <code>items.py</code> looks` like this:</p>
<pre><code>import scrapy
class BookPipeline(scrapy.Item):
title = scrapy.Field()
author = scrapy.Field()
... | <python><scrapy><scrapy-pipeline> | 2024-04-09 13:55:36 | 1 | 48,763 | user984621 |
78,298,885 | 8,290,689 | Wrong axis data when ploting panda dataframe | <p>I have the following dataframe:</p>
<div class="s-table-container"><table class="s-table">
<thead>
<tr>
<th></th>
<th>date</th>
<th>new</th>
<th>todo</th>
<th>fixed</th>
<th>close</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td><code>2023-08-20 00:00:00+00:00</code></td>
<td>2</td>
<td>0</td>
<td>0</td>
<td>0</td>
<... | <python><pandas><matplotlib> | 2024-04-09 13:40:29 | 1 | 312 | Tradjincal |
78,298,849 | 7,785,154 | Apply function to a groupby and rolling group | <p>Given a pandas dataframe, group it by 3 levels and apply a function which takes two columns as arguments on a rolling basis:</p>
<p>Code to create the data frame:</p>
<pre><code>import pandas as pd
import numpy as np
df_index = pd.DataFrame({
'classes': ['A']*3*3 + ['B']*3*3 +['C']*3*3,
'names': ['Alex']*3 ... | <python><pandas><group-by><apply><rolling-computation> | 2024-04-09 13:35:01 | 2 | 607 | AlexSB |
78,298,731 | 7,861,171 | drop specific column in pandas | <p>My data has some columns with format <code>ABC_number_AX</code> and <code>ABC_number_AX_MED</code>. I would like to exclude column <code>ABC_number_AX</code>. To do that I define the following pattern to filter out columns with a specific pattern in their name.</p>
<pre><code># Define patterns to filter out patterns... | <python><pandas><regex> | 2024-04-09 13:15:05 | 2 | 414 | P.Chakytei |
78,298,579 | 12,291,295 | Building a PyPi package using setuptools & pyproject.toml with a custom directory tree | <p>I have a custom directory structure which is not the traditional "src" or "flat" layouts setuptools expects.</p>
<p>This is a sample of the directory tree:</p>
<pre><code>my_git_repo/
├── Dataset/
│ ├── __init__.py
│ ├── data/
│ │ └── some_csv_file.csv
│ ├── some_ds1_script.py
│ └── some_ds2_scri... | <python><python-3.x><setuptools><pyproject.toml> | 2024-04-09 12:51:25 | 1 | 872 | ImSo3K |
78,298,555 | 3,437,787 | How to add columns to a Pandas DataFrame containing max of each row, AND corresponding column name using iloc or iloc? | <p>This is a revisit to the question <a href="https://stackoverflow.com/questions/38223461/add-columns-to-pandas-dataframe-containing-max-of-each-row-and-corresponding-co">Add columns to pandas dataframe containing max of each row, AND corresponding column name</a> where a solution was provided using the now deprecated... | <python><pandas> | 2024-04-09 12:47:43 | 4 | 62,064 | vestland |
78,298,421 | 5,852,506 | Marshmallow Flask Python pass path parameters to Schema for handling logic of body parameters | <p>I am trying to validate some body params with the help of the path params as I have several types of Orders.</p>
<p>Is there a way for passing some arguments, like the path parameters (commodity and day), to the load method or to a pre_load method or to a constructor of the Schema CreateOrder class ?</p>
<pre class=... | <python><flask><flask-marshmallow> | 2024-04-09 12:25:27 | 0 | 886 | R13mus |
78,298,310 | 6,943,622 | Dice Roll Simulation (Permutation Approach) | <p>This is a question on leetcode. I'm aware it's efficiently a dynamic programming question, but I wanted to try a different approach to really exercise my understanding of data structures and algorithms.</p>
<p>Here's the question:</p>
<blockquote>
<p>A die simulator generates a random number from 1 to 6 for each rol... | <python><algorithm><dynamic-programming><permutation> | 2024-04-09 12:08:21 | 0 | 339 | Duck Dodgers |
78,298,181 | 1,511,294 | lightgbm classifier: predictions are all 1 | <p>I have a lightGBM classifier model that I want to train on un_balanced data. In the training set there are 32500 1's and 2898 0's . The no of features are 30 and 17 of them are categorical data. This is how I am training the data . All the predictions are becoming 1's .</p>
<pre><code>params_dict = dict(
obj... | <python><lightgbm> | 2024-04-09 11:45:18 | 2 | 1,665 | Ayan Biswas |
78,298,089 | 5,710,793 | How to multimap list that has comma separated values as elements | <p>Assume a list that has comma separated element:
<code>x = ["FOO,BAR", "BAZ"]</code></p>
<p>How can someone map the above list to:</p>
<pre><code>["FOO", "BAZ"]
["BAR", "BAZ"]
</code></pre>
| <python><list> | 2024-04-09 11:24:00 | 2 | 301 | leas |
78,297,965 | 160,665 | How can I tell FastAPI to generate "securitySchemas" in openapi.json if the auth-method is dynamically injected? | <p>I have an application that requires authentication. The authentication setup needs value from my app-settings and I want to use dependency-injection instead of a static global variable.</p>
<p>In the program below, you will see that the only route that properly advertises its need for authentication is the one that ... | <python><fastapi> | 2024-04-09 11:02:34 | 1 | 22,091 | exhuma |
78,297,862 | 4,784,914 | Python Unittest - How to properly handle tests in different folders and shared base testcases? | <p>My project looks like this:</p>
<pre><code>|- src/
| |- my_package/
| |- __init__.py
| |- ...
|
|- tests/
| |- group1/
| | |- __init__.py (empty)
| | |- test_thing_1.py
| |- ...
| |- base_test_case.py
|
|- pyproject.toml
</code></pre>
<p>Here <code>test_thing_1.py</code> (and other test files) rely o... | <python><python-import><python-unittest> | 2024-04-09 10:43:08 | 1 | 1,123 | Roberto |
78,297,687 | 2,653,179 | Parsing command line in Python | <p>I'm trying to parse Windows command line to executable (like "python.exe"), script file / EXE file that the command runs, and arguments that are passed to this file.</p>
<p>This is what I've done so far:</p>
<pre><code>def parse_cmd(cmd):
executable = filepath = args = ""
split_cmd = shle... | <python> | 2024-04-09 10:10:25 | 1 | 423 | user2653179 |
78,297,386 | 2,419,751 | Can I add a custom TraceConfig to an existing aiohttp ClientSession? | <p>I have a code which uses an existing <code>aiohttp.ClientSession</code>.
I want to add custom tracing for this session.</p>
<p>Tried doing something like (not working):</p>
<pre><code>from aiohttp import ClientSession, TraceConfig
async def on_request_start_debug(
session: aiohttp.ClientSession,
con... | <python><python-3.x><logging><trace><aiohttp> | 2024-04-09 09:18:35 | 1 | 505 | GuyKhmel |
78,297,350 | 13,371,166 | Define return value after chained mocks | <p>I am using <a href="https://docs.python.org/3/library/unittest.mock-examples.html#creating-a-mock-from-an-existing-object" rel="nofollow noreferrer"><code>unittest.mock</code></a> to test my Django application.</p>
<p>The set-up is the following:</p>
<ul>
<li>I want to test a function <code>foo</code></li>
<li><code... | <python><django><python-unittest><python-unittest.mock><django-unittest> | 2024-04-09 09:10:54 | 0 | 542 | kenshuri |
78,297,309 | 17,556,733 | How to force all exceptions to go through a FastAPI middleware? | <p>I am writing an app using FastAPI. Parts of my code raise different exceptions, which I need to process. I want all that processing to be done in a single place (with different <code>except</code> blocks depending on what exception was raised). I tried to do this by adding the following (simplified) middleware to my... | <python><exception><fastapi><middleware><starlette> | 2024-04-09 09:04:02 | 1 | 495 | TheMemeMachine |
78,297,270 | 7,878,083 | VSCode Conditional Breakpoint (Python) | <p>I can not get VSCode to stop on a simple conditional breakpoint for a python project.</p>
<p>Enviroment:
OS: Windows 10
Language: Python
Version: VSCode 1.87.2</p>
<p>Breakpoint I am trying to implement is based on <code>chunk_count</code> which is a integer based counter in my code:</p>
<pre><code>if (chunk_count i... | <python><visual-studio-code><ide><vscode-debugger> | 2024-04-09 08:56:21 | 1 | 487 | Ray Bond |
78,297,219 | 10,200,497 | How can I get the first index of a mask and get None if the condtion does not met? | <p>This is my DataFrame:</p>
<pre><code>import pandas as pd
import numpy as np
df = pd.DataFrame(
{
'a': [np.nan, np.nan, 1, 2, 3, 1, 0, 1, -1, -1],
}
)
</code></pre>
<p>My mask is:</p>
<pre><code>mask = (df.a.gt(2))
</code></pre>
<p>And the expectet output is 4. The index of <code>mask</code>.</p>
<p>I... | <python><pandas><dataframe><numpy> | 2024-04-09 08:48:19 | 4 | 2,679 | AmirX |
78,297,177 | 20,508,530 | How to use multiple databases in a single Django app? | <p>I'm trying to set up my Django application to use multiple databases within a single app.
I have defined different database in my settings.py
I have only one app <code>polls</code>.</p>
<pre><code>DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mypage',
'USER': '... | <python><django> | 2024-04-09 08:43:36 | 0 | 325 | Anonymous |
78,297,095 | 12,829,151 | Import Error Resolution in Python: Pylint Compliance vs. Runtime Execution | <p>I have the following folder structure:</p>
<pre><code>├── docs
├── setup.py
├── python_package_
│ ├── __init__.py
│ ├── __main__.py
│ ├── __version__.py
│ ├── arg_parser.py
│ ├── classes
│ │ ├── __init__.py
│ │ └── file_generator.py
│ ├── settings.py
│ ├── python_package.py
│ └── utils
│ ... | <python><module><python-import><pylint><python-packaging> | 2024-04-09 08:29:32 | 0 | 1,885 | Will |
78,297,083 | 5,719,169 | pyqt5 label position in mainwindow | <p>This is my layout from the Qt Designer:</p>
<p><a href="https://i.sstatic.net/5VxLn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/5VxLn.png" alt="enter image description here" /></a></p>
<p>And this is the output from this
<a href="https://i.sstatic.net/4s9Ux.png" rel="nofollow noreferrer"><img src=... | <python><pyqt5> | 2024-04-09 08:27:28 | 2 | 411 | NetworkStudent |
78,296,889 | 10,580,536 | Integrating tdqm with cx.Oracle query | <p>I am running an SQL Oracle query through Python with <code>cx.Oracle</code>. However, the execution time is very long and I would like to have some progress bar (either with a live counter or a visual progress bar) that shows the run rate of the query.</p>
<p>I have found that this is possible with the <code>tqdm</c... | <python><oracle-database><tqdm> | 2024-04-09 07:53:14 | 1 | 373 | MOA |
78,296,362 | 4,847,250 | How to adapt a QscrollArea to correctly display a QgridLayout that is changing inside? | <p>I would like to create a bunch of QcheckBox with a QgridLayout inside a QscrollArea, and I need to modify the number of Checkbox of the QGridLayout.</p>
<p>My issue is when I increase the number of check boxes, they are compressed inside the QscrollArea instead of creating a scrollBar at the right side.</p>
<p>Here ... | <python><pyqt6><qscrollarea><qgridlayout> | 2024-04-09 05:58:52 | 1 | 5,207 | ymmx |
78,296,190 | 10,827,766 | Keep python click argument case | <p>Using the following click application:</p>
<pre class="lang-py prettyprint-override"><code>from rich.traceback import install
install(show_locals=True)
import click
@click.command()
@click.argument("PATH", envvar="PATH", nargs=-1, type=click.Path())
def f1(PATH):
print(PATH)
if __name__... | <python><python-click> | 2024-04-09 05:05:47 | 1 | 409 | syvlorg |
78,296,150 | 755,934 | SQLAlchemy relationship to fetch most recent child in list for each parent | <p>I have a table of <code>Automation</code>s expressed as an SQLAlchemy model. Each automation may be run many hundreds of times. Each run is tracked in <code>AutomationRun</code> model. This model has a <code>created_at</code> field.</p>
<p>I have a REST endpoint: <code>/automations</code> which will return all the a... | <python><python-3.x><sqlalchemy><flask-sqlalchemy> | 2024-04-09 04:48:41 | 0 | 5,624 | Daniel Kats |
78,295,847 | 342,553 | Python datetime object does not change date light saving automatically when setting day | <p>I am in NZ and we just ended daylight saving on 7th April, when I change the day of the object back to before daylight saving ends, it does not update the timezone back to +13.</p>
<pre><code>from django.utils import timezone
In [8]: timestamp = timezone.localtime(timezone.now())
In [9]: print(timestamp)
2024-04-0... | <python><django> | 2024-04-09 02:24:03 | 1 | 26,828 | James Lin |
78,295,801 | 5,938,276 | numpy convolve with valid | <p>I am working on convolving chunks of a signal with a moving average type smoothing operation but having issues with the padding errors which affects downstream calculations.</p>
<p>If plotted this is the issue that is caused on the chunk boundaires.</p>
<p><a href="https://i.sstatic.net/hmpr2.png" rel="nofollow nore... | <python><numpy> | 2024-04-09 02:03:20 | 1 | 2,456 | Al Grant |
78,295,601 | 3,357,984 | simple-salesforce create a task or create a call log. python api | <p>using python api simple-salesforce, <a href="https://pypi.org/project/simple-salesforce/" rel="nofollow noreferrer">https://pypi.org/project/simple-salesforce/</a></p>
<p>i want to create a task or call log.
is it possible?</p>
<p>I saw a failed attempt <a href="https://trailhead.salesforce.com/trailblazer-communit... | <python><salesforce><simple-salesforce> | 2024-04-09 00:33:30 | 2 | 380 | not_fubar_yet |
78,295,364 | 1,390,639 | speed of Python function with dict/numpy array input | <p>I am using Python <code>3.9.12</code>. I have an application where a certain function call will run many times and also has many necessary input arguments. I first coded the function with named inputs (with default values), this was fastest. Then I wanted to "clean up" how the arguments were passed to the ... | <python> | 2024-04-08 22:52:38 | 2 | 1,259 | villaa |
78,295,318 | 817,659 | questdb can't flush table | <p>I have python code that gets data and tries to insert it into a <code>questdb</code> table:</p>
<pre><code>conf = f'http::addr=localhost:9000;'
with Sender.from_conf(conf) as sender:
sender.dataframe(data, table_name=ticker, at='Date')
</code></pre>
<p>I have been able to insert t... | <python><questdb> | 2024-04-08 22:30:29 | 0 | 7,836 | Ivan |
78,295,146 | 12,304,000 | No matching distribution found for torch==1.9.0+cu102 | <p>I am trying to use <a href="https://github.com/pixray/pixray" rel="nofollow noreferrer">pixray</a> on macOS</p>
<p>but it looks like the dependencies mentioned in the requirements.txt aren't updated. These are the steps I followed:</p>
<ul>
<li><p>created a pyenv virtual env:
Python 3.8.10</p>
</li>
<li><p>Cloned th... | <python><python-3.x><pytorch> | 2024-04-08 21:33:58 | 2 | 3,522 | x89 |
78,295,126 | 1,506,763 | polars cumsum on column if value changes | <p>I'm stuck with a <code>cum_sum</code> problem where I only want tot cumulatively sum unique values over a column.</p>
<p>Here's an example of what I want to achieve:</p>
<pre class="lang-py prettyprint-override"><code>┌─────┬─────┬─────┐
│ a ┆ b ┆ d │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 │
╞═════╪═════╪═════╡... | <python><python-polars> | 2024-04-08 21:28:14 | 1 | 676 | jpmorr |
78,295,117 | 2,329,968 | Bokeh server - memory leaks when on_event is used | <p>I need to execute a Python callback when the ranges are changed. For that, I have to run a Bokeh application on a Bokeh server. I'm using Bokeh 3.4.0.</p>
<p>Everything works fine if I run the following code from Jupyter Notebook.</p>
<pre class="lang-py prettyprint-override"><code>from bokeh.plotting import figure,... | <python><server><bokeh> | 2024-04-08 21:24:19 | 0 | 13,725 | Davide_sd |
78,295,011 | 7,914,054 | AttributeError: module 'tensorflow' has no attribute 'estimator' | <p>I'm trying use the following function:</p>
<pre><code>def tfexamples_input_fn(examples, feature_spec, label, mode=tf.estimator.ModeKeys.EVAL,
num_epochs=None,
batch_size=64):
def ex_generator():
for i in range(len(examples)):
yield examples[i].Se... | <python><tensorflow> | 2024-04-08 20:48:16 | 1 | 789 | QMan5 |
78,294,978 | 2,817,520 | How to add a middleware before the application starts up in FastAPI? | <p>Using <a href="https://fastapi.tiangolo.com/advanced/events/" rel="nofollow noreferrer">Lifespan Events</a> and <a href="https://fastapi.tiangolo.com/tutorial/middleware/" rel="nofollow noreferrer">Middleware</a>, I would like to add a middleware inside an <code>asynccontextmanager</code> at application startup. It ... | <python><fastapi><middleware><startup><starlette> | 2024-04-08 20:38:50 | 1 | 860 | Dante |
78,294,969 | 175,201 | Why does capturing the output of a Python subprocess fail when the subprocess generates UTF-8 output? | <p>I'm trying to redirect the output of a subprocess to a temporary file for later reprocessing.</p>
<p>When the subprocess generates 7-bit output (e.g. for en-US), the redirection works and the temporary file has valid content.</p>
<p>When the subprocess generates full UTF-8 output (e.g., for zh-CN), the redirection f... | <python><linux><subprocess> | 2024-04-08 20:34:55 | 0 | 13,962 | Eric Brown |
78,294,946 | 1,700,890 | "Login failed" with odbc_connect (raw) connection string; works with pyodbc | <p>The following pyodbc connection works fine:</p>
<pre><code>import pyodbc
import pandas as pd
conn = pyodbc.connect(Driver='SQL Server',
Server='some_server_address,1433',
Database='some_db',
UID ='some_user',
PWD = 'some_password... | <python><sqlalchemy><pyodbc> | 2024-04-08 20:27:30 | 1 | 7,802 | user1700890 |
78,294,920 | 2,659,268 | Select Unique Pairs from Pyspark Dataframe | <p>Let's assume, I have a PySpark data frame:</p>
<pre><code>X Y
1 a
1 b
1 c
2 b
2 a
2 c
3 a
3 c
3 b
4 p
</code></pre>
<p>I have to select any possible pair, of X and Y, but same X and Y should not be repeated in result.</p>
<p>Possible output 1</p>
<pre><code>X Y
1 b
2 c
3 a
4 p
</code></pre>
<p>Possible output 2</p>
... | <python><apache-spark><pyspark><apache-spark-sql><data-analysis> | 2024-04-08 20:19:49 | 2 | 335 | Nishant |
78,294,814 | 10,199,656 | Django logging isn't working, despite having proper settings | <h1>Problem and background</h1>
<p>Hi, I have a Django project using Django 2.2.28, and python 3.5.2.</p>
<p>The live site runs fine, except for one function I'm trying to debug.</p>
<p>I've used logging before, but for some reason it's not working now.</p>
<p>Here's my code...</p>
<h2>production_settings.py</h2>
<p>I ... | <python><python-3.x><django><logging><django-views> | 2024-04-08 19:51:11 | 1 | 1,340 | Action Jackson |
78,294,746 | 655,802 | Breaking up python computation to speed up ssh | <p>I'm using a Paramiko connection to execute a handful of commands over ssh. A few (not entirely real) examples to show the idea:</p>
<pre><code>def get_version(conn):
stdin, stdout, stderr = conn.exec_command('ipmitool bla bla')
result = stdout.readlines()[-1].strip()
if result == 'the expected value':
... | <python><concurrency><paramiko> | 2024-04-08 19:31:59 | 0 | 2,797 | Sonicsmooth |
78,294,587 | 10,461,632 | Using **kwargs with dataclass and YAMLWizard | <p>How can I store additional kwargs in the kwargs attribute using <code>YAMLWizard</code>?</p>
<p>I have a dataclass and want to store any kwargs that aren't explicitly defined in the kwargs attribute. I can accomplish this with the code below.</p>
<pre><code>from dataclasses import dataclass, field
from inspect impor... | <python><python-dataclasses> | 2024-04-08 18:51:38 | 1 | 788 | Simon1 |
78,294,477 | 12,162,229 | Create a conditional cumulative sum in Polars | <p>Example dataframe:</p>
<pre><code>testDf = pl.DataFrame({
"Date1": ["2024-04-01", "2024-04-06", "2024-04-07", "2024-04-10", "2024-04-11"],
"Date2": ["2024-04-04", "2024-04-07", "2024-04-09", "2024-04-10&q... | <python><python-polars> | 2024-04-08 18:24:34 | 2 | 317 | AColoredReptile |
78,294,423 | 23,260,297 | Create new row index and calculate sum for each column | <p>I have a dataframe that is shaped like this:</p>
<pre><code> com1 com2 com3
party1 10 0 0
party2 0 20 10
party3 0 0 25
</code></pre>
<p>I want to create a new row index called total, and then take the sum of each column and display it like this</p>
<pre><co... | <python><pandas> | 2024-04-08 18:14:20 | 1 | 2,185 | iBeMeltin |
78,294,043 | 8,942,319 | Postgresql/psycopg2: how to start a transaction, pause for manual inspection of the DB, and commit if satisfied? | <p>Looks like the default transaction isolation level in psycopg2 doesn't persist anything in the DB until it is committed.</p>
<p>I'm automating some DB operations and the script will pause for me to inspect the DB manually. But the uncommitted changes don't show in the DB.</p>
<p>In plain SQL I could <code>begin;</co... | <python><postgresql><psycopg2> | 2024-04-08 16:49:40 | 0 | 913 | sam |
78,293,897 | 9,251,158 | Girvan-Newnam with custom centrality index throws "remove_edge() must be an iterable, not int" | <p>I want to apply Girvan-Newnam to a graph with a custom centrality index (betweenness centrality based on edge weights). I follow <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.community.centrality.girvan_newman.html" rel="nofollow noreferrer">the documentation</... | <python><networkx> | 2024-04-08 16:19:29 | 1 | 4,642 | ginjaemocoes |
78,293,810 | 16,798,185 | cache position when same dataframe name used | <p>I have dataframe called source_dataframe which is referenced by multiple places in the pyspark code. Hence, I was planning to cache the data frame source_dataframe, so that cached referenced would be used instead of re-reading the same data multiple times.</p>
<pre><code>source_dataframe = spark.read.format("de... | <python><apache-spark><pyspark><apache-spark-sql><sql-execution-plan> | 2024-04-08 16:02:01 | 1 | 377 | user16798185 |
78,293,602 | 4,451,521 | Python finds another file | <p>If I have a folder with two python scripts: <code>contants.py</code> and <code>appl.py</code> (inside the folder something) and the files are</p>
<pre><code>THEKONST = 5
</code></pre>
<p>and</p>
<pre><code>from something.constants import THEKONST
print(THEKONST)
</code></pre>
<p>What do I have to do so that I can c... | <python> | 2024-04-08 15:27:43 | 0 | 10,576 | KansaiRobot |
78,293,244 | 2,501,018 | Programmatically create a Python function that takes exactly one more argument than a given function | <p>Say I have a python function:</p>
<pre><code>def my_func(first, second=2):
return first * second
</code></pre>
<p>What I want is a way to generate a new function that takes exactly one more argument than my function and behaves like this:</p>
<pre><code>def my_new_func(first, second=2, exclamation='hello'):
... | <python><signature> | 2024-04-08 14:31:09 | 2 | 13,868 | 8one6 |
78,293,209 | 4,451,521 | poetry does not find the python version of pyenv | <p>My ubuntu system has pyenv installed. The system python version is 3.8. However I have set <code>pyenv global 3.10.1</code> and when I do <code>pyenv versions</code> I can clearly see that it is activated. Also doing <code>python --version</code> gives me python 3.10</p>
<p>I have run <code>poetry install</code> in ... | <python><python-poetry><pyenv> | 2024-04-08 14:26:07 | 0 | 10,576 | KansaiRobot |
78,293,196 | 1,119,649 | Python Parsing (separate statements and/or blocks) a C# code - regex or machine state | <p>I need to parsing a C# code. Just separate the statements, considering break lines. Need to ignore comments, multiline comments, verbatim strings and multiline verbating strings.</p>
<p>What i try...
I read the file into a variable and then split by break lines (because i need the original line number)... then i a... | <python><regex><parsing><state-machine> | 2024-04-08 14:23:55 | 1 | 386 | Shoo Limberger |
78,293,096 | 3,125,592 | Copying data from S3 into RDS Postgresql using Python: "FeatureNotSupported: COPY from a file is not supported" | <p>I am trying to load 2800 CSVs into RDS Postgres using the COPY command. My program below is loosely based on <a href="https://towardsdatascience.com/upload-your-pandas-dataframe-to-your-database-10x-faster-eb6dc6609ddf" rel="nofollow noreferrer">this</a> and what it's doing is (1) listing all S3 objects (2) creating... | <python><postgresql><amazon-s3><amazon-rds> | 2024-04-08 14:04:57 | 1 | 2,961 | Evan Volgas |
78,293,077 | 2,501,018 | Registering Pandas "accessors" without repeating yourself | <p>I would like to use the Pandas <code>register_series_accessor</code> and <code>register_dataframe_accessor</code> functions to "tack on" a large number of functions/features to both <code>Series</code> and <code>DataFrame</code> objects. But I would like to do so in a way "doesn't repeat myself"... | <python><pandas><signature><method-signature> | 2024-04-08 14:01:29 | 1 | 13,868 | 8one6 |
78,293,013 | 2,057,516 | Is there a way to autofit the comment window height with Python's xlsxwriter? | <p>I just implemented a way to attach various metadata to cells in the excel files we produce in our data validation interface for our scientific data django app. I'm basically migrating from our usage of google sheets.</p>
<p>The one thing that google sheets was better at was displaying comments. Whatever the conten... | <python><excel><xlsxwriter> | 2024-04-08 13:51:25 | 1 | 1,225 | hepcat72 |
78,292,941 | 4,016,385 | Async call of conn.execute seems to block other async calls from executing | <p>I'm using two libraries that are supposed to handle all operations asynchronously: one for receiving streaming data from the server and another one, psycopg, for saving data into TimescaleDB. However, for some reason, conn.commit() is blocking the main event loop, and because of this, the time lag between receiving ... | <python><python-asyncio><streaming><psycopg3> | 2024-04-08 13:41:27 | 1 | 397 | Alexander Zar |
78,292,878 | 6,195,489 | Create python package and make it automatically install dependencies | <p>I am creating a python package.</p>
<p>I have been using Pipenv to manage environments, and dependencies.</p>
<p>I would like to create the package and have dependencies installed when someone pip installs, or installs from the .whl</p>
<p>Say my Pipfile has:</p>
<pre><code>[[source]]
url = "https://pypi.org/si... | <python><build><setuptools><pipenv><pyproject.toml> | 2024-04-08 13:28:26 | 0 | 849 | abinitio |
78,292,857 | 8,548,562 | Gunicorn workers on Google App Engine randomly sending SIGKILL leading to TIMEOUT. What is going on? | <p>This happens randomly, sometimes when a new instance is spun up (example below), sometimes when an instance is already been running for some time.</p>
<p>This error cycle of "Boot worker - SIGKILL - TIMEOUT" can last anywhere from 10s to more than an hour.</p>
<p>This can also happen to any endpoint in my ... | <python><flask><google-app-engine><gunicorn> | 2024-04-08 13:25:32 | 1 | 2,050 | Ryan |
78,292,844 | 2,475,195 | Eclipse PyDev - automatic author comment | <p>I am using PyDev plug in in eclipse. I want to edit or disable the @author comment it adds to each new file, how do I do this? I want to either modify the username, or disable this functionality completely. How do I do this?</p>
| <python><eclipse><pydev><documentation-generation> | 2024-04-08 13:22:46 | 1 | 4,355 | Baron Yugovich |
78,292,627 | 15,462,497 | How to pack multiple int8 data into a string that can be a initializer for C++ variable? | <p>I want to use python to convert a int8 numpy array to a string that can be a included as intializer for my C++ array defined like <code>uint32 arr[]={packed_int8_data, ...}</code>. Notice that uint32 is just a data container and I want to split it into multiple C++ int8 variables later.</p>
<p>I write python code li... | <python><c++><numpy> | 2024-04-08 12:44:04 | 1 | 385 | zjnyly |
78,292,482 | 736,662 | Use one correlated value from one Locust call in anoher (within same class) | <p>I have the following working code:</p>
<pre><code>import json
import requests
import os
import pandas as pd
import random
from locust import task, events
from locust.contrib.fasthttp import FastHttpUser
from azure.identity import DefaultAzureCredential
server_name = "https://test"
credential = DefaultAzu... | <python><scope><locust> | 2024-04-08 12:19:17 | 1 | 1,003 | Magnus Jensen |
78,292,391 | 22,418,446 | Y-axis ticks not displayed correctly in Plotly bar chart in Streamlit app | <p>I have a function <code>free_vs_paid(df_clean)</code> that generates a <code>Plotly bar chart</code> comparing the number of free and paid apps across different categories. In <code>Jupyter Notebook</code>, the chart displays the y-axis ticks correctly <strong>(1, 10, 100,1000)</strong> it shows in below. I know tha... | <python><pandas><plotly><streamlit> | 2024-04-08 12:03:58 | 1 | 1,160 | msamedozmen |
78,292,388 | 12,234,535 | Applying identical axis format to all subplots | <p>I'm building 5 subplots in a Figure, so that the larger sublot fig_1 occupies [rows_0, cols_0:3] of the Figure, and smaller sublots fig_2-fig_5 occupy [rows_1, cols_0-cols_3] of the Figure.</p>
<p><strong>How could I apply an identical x-axis format to all of the listed figs in the Figure at once?</strong> Or maybe ... | <python><matplotlib><plot><format><axis> | 2024-04-08 12:03:16 | 1 | 379 | Outlaw |
78,292,114 | 17,530,552 | How to avoid "RuntimeWarning: divide by zero encountered in log10" in a for loop with over 20.000 elements? | <p>I have a list of data called <code>data</code>. This list contains 21073 nested <code>numpy</code> arrays. Each numpy array, in turn, contains 512 values. Paradigmatially, one nested numpy array looks as follows:</p>
<p><code>[534.42623424, 942.2323, 123.73434 ...]</code>.</p>
<p>Moreover, I have another list of dat... | <python><arrays><numpy><integer-overflow><int64> | 2024-04-08 11:15:55 | 2 | 415 | Philipp |
78,291,778 | 22,538,132 | How to erode cloud edges on x,y directions to sharpen edges | <p>I have a <a href="https://drive.google.com/file/d/1p1mQCx10Ls-URdr6H95jk5LfIqNbAzEp/view?usp=sharing" rel="nofollow noreferrer">noisy pointcloud</a> of a flat surface that I want to estimate its dimensions, so I want to sharpen the edges, to do so I decided to use a statistical approach using mean of histogram to fi... | <python><histogram><point-clouds><open3d> | 2024-04-08 10:16:54 | 1 | 304 | bhomaidan90 |
78,291,757 | 2,651,073 | How to drop a range of rows from dataframe? | <p>I use the following code to drop some rows based on their position in df:</p>
<pre><code>for i in irange:
df.drop(df.iloc[i].name, inplace=True)
</code></pre>
<p>However, it seems I can't do it in a loop and I get:</p>
<pre><code>raise IndexError("single positional indexer is out-of-bounds")
IndexError... | <python><pandas><dataframe><drop> | 2024-04-08 10:13:52 | 1 | 9,816 | Ahmad |
78,291,703 | 11,233,365 | Pre-Commit MyPy unable to disable non-error messages | <p>I'm putting together some pre-commit hooks for a project that I'm working on, and one of the hooks we want to use is MyPy. The pre-commit results are throwing up a lot of non-error notes related to the "annotation-unchecked" flag, which I want to disable to de-clutter the command line output.</p>
<p>I have... | <python><mypy><pre-commit-hook><pre-commit.com> | 2024-04-08 10:00:37 | 1 | 301 | TheEponymousProgrammer |
78,291,642 | 1,577,940 | Tensorflow Keras ProgbarLogger does not accept arguments | <p>In Python 3.10.14, and with tensorflow version 2.16.1, the following minimum working example produces an error:</p>
<pre><code>import tensorflow as tf
pb = tf.keras.callbacks.ProgbarLogger(count_mode='steps')
</code></pre>
<p>the error being: <code>TypeError: ProgbarLogger.__init__() got an unexpected keyword argume... | <python><tensorflow><keras> | 2024-04-08 09:49:59 | 1 | 327 | Sirplentifus |
78,291,623 | 9,805,514 | Python requests returning Failed to resolve ([Errno 11001] getaddrinfo failed) | <p>I downloaded the requests library and was following the quickstart example in their documentation: <a href="https://requests.readthedocs.io/en/latest/user/quickstart/#make-a-request" rel="nofollow noreferrer">https://requests.readthedocs.io/en/latest/user/quickstart/#make-a-request</a>, only to face the following er... | <python><python-requests> | 2024-04-08 09:47:03 | 1 | 690 | IceTea |
78,291,378 | 20,386,110 | Godot: How can I reset a scene after using queue_free()? | <p>I have a ball (<code>CharacterBody2D</code>) that when it collides with an <code>Area2D</code>, it gets destroyed via <code>queue_free()</code></p>
<pre><code>extends CharacterBody2D
func _on_bottom_wall_body_entered(body):
queue_free()
</code></pre>
<p>I also have a main <code>Node</code> scene which sets the ... | <python><game-development><godot><gdscript> | 2024-04-08 09:04:57 | 1 | 369 | Dagger |
78,291,242 | 355,485 | How to import win32api from pywin32 when running pythonnet in a c#/.NET environment? | <p>I am working on integrating Python with a C#/.NET runtime using pythonnet, but I keep encountering a module import error with <code>win32api</code>. The error message is "No module named 'win32api'." I have already taken several troubleshooting steps but haven't resolved the issue.</p>
<h3>What I've tried:... | <python><pywin32><python.net> | 2024-04-08 08:38:37 | 1 | 3,068 | thalm |
78,291,128 | 6,011,193 | Making 'python setup.py sdist' don't rename pkg name in PKG-INFO | <p>my setup.py</p>
<pre><code>from setuptools import setup
setup(
name='py_lib',
version='0.0.0',
packages=["py_lib"],
url='',
license='',
author='',
author_email='',
description=''
)
</code></pre>
<p>when run <code>python setup.py sdist</code>, the py_lib.egg-info/PKG_INFO is... | <python><pip> | 2024-04-08 08:18:44 | 1 | 4,195 | chikadance |
78,291,110 | 14,610,650 | Python - Select a complex subset of columns from a np.array | <p>I want have an array X, and I want to select, for example, the 1st, 5th, 7th, and all of the last 1000 columns (non-overlapping). I know I can get the 1st, 5th, 7th columns using <code>X[:, [0,4,6]]</code> and the last 1000 columns by <code>X[:, -1000:]</code>. But is there a quick and easy way to select them all to... | <python><arrays><numpy> | 2024-04-08 08:16:01 | 2 | 381 | Grumpy Civet |
78,291,010 | 6,289,554 | df['col_name'].astype('string') raises error in pyright | <p>I recently added pyright to my project and I'm facing this issue.</p>
<pre><code>import pandas as pd
# Define the cleanup function
def cleanup(df: pd.DataFrame) -> pd.DataFrame:
df['col_name_1'] = df['col_name_1'].astype('string')
df = df.drop_duplicates(subset=['col_name_2'])
return df
# Create a s... | <python><pandas><python-typing><pyright> | 2024-04-08 07:54:57 | 2 | 1,455 | Siddharth Prajosh |
78,291,003 | 861,364 | Cryptodome raises "RSA key format is not supported" | <p>I've just written a few lines of code as example of file encryption/decryption using asymmetric crypthography (RSA). Nevertheless, I always receive the "RSA key format is not supported" error as it imports the public key. I think it's something related to encoding, but I've already tried to import that as ... | <python><cryptography><rsa><encryption-asymmetric><pycryptodome> | 2024-04-08 07:53:38 | 0 | 1,823 | redcrow |
78,291,000 | 1,637,673 | pandas/pyarrow ArrowTypeError: Unable to merge: Field on handcrafted partitioned parquet | <p>I read the parquet file directly</p>
<pre><code>pd.read_parquet(r'C:\Datasets\cn_data\dm\qmt\wqa_mfeatures\30m\year=2020\month=11\data.parquet')
</code></pre>
<p>No error will be reported.</p>
<p>But when I read the directory:</p>
<pre><code>pd.read_parquet(r'C:\Datasets\cn_data\dm\qmt\wqa_mfeatures\30m\year=2020')
... | <python><pandas><pyarrow> | 2024-04-08 07:53:09 | 2 | 13,946 | Mithril |
78,290,935 | 14,045,537 | Update table using Langchain SQL Agent/Tool got OutputParserException/Parsing LLM output | <p>How to use the Python <code>langchain</code> agent to update data in the SQL table?</p>
<p>I'm using the below <a href="/questions/tagged/py-langchain" class="post-tag" title="show questions tagged 'py-langchain'" aria-label="show questions tagged 'py-langchain'" rel="tag" aria-labelledby="tag-py-lan... | <python><large-language-model><py-langchain><langchain-agents> | 2024-04-08 07:41:52 | 1 | 3,025 | Ailurophile |
78,290,601 | 5,790,653 | find duplicates values in a list of dictionaries while a key's value have some similarities | <p>With this <a href="https://stackoverflow.com/questions/38621915/find-duplicates-in-python-list-of-dictionaries">question</a> and its answers, I know how can I find if a key has duplicate values, but my issue is this:</p>
<p>This is my list:</p>
<pre class="lang-py prettyprint-override"><code>list1 = [
{'name': '... | <python> | 2024-04-08 06:35:32 | 4 | 4,175 | Saeed |
78,290,413 | 2,981,639 | avxspan with pandas period_range | <p>I'm using <code>gluonts</code> and trying to adapt one of the examples to plot my data. I'm not overly proficient with pandas (I mostly use polars now) and I'm having an issue with the code below - this is basically cut/paste from gluonts code (i.e. <code>gluonts.dataset.util.to_pandas</code> in particular).</p>
<p>... | <python><pandas><matplotlib><gluonts> | 2024-04-08 05:45:55 | 1 | 2,963 | David Waterworth |
78,290,287 | 482,742 | why js only displays the second element of json? | <p>I want to display all elements of json. but it only displays the second element. please help.
A pkl file is:</p>
<pre><code>[('2003@Bush.txt', [[('That', 'DT'), ('request', 'NN'), ('will', 'MD'), ('present', 'VB'), ('President', 'NNP'), ('Bush', 'NNP'), ('with', 'IN'), ('a', 'DT'), ('good', 'JJ'), ('quandary', 'NN')... | <javascript><python><json><flask> | 2024-04-08 05:00:54 | 0 | 1,183 | Dylan |
78,290,178 | 10,200,497 | How can I change a streaks of numbers according to the previous streak? | <p>This is my DataFrame:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
{
'a': [1, 1, 1, 2, 2, 2, 2, 2, -1, -1, 2, 2, 2],
}
)
</code></pre>
<p>Expected output: Changing column <code>a</code>:</p>
<pre><code> a
0 1
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 -1
9 -1
10 2
11 2
12 2
</code... | <python><pandas><dataframe> | 2024-04-08 04:24:18 | 1 | 2,679 | AmirX |
78,290,155 | 1,266,109 | Python command not working even though preinstalled on M3 Mac Sonoma | <p>I just purchased a new M3 MacBook Pro.</p>
<p>Python is already installed. If I do "brew install python" then I get a message saying:</p>
<pre class="lang-none prettyprint-override"><code>Warning: python@3.12 3.12.2_1 is already installed and up-to-date.
To reinstall 3.12.2_1, run:
brew reinstall python@... | <python><macos-sonoma> | 2024-04-08 04:13:35 | 2 | 21,085 | Rahul Iyer |
78,290,127 | 897,968 | Strange behaviour using __init_subclass__ with multiple modules | <p>Inspired by <a href="https://stackoverflow.com/a/41924331/897968">an answer about a plugin architecture</a>, I was playing around with <a href="https://peps.python.org/pep-0487/#subclass-registration" rel="nofollow noreferrer">PEP-487's subclass registration</a> and found that it led to surprising results when chang... | <python><python-import><subclass> | 2024-04-08 03:59:16 | 2 | 3,089 | FriendFX |
78,290,005 | 3,511,695 | PyQt5 - Center a Widget *relative to the Window dimensions* while ignoring other widgets? | <p>How can I vertically + horizontally center a widget, while ignoring all other widgets within the View/Window?</p>
<p>I'm trying to add equally-sized Expanding spacers on both the top and bottom of my QPushButton. I want these spacers to respect the window's height -- and the window's height <em>only</em>. However, ... | <python><qt><pyqt><pyqt5> | 2024-04-08 03:02:37 | 1 | 1,000 | velkoon |
78,289,965 | 2,774,885 | less memory intensive mechanism (vs .communiciate) for capturing output from a large number of subprocesses? | <p>My use case here is to run a number of python subprocesses, using multiple threads, and capture the output of those commands (which is just a sometimes-quite-large blob of text) into the values of another dict.</p>
<p>The OS I'm running this on is linux, but has a number of customizations: one of which is a pretty a... | <python><memory-management> | 2024-04-08 02:44:27 | 0 | 1,028 | ljwobker |
78,289,579 | 7,175,213 | matplotlib does not plot two figures on the same plot | <p><em>(fully reproductible copy-and-paste example)</em></p>
<p>I have the following code on my Jupyter Notebook and my goal is to plot the three lines on the same plot. Moreover, only two lines are being plot</p>
<pre><code>import matplotlib.pyplot as plt
from pathlib import Path
def plot_metric_from_history() -> N... | <python><matplotlib> | 2024-04-07 23:09:13 | 1 | 1,148 | Catarina Nogueira |
78,289,573 | 2,144,877 | rasterio rasterize shapely ploygons and save plot to file | <p>Ultimately I will create a bunch of rasters from a bunch of building polygons in a geopandas dataframe. But this is preliminary testing.</p>
<pre><code>>>> import shapely
>>> import shapely.geometry
>>> import rasterio.features
>>> poly1 = shapely.geometry.Polygon([(2,2), (6,2), ... | <python><plot><rasterio><rasterize><savefig> | 2024-04-07 23:06:54 | 1 | 459 | Don Mclachlan |
78,289,548 | 774,575 | Incorrect behavior of Spyder or Pandas when calling function DataFrame.info() | <p>I'm using Spyder. Creating some dataframe with Pandas:</p>
<pre><code>import pandas as pd
import numpy.random as npr
npr.seed(0)
df = pd.DataFrame(npr.randint(1, 10, size=(3,4)))
</code></pre>
<p>I get a strange behavior when using <code>df.info()</code>:</p>
<pre><code>dfi = df.info()
</code></pre>
<p>results in pr... | <python><pandas><debugging><spyder> | 2024-04-07 22:52:08 | 1 | 7,768 | mins |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.