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,779,650 | 12,131,013 | Capture KeyboardInterrupt in context manager when OpenMPI run is manually terminated | <p>I am running code in parallel using <code>mpi4py</code>. I've noticed that if I run the code and perform a keyboard interrupt, my context manager <code>__exit__</code> will run if I run the code as <code>python file.py</code> but will not when run as <code>mpirun -np 1 file.py</code> (this is only one process, but i... | <python><mpi><contextmanager><mpi4py> | 2024-07-22 15:49:20 | 1 | 9,583 | jared |
78,779,292 | 4,691,830 | Cannot use fileinput.input as stdin in subprocess.run | <p>I was under the impression that <code>fileinput.input([path_1, path2, ...])</code> is basically interchangeable with <code>open(path_1)</code> except that the former concatenates the contents of all the files given. However, <a href="https://docs.python.org/3/library/fileinput.html#fileinput.input" rel="nofollow nor... | <python><file-io><subprocess> | 2024-07-22 14:33:43 | 3 | 4,145 | Joooeey |
78,779,247 | 5,333,970 | Upgrading python3-pip for security issues | <p>A security scan has identified python3-pip 9.0.3 on EL8 as a security issue. I don't use Python on the machine. But when I tried to remove it, I got an error because dnf is dependent on Python..</p>
<p>There is no newer version of python3-pip for EL8 that I can find.</p>
<p>Does anyone have any suggestions on how I ... | <python><python-3.x><rpm><yum><dnf> | 2024-07-22 14:26:51 | 1 | 303 | Daniel Cosio |
78,779,076 | 9,284,651 | add date columns | <p>I have two columns with date and I need to create another based on sum of those two. df looks like below:</p>
<pre><code>date_1 date_2 result_date
2024-07-07 18:00:00.000000 0001-01-02T01:12:53.832 2024-07-08 19:12:53
2024-07-07 08:46:00.000000 0001-01-04T08:00:00... | <python><pandas><dataframe><datetime><time> | 2024-07-22 13:48:26 | 2 | 403 | Tmiskiewicz |
78,779,017 | 2,855,689 | When using Docker and python:3.11 image the module "test" is not found | <p>I have a multistage docker image as below.</p>
<pre><code># syntax=docker/dockerfile:1
FROM python:3.11 as DEP_BUILDER
ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_CACHE_DIR=... | <python><python-3.x><docker><dockerfile> | 2024-07-22 13:36:03 | 1 | 732 | Aitor Martin |
78,779,016 | 2,107,030 | Setting the same axis limits for all *unpacked* subplots | <p>What is an efficient way to assign the same specs (for example, <code>xlim</code>) to matplotlib unpacked subplots?</p>
<p>I have</p>
<pre><code>fig, (axs1, axs2,axs3) = plt.subplots(3, sharex=True, figsize=(10,6), gridspec_kw={'height_ratios': [2, 1, 1], 'hspace':0})
</code></pre>
<p>And I want to cycle over them, ... | <python><matplotlib><subplot> | 2024-07-22 13:35:59 | 1 | 2,166 | Py-ser |
78,778,988 | 9,714,255 | Do I need to use Named Entity Recognition (NER) in tokenization? | <p>I am working on an NLP project for sentiment analysis. I am using SpaCy to tokenize sentences. As I was reading the <a href="https://spacy.io/usage/linguistic-features#named-entities" rel="nofollow noreferrer">documentation</a>, I learned about NER. I've read that it can be used to extract entities from text for aid... | <python><python-3.x><nlp><spacy><named-entity-recognition> | 2024-07-22 13:28:14 | 1 | 1,348 | LoukasPap |
78,778,978 | 7,290,715 | Get the last child node and its associated namespace mapping dynamically in xml file using python | <p>I have an xml file as below:</p>
<pre><code>xml_s = """
<?xml version="1.0" encoding="utf-8"?>
<feed xml:base="https://url_path/1f3a6012-d6b2-4258-a91a-fc6d4e86c304/"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://s... | <python><xml> | 2024-07-22 13:26:32 | 2 | 1,259 | pythondumb |
78,778,961 | 1,376,848 | Equivalent of TS Parameters in Python | <p>In TypeScript I can do this:</p>
<pre class="lang-js prettyprint-override"><code>function a(b: string): string {
return b + "Bar";
}
let c: Parameters<typeof a>[0]; // string
c = "Foo";
e = a(d); // FooBar
</code></pre>
<p>How do I do <code>Parameters</code> in Python?</p>
<p>Context: in... | <python><python-typing> | 2024-07-22 13:22:31 | 0 | 2,086 | Otto |
78,778,953 | 11,291,788 | Chrome is ignoring my attempts to unset cookies (Django) | <p>I'm trying to unset my cookie on an https site. The cookie was set by the server after successful login but chrome is not unsetting the cookie when logout is called even though the Set-Cookie header is present on the response headers with the correct directives.</p>
<pre><code>@api_view(['POST'])
def login(request):... | <python><reactjs><django><google-chrome> | 2024-07-22 13:20:33 | 1 | 534 | Warwick |
78,778,926 | 2,521,423 | Creating a metaclass that inherits from ABCMeta and QObject | <p>I am building an app in PySide6 that will involve dynamic loading of plugins. To facilitate this, I am using <code>ABCMeta</code> to define a custom metaclass for the plugin interface, and I would like this custom metaclass to inherit from <code>ABC</code> and from <code>QObject</code> so that I can abstract as much... | <python><abstract-class><multiple-inheritance><metaclass><pyside6> | 2024-07-22 13:14:40 | 1 | 1,488 | KBriggs |
78,778,894 | 15,948,240 | How to make a clickable URL in Shiny for Python? | <p>I tried this:</p>
<pre><code>app_ui = ui.page_fluid(
ui.output_text("the_txt")
)
def server(input, output, session):
@render.text
def the_txt():
url = 'https://stackoverflow.com'
clickable_url = f'<a> href="{url}" target="_blank"... | <python><py-shiny> | 2024-07-22 13:09:29 | 1 | 1,075 | endive1783 |
78,778,792 | 3,018,860 | Plotting star maps with equatorial coordinates system | <p>I'm trying to generate star maps with the equatorial coordinates system (RAJ2000 and DEJ2000). However, I only get a grid system where meridians and parallels are in parallel, while parallels should be curved and meridians should converge to the north celestial pole and the south ceestial pole.</p>
<p>I'm using some... | <python><matplotlib><astropy><skyfield> | 2024-07-22 12:45:55 | 2 | 2,834 | Unix |
78,778,698 | 8,964,393 | Random stratified sampling in pandas | <p>I have created a pandas dataframe as follows:</p>
<pre><code>import pandas as pd
import numpy as np
ds = {'col1' : [1,1,1,1,1,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,4,4,4,4,4],
'col2' : [12,3,4,5,4,3,2,3,4,6,7,8,3,3,65,4,3,2,32,1,2,3,4,5,32],
}
df = pd.DataFrame(data=ds)
</code></pre>
<p>The dataframe looks as ... | <python><pandas><dataframe><random><sampling> | 2024-07-22 12:25:42 | 1 | 1,762 | Giampaolo Levorato |
78,778,569 | 1,424,746 | Sentry Logging python integration - which handler? | <p>So if there are 2 handlers to a logger say</p>
<pre><code> ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.DEBUG)
ch.setFormatter(logging.Formatter('%(message)s')) # Logs are pre-formatted as JSON strings
# File handler for custom human-readable output
... | <python><logging><sentry> | 2024-07-22 12:01:23 | 1 | 369 | Ram |
78,778,481 | 8,973,620 | Joblib parallel processing introduces {built-in method time.sleep} in profiling | <p>I am using Joblib to run parallel jobs in my Python application. During profiling, I noticed that the slowest process was <code>{built-in method time.sleep}</code>. Interestingly, this issue disappears when I remove Joblib parallel processing. Could you explain why {built-in method time.sleep} becomes a bottleneck w... | <python><parallel-processing><multiprocessing><joblib> | 2024-07-22 11:40:22 | 1 | 18,110 | Mykola Zotko |
78,778,438 | 12,331,569 | A created python thread stucks when code is compiled to cython | <p>I have been trying to figure out why the created thread doesn't work and get stuck when compiled into Cython, as it works normally with CPython...</p>
<p>main.py</p>
<pre class="lang-py prettyprint-override"><code>from count import count_launcher
if __name__ == "__main__":
tracker = {"running&qu... | <python><cython><python-multithreading><cythonize> | 2024-07-22 11:30:47 | 1 | 316 | Muhammad Hawash |
78,778,401 | 1,587,329 | webbrowser.open steals focus, how to avoid | <p>On Windows, calling <a href="https://docs.python.org/3/library/webbrowser.html#webbrowser.open" rel="nofollow noreferrer"><code>webbrowser.open</code></a> steals the e.g. keyboard input focus, and sets it to the newly opened webbrowser tab.</p>
<p>Is there a way to avoid this, that is: to open the page in the backgr... | <python><focus><python-webbrowser> | 2024-07-22 11:21:12 | 1 | 38,730 | serv-inc |
78,778,227 | 5,255,911 | How to make code formatting work again for Python (Visual Studio Code on Mac)? | <p>On Mac, <code>Option</code> +<code>Shift</code> + <code>F</code> now brings up the "There is no formatter for 'python' files installed." message box:</p>
<img src="https://i.sstatic.net/WK2r2vwX.png" width="300" />
<p>I tried installing this plugin, without a change seen to this situation:</p>
<img src="ht... | <python><visual-studio-code> | 2024-07-22 10:44:40 | 5 | 896 | MaduKan |
78,778,114 | 19,626,271 | Why is np.sort() with order slow on multi dtype arrays? (sorting by unsigned integer ID) | <p>Working with embedded software, I'm using <code>numpy</code> arrays with specified datatypes to save memory and other reasons. I'm using version '1.23.4' and Python 3.10.0, but this seems to be an issue with latest versions too. In a task I noticed that sorting this array with <code>np.sort(..., order='id')</code>se... | <python><arrays><numpy><performance><sorting> | 2024-07-22 10:17:56 | 0 | 395 | me9hanics |
78,777,978 | 10,267,104 | Socket IO is rejecting requests from Nginx proxy | <p>I have this docker application running several containers. One of these containers is a Python application that can handle both socket io requests and normal HTTP requests. Django's ASGI handles HTTP/ASGI requests while <code>python-socketio</code> handles socket requests.</p>
<p>Since there are 4 other applications... | <python><django><sockets><nginx><python-socketio> | 2024-07-22 09:46:24 | 2 | 369 | lordsarcastic |
78,777,855 | 4,451,315 | Dummy-encoded PyArrow table from PyArrow ChunkedArray, without going through pandas? | <p>Say I have</p>
<pre><code>import pyarrow as pa
ca = pa.chunked_array([['a', 'b', 'b', 'c']])
print(ca)
</code></pre>
<pre><code><pyarrow.lib.ChunkedArray object at 0x7fc938bcea70>
[
[
"a",
"b",
"b",
"c"
]
]
</code></pre>
<p>I'd like to end up with:</... | <python><pyarrow> | 2024-07-22 09:16:18 | 3 | 11,062 | ignoring_gravity |
78,777,829 | 5,269,892 | PyCharm breakpoint in Ipython console not triggering | <p>I have two python scripts, <em>test_breakpoints.py</em> and <em>test_breakpoints_import.py</em> (see below), with breakpoints set in <em>PyCharm</em>. The former script imports a function from the latter.</p>
<p>When using the interactive console (IPython), connecting the debugger, and running code (via Alt+Shift+e)... | <python><pycharm><breakpoints> | 2024-07-22 09:10:29 | 0 | 1,314 | silence_of_the_lambdas |
78,777,372 | 16,723,655 | Pydub library has an error with version check | <p>I am just curious why only this library has an error of version check.</p>
<p>Below is the code.</p>
<pre><code>import pydub
print('Pydub version: ', pydub.__version__)
</code></pre>
<p>I got the error as below.</p>
<pre><code>AttributeError: module 'pydub' has no attribute '__version__'
</code></pre>
<p>Other libra... | <python><version><pydub> | 2024-07-22 07:15:17 | 1 | 403 | MCPMH |
78,777,096 | 972,647 | Python: Submitting and tracking many subprocesses leads to "stuck" subprocesses | <p>I have an 3rd party cli executable I need to call from my python code. These are heavy calculations (cpu) and there are around 50-100 times I need to call it. The executable itself is to some degree multi-threaded but not all steps and I have a lot of cores available.</p>
<p>This means I want to have multiple subpro... | <python><popen> | 2024-07-22 05:42:54 | 2 | 7,652 | beginner_ |
78,777,074 | 1,488,641 | Uploaded media doesn't server in production mode without restarting django | <p>I need to serve media in Django in production mode and it is very little need to serve telegram user photos in Django admin. so I know everything about Django it's not for serving files or media so there is no need to repeat repetitive things. I just need to serve media in production mode for my purpose so I use Whi... | <python><django><webserver><django-media><whitenoise> | 2024-07-22 05:33:28 | 1 | 435 | minttux |
78,776,546 | 3,486,684 | How do I type annotate a variable that stores a type annotation? | <p>Suppose I have:</p>
<pre class="lang-py prettyprint-override"><code>x: type = Optional[str] # <--- type error
</code></pre>
<p>This results in the type error:</p>
<pre><code>Expression of type "UnionType" is incompatible with declared type "type"
"UnionType" is incompatible with &q... | <python><python-typing><pyright> | 2024-07-21 23:20:54 | 1 | 4,654 | bzm3r |
78,776,507 | 3,486,684 | How to inherit (from a parent class) dataclass field introspection functionality? | <p>I have a parent dataclass, and various other classes will then extend this parent dataclass. Let's call these dataclasses <code>DC</code>s. In the example code below, see <code>ParentDC</code>, and an example <code>ChildDC</code>:</p>
<pre class="lang-py prettyprint-override"><code>from dataclasses import dataclass,... | <python><inheritance><python-dataclasses><python-class> | 2024-07-21 22:53:44 | 1 | 4,654 | bzm3r |
78,776,495 | 3,486,684 | No hang when stepping manually through problematic code; otherwise, it hangs. What tools does the editor + debugger have to examine? | <p>I have a problematic section of code. The start of the section is decorated with a print statement, as is the end:</p>
<pre class="lang-py prettyprint-override"><code>print("starting problematic section") # <-- breakpoint set here
# various calls # <--- program hangs somewhere here if not manually s... | <python><visual-studio-code><debugging> | 2024-07-21 22:40:26 | 0 | 4,654 | bzm3r |
78,776,454 | 3,329,877 | NumPy successive matrix multiplication vectorization | <p>I have a NumPy array <code>ar</code> of shape <code>(M, L, 2, 2)</code>. <code>M</code> is usually in the hundreds or thousands, <code>L</code> is usually <code><= 5</code>.</p>
<p>I want to multiply the <code>L</code> <code>(N, N)</code> matrices successively (<code>multiplied_ar[m] = ar[m, 0, :, :] @ ar[m, 1, :... | <python><numpy><numpy-ndarray><matrix-multiplication><numpy-einsum> | 2024-07-21 22:08:23 | 1 | 397 | VaNa |
78,776,354 | 3,437,787 | How to fill missing values based on relationships between existing data | <h2>Question</h2>
<p>How to fill missing values of a pandas dataframe based on the relationship between an existing preceeding row (predictions for a commodity), and an associated existing value in another column (actual values for a commodity).</p>
<h2>Details</h2>
<p>I have a pandas dataframe with 10 columns and 40 r... | <python><pandas><missing-data> | 2024-07-21 21:09:55 | 3 | 62,064 | vestland |
78,776,334 | 13,559,669 | pd.to_datetime() not working for old dates | <p>When trying to convert the "Date" field of a pandas DataFrame using pd.to_datetime(), I get an "OutOfBoundsDatetime" error only when the date is before Year 1700 (otherwise the conversion works fine). Any help?</p>
<pre><code>df = pd.read_excel('Timeline_SecondMillenialH2.xlsx')
df['Date'] = pd.t... | <python><pandas><dataframe><datetime><python-datetime> | 2024-07-21 20:54:03 | 0 | 436 | el_pazzu |
78,776,284 | 3,579,212 | How to register Django hooks with PyInstaller | <p>I want to use the Django <a href="https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/hooks/hook-django.py" rel="nofollow noreferrer">hooks</a> in Pyinstaller. I have tried the following:</p>
<pre><code> python -m PyInstaller
--runtime-hook='hook-django.contrib.sessions.py'
--r... | <python><django><pyinstaller> | 2024-07-21 20:21:22 | 2 | 3,664 | adnanmuttaleb |
78,776,268 | 3,486,684 | How can I efficiently `fill_null` only certain columns of a DataFrame? | <p>For example, let us say I want to <code>fill_null(strategy="zero")</code> only the numeric columns of my DataFrame. My current strategy is to do this:</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
import polars.selectors as cs
df = pl.DataFrame(
[
pl.Series("id&q... | <python><python-polars> | 2024-07-21 20:11:25 | 1 | 4,654 | bzm3r |
78,776,267 | 4,974,980 | Blocking OpenAI Requests | <p>After multiple attempts at this myself along with numerous ChatGPT and Claude queries, I am throwing my hands up and asking StackOverflow what would seem to be an easy question:</p>
<p>How does one block OpenAI, at the global level, from making HTTP requests when testing using pytest?</p>
<p>Things I have tried (and... | <python><unit-testing><openai-api><azure-openai> | 2024-07-21 20:10:36 | 0 | 2,454 | Jens Astrup |
78,776,035 | 19,251,893 | nlst times out while connecting FTPS server with Python | <p>I can login to with Total Commander to<br />
server: ftps://publishedprices.co.il<br />
username: "XXXX"<br />
password empty</p>
<p>And with</p>
<pre><code>lftp -u XXXX: publishedprices.co.il
</code></pre>
<p>But when I tried to login and get the file list with Python on the same machine the <code>nlst</c... | <python><python-3.x><ftp><ftplib><ftps> | 2024-07-21 18:19:44 | 1 | 345 | python3.789 |
78,775,967 | 1,649,171 | One project (Django 3 with mod_wsgi installed within py 3.8 venv) works but another (Django 5 with mod_wsgi installed within py 3.12) fails | <p><strong>Issue:</strong> Internal Server Error with Django and mod_wsgi on Ubuntu Server</p>
<p><strong>Setup:</strong></p>
<ul>
<li>Ubuntu 20.04</li>
<li>Python 3.8 for existing project (and the base python for the OS too)</li>
<li>Python 3.12.4 for new project</li>
<li>Apache</li>
<li>mod_wsgi installed in respecti... | <python><django><apache><ubuntu><mod-wsgi> | 2024-07-21 17:53:18 | 0 | 910 | Ken |
78,775,890 | 13,215,289 | How to relay and stream HTTP response chunks directly using httpx and FastAPI? | <p>I'm working on a relay handler using <code>httpx</code> and FastAPI to stream HTTP response chunks directly from an upstream server to a client. The goal is to send each chunk of the streamed response directly as it is received, instead of buffering all data and sending it at the end.</p>
<p><strong>Here's what I've... | <python><http><fastapi><http-streaming><httpx> | 2024-07-21 17:25:51 | 1 | 542 | leon |
78,775,683 | 110,963 | Change title (verbose name plural) in custom admin.TabularInline | <p>In my Django admin UI I use a <code>TabularInline</code> like this:</p>
<pre><code>class MyCustomInline(admin.TabularInline):
# ...
def get_queryset(self, request):
# ...
</code></pre>
<p>The overridden functions adds a filter, so that only a subset of related objects is displayed. In the admin UI I ... | <python><django><django-admin> | 2024-07-21 16:00:54 | 1 | 15,684 | Achim |
78,775,434 | 19,381,612 | How do create a new line break in python-doxc that has a specified character size? | <p>I currently have a paragraph as a header that is <code>Pt48</code> in size and I want to create a new line break using <code>add_break()</code> which works perfectly fine but it inherits the top paragraph character size. Is there a way to specify the new line break character size. I've look at the documentation and ... | <python><python-docx> | 2024-07-21 14:20:29 | 1 | 1,124 | ThisQRequiresASpecialist |
78,775,408 | 6,703,592 | dataframe filter groupby based on a subset | <pre><code>df_example = pd.DataFrame({'name': ['a', 'a', 'a', 'b', 'b', 'b'],
'class': [1, 2, 2, 3, 2, 2],
'price': [3, 4, 2, 1, 6, 5]})
</code></pre>
<p>I want to filter each <code>name</code> where the <code>price</code> is larger than the smallest <code>price</code... | <python><pandas><dataframe><group-by> | 2024-07-21 14:06:28 | 3 | 1,136 | user6703592 |
78,775,364 | 16,527,170 | Pandas - Convert Multiple colums to rows in Dataframe | <p>I have df as below:</p>
<pre><code>import pandas as pd
import numpy as np
data = {
'NIFTYBEES.NS': [0.26, 0.18],
'abc.NS': [0.1, 0.1],
'NIFTYBEES.NS_pct_change': [0.86, -0.21],
'abc.NS_pct_change': [0.2, 0.2],
'avg': [0.4775, 0.76],
'weekday': ['Monday', 'Tuesday']
}
Date = pd.date_range('202... | <python><pandas><dataframe> | 2024-07-21 13:47:25 | 2 | 1,077 | Divyank |
78,775,326 | 16,883,182 | How to generically type-annotate a fuction/method parameter to accept any real number type? | <p>I would like to write a generic function that takes an instance of any type that implements all real number operations (such as <code>int</code>, <code>float</code>, <code>fractions.Fraction</code>, or third-party types). I found the <code>numbers.Real</code> ABC which works great for enforcing the type at runtime w... | <python><python-typing> | 2024-07-21 13:30:24 | 1 | 315 | I Like Python |
78,775,207 | 22,886,184 | Cloud Run - Authenticated request doesn't work on custom (sub)domain | <p>I have a Cloud Run service running with authenticated requests turned on. I've created a domain mapping using Load Balancing to point a subdomain to the container.</p>
<p>I have been sending requests to the direct container url without any problems.</p>
<pre class="lang-py prettyprint-override"><code>import os
from ... | <python><google-cloud-platform><google-cloud-run> | 2024-07-21 12:39:55 | 1 | 537 | Victor |
78,775,206 | 4,306,274 | How to plot a line on the second axis over a HORIZONTAL (not VERTICAL) bar chart with Matplotlib? | <p>I know how to plot a line on the second axis over a VERTICAL bar chart.</p>
<p>Now I want the bars HORIZONTAL and the line top-to-bottom, just like the whole chart rotates 90°.</p>
<p>If I simply replace <code>bar</code> with <code>barh</code>, the line is still left-to-right...</p>
<p>Can I do this with Matplotlib?... | <python><pandas><matplotlib> | 2024-07-21 12:39:43 | 1 | 1,503 | chaosink |
78,775,101 | 828,647 | Iterate through child elements in robot framework | <p>I have a list of users on a webpage like this</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><div id="users">
<li class="user_list">
<div c... | <python><selenium-webdriver><robotframework> | 2024-07-21 11:51:25 | 1 | 515 | user828647 |
78,774,956 | 13,132,640 | Vectorize a sampling of a dataframe based on filtered conditions? | <p>I have two dataframes, one which has three variables (one discrete, two continuous) and the other which has the same, except with also an additional 4th variable. For the purposes of a minimum reproducible example, I use random data, but in reality these variables are related to each other.</p>
<p>Anyway, for the fi... | <python><pandas><vectorization> | 2024-07-21 10:42:30 | 2 | 379 | user13132640 |
78,774,602 | 739,809 | How to parallelize transformer model for machine translation on 8 GPUs? | <p>I am attempting to perform machine translation using a transformer model in a manner almost identical to the original article. While the model works reasonably well, it requires greater computational resources. To address this, I ran the model on a computer with 8 GPU processors, but I lack experience in this area.
... | <python><machine-learning><parallel-processing> | 2024-07-21 07:14:42 | 0 | 2,537 | dsb |
78,773,967 | 5,626,776 | Module import error for PYTHON_PYLINT when using super-linter/super-linter@v6.7.0 | <p>I've been working on getting super-linter within a GitHub Action to accept my recent Python project import for a while now without success. I am using <code>py3langid</code> to detect English language in a pretty basic Caesar Cipher implementation.</p>
<p>The linting error is:</p>
<pre><code>PYTHON_PYLINT
2024-07-20... | <python><python-3.x><github-actions><super-linter> | 2024-07-20 21:45:48 | 1 | 925 | PumpkinBreath |
78,773,889 | 11,443,551 | TRL SFTTrainer clarification on truncation | <p>I am currently finetuning LLama models using SFTTrainer in huggingface. However, I came up with a question, I can not answer through the documentations (atleast, it is a bit ambigious).</p>
<p>My dataset contains samples from 20 tokens to 5k tokens.</p>
<p>Currently I am using a <code>max_seq_length=512,</code> and ... | <python><large-language-model><huggingface><llama> | 2024-07-20 20:46:23 | 0 | 369 | iiiiiiiiiiiiiiiiiiii |
78,773,843 | 893,254 | How to handle external dependencies like datetime.now() in FastAPI tests? | <p>I have some existing FastAPI tests which no longer pass, because some internal server logic has changed such that there is now a dependency on a value returned by <code>datetime.now()</code>.</p>
<p>This is an external dependency. Normally to handle external dependencies, we would write a mock implementation of the ... | <python><python-3.x><fastapi> | 2024-07-20 20:24:24 | 1 | 18,579 | user2138149 |
78,773,780 | 1,179,689 | BrokenPipeError when using python print with gdb | <p>I am trying to run an application in Linux and generate the input with Python:</p>
<pre><code>python3 -c 'print(".....")' | ./someapp
</code></pre>
<p>but getting the next error:</p>
<pre><code>Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>
BrokenPipeError: ... | <python> | 2024-07-20 19:56:58 | 1 | 2,708 | yehudahs |
78,773,489 | 11,748,924 | Combine three trained binary classification models into single multiclassification model in keras | <p>I have three trained binary classification models, they are trained with <strong>sigmoid</strong> activation at output layer.</p>
<ol>
<li>First model returning probability scalar from 0 to 1 to check whether image is number <strong>ZERO</strong> or not.</li>
<li>Second model returning probability scalar from 0 to 1... | <python><tensorflow><machine-learning><keras><deep-learning> | 2024-07-20 17:44:05 | 1 | 1,252 | Muhammad Ikhwan Perwira |
78,773,339 | 2,612,259 | Is there a way to keep the context of a context manager local to the as block? | <p>I am trying to find a way to avoid having to create a bunch of names for some functions that I pass into another function. I realize that if the functions were just simple expressions then I could just pass in lambdas and avoid creating named functions, but in many cases they are longer functions needing statements... | <python> | 2024-07-20 16:37:47 | 1 | 16,822 | nPn |
78,773,176 | 11,626,909 | How to ignore or bypass instances that result in NoneType non-iterable object | <p>I am trying to parse a section from 10K in Edgar database, when I run the following code,</p>
<pre><code># pip install edgartools
import pandas as pd
from edgar import *
# Tell the SEC who you are
set_identity("Your Name youremail@outlook.com")
filings2 = get_filings(form='10-K', amendments=False,
filing... | <python><edgar> | 2024-07-20 15:32:29 | 1 | 401 | Sharif |
78,773,065 | 4,701,426 | Lists in pandas dataframe cells | <p>If we have a (part of a bigger) dataframe that shows what states individuals (rows) visited in a trip:</p>
<pre><code>df = pd.DataFrame({'states_visited': [['NY', 'CA'], 'CA', 'CA']}, index = ['John', 'Mary', 'Joe'])
states_visited
John [NY, CA]
Mary CA
Joe CA
</code></pre>
<p>Because the <code>st... | <python><pandas> | 2024-07-20 14:45:42 | 2 | 2,151 | Saeed |
78,773,026 | 1,391,441 | Hide warnings and/or errors when importing Keras | <p>My script imports the following <a href="https://keras.io/" rel="nofollow noreferrer">Keras</a> modules:</p>
<pre><code>from keras.models import Sequential
from keras.layers import Dense, Input
from keras.utils import to_categorical
</code></pre>
<p>and every time the same warnings/errors are shown:</p>
<pre><code>2... | <python><tensorflow><keras> | 2024-07-20 14:27:59 | 1 | 42,941 | Gabriel |
78,772,912 | 21,376,217 | Why does `ssl.SSLContext.wrap_socket` cause socket to close? | <p>I found some "strange" phenomena when using Python for network programming.</p>
<p>After constructing the SSL context and obtaining the SSL socket, the original socket will be automatically closed. Why is this? Is there any need to do this?</p>
<p>Just like the following code:</p>
<p>main.py</p>
<pre class... | <python><sockets><ssl> | 2024-07-20 13:36:21 | 1 | 402 | S-N |
78,772,897 | 3,225,420 | How to store nested lists in Postgres? | <p>How can I store nested lists in <code>Postgres</code> in way that's easy to use them in my <code>Python</code> program later?</p>
<p>I plan to write the lists to the database once and reuse them many times. I've been able to store the nested lists as a <code>string</code> but it's not optimal, I'm trying to accompl... | <python><postgresql><nested-lists> | 2024-07-20 13:28:38 | 1 | 1,689 | Python_Learner |
78,772,795 | 6,657,842 | What is the Python code to check all the GenerativeAI models supported by Google Gemini? | <p>Being new to <strong>GenerativeAI</strong> world, I am trying to load a pre-trained text generation model and doing some stuff which is not working. This is how I load the <strong>GenerativeAI</strong> model.</p>
<pre><code>from vertexai.generative_models import GenerativeModel
generation_model = GenerativeModel(&qu... | <python><google-cloud-platform><google-gemini><google-generativeai> | 2024-07-20 12:43:31 | 3 | 2,025 | RLD |
78,772,666 | 3,107,798 | How to start consuming messages from specific offset using Confluent Kafka Python consumer | <p>Using the <a href="https://docs.confluent.io/platform/current/clients/confluent-kafka-python/html/index.html#pythonclient-consumer" rel="nofollow noreferrer">Confluent Kafka Python consumer</a>, how do I start consuming from a specific offset? At first I was going use the <a href="https://docs.confluent.io/platform/... | <python><apache-kafka><confluent-kafka-python> | 2024-07-20 11:51:12 | 1 | 11,245 | jjbskir |
78,772,435 | 4,447,899 | The AWS SAM common layer can't find the modules | <p>I have the follow directory structure:</p>
<pre><code>common =>
__init__.py
common.py
customer =>
app.py
template.yaml
</code></pre>
<p>My template looks like this:</p>
<pre><code>AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Resources:
CommonLayer... | <python><aws-lambda><aws-sam><aws-sam-cli> | 2024-07-20 10:00:37 | 0 | 342 | user4447899 |
78,772,431 | 13,562,186 | Load 2 Tkinter windows simultaneously. one with animation | <p>The following script runs standalone to run a scenario:</p>
<p>The results are printed first, followed by the plot is closed with an animation.</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
import tkinter as tk
from tkinter import ttk
from matplotlib.animation import FuncAnimation
def run_model(... | <python><matplotlib><tkinter><tkinter-canvas><matplotlib-animation> | 2024-07-20 09:59:10 | 1 | 927 | Nick |
78,771,991 | 17,947,699 | How to add value to mood in an mp3 file via mutagen (Python)? | <p>I couldn't find a way to write mood to an mp3 file via mutagen (Python library)</p>
<p>Initializing:</p>
<pre><code>from mutagen.mp3 import MP3
from mutagen.id3 import ID3, TIT2, TALB, TPE1, TPE2, TCON, TPUB, TENC, TIT3, APIC, WOAR, PRIV
audio = MP3(mp3_file, ID3=ID3)
</code></pre>
<p>I could write the subtitle usin... | <python><python-3.x><mp3><id3><mutagen> | 2024-07-20 06:13:26 | 0 | 374 | Parijat Softwares |
78,771,514 | 395,857 | How can I export all submission attachments with the OpenReview API? | <p>I have access to the program chairs console of a venue in OpenReview. I followed <a href="https://docs.openreview.net/how-to-guides/data-retrieval-and-modification/how-to-export-all-submission-attachments" rel="nofollow noreferrer">https://docs.openreview.net/how-to-guides/data-retrieval-and-modification/how-to-expo... | <python><download><openreview> | 2024-07-19 23:59:11 | 0 | 84,585 | Franck Dernoncourt |
78,771,443 | 9,779,026 | Maximizing sum of And()ed BoolVars in Python ortools | <p>Given a set of cards, I have a list of combos that each involve one or more of these cards. I want to find a subset of these cards of a fixed size (<code>DECKSIZE</code>), that optimizes the number of combos that can be played using the chosen cards (the number of combos that include only the chosen cards is maximiz... | <python><optimization><or-tools><cp-sat> | 2024-07-19 23:09:32 | 1 | 1,437 | 2080 |
78,771,249 | 3,486,684 | Given a type `ScalarOrList` defined `ScalarOrList[T] = T | list[T]`, static check refuses `input: list[str]` for `arg: ScalarOrList[str | int]`? | <p>I had:</p>
<pre class="lang-py prettyprint-override"><code>from typing import Optional
type ScalarOrList[T] = T | list[T]
def as_list[T](xs: Optional[ScalarOrList[T]], length: int = 1) -> list[T]:
if isinstance(xs, Sequence) and not isinstance(xs, str):
return list(x for x in xs)
elif xs is not... | <python><python-typing><pyright> | 2024-07-19 21:20:30 | 1 | 4,654 | bzm3r |
78,771,213 | 3,826,115 | Downloading from THREDDS Data Server fails when running in parallel, but works when running in series | <p>I am attempting to download/subset a list of gridded parameters from the UCAR THREDDS servers.</p>
<p>Here is how I am setting things up:</p>
<pre><code>import pandas as pd
import xarray as xr
import concurrent.futures
from functools import partial
from tqdm import tqdm
from siphon.catalog import TDSCatalog
bounds ... | <python><thredds><python-siphon> | 2024-07-19 21:04:08 | 1 | 1,533 | hm8 |
78,770,947 | 12,027,869 | Map Dataframe Column Values Based on Two Dictionaries Conditionally | <p>I have a dataframe <code>df_test</code>. I want to map the column <code>color</code> conditionally:</p>
<ul>
<li>if <code>category</code> is <code>'tv</code>', then map using the <code>tv_map</code> dictionary</li>
<li>else map using the <code>radio_map</code> dictionary</li>
</ul>
<p>I could split <code>df_test</co... | <python><pandas> | 2024-07-19 19:27:42 | 2 | 737 | shsh |
78,770,943 | 8,479,386 | Banner is not displaying at the top and css is not working | <p>I have html like following, in my Django project</p>
<pre><code><!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Index ... | <javascript><python><html><css><django> | 2024-07-19 19:26:53 | 2 | 866 | Karan |
78,770,897 | 1,788,771 | Filtered reverse of a one to many relation in Django | <p>I have a model called <code>Item</code> and another called <code>ItemSynonym</code> with a one to many relation like so:</p>
<pre class="lang-py prettyprint-override"><code>from django.db import models
from django.conf import settings
from project.utils.models import UUIDModel
class Item(UUIDModel):
name = mo... | <python><django><django-models><orm> | 2024-07-19 19:10:43 | 1 | 4,107 | kaan_atakan |
78,770,569 | 13,849,446 | Converting pigpio code to Gpiod library python | <p>I have the following code of <a href="https://abyz.me.uk/rpi/pigpio/" rel="nofollow noreferrer">pigpio</a> library and I have to convert it's functionality using <a href="https://pypi.org/project/gpiod/" rel="nofollow noreferrer">gpiod</a> library. Where pigpio has a good documentation I can understand the working o... | <python><python-3.x><libgpiod><pigpio><gpiod> | 2024-07-19 17:23:06 | 0 | 1,146 | farhan jatt |
78,770,408 | 5,431,734 | cannot create a storer when reading an hdf5 filre with `dd.read_hdf` | <p>I want to use a dask dataframe to load a pandas dataframe using the <code>dd.read_hdf()</code> method. I create a very basic pandas dataframe, then I separate the values from column headers and index and I save them in an hdf5 file. I can read the hdf5 file and recreate the orinal dataframe, that loos ok</p>
<p>I ca... | <python><dask> | 2024-07-19 16:35:54 | 0 | 3,725 | Aenaon |
78,770,327 | 8,507,034 | Read/Write pipeline in pandas | <p>I'm building a simple pipeline to pull a dataset from a database and write it to a csv so that I can access the data more quickly in the future.</p>
<p>Currently, I have this:</p>
<pre><code># data loading as a pipeline
# ingests and writes batches of CHUNK_SIZE
CHUNK_SIZE = 10_000
data_loader = pd.read_sql(sql=SQL,... | <python><pandas><parallel-processing><file-io><export-to-csv> | 2024-07-19 16:15:15 | 1 | 315 | Jred |
78,770,307 | 1,833,218 | sharex and imshow do not produce plots of the same width | <p><strong>Context:</strong> I have the x,y and x,z projection of an image. I want the two images to be stacked vertically sharing the same width.</p>
<p><strong>My trial:</strong> I tried the following:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
import matplotlib.pyplot as plt
N1, N2 = 256... | <python><numpy><matplotlib> | 2024-07-19 16:09:55 | 2 | 2,317 | Antonio Ragagnin |
78,770,272 | 12,553,917 | Redirecting python script's stdin to fifo results in RuntimeError: input(): lost sys.stdin | <p>I have this python script that's meant to function as a server which reads commands from stdin which is redirected to a fifo:</p>
<p>test.py:</p>
<pre class="lang-py prettyprint-override"><code>while True:
try:
line = input()
except EOFError:
break
print(f'Received: {line}')
</code></pre... | <python><bash><mingw><fifo><mkfifo> | 2024-07-19 16:00:49 | 0 | 776 | Verpous |
78,770,245 | 6,618,289 | shiboken6: constexpr variable must be initialized by a constant expression | <p>I am trying to build some python wrappers using shiboken6 and Pyside6. I have managed to get the code compiling on a single machine, but now that I migrated the code to a build server, I am getting a compile error from within the shiboken compiler:</p>
<blockquote>
<p>QtCore/qplugin.h(146,33): error G3F63BFAE: const... | <python><c++><qt><pyside6> | 2024-07-19 15:53:15 | 1 | 925 | meetaig |
78,770,236 | 4,538,529 | Calling python "concurrent.futures" multiprocessing from C# opens multiple winform instances of the application | <ul>
<li>pythonnet by Python.Runtime 3.0.3 (Installed the winform application in Visual Studio 2022)</li>
<li>adfuller_test.py (This is my python script file)</li>
</ul>
<hr />
<p>I am calling python code from a winform application which works great normally.</p>
<p>The problem that I encounter now is that when I now t... | <python><c#><winforms><concurrent.futures><python.net> | 2024-07-19 15:49:23 | 0 | 1,295 | Andreas |
78,770,228 | 6,328,506 | Ensuring at least one required field in a TypedDict in Python | <p>Giving the following code:</p>
<pre class="lang-py prettyprint-override"><code>from typing_extensions import NotRequired, TypedDict, Unpack
class LoginParams(TypedDict):
url: NotRequired[str]
username: NotRequired[str]
password: NotRequired[str]
api_key: NotRequired[str]
def do_login(**kwargs: Unpa... | <python><python-typing> | 2024-07-19 15:47:24 | 0 | 416 | Kafka4PresidentNow |
78,770,134 | 7,380,827 | Why is the 'limit' limit of maximum recursion depth in python 2**32 / 2 - 31? | <p>In Python, some programs create the error <code>RecursionError: maximum recursion depth exceeded in comparison</code> or similar.</p>
<p>This is because there is a limit set for how deep the recursion can be nested.</p>
<p>To get the current value for maximum recursion depth, use</p>
<pre class="lang-py prettyprint-... | <python><recursion> | 2024-07-19 15:21:02 | 1 | 534 | Twistios_Player |
78,770,117 | 8,964,393 | How to calculate the Relative Strength Index (RSI) through record iterations in pandas dataframe | <p>I have created a pandas dataframe as follows:</p>
<pre><code>import pandas as pd
import numpy as np
ds = { 'trend' : [1,1,1,1,2,2,3,3,3,3,3,3,4,4,4,4,4], 'price' : [23,43,56,21,43,55,54,32,9,12,11,12,23,3,2,1,1]}
df = pd.DataFrame(data=ds)
</code></pre>
<p>The dataframe looks as follows:</p>
<pre><code>display... | <python><pandas><dataframe><loops><iterator> | 2024-07-19 15:17:30 | 2 | 1,762 | Giampaolo Levorato |
78,770,116 | 2,132,593 | Limit Horizontal Scrolling in Dash DataTable with multi-level header (no Extra Blank Space) | <p>I'm building a Dash app using Plotly that displays two tables <code>dash_table.DataTable</code> with many columns. The first table has multi-level header.</p>
<p>The first columns of each table are fixed and horizontal scrolling is enabled for the remaining columns.</p>
<p>I'm experiencing an issue when scrolling ho... | <python><css><plotly-dash> | 2024-07-19 15:17:28 | 1 | 1,964 | Giacomo |
78,770,111 | 1,304,376 | better way of initializing python object method variables with object variable values if not passed in | <p>I have many object methods where I can pass in values, but want to be able to default them to the object variable if not passed. Something like this example that I came up to illustrate what I want to do:</p>
<pre><code>from datetime import datetime
class Appointment :
def __init__(self, resource, startTime:dateti... | <python> | 2024-07-19 15:16:14 | 1 | 1,676 | Ching Liu |
78,770,014 | 188,331 | How to use HuggingFace's run_translation.py script to train a translation from scratch? | <p>I tried various HuggingFace scripts to build language models, such as <code>run_mlm.py</code> (<a href="https://github.com/huggingface/transformers/blob/main/examples/pytorch/language-modeling/run_mlm.py" rel="nofollow noreferrer">link</a>), <code>run_clm.py</code> (<a href="https://github.com/huggingface/transforme... | <python><huggingface-transformers> | 2024-07-19 14:53:00 | 1 | 54,395 | Raptor |
78,769,948 | 5,189,215 | Slow __repr__ calculation for one of Python classes slows down the jupyter notebook debugger in VSCode | <p>I am trying to debug some code in VSCode Jupyter Notebook.
I get the following warning:</p>
<pre><code>pydevd warning: Computing repr of Out (dict) was slow (took 6.62s)
Customize report timeout by setting the `PYDEVD_WARN_SLOW_RESOLVE_TIMEOUT` environment variable to a higher timeout (default is: 0.5s)
</code></pre... | <python><visual-studio-code> | 2024-07-19 14:35:24 | 0 | 1,102 | Maksim Gayduk |
78,769,892 | 5,188,353 | Wrong greeks (delta, vega, ...) results when requesting data using reqMktData | <p>I am using the native library ibapi (Interactive Brokers). I have the following code:</p>
<pre class="lang-py prettyprint-override"><code> from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import Contract
import threading
import time
class TradingApp(EWra... | <python><algorithmic-trading><interactive-brokers><ib-api> | 2024-07-19 14:21:39 | 1 | 675 | clex |
78,769,876 | 4,701,426 | Filtering a pandas series consisting of lists and NaN values if the elements contain a string | <p>Let's consider this dataframe:</p>
<pre><code>temp = pd.DataFrame({'x': [['ab', 'bc'], ['hg'], np.nan]})
temp
x
0 [ab, bc]
1 [hg]
2 NaN
</code></pre>
<p>I'd like to create a new column called <code>dummy</code> that takes the value of 1 if a row contains letter 'a' in any of its elements, value of 0 if it... | <python><pandas> | 2024-07-19 14:18:19 | 1 | 2,151 | Saeed |
78,769,837 | 7,206,559 | How do I compose or chain multiple function in Python | <p>When writing a program, I often want to perform a series of steps on a piece of data (usually a list or string). For example I might want to call a function which returns a string, convert it to a list, map over the list, and then reduce to get a final result.</p>
<p>In programming languages I've used in the past, I... | <python><python-3.x><method-chaining><function-composition> | 2024-07-19 14:10:07 | 2 | 899 | David Moneysmith |
78,769,769 | 1,484,601 | python typing TypeVar: understanding unbound error | <p>I do not understand error like</p>
<blockquote>
<p>Type variable "T" is unbound</p>
</blockquote>
<p>Here a concrete example:</p>
<pre class="lang-py prettyprint-override"><code>from typing import Dict, Type, Callable, TypeVar
class Sup: ...
class A(Sup): ...
class B(Sup): ...
def get_A(a: A) -> int:
... | <python><python-typing><type-variables> | 2024-07-19 13:55:30 | 1 | 4,521 | Vince |
78,769,759 | 6,128,612 | Jupyter notebook lost syntax highlithing | <p>After creating environments (ubuntu VM) Jupyter Notebook lost highlighting of code syntax for some reason. Highlighting is now unavailable for all environments. How to fix that? Below you can see my language syntax highlighting is grayed out and below how my code looks right now.</p>
<p><a href="https://i.sstatic.ne... | <python><jupyter-notebook> | 2024-07-19 13:53:40 | 0 | 343 | Alexandros |
78,769,746 | 200,783 | Why does mypy give an error: Generator has incompatible item type "Sequence[str]"? | <p>I've used mypy to type-check <code>rbast.py</code> from <a href="https://medium.com/workpath-thewaywework/learning-ruby-2-things-i-like-2-things-i-miss-from-python-6f60af8ed16c" rel="nofollow noreferrer">this post</a>:</p>
<p><a href="https://mypy-play.net/?mypy=latest&python=3.12&gist=19931c644949c29b715b79... | <python><mypy> | 2024-07-19 13:50:52 | 1 | 14,493 | user200783 |
78,769,678 | 3,932,263 | VSCode autosuggest python imports without relying on Intellisense | <p>This is explicitly about not using pylance/intellisense because it is broken sometimes, and would be easier to fix through text matching by identifying common names with hardcoded import statements.</p>
<p>I am using objects like AutoModel from the transformers and frequently come across objects that the auto-import... | <python><visual-studio-code><python-import><intellisense> | 2024-07-19 13:35:48 | 1 | 1,399 | Maximilian Mordig |
78,769,542 | 1,484,601 | Type hints for a callable taking a subclass type as argument | <p><code>A</code> and <code>B</code> are sub-classes of <code>Sup</code>. These functions are defined:</p>
<pre class="lang-py prettyprint-override"><code>def get_A_report(a: A) -> int
def get_B_report(b: B) -> int
</code></pre>
<p>What are the correct typing hints for <code>f</code>?</p>
<pre class="lang-py pre... | <python><python-typing> | 2024-07-19 13:08:28 | 0 | 4,521 | Vince |
78,768,949 | 1,818,935 | A seemingly stopped HTTP service continues to work | <p>I wrote a python function, detailed <a href="https://stackoverflow.com/a/78768222/1818935">in another post</a>, which communicates with an HTTP-based <a href="https://rumbledb.org/" rel="nofollow noreferrer">RumbleDB</a> server, running on my local machine, in order to evaluate <a href="https://www.jsoniq.org/" rel=... | <python><windows><apache-spark><http><git-bash> | 2024-07-19 10:47:20 | 1 | 6,053 | Evan Aad |
78,768,907 | 2,107,030 | split pandas datafram based on given row string | <p>I have a text file with a data set of the form</p>
<pre><code>Line 1
Line 2
!
1.01499999 0.504999995 6.19969398E-7 5.38933136E-7 1.35450875E-6
1.74000001 0.220000029 7.92876381E-6 4.1831604E-6 6.61433387E-6
2.10750008 0.147500038 2.06282803E-5 9.86384475E-6 9.99511121E-6
2.54500008 0.289999962 1.9321451E-5 9.412... | <python><pandas><dataframe><split> | 2024-07-19 10:37:40 | 1 | 2,166 | Py-ser |
78,768,827 | 240,443 | A local variable seemingly breaking scope in Django | <p>I have introduced this function in a file <code>storage.py</code> that is imported from <code>models.py</code>:</p>
<pre><code>def uuid_file_name(kind):
def file_name(instance, filename):
h = str(uuid.uuid4())
basename, ext = os.path.splitext(filename)
return os.path.join(f'{kind}_files',... | <python><django><scope> | 2024-07-19 10:19:35 | 0 | 199,494 | Amadan |
78,768,753 | 13,942,929 | Cython - How do we implement Tuple of Object in Cython? | <p>I want to implement tuple of object in my cython project.
I couldn't find a way to implement in <code>.pyx</code> file so that I can use it in python.</p>
<p>You can check my <code>get_language</code> method for some reference.</p>
<p>And please help me with my <code>get_value</code> method which has <code>tuple of ... | <python><c++><cython><cythonize> | 2024-07-19 10:04:49 | 1 | 3,779 | Punreach Rany |
78,768,062 | 9,097,114 | Isuues with pyinstaller (Module Not found) | <p>I have created a Python (.PY) file thatuses the Tkinter package inside it and executes perfectly in Spyder.</p>
<p>Now I am trying to convert it to .EXE file using pyinstaller package, once I convert tried to run and got the below error:</p>
<p><a href="https://i.sstatic.net/FyaoN74V.png" rel="nofollow noreferrer"><... | <python><python-3.x><tkinter> | 2024-07-19 07:26:03 | 1 | 523 | san1 |
78,767,993 | 11,756,186 | Shift part of row in dataframe to new row | <p>I have a dataframe (pandas) that I want to transform for displaying purposes.
Therefore I want to shift some parts of the dataframe to new rows like below :</p>
<pre><code> col1 col2 col_to_shift col_not_to_shift1 col_not_to_shift2
0 a1 a2 a3 a4 a5
1 b1 b2 Na... | <python><pandas><dataframe> | 2024-07-19 07:09:24 | 4 | 681 | Arthur |
78,767,971 | 9,879,534 | Why does `timezone` not work in `sqlmodel`? | <p>I'm using <code>sqlmodel</code> to do sql-orm. I learned from <a href="https://stackoverflow.com/questions/75350395/how-should-we-manage-datetime-fields-in-sqlmodel-in-python">this page</a> and <a href="https://github.com/tiangolo/sqlmodel/issues/370" rel="nofollow noreferrer">this page</a>, but both failed, the tim... | <python><sqlmodel> | 2024-07-19 07:04:09 | 1 | 365 | Chuang Men |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.