QuestionId int64 74.8M 79.8M | UserId int64 56 29.4M | QuestionTitle stringlengths 15 150 | QuestionBody stringlengths 40 40.3k | Tags stringlengths 8 101 | CreationDate stringdate 2022-12-10 09:42:47 2025-11-01 19:08:18 | AnswerCount int64 0 44 | UserExpertiseLevel int64 301 888k | UserDisplayName stringlengths 3 30 ⌀ |
|---|---|---|---|---|---|---|---|---|
77,167,011 | 9,064,266 | Why do my tf-idf values not appear consistent? | <p>I have a series of tweets that I've converted to tokens. Among them are the following:</p>
<ul>
<li>geraldkutney happen realize happen conveniently rename catch yet emergency post fact come government</li>
<li>michaelemann burn happen chickenshittily change get make stupid argument good deed go unpunished</li>
<li>r... | <python><scikit-learn> | 2023-09-24 12:10:14 | 3 | 1,380 | Daniel V |
77,166,930 | 7,422,392 | Add method to the Django CMS Page Model | <p><strong>Problem/Gap</strong></p>
<p>The Django CMS documentation clearly describes the process for <a href="https://docs.django-cms.org/en/latest/how_to/extending_page_title.html" rel="nofollow noreferrer">extending the Page and Title Models</a>.
However, documentation on the possibility of adding a method such as t... | <python><django><django-cms> | 2023-09-24 11:41:07 | 1 | 1,006 | sitWolf |
77,166,897 | 2,604,247 | How to Form a Polars DataFrame from SQL Alchemy Asynchronous Query Result? | <p>The title says it all. Here is the code snippet.</p>
<pre class="lang-py prettyprint-override"><code>async with EngineContext(uri=URI) as engine:
session = async_sessionmaker(bind=engine, expire_on_commit=True)()
async with session.begin():
stmt: Select = select(User).order_by(_GenerativeSelect__firs... | <python><mysql><sqlalchemy><python-polars> | 2023-09-24 11:33:30 | 5 | 1,720 | Della |
77,166,604 | 6,494,707 | How we can group the spectral bands into subgroups? | <p>The simplest way is to group based on the neighboring wavelength groups in <code>hyperspectral images</code>, as shown in the following image, where there are $G$ different groups and the <code>spectral bands</code> are grouped in equally sized bands. For example, each group $$g_i$$ has 10 spectral neighboring bands... | <python><pca><satellite-image><spectral-python> | 2023-09-24 10:13:22 | 1 | 2,236 | S.EB |
77,166,543 | 5,049,813 | Number in df column, but not in list version of that column | <p>I have the following code:</p>
<pre class="lang-py prettyprint-override"><code> if 0 in df[RATING_COL]:
rating_col_list = df[RATING_COL].to_list()
assert 0 in rating_col_list
</code></pre>
<p>The assert is triggering an <code>AssertionError</code>. How can this be possible? <strong>How can it be t... | <python><pandas><assert> | 2023-09-24 09:57:54 | 2 | 5,220 | Pro Q |
77,166,452 | 1,954,677 | How to control pytest-cov (or generally any pytest plugin) from my own plugin | <p>I have a plugin <code>myplugin</code> with the following behavior: When calling <code>pytest ... --myplugin=X</code> it should trigger the same behavior as <code>pytest ... --cov=X --cov-report=json</code>.</p>
<p>I'm still new to <code>pytest</code> and while my implementation technically works, I feel very uncomfo... | <python><plugins><pytest><pytest-cov> | 2023-09-24 09:26:26 | 1 | 3,916 | flonk |
77,166,143 | 714,564 | Creating a custom Python type from existing dataclass / pydandic class | <p>I have a kind of standard response format I want to apply to all my fastAPI responses. For this example, we'll talk about something like this:</p>
<pre><code>@dataclass
class Response:
status: str = "OK"
data: Any
</code></pre>
<p>Where the data can be any other dataclass. However, I don't want to ... | <python><python-typing><pydantic><python-dataclasses> | 2023-09-24 07:45:07 | 1 | 671 | GuruYaya |
77,165,974 | 971,355 | NameError: name 'ExceptionGroup' is not defined | <p>I work through Python tutorial and ran against a sample in <a href="https://docs.python.org/3/tutorial/errors.html" rel="nofollow noreferrer">https://docs.python.org/3/tutorial/errors.html</a> in section <strong>8.9. Raising and Handling Multiple Unrelated Exceptions</strong> which doesn't work by me:</p>
<pre><code... | <python><exception> | 2023-09-24 06:37:20 | 1 | 3,401 | ka3ak |
77,165,787 | 11,141,271 | Get current song title from Windows Media Player UI in the bottom left | <p><a href="https://i.sstatic.net/QIexZ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/QIexZ.png" alt="enter image description here" /></a></p>
<p>I want to get the text from the UI element in the bottom left of Windows Media Player. I want to store it in a python variable. How can I programmatically na... | <python><ui-automation><windows-media-player><microsoft-ui-automation><comtypes> | 2023-09-24 05:15:46 | 1 | 1,045 | TeamDman |
77,165,623 | 489,607 | Django: Validate DateTimeField based on another DateTimeField | <p>I'd like to validate a <code>DateTimeField</code> based on another <code>DateTimeField</code> in the same mode, like so:</p>
<pre><code>class Operation(models.Model):
machine = models.ForeignKey(Machine, on_delete=models.CASCADE)
start = models.DateTimeField(auto_now_add=True)
end = models.DateTimeField(... | <python><django><validation><django-models> | 2023-09-24 03:37:37 | 2 | 16,248 | davidcesarino |
77,165,603 | 308,827 | Repeating values in a specific pattern in pandas dataframe column | <p>I want to create a column in a pandas dataframe such that it contains values from 10 to 100 with an increment of 10. The value of 10 is assigned to the first 10 percent of the rows and the value of 20 is assigned to the next 10% of the rows and so on. Assuming that the dataframe has a length of 153, this is what I t... | <python><pandas> | 2023-09-24 03:26:27 | 2 | 22,341 | user308827 |
77,165,535 | 2,357,712 | Can regex transformations be stored in a dictionary? | <p>I have thousands of lines of text to which I can apply a regex approach. I'm doing it in two steps, but I don't think my second step is possible.</p>
<ul>
<li>Step 1: Pick the correct regex pattern from a dictionary</li>
<li>Step 2: apply the correct transformation <strong>from a dictionary</strong> to create new ou... | <python><regex> | 2023-09-24 02:19:06 | 1 | 1,617 | Maxcot |
77,165,423 | 2,223,706 | Strictly Convert JSON dict to dataclass with enums at runtime | <p>So, this actually does work:</p>
<pre class="lang-py prettyprint-override"><code>from dataclasses import dataclass
from enum import Enum
from typing import Any, TypeVar
from pydantic import TypeAdapter, parse_obj_as
T = TypeVar('T')
def dict_to_dataclass_2(dict_: dict[Any, Any], dataclass_: type[T]) -> T:
... | <python><pydantic><python-dataclasses><typeddict> | 2023-09-24 01:04:18 | 0 | 4,643 | Garrett |
77,165,412 | 1,230,724 | Fastest way to assign series to dataframe | <p>I need to convert a series of a dataframe. The dataframe has about ~1M rows. The conversion works fine, but I noticed that assigning the series back to the dataframe (same column, with same index, name, etc) takes a lot of time (supposedly because the index is aligned, data is copied and some validation which isn't ... | <python><pandas> | 2023-09-24 00:56:25 | 1 | 8,252 | orange |
77,165,374 | 2,223,706 | Runtime checking for extra keys in TypedDict | <p><a href="https://stackoverflow.com/a/68483666/2223706">This answer</a> tells how to validated a TypedDict at runtime, but it won't catch the case of an extra key being present.</p>
<p>For example, this doesn't throw. How can I make it throw?</p>
<pre class="lang-py prettyprint-override"><code>from typing import Any... | <python><pydantic><typeddict> | 2023-09-24 00:31:56 | 1 | 4,643 | Garrett |
77,165,193 | 3,917,465 | pytest @patch does not work for mocking the whole class (all the methods of the class) but works for mocking individual methods of the class | <p>I have two classes like below:</p>
<p>in parent.py:</p>
<pre><code>class TestClassParent(ABC):
def test_method(self):
print('the method TestMethod is called')
return True
</code></pre>
<p>in child.py:</p>
<pre><code>from src.scripts.parent import TestClassParent
class TestClassChild(TestClassPare... | <python><pytest><pytest-mock><pytest-mock-patch> | 2023-09-23 22:55:16 | 2 | 4,500 | Code_Worm |
77,165,149 | 19,628,700 | setting a lower bound constraint based on condition in gekko | <p>I am trying to set up something similar to the facility location problem using gekko in python. I'm trying to minimize the distance between a set of facilities and corresponding counties while ensuring that if a facility is used as an optimal assignment it accounts for at least 10% of the total population in all of... | <python><linear-programming><gekko><integer-programming> | 2023-09-23 22:36:46 | 1 | 311 | finman69 |
77,165,100 | 5,843,769 | Only the first row of annotations displayed on seaborn heatmap | <p>As it's usually advised, I have managed to reduce my problem to a minimal reproducible example:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
matrix = np.array([[0.1234, 1.4567, 0.7890, 0.1234],
[0.9876, 0, 0.5432, 0.6... | <python><matplotlib><seaborn> | 2023-09-23 22:19:13 | 6 | 1,558 | Mantas Kandratavičius |
77,164,983 | 1,080,189 | Type hinting Python dataclasses subclass without redefining default value | <p>When using keyword only dataclasses to define fields of a base class that are inherited by subclasses, how should the fields be type hinted in the subclasses to denote that the fields have a limited set of permissible values without re-assigning the default value?</p>
<p>Example (for illustrative purposes - not a re... | <python><python-typing><python-dataclasses> | 2023-09-23 21:28:25 | 0 | 1,626 | gratz |
77,164,975 | 20,258,214 | _tkinter.TclError: invalid command name | <p>I am getting the following error while dragging the window to another screen:</p>
<pre><code>Exception in Tkinter callback
_tkinter.TclError: invalid command name ".!sortingframe.!dynamicgrid.!imagebuttonwidget"
</code></pre>
<p>I am trying to use <a href="https://stackoverflow.com/users/7432/bryan-oakley"... | <python><tkinter> | 2023-09-23 21:24:50 | 1 | 1,598 | nokla |
77,164,963 | 11,494,082 | How to Merge Fine-tuned Adapter and Pretrained Model in Hugging Face Transformers and Push to Hub? | <p>I have fine-tuned the Llama-2 model following the <a href="https://github.com/facebookresearch/llama-recipes" rel="nofollow noreferrer">llama-recipes</a> repository's <a href="https://github.com/facebookresearch/llama-recipes/blob/main/examples/quickstart.ipynb" rel="nofollow noreferrer">tutorial</a>. Currently, I h... | <python><huggingface-transformers><huggingface><llama><huggingface-hub> | 2023-09-23 21:20:21 | 2 | 315 | Aun Zaidi |
77,164,957 | 5,956,947 | Python: Using kwargs with patch() decorator | <p><strong>I can only use positional arguments with a function that uses <code>@patch</code></strong>. Running <code>being_patched(True)</code> works. Running <code>being_patched(arg=True)</code> does not.</p>
<p>The general principle is positional args cannot come after keyword args. I just find the the interaction wi... | <python><python-3.x><mocking><monkeypatching> | 2023-09-23 21:18:26 | 0 | 400 | Mike Ulm |
77,164,909 | 17,342,313 | module "QtQml.StateMachine" is not installed in PyQT application | <p>I wanted to use <a href="https://doc.qt.io/qt-6/qml-qtqml-statemachine-state.html" rel="nofollow noreferrer">Qt State Machine QML</a> in my PyQt 6 app, however when I try to run it, I get the following error:</p>
<pre class="lang-bash prettyprint-override"><code>QQmlApplicationEngine failed to load component
.../src... | <python><qt><qml><pyqt6><qt6> | 2023-09-23 21:06:13 | 1 | 554 | satk0 |
77,164,700 | 7,212,809 | How to view plot in ipython? | <p>Repro</p>
<pre><code>In [2]: df = pd.read_csv('https://raw.githubusercontent.com/facebook/prophet/main/examples/example_pedestr
...: ians_covid.csv')
...:
In [3]: df.set_index('ds').plot();
...:
</code></pre>
<p>But this isn't plotting anything? How do I view the plot?</p>
<p>Following docs here: <a href=... | <python><ipython> | 2023-09-23 19:58:30 | 0 | 7,771 | nz_21 |
77,164,571 | 11,686,518 | Reverse a series within DataFrame to new column | <p>How would I reverse the order of a series within a DataFrame into a new column?</p>
<pre><code>data = [["US Dollar", 7.00],
['Euro', 2.00],
['British Pound', 4.00],
['Indian Rupee', 2.00],
['Australian Dollar', 9.00],
['Canadian Dollar', 3.00],
['Singapore Do... | <python><pandas> | 2023-09-23 19:13:58 | 4 | 1,633 | Jesse Sealand |
77,164,541 | 395,857 | How can I programmatically remove all the datasets that HuggingFace has saved on the disk? | <p>I have downloaded a HuggingFace dataset (<a href="https://huggingface.co/datasets/uonlp/CulturaX" rel="nofollow noreferrer"><code>uonlp/CulturaX</code></a>) with the following Python code:</p>
<pre><code>from datasets import load_dataset
ds = load_dataset("uonlp/CulturaX", "ar")
</code></pre>
<p>... | <python><download><huggingface><huggingface-datasets> | 2023-09-23 19:06:34 | 1 | 84,585 | Franck Dernoncourt |
77,164,443 | 4,811,803 | Why does my match/case statement not work for class members? | <p>I'm finally using a Python version with support for the <code>match</code> statement, and was surprised that one of my <code>case</code>s didn't match. It seems to work fine for local or global variables, but not class/object members.</p>
<p>I've boiled it down to this example:</p>
<pre><code>#!/usr/bin/env python3
... | <python><pattern-matching> | 2023-09-23 18:37:03 | 2 | 6,886 | Snild Dolkow |
77,164,318 | 1,170,805 | Error with LangChain ChatPromptTemplate.from_messages | <p>As shown in <a href="https://python.langchain.com/docs/get_started/quickstart" rel="nofollow noreferrer">LangChain Quickstart</a>, I am trying the following Python code:</p>
<pre><code>from langchain.prompts.chat import ChatPromptTemplate
template = "You are a helpful assistant that translates {input_language} ... | <python><langchain> | 2023-09-23 18:00:22 | 3 | 380 | Yannick Serra |
77,164,310 | 4,396,778 | How to enter text into a website via selenium and xpath | <p>I am using selenium to try and input text into a text field on a webpage via its xpath. My code to do this is as follows:</p>
<pre><code>import names
from fake_email import Email
import time
import undetected_chromedriver as uc
from selenium.webdriver.common.by import By
#initialize_VPN(save=1,area_input=['united ... | <python><selenium-webdriver><xpath> | 2023-09-23 17:58:24 | 3 | 335 | tribo32 |
77,164,221 | 10,452,700 | Visualizaion of count records of categorical variables including their missing values (`None` or `NaN`) | <p>Let's say I have the following time series data dataframe:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
import pandas as pd
import random
np.random.seed(2019)
# Generate TS
#rng = pd.date_range('2019-01-01', freq='MS', periods=N)
ts = pd.date_range('2000-01-01', '2000-12-31 23:00', freq='H... | <python><dataframe><matplotlib><time-series><missing-data> | 2023-09-23 17:35:07 | 1 | 2,056 | Mario |
77,163,990 | 617,864 | How to programmatically determine the minimum set of files required to import a given Python module? | <p>I'm working on a Python3 script that uses <a href="https://pypi.org/project/pyobjc/" rel="nofollow noreferrer">pyobjc</a> to access the macOS clipboard via <code>NSPasteboard</code>. To do this, it requires the following import:</p>
<pre class="lang-py prettyprint-override"><code>from AppKit import NSPasteboard
</co... | <python><macos><python-import><appkit><pyobjc> | 2023-09-23 16:37:25 | 1 | 861 | luckman212 |
77,163,863 | 2,023,111 | Should I wait after searching for elements and/or scrolling while web scraping? | <p>I'm trying to understand when to wait during a simple python/selenium web scraping script. I'm pulling titles and links for the top 100 results for approximately 50 search terms. I understand some waits are needed to ensure the page content has loaded, and other waits are needed to mimic human behavior (to avoid get... | <python><web-scraping><selenium-chromedriver><infinite-scroll> | 2023-09-23 16:08:08 | 0 | 319 | Jonathan Cakes |
77,163,838 | 1,224,886 | Why are my arguments ignored only when passed with `subprocess.call`? | <p>I'm trying to call the command</p>
<pre><code>& 'C:\Users\USERNAME\AppData\Local\Programs\Microsoft VS Code\bin\code' --folder-uri='vscode-remote://ssh-remote+SERVER.domain.net/home/USERNAME/Dropbox/Projects/PROJECTNAME'
</code></pre>
<p>from a Python script with</p>
<pre class="lang-py prettyprint-override"><co... | <python><shell><visual-studio-code> | 2023-09-23 16:02:07 | 1 | 1,569 | tsbertalan |
77,163,726 | 1,008,596 | square api add image with python fails | <p>When using the squareup python API to upload an image to the catalog it fails on the file parameter. I will post the code, the failure and then some observations regarding the API documentation.</p>
<h2>pip install method #1</h2>
<p>I actually used a <code>requirements.txt</code>, but this is effectivly how I insta... | <python><square> | 2023-09-23 15:31:22 | 1 | 4,629 | netskink |
77,163,685 | 6,498,757 | Implementation of Perceptron algorithm, but not efficent when I run it | <p>When the sample size is set to 10, the average number of iterations until convergence should be around 15. However, when implementing the algorithm in my code, it takes approximately 225(or more!) iterations to reach convergence. This leads me to suspect that there may be an issue with the while loop in my code, but... | <python><python-3.x><numpy><machine-learning><neural-network> | 2023-09-23 15:22:05 | 2 | 351 | Yiffany |
77,163,626 | 7,581,507 | Running code after Jupyter notebook finishes | <p>I would like to run code after the notebook finishes running (the code should run inside the same kernel)</p>
<p>I am familiar with registering callbacks on <a href="https://ipython.readthedocs.io/en/stable/config/callbacks.html" rel="nofollow noreferrer">IPython events</a>, but these only work at the cell level.</p... | <python><jupyter-notebook><ipython> | 2023-09-23 15:11:27 | 0 | 1,686 | Alonme |
77,163,495 | 1,259,374 | Refreshing Google API credentials throws TypeError after working several times in Python | <p>I am trying to authenticate and send an email using the <strong>Gmail API</strong> in <strong>Python</strong>. I've set up a function to handle the authentication. It worked well for several times, but then I started encountering an issue when trying to refresh the credentials:</p>
<pre><code>from google.oauth2.cred... | <python><google-oauth><gmail-api><google-api-python-client> | 2023-09-23 14:39:24 | 2 | 1,139 | falukky |
77,163,494 | 3,076,544 | How to load specific Firefox profile into selenium (Macos M1) | <p>I'm trying to load a specific profile into selenium, but it always opens with the default profile. Here is my code:</p>
<pre><code>profile_path = '/Users/mymachine/Library/Application Support/Firefox/Profiles/specificprofile.default'
options = webdriver.FirefoxOptions()
options.set_preference('profile', profile_path... | <python><selenium-webdriver><selenium-firefoxdriver> | 2023-09-23 14:38:57 | 3 | 993 | MrT77 |
77,162,989 | 1,881,329 | Flask get public IP from client behind NGINX - not quite working | <p>I'm struggling to get the public IP from clients.</p>
<p>I have a Flask app served using Waitress behind an NGINX running on an AWS EC2 instance.</p>
<p>When I access the website using <a href="https://myservice.com" rel="nofollow noreferrer">https://myservice.com</a>, I get the AWS EC2 private IPv4.</p>
<p>When I a... | <python><amazon-web-services><nginx><flask> | 2023-09-23 12:17:29 | 0 | 436 | Carlos Souza |
77,162,824 | 1,186,991 | Unable to merge data from FRED | <p>The following code works using pandas get_data_fred() method.</p>
<pre><code>start = dt.datetime(2018, 1, 1)
end = dt.datetime(2022, 3, 28)
stk_tickers = ["AAPL", "MSFT", "TSLA", "GOOG"]
ccy_tickers = ["DEXJPUS", "DEXUSUK"]
idx_tickers = ["SP500"... | <python><dataframe> | 2023-09-23 11:29:21 | 1 | 3,631 | Hans Rudel |
77,162,780 | 10,354,066 | Debugger in Python is running like in no debug mode | <p>I am coding in VS code with Python and I have Python extension installed. I put breakpoints anywhere in my program (I am sure the code works) and when I launch my program in debugging mode (F5 or start debugging) it runs just like in no debugging mode. Maybe any ideas what can cause this?</p>
<p>Simplest code I try ... | <python><visual-studio-code><debugging> | 2023-09-23 11:13:47 | 1 | 1,548 | vytaute |
77,162,718 | 2,005,559 | pandas dataframe style format not printing specified precision | <p>I am trying to format the dataframe using <a href="https://pandas.pydata.org/docs/reference/api/pandas.io.formats.style.Styler.format.html" rel="nofollow noreferrer">https://pandas.pydata.org/docs/reference/api/pandas.io.formats.style.Styler.format.html</a>.</p>
<p>But, I am not getting the desired result:</p>
<pre>... | <python><pandas><format> | 2023-09-23 10:56:35 | 2 | 3,260 | BaRud |
77,162,687 | 1,460,461 | AWS lambda with python and langchain in docker: No module named 'langchain' (Runtime.ImportModuleError) | <p>I cannot make my python script run in <code>AWS lambda</code> using <code>langchain</code> as a dependency in a docker-container. I got the docker-container created and the lambda-function deployed correctly. But as soon as I try to execute it, I get the message:</p>
<pre><code>"errorMessage": "Unable... | <python><docker><aws-lambda><langchain> | 2023-09-23 10:48:29 | 1 | 7,802 | Benvorth |
77,162,653 | 16,171,413 | Python match-case return statement works in an interpreter but doesn't work in a text editor | <p>I am looking at the <a href="https://docs.python.org/3.10/tutorial/controlflow.html" rel="nofollow noreferrer">official python tutorial</a> for educational purposes and I tried this simple match case codes below:</p>
<pre><code>def http_error(status):
match status:
case 400:
return "Bad ... | <python> | 2023-09-23 10:38:32 | 1 | 5,413 | Uchenna Adubasim |
77,162,585 | 14,820,295 | Allocate resources on tasks | <p>I'm working on a Resource-Task allocation problem that considers 2 datasets:</p>
<ol>
<li>for each Resource and month I have availability (in working days)</li>
<li>for each Task I need certain working days</li>
</ol>
<p>Is there any possibility in Python to be able to randomly allocate my IDs on certain Tasks (only... | <python><pandas><while-loop> | 2023-09-23 10:22:17 | 0 | 347 | Jresearcher |
77,162,489 | 11,630,148 | join() argument must be str, bytes, or os.PathLike object, not 'NoneType' with Django | <p>I'm running into an issue on my Django app. The issue is when I click on <code>Add a Record</code> the app returns the error: <code>join() argument must be str, bytes, or os.PathLike object, not 'NoneType'</code> but it shouldn't since I'm not doing any joining in my code. The view for this is:</p>
<pre class="lang-... | <python><django> | 2023-09-23 09:56:09 | 1 | 664 | Vicente Antonio G. Reyes |
77,162,385 | 839,733 | mypy errors with decorator | <pre><code>class Cell(ABC):
def __init__(self, value: int | None = None):
...
@property
def value(self) -> int | None:
return self._value
class InputCell(Cell):
@Cell.value.setter
def value(self, value: int) -> None:
...
</code></pre>
<p>Running mypy with <code>--str... | <python><python-decorators><mypy> | 2023-09-23 09:22:37 | 0 | 25,239 | Abhijit Sarkar |
77,162,381 | 18,164,421 | CoinBase API not returning product ticker data | <p>I am trying to get the product ticker from CoinBase API <a href="https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductticker" rel="nofollow noreferrer">https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductticker</a> using two different functions. The first one is the ... | <python><coinbase-api> | 2023-09-23 09:21:54 | 1 | 302 | useeeeer132 |
77,162,144 | 7,383,971 | Average precision implementation for object detection - low confidence detections do not impact the score | <p>I have the following code that calculates precision-recall curve for object detection task, where detections are matched to ground-truth first by creating 1-to-1 pairs starting from detection with the highest confidence score and matching it to ground-truth object for which the overlap is the highest. The results ar... | <python><numpy><scikit-learn><precision-recall><average-precision> | 2023-09-23 08:01:02 | 2 | 832 | Kuba_ |
77,161,886 | 2,217,263 | Compilation of Fortan code with f2py creates empty Python module | <p>I have a large Fortran 90 code that I would like to compile with <code>f2py</code> so I can run it from within a Python code. I do get the compilation to run without any errors, like this:</p>
<p><code>f2py -c -lgomp -lcfitsio.10 -L/usr/local/opt/cfitsio/lib/ -m code_name code_name.f90</code></p>
<p>Importing of <co... | <python><fortran><f2py> | 2023-09-23 06:24:49 | 0 | 543 | Tomas |
77,161,846 | 4,794 | Model structure for regression from images | <p>I'm trying to build a tensorflow model for analysing board games, so I started with a simpler 2D dataset. I generated 1000 images of black semicircles like these:</p>
<p><a href="https://i.sstatic.net/07Ik7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/07Ik7.png" alt="input image 1" /></a> <a href="... | <python><tensorflow><machine-learning><deep-learning><neural-network> | 2023-09-23 06:02:33 | 3 | 56,676 | Don Kirkby |
77,161,326 | 308,827 | groupby in pandas giving error when combining columns with NaNs | <p>I have the following dataframe and I want to combine the three columns <code>["Area (ha)", "Yield (tn per ha)", "Production (tn)"]</code> such that no NaNs are present:</p>
<pre><code> Country Crop Season Year Area Yield Production
0 Argentina maize 1 2000 3088... | <python><pandas> | 2023-09-23 01:18:30 | 1 | 22,341 | user308827 |
77,161,295 | 19,251,203 | Reorder Series Data Based on Month | <p>I have a data frame with the following data:</p>
<pre><code>month
April 4484.900000
August 5664.419355
December 3403.806452
February 2655.298246
January 2176.338710
July 5563.677419
June 5772.366667
March 3692.258065
May 5349.774194
November 4247.183333
O... | <python><python-3.x><dataframe><series> | 2023-09-23 01:04:26 | 1 | 392 | user19251203 |
77,161,259 | 1,231,714 | Pandas - exclude rows that have wrong format | <p>I am logging some data and for some reason i have <code>@^</code> in the date column. Is there a way to exclude the rows that are not dates. It may happen that there are undesirable characters in other columns as well.</p>
<pre><code>2023/08/22 14:26:11, 1.3337, 1.0915, 1.2119, 1.5757
2023/08/22 14:27:15, 1.3161, 1.... | <python><pandas><dataframe><csv> | 2023-09-23 00:41:39 | 2 | 1,390 | SEU |
77,161,209 | 22,466,650 | How to nest a list based on increasing sequences and ignore left overlapping ranges | <p>This is my input</p>
<pre><code>mylist = [2, 7, 8, 11, 7, 9, 10, 15, 22, 30, 32]
</code></pre>
<ul>
<li>from 2 to 11, it's increasing, so we need to grab the min max <code>[2, 11]</code></li>
<li>from 7 to 10 it's increasing, but we need to ignore it because the range
(7 to 10) is inluded in the first grabed list</... | <python><algorithm><math> | 2023-09-23 00:15:19 | 2 | 1,085 | VERBOSE |
77,161,176 | 2,824,791 | Simple Python Script in Nextflow fails | <p>I am attempting to run Python from inside a <strong>Nextflow</strong> pipeline launched via <strong>Nextflow-Tower</strong>. I forked the <strong>nextflow-io/hello</strong> repo and made sure I could launch it successfully from my own repo. What I am doing wrong? If there is a simple python pipeline repo that can be... | <python><nextflow><nextflow-tower> | 2023-09-22 23:59:57 | 2 | 5,096 | jlo-gmail |
77,161,173 | 395,857 | How can I multithreadedly download a HuggingFace dataset? | <p>I want to download a HuggingFace dataset, e.g. <a href="https://huggingface.co/datasets/uonlp/CulturaX" rel="nofollow noreferrer"><code>uonlp/CulturaX</code></a>:</p>
<pre><code>from datasets import load_dataset
ds = load_dataset("uonlp/CulturaX", "en")
</code></pre>
<p>However, it downloads on o... | <python><multithreading><download><huggingface><huggingface-datasets> | 2023-09-22 23:59:18 | 2 | 84,585 | Franck Dernoncourt |
77,160,966 | 9,072,753 | Is there a convention which fields are reserved for implementation in python? | <p>I read the documentation of <code>threading.Thread</code> that mentions:</p>
<blockquote>
<p>There are two ways to specify the activity: by passing a callable object to the constructor, or by overriding the run() method in a subclass</p>
</blockquote>
<p>I have written the following program to test it:</p>
<pre><cod... | <python><python-3.x><inheritance> | 2023-09-22 22:33:47 | 0 | 145,478 | KamilCuk |
77,160,935 | 5,256,563 | Python PIL error 'L' format requires 0 <= number <= 4294967295 | <p>I create a numpy array of int, then I transform it as a PIL <code>Image</code> of type <code>uint32</code>, and then I try to save it. See simple mock code below:</p>
<pre><code>import numpy
resLabels = numpy.ndarray(shape=(38000, 38000), dtype=numpy.int32)
resLabels.fill(0)
resLabels[0,0] = 10000000 # Just a dumb v... | <python><python-3.x><python-imaging-library> | 2023-09-22 22:21:39 | 1 | 5,967 | FiReTiTi |
77,160,797 | 9,811,964 | Automatically shift rows with same spatial coordinates into a different cluster | <p>I have a dataframe <code>df</code>:</p>
<pre><code>import pandas as pd
data = {
"latitude": [49.5659508, 49.568089, 49.5686342, 49.5687609, 49.5695834, 49.5706579, 49.5711228, 49.5716422, 49.5717749, 49.5619579, 49.5619579, 49.5628938, 49.5628938, 49.5630028, 49.5633175, 49.56397639999999, 49.566359, 49.5... | <python><pandas><dataframe><cluster-computing> | 2023-09-22 21:38:55 | 1 | 1,519 | PParker |
77,160,785 | 2,363,252 | sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table expected to update X row(s); Y were matched | <p>Using sqlalchemy 2.0.21 with postgresql 14, I have the following model:</p>
<pre class="lang-py prettyprint-override"><code>
class MyModel(TimestampedMixin):
id = Column(String(12), primary_key=True)
rating = Column(Float, index=True)
... more fields ...
</code></pre>
<p>Inspired by the <a href="https:/... | <python><postgresql><sqlalchemy> | 2023-09-22 21:35:11 | 1 | 2,865 | stelios |
77,160,753 | 5,937,760 | How to format unconventional output into simple json dump | <p>In the answer from this post:
<a href="https://stackoverflow.com/a/55832055/5937760">https://stackoverflow.com/a/55832055/5937760</a></p>
<p>The output is:</p>
<pre><code>{TopicPartition(topic=u'python-test', partition=0): 5,
TopicPartition(topic=u'python-test', partition=1): 20,
TopicPartition(topic=u'python-test... | <python><json><kafka-python> | 2023-09-22 21:29:11 | 1 | 1,317 | sojim2 |
77,160,736 | 188,159 | How to insert (append) a string containing XML as XML into inner XML (or remove a parent tag but keep the content) with lxml in Python? | <p>I'm trying to insert text into XML with lxml. The text contains XML which is supposed to become part of the XML it gets inserted into.</p>
<p>The following code does not work:</p>
<pre class="lang-py prettyprint-override"><code>from lxml import etree
tree = etree.fromstring('<tag><src></src><sr... | <python><xml><lxml> | 2023-09-22 21:22:25 | 4 | 9,813 | qubodup |
77,160,524 | 2,291,710 | What is type annotation for "any callable but a class" in Python using Mypy? | <p>I'm trying to perfectly type annotate the following Python function:</p>
<pre class="lang-py prettyprint-override"><code>from typing import Callable, Any
import inspect
def foo(func: Callable[..., Any]) -> None:
if inspect.isclass(func):
raise ValueError
# Do something...
class Bad:
pass
de... | <python><mypy><python-typing> | 2023-09-22 20:34:09 | 2 | 19,937 | Delgan |
77,160,469 | 471,376 | mock patch for the entire test session | <p><em><strong>tl;dr</strong></em> how to have a <code>mock.patch</code> for a <code>@classmethod</code> last an entire test session instead of only within <code>with</code> scope or function scope?</p>
<p>I want to <a href="https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch" rel="nofollow norefer... | <python><python-unittest><python-mock><python-unittest.mock> | 2023-09-22 20:22:13 | 1 | 7,289 | JamesThomasMoon |
77,160,268 | 19,127,570 | How to reconstruct the 3D coordinate system using feature points from an image? | <p>Given a picture of a rubiks cube, is it possible to construct the world space by using feature points from the faces and edges in the image?</p>
<p>By using some Topological Data Analysis methods I can take an image of a rubiks cube and identify the squares on each face. I can also determine the vertices and edges t... | <python><image-processing><3d><coordinate-transformation> | 2023-09-22 19:35:59 | 0 | 773 | trent |
77,160,258 | 8,942,319 | SQL Alchemy: table.col == None or table.col.is_(None)? | <p>Running SQLAlchemy version < 2.0.0 and mysql. Wondering what the difference is between these</p>
<pre><code>select_stmt.where(
table.c.my_column.is_(None)
)
</code></pre>
<p>versus</p>
<pre><code>select_stmt.where(
table.c.my_column == None
)
</code></pre>
<p>Or even</p>
<pre><code>select_stmt.where(
... | <python><mysql><sqlalchemy> | 2023-09-22 19:34:03 | 1 | 913 | sam |
77,160,202 | 1,609,514 | How to manually select features for Scikit-Learn model regression? | <p>There are various methods for doing <a href="https://scikit-learn.org/stable/modules/classes.html#module-sklearn.feature_selection" rel="nofollow noreferrer">automated feature selection</a> in Scikit-learn.</p>
<p>E.g.</p>
<pre><code>my_feature_selector = SelectKBest(score_func=f_regression, k=3)
my_feature_selector... | <python><scikit-learn><pipeline><feature-selection> | 2023-09-22 19:20:02 | 1 | 11,755 | Bill |
77,160,103 | 1,769,327 | Exponential Moving Average (EMA) calculations in Polars dataframe | <p>I have the following list of 20 values:</p>
<pre><code>values = [143.15,143.1,143.06,143.01,143.03,143.09,143.14,143.18,143.2,143.2,143.2,143.31,143.38,143.35,143.34,143.25,143.33,143.3,143.33,143.36]
</code></pre>
<p>In order to find the Exponential Moving Average, across a span of 9 values, I can do the following ... | <python><python-polars> | 2023-09-22 18:56:56 | 2 | 631 | HapiDaze |
77,160,087 | 113,586 | Correct typing of a method without a fixed signature | <p>I wonder what is the correct way to type hint <a href="https://github.com/scrapy/scrapy/blob/2.11.0/scrapy/spiders/__init__.py#L81" rel="nofollow noreferrer"><code>scrapy.Spider.parse()</code></a>.</p>
<p>If defined in a subclass, it has a specific first argument (<code>response: Response</code>) but can have an arb... | <python><python-typing> | 2023-09-22 18:53:17 | 1 | 25,704 | wRAR |
77,160,020 | 14,692,430 | Get proper intellisense with overloaded multimethods in python | <p>The following code works as expected:</p>
<pre class="lang-py prettyprint-override"><code>from multimethod import multimethod
@multimethod
def foo(a: int):
print(f"only {a}")
@multimethod
def foo(a: int, b: int):
print(f"{a} and {b}")
foo(1)
foo(1, 2)
</code></pre>
<p>Output:</p>
<pre>... | <python><overloading><intellisense><multiple-dispatch><multimethod> | 2023-09-22 18:43:24 | 1 | 352 | DaNubCoding |
77,159,772 | 22,466,650 | How to expand a Multiindex while incrementing the data inserted? | <p>This is my input :</p>
<pre><code>df = pd.DataFrame(
np.arange(0, 30).reshape(-1, 5),
index=pd.MultiIndex.from_product([["a"], ["b", "c", "d"], ["e", "g"]]),
columns= ["class", "type", "id", "name", "... | <python><pandas> | 2023-09-22 17:55:24 | 2 | 1,085 | VERBOSE |
77,159,548 | 8,512,262 | How can I watch for user activity from a service (session 0) in Windows 11? | <p>I came up with the solution below to watch for user activity from a service. This is working as expected in Windows 10, but doesn't work for mouse activity in Windows 11 (only key press/release events are detected); evidently something has changed <em>WRT</em> the behavior of csrss.exe under Windows 11.</p>
<p>I've ... | <python><service><windows-11><user-activity> | 2023-09-22 17:10:53 | 1 | 7,190 | JRiggles |
77,159,384 | 7,658,051 | How to run Python code on the host like the 'ansible.builtin.shell' module does for Bash? | <p>Sometimes I cannot use the native Ansible / Jinja2 functions to get what I want, so I go get it via Bash.</p>
<p>For example, I had to type yesteday's date in <code>yyyy-mm-dd</code> format, and I found the easisest Ansible way to get it to be over complicated, being the task such a basic one</p>
<pre class="lang-ya... | <python><bash><cmd><ansible><stdout> | 2023-09-22 16:40:52 | 1 | 4,389 | Tms91 |
77,159,305 | 10,999,070 | A regular expression with a pattern to exclude, but the pattern itself contains a substring we want to include | <p>For string: <code>.test[?(@.foo=="bazz")].boo</code>, using Python I want to get matches on this string based on <code>.</code>, <code>[?</code>, <code>]</code>, but ignore on <code>@.</code>.</p>
<p>I've managed to figure out how to match the pattern for all splits, but can't seem to figure out the ignore... | <python><regex> | 2023-09-22 16:23:50 | 1 | 385 | phaseTiny |
77,159,222 | 5,916,316 | Django Serializer with Many To Many fileld returns empty list, How to fix it? | <p>I have two models <code>Product</code> and <code>Lessons</code>. I join them in one Product serializer. But I get empty list in <code>lesson</code> fileld. This is what I am getting now:</p>
<pre><code> {
"id": 1,
"name": "Python",
"owner": 1,
... | <python><django><django-rest-framework> | 2023-09-22 16:10:25 | 1 | 429 | Mike |
77,159,166 | 8,372,455 | BACnet server as a docker application | <p>On the Python BACnet stack bacpypes there is simple examples on how to make a BACnet server, like this <a href="https://github.com/JoelBender/bacpypes/blob/master/samples/mini_device.py" rel="nofollow noreferrer">mini_device.py</a> on the git repo.</p>
<p>The BACpypes applications require a <code>.ini</code> file li... | <python><docker><bacnet><bacpypes> | 2023-09-22 16:00:48 | 1 | 3,564 | bbartling |
77,159,136 | 15,587,184 | Efficiently using Hugging Face transformers pipelines on GPU with large datasets | <p>I'm relatively new to Python and facing some performance issues while using Hugging Face Transformers for sentiment analysis on a relatively large dataset. I've created a DataFrame with 6000 rows of text data in Spanish, and I'm applying a sentiment analysis pipeline to each row of text. Here's a simplified version ... | <python><gpu><huggingface-transformers><huggingface-datasets> | 2023-09-22 15:57:36 | 3 | 809 | R_Student |
77,159,092 | 1,659,599 | CHORD_TYPE for Chord in music21 | <p>The property <code>Chord.commonName</code> returns the most common name associated with a chord. The returned string is from the table <a href="https://github.com/cuthbertLab/music21/blob/f457a2ba52ea3f978d805cd52fa101dfb0dd8577/music21/chord/tables.py#L981" rel="nofollow noreferrer">chord.tables.tnIndexToChordInfo<... | <python><music21> | 2023-09-22 15:49:46 | 1 | 7,359 | wolfrevo |
77,159,000 | 20,358 | xml manipulation with Python | <p>I am using Python 3.9. I have a nested xml document string like this</p>
<pre><code>payload_xml = """
<AllData>
<MyPayload>
...
...
...
</MyPayload>
</AllData>
"""
</code></pre>
<p>Now I want to create another parent xml document string and... | <python><python-3.x><lxml> | 2023-09-22 15:34:03 | 1 | 14,834 | user20358 |
77,158,844 | 8,440,356 | Creating and Working with a Class of Classes | <p>I have inherited some Python code that contains a class that is designed to get a series of objects from a running application using their API. However, I am struggling to work out the best way to handle those objects within my class.</p>
<p>I was thinking of dividing this class into two classes:</p>
<ul>
<li>the fi... | <python><class><oop> | 2023-09-22 15:12:07 | 1 | 565 | rockdoctor |
77,158,832 | 7,972,989 | Dash suppress error "A nonexistent object was used in an `Input` of a Dash callback" | <p>I have a complex Dash app where different layouts are displayed depending on some inputs. These output layouts (created in callbacks) contain some inputs.</p>
<p>Because those inputs are not defined yet in the layout, I have the error "A nonexistent object was used in an <code>Input</code> of a Dash callback.&q... | <python><plotly-dash> | 2023-09-22 15:10:51 | 2 | 2,505 | gdevaux |
77,158,712 | 1,147,321 | Looping through a list of strings, getting tuples instead | <p>I have a problem and hope anyone here has seen something similar. What looks like a loop through a list of strings returns a tuple with data of unknown origin.</p>
<p>I am using Pycharm as my IDE. The error only happens if the code is executed in debug mode.</p>
<p>I have the following code.</p>
<pre><code>from mult... | <python><debugging><pycharm><python-3.10> | 2023-09-22 14:55:21 | 1 | 2,167 | Ephreal |
77,158,299 | 6,368,549 | Python, create dataframe from data dump | <p>We pull some data from a URL. The data comes down as one huge string, but within it is delimited into small lists / pairs. A small sample of the data is here:</p>
<pre><code>[{"date_of_fix ":"9\/4\/2023","fix_description":"Broken report links\r","issue_no ":"... | <python><dataframe> | 2023-09-22 14:00:42 | 1 | 853 | Landon Statis |
77,158,196 | 8,184,694 | Get list of column names with values > 0 for every row in polars | <p>I want to add a column <code>result</code> to a polars <code>DataFrame</code> that contains a list of the column names with a value greater than zero at that position.</p>
<p>So given this:</p>
<pre><code>import polars as pl
df = pl.DataFrame({"apple": [1, 0, 2, 0], "banana": [1, 0, 0, 1]})
cols... | <python><python-polars> | 2023-09-22 13:48:14 | 3 | 541 | spettekaka |
77,157,820 | 54,557 | How can I disable tab complete in IPython? | <p>I have a complex data structure, with essentially a tree-like structure, that takes a while (minutes) to load (it has to scan the filesystem and look for changes to lots files). I want to interrogate this structure, with a top-level variable called <code>obj</code>, in IPython. When I do so, muscle memory often kick... | <python><ipython> | 2023-09-22 12:57:48 | 0 | 9,654 | markmuetz |
77,157,721 | 5,013,752 | use-case streaming in pyspark | <p>I am working with Databricks on Azure, my data are hosted on ADLS2.<br />
Current version of runtime is 10.4 LTS (I can upgrade if needed)</p>
<p>I have a table <strong>Pimproduct</strong>:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>action</th>
<th>dlk_last... | <python><azure><pyspark><azure-databricks><spark-structured-streaming> | 2023-09-22 12:45:20 | 1 | 15,420 | Steven |
77,157,695 | 15,341,457 | Scrapy - Only first url in url list is scraped | <p>I'm scraping reviews from restaurants in Rome, Milan and Bergamo. For each one of those cities there's one dedicated url containing 30 or more restaurants. The scraper starts crawling the Rome restaurants but never switches to the other cities. It correctly scrapes all the restaurants and reviews from Rome but then ... | <python><html><web-scraping><xpath><scrapy> | 2023-09-22 12:42:21 | 1 | 332 | Rodolfo |
77,157,638 | 2,363,252 | Pandas: parse_csv throws "ValueError: Unable to parse string", when column starts with: " | <p>I am trying to read a tab-separated <a href="https://datasets.imdbws.com/title.basics.tsv.gz" rel="nofollow noreferrer">file</a> with pandas</p>
<pre class="lang-py prettyprint-override"><code>
import pandas as pd
basics_cols_to_use = [
'tconst', 'titleType', 'originalTitle', 'startYear', 'runtimeMinutes', 'gen... | <python><pandas> | 2023-09-22 12:32:29 | 1 | 2,865 | stelios |
77,157,476 | 5,074,060 | Running tslearn via reticulate leads to TypeError | <p>I am trying to run <code>TimeSeriesKMeans</code> from <a href="https://tslearn.readthedocs.io/en/latest/gen_modules/clustering/tslearn.clustering.TimeSeriesKMeans.html" rel="nofollow noreferrer">TSlearn</a> via reticulate but apparently fail to properly convert my R data.frame to a numpy array. Full code and error b... | <python><r><reticulate> | 2023-09-22 12:06:28 | 1 | 878 | ATpoint |
77,157,310 | 7,093,241 | What's the correct index-url for PyPI? | <p>I am trying to install packages from <code>requirements.txt</code> on a machine with a different <code>global.index</code> and different <code>search.index</code>. I am using the <code>--index-url</code> option but I get an error.</p>
<pre><code>$ pip3 install --index-url https://pypi.org/ -r requirements.txt
Lookin... | <python><pip><windows-subsystem-for-linux><pypi> | 2023-09-22 11:40:55 | 1 | 1,794 | heretoinfinity |
77,157,208 | 2,725,810 | Understanding the pickled object size | <p>I execute the following line in Python interpreter:</p>
<pre><code>len(pickle.dumps([numpy.random.random(384).tolist()]*55))
</code></pre>
<p>It gives 3584.</p>
<p>Given that <code>numpy.random.random</code> produces 8-byte floats, the data being pickled is 384 * 8 * 55 = 168,960 bytes. How come <code>len</code> giv... | <python><numpy><serialization><pickle> | 2023-09-22 11:26:25 | 2 | 8,211 | AlwaysLearning |
77,157,114 | 1,797,689 | How to understand when the user has changed the subject in a conversation? | <p>I am using LangChain for a chat bot. I have managed to create the prompt and send the chat history in it. A problem I am facing is that when the user is talking about a certain topic for some time and then starts another, the LM is unable to understand the change of subject. How do I make it understand? Is there a t... | <python><langchain><py-langchain> | 2023-09-22 11:12:03 | 0 | 5,509 | khateeb |
77,156,996 | 5,439,470 | spark worker is receiving job but does not start working | <p>I use this compose-file to create a local spark "cluster"</p>
<pre><code>version: "3"
services:
spark-master:
image: spark:3.5.0
entrypoint: /opt/spark/bin/spark-class org.apache.spark.deploy.master.Master
ports:
- 8080:8080
- 7077:7077
spark-worker:
image: spa... | <python><docker><apache-spark><pyspark><docker-compose> | 2023-09-22 10:54:44 | 0 | 1,303 | jan-seins |
77,156,969 | 3,198,895 | Numpy promotion in integer-float product | <p>When profiling some code today I was surprised by the following behaviour:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
print(repr(10**19 * np.ones(1, dtype=np.float64)))
print(repr(10**20 * np.ones(1, dtype=np.float64)))
</code></pre>
<p>which returns:</p>
<pre><code>array([1.e+19])
array(... | <python><numpy> | 2023-09-22 10:51:29 | 1 | 1,721 | Svaberg |
77,156,768 | 5,505,224 | Importing module error and relative import error | <p>I went through posts on stackoverflow and I couldn't figure out. Current work around was hard-coding sys.path.append in run.py for the application to run locally.</p>
<p>[![Folder Structure Image][1]][1]</p>
<p>Without path append and I try to run with python3 app/run.py from project folder I receive no module name ... | <python> | 2023-09-22 10:21:25 | 0 | 482 | Rajesh Mappu |
77,156,673 | 15,189,432 | How do I get the output as a dataframe? | <p>How do I get the output as a dataframe? I can't seem to find out what type the output is.</p>
<pre><code>from bs4 import BeautifulSoup
url = "https://www.bvb.de/Spiele/Alle-Spiele"
soup = BeautifulSoup(requests.get(url).content, "html.parser")
table = soup.select("table.statistics")
... | <python><dataframe> | 2023-09-22 10:06:38 | 0 | 361 | Theresa_S |
77,156,285 | 7,188,690 | create a generalized function to transpose the columns and make dictionaries as values in the other column | <p>I have this spark data frame. I am trying to convert the columns to rows and make one of the columns gw are the key of the dictionary in the other column. I want to write a generalized function for this which can take multiple columns as input.</p>
<pre><code>+-----+-----+-----+-------+
| gw |rrc |re_est|
+-----+--... | <python><pyspark> | 2023-09-22 09:13:13 | 1 | 494 | sam |
77,156,217 | 8,430,629 | Calling model.fit on target array of columns vs array of rows with separate output nodes | <p>The two <em>should</em> be equivalent in terms of how they are fed into the model or one should be accepted and the other incompatible. A list of columns vs a list of rows. My model architecture takes 5 inputs and spits out 3 outputs. I noticed that in training - when my target data was a 3 x 1000 numpy array I had ... | <python><tensorflow><keras><deep-learning><neural-network> | 2023-09-22 09:02:43 | 1 | 312 | Governor |
77,156,187 | 11,267,783 | Set axis to specific value in pyqtgraph | <p>I would like to specify the value of my axis on my imageItem.</p>
<p>This is my code :</p>
<pre><code>import numpy as np
import pyqtgraph as pg
app = pg.mkQApp('Example')
layout = pg.GraphicsLayoutWidget(show=True)
plot_item = pg.PlotItem(title="")
image_item = pg.ImageItem()
plot_item.addItem(image_item... | <python><pyqt><pyqtgraph> | 2023-09-22 08:59:32 | 1 | 322 | Mo0nKizz |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.