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 ⌀ |
|---|---|---|---|---|---|---|---|---|
75,644,550 | 12,226,377 | Rule based extraction from a pandas string using NLP | <p>I have a sit-in where I am performing a keyword extraction and building a category on top of it which is working fine as I am able to do a <code>str.contains</code> for a single keyword.
But what if I want to use a string of keywords and build multiple sub categories on top of it. For example from the column Text I ... | <python><pandas><text-extraction> | 2023-03-05 18:44:55 | 1 | 807 | Django0602 |
75,644,507 | 11,665,178 | Python AWS Lambda in error because of pyjwt[crypto] (cryptography) | <p>I have the following error when i run my AWS lambda under python 3.9 :</p>
<pre><code>[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/cryptography/hazmat/bindings/_rust.abi3.so)
Traceback (most recent call last):
</... | <python><docker><ubuntu><aws-lambda><python-cryptography> | 2023-03-05 18:40:52 | 1 | 2,975 | Tom3652 |
75,644,459 | 12,871,587 | Polars read_excel issue with a date format | <p>I'm trying to read rather messy excel file(s) to Polars dataframe, but getting a "XlsxValueError: Error: potential invalid date format.".</p>
<p>I believe that the issue is related to some date column values being in excel numerical date format that raises the error. Is there a way for me to put a setting ... | <python><python-polars> | 2023-03-05 18:32:16 | 1 | 713 | miroslaavi |
75,644,257 | 1,873,108 | Unable to cast Python instance of type <class 'dict'> to C++ | <p>I'm trying to pass dict[str, object] from Python to C++ to do some operations & keep object in C++ while it's being used.</p>
<pre class="lang-cpp prettyprint-override"><code>typedef std::map<std::string, py::object> dataMap;
void init_basicWindowMule(pybind11::module_ & m) {
pybind11::class_<t... | <python><c++><pybind11> | 2023-03-05 17:56:44 | 1 | 1,076 | Dariusz |
75,644,182 | 3,552,975 | Change the color of placeholder text of prompt_toolkit prompt in Python? | <p>The following is my code that causes this error: <code>TypeError: argument of type 'HTML' is not iterable</code></p>
<pre><code>from prompt_toolkit import prompt
from prompt_toolkit.formatted_text import FormattedText, HTML
def get_input():
prompt_text = [
("class:prompt-prefix", HTML('<an... | <python><colors><prompt-toolkit> | 2023-03-05 17:43:15 | 1 | 7,248 | Lerner Zhang |
75,644,169 | 2,326,961 | How to stop subprocesses that communicate with the main process through request and response queues? | <p>I have a Python program that starts <em>N</em> subprocesses (clients) which send requests to and listen for responses from the main process (server). The interprocess communication uses pipes through <code>multiprocessing.Queue</code> objects according to the following scheme (one queue per consumer, so one request ... | <python><multiprocessing><pipe><client-server><message-queue> | 2023-03-05 17:41:34 | 2 | 8,424 | Géry Ogam |
75,644,097 | 2,783,767 | Is there a way to clear GPU memory after training the TF2 model | <p>I’m training multiple models sequentially, which will be memory-consuming if I keep all models without any cleanup. However, I am not aware of any way to the graph and free the GPU memory in Tensorflow 2.x. Is there a way to do so?
Below is my code.</p>
<pre><code>import os
os.chdir(os.path.dirname(os.path.abspath(_... | <python><tensorflow> | 2023-03-05 17:30:50 | 1 | 394 | Granth |
75,644,077 | 6,494,707 | PyTorch: RuntimeError: zero-dimensional tensor (at position 0) cannot be concatenated | <p>I have two tensors:</p>
<pre><code># losses_q
tensor(0.0870, device='cuda:0', grad_fn=<SumBackward0>)
# this_loss_q
tensor([0.0874], device='cuda:0', grad_fn=<AddBackward0>)
</code></pre>
<p>When I am trying to concat them, PyTorch raises an error:</p>
<pre><code>losses_q = torch.cat((losses_q, this_loss... | <python><python-3.x><pytorch><tensor><pytorch-geometric> | 2023-03-05 17:28:01 | 1 | 2,236 | S.EB |
75,644,033 | 403,425 | Pillow gives AttributeError: 'NoneType' object has no attribute 'seek' when trying to save a file | <p>I'm trying to create a view in Django, using Django REST Framework and its <code>FileUploadParser</code>, where I can upload an image to, and it then stores both the original image and a thumbnail.</p>
<pre class="lang-py prettyprint-override"><code>class ImageUploadParser(FileUploadParser):
media_type = "i... | <python><django-rest-framework><python-imaging-library> | 2023-03-05 17:19:13 | 1 | 5,828 | Kevin Renskers |
75,644,014 | 10,566,763 | Python `pip` on Windows - SSL: CERTIFICATE_VERIFY_FAILED | <p>I'm working with Windows and since two days ago, I'm getting the following error:</p>
<pre><code> ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='f
iles.pythonhosted.org', port=443): Max retries exceeded with url: /packages/da/6
d/1235da14daddaa6e47f74ba0c255358f0ce7a6ee05da8bf8eb49... | <python><pip><ssl-certificate> | 2023-03-05 17:15:51 | 3 | 706 | notarealgreal |
75,643,921 | 4,020,302 | Append new column to csv based on lookup | <p>I have two csv files lookup.csv and data.csv. I'm converting lookup.csv as dictionary and need to add new column in data.csv based on the column.</p>
<p>Input:</p>
<p>lookup.csv</p>
<pre><code> 1 first
2 second
...
</code></pre>
<p>data.csv</p>
<pre><code> 101 NYC 1
202 DC 2
</code></pre>
<p>Expected out... | <python><python-3.x><pandas><csv> | 2023-03-05 17:02:47 | 3 | 405 | praneethh |
75,643,822 | 14,729,820 | How to replace specific string in data frame column value? | <p>I have <code>input.txt</code> file that has 2 columns (<code>file_name,text</code>) and want to replace " " seprater charchter (which represnt tab here becuse I spreated txt file by this char) that apperar in <code>text</code> column</p>
<p>example for input file :</p>
<pre><code>0.jpg Jól olvasom? ... | <python><pandas><dataframe><text><deep-learning> | 2023-03-05 16:45:52 | 2 | 366 | Mohammed |
75,643,736 | 5,378,816 | What is the correct typing for this case (subclassed method)? | <p>I can't get the following type hint right. Could you please help?</p>
<pre><code># example edited to make simpler (was async)
from typing import Any, Callable, ClassVar
class Base:
def n_a(self) -> str:
return 'N/A'
meth1: ClassVar[Callable[[Base], str]] = n_a
# also meth2, meth3, ...
clas... | <python><python-typing> | 2023-03-05 16:33:51 | 1 | 17,998 | VPfB |
75,643,701 | 10,415,970 | How to stop headless Python Selenium from stealing window focus? | <p>I'm using Python Selenium in headless mode and I have some parts of the script that open new tabs, do clicks, etc.</p>
<p>However, it keeps stealing my computer's window focus and putting it on the script. Is there a way to prevent this from happening?</p>
<p>For example: I'm doing literally anything else on my comp... | <python><selenium-webdriver><headless-browser> | 2023-03-05 16:28:40 | 0 | 4,320 | Zack Plauché |
75,643,572 | 1,770,724 | Get Dropbox folder path in Python | <p>I need to know the local Dropbox path in any machine (mac or windows) whereever is this file (might be in a seconcary hard drive) and whatever is its name (might be 'E:\My_funny_dropbox'). I'm using the dropbox API. In the Dropbox website, I've set a token to grant access to "files.metadata.read". The toke... | <python><python-3.x><dropbox> | 2023-03-05 16:12:07 | 2 | 4,878 | quickbug |
75,643,203 | 12,715,723 | How to make a random function without using any library? | <p>I know that the way to produce random numbers from 0 to 1 (<code>0.0 ≤ n < 1.0</code>) can be done using a code like this in Python:</p>
<pre class="lang-py prettyprint-override"><code>import random
print(random.random())
</code></pre>
<p>But I'm curious about how this function can be made and how it works. Is an... | <python><random> | 2023-03-05 15:13:55 | 1 | 2,037 | Jordy |
75,643,086 | 11,498,867 | how to loop over a list of dataframes and change specific values | <p>I have a list of dataframes. Each dataframe of the list has following format:</p>
<p><a href="https://i.sstatic.net/s5qYC.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/s5qYC.png" alt="enter image description here" /></a></p>
<p>(screenshot from spyder)</p>
<p>On this list of dataframes, I perform se... | <python><pandas><dataframe><for-loop> | 2023-03-05 14:55:00 | 1 | 1,302 | RobH |
75,643,059 | 683,367 | How to yield into asyncio.run? | <p>I know I'm missing something basic here.</p>
<p><strong>Prerequisite</strong>: I'm not allowed to edit <code>'__main__'</code>.</p>
<p>Given that prerequisite, how can I print <code>x</code> as soon as <code>fun()</code> returns something ? I know I can use <code>asynio.gather</code>, but that would mean waiting for... | <python><python-asyncio> | 2023-03-05 14:50:59 | 0 | 3,102 | Jibin |
75,642,930 | 4,473,615 | For loop in a single line and assign it to a variable in Python | <p>I need to assign a result of for loop to a variable. It is easy to print the for loop in a single line using <code>end =" "</code>, but I am unable to assign the result as a single line.</p>
<pre><code>a = [1, 2, 3, 4]
for i in range(4):
print(a[i], end =" ")
</code></pre>
<p>Result is <code... | <python> | 2023-03-05 14:30:23 | 3 | 5,241 | Jim Macaulay |
75,642,865 | 6,275,705 | How can modify ViT Pytorch transformer model for regression task | <p>How can modify ViT Pytorch transformer model for regression task on datasets such as:</p>
<ol>
<li>Stock Prediction Dataset</li>
<li>Real Estate Price Prediction</li>
</ol>
<p>Anyone have code or worked on transformer model for regression?</p>
| <python><regression><transformer-model> | 2023-03-05 14:17:00 | 1 | 396 | saifhassan |
75,642,673 | 11,028,342 | ImportError: cannot import name 'ViT' from 'tensorflow.keras.applications' | <p>how to use Vision Transformer (ViT) models for image classification in tensorflow. I'm unable to import them in my pc with tensorflow (2.4.0) or in Google Colab (tensorflow 2.11) with</p>
<pre><code>from tensorflow.keras.applications import ViT
</code></pre>
<p>The error bellow accured while executing the code:</p>
... | <python><tensorflow> | 2023-03-05 13:46:10 | 2 | 547 | Baya Lina |
75,642,455 | 1,469,465 | Django admin - building HTML page with 2,000 inlines is slow, while DB query is fast | <p><strong>Question in short</strong>: I have a model admin with tabular inlines. There are around 2,000 related records. Fetching them from the database takes only 1 ms, but then it takes 4-5 seconds to render them into an HTML page. What can I do to speed this up?</p>
<p><strong>Question in detail:</strong></p>
<p>I ... | <python><django><django-templates><django-admin> | 2023-03-05 13:13:13 | 1 | 6,938 | physicalattraction |
75,642,266 | 4,317,058 | Default lib jars folder for Apache Toree kernel | <p>Say I want a default relative <code>lib</code> folder in jupyter notebook project directory where I can download custom jars so that I can import later without <code>%addjar</code> magic.</p>
<p>I was under <a href="https://toree.incubator.apache.org/docs/current/user/installation/" rel="nofollow noreferrer">impress... | <python><scala><apache-spark><jupyter-notebook><apache-toree> | 2023-03-05 12:38:44 | 2 | 25,529 | Sergey Bushmanov |
75,642,045 | 17,696,880 | Separate this string using these separator elements but without removing them from the resulting strings | <pre class="lang-py prettyprint-override"><code>import re
input_string = "Sus cosas deben ser llevadas allí, ella tomo a sí, Lucy la hermana menor, esta muy entusiasmada. por verte hoy por la tarde\n sdsdsd"
#result_list = re.split(r"(?:.\s*\n|.|\n|;|,\s*[A-Z])", input_string)
result_list = re.spl... | <python><regex><split> | 2023-03-05 11:55:52 | 2 | 875 | Matt095 |
75,641,934 | 3,718,065 | matplotlib fixed size when dragging RectangleSelector | <p>When I click the center of <code>RectangleSelector</code> and drag it to the edges of <code>axes</code>, the <strong>width</strong> or <strong>height</strong> will be changed (become smaller). This behavior is different from <code>EllipseSelector</code> whose <strong>width</strong> and <strong>height</strong> don't ... | <python><matplotlib> | 2023-03-05 11:35:53 | 2 | 791 | sfzhang |
75,641,925 | 6,494,707 | How to deal with the peptide sequences that have atypical amino acids in the seuqnces? | <p>I am not a bioinformatician and my question may sound basic.</p>
<p>I have some issues with RDKit
<strong>The issue:</strong> there are some sequences that have X in the antimicrobial peptide sequence. Seems that RDKit cannot process these cases. For example the following sequences:
<code>seq = 'HFXGTLVNLAKKIL', 'H... | <python><bioinformatics><fingerprint><rdkit><cheminformatics> | 2023-03-05 11:33:45 | 1 | 2,236 | S.EB |
75,641,662 | 12,902,027 | Load csv file, using python | <pre><code>Beijing, China, [123,456,789,11]
Tokyo, Japan, [153,456,788,12]
Seoul, Korea, [144,559,363,211]
</code></pre>
<p>Using python, I would like to load this format of csv file.
I know there are lots to achieve this. Show me some relevant smart way.
I especially wish to know the way using pickle module.</p>
<p>Th... | <python><json><csv><pickle> | 2023-03-05 10:44:50 | 1 | 301 | agongji |
75,641,472 | 19,694,624 | How to expose FastAPI app to the outside world? | <p>I've built a simple rest api with just one POST endpoint and I want to send the link (i.e., <code>https://mylink/docs</code>) to a another person who will be sending a POST request to my application.</p>
<p>How do I send them the link? I'm running the app on <code>localhost</code> now obviously. I tried accessing <... | <python><fastapi> | 2023-03-05 10:11:37 | 0 | 303 | syrok |
75,641,459 | 10,535,123 | What are Keyword-only fields in Python, and when should I use them? | <p>I'm having trouble understanding what their role is and when I would want to use them. I would appreciate an explanation with an example.</p>
<p>From the <a href="https://docs.python.org/3/whatsnew/3.10.html" rel="nofollow noreferrer">doc</a>:
dataclasses now supports fields that are keyword-only in the generated <s... | <python><python-dataclasses> | 2023-03-05 10:09:04 | 0 | 829 | nirkov |
75,641,448 | 16,347,614 | How to query nested object (with a particular key, value pair) in an array (in firebase) with python? | <p>I am new to Firebase and have started working with it. I have stored the data, and a document is in the following format:</p>
<pre class="lang-js prettyprint-override"><code>{
title: "Tera Hone Laga Hoon",
album: "Ajab Prem Ki Ghazab Kahani"
artists: [
{name: "Atif Aslam&... | <python><firebase><google-cloud-firestore><nosql> | 2023-03-05 10:06:29 | 1 | 574 | Harsh Narwariya |
75,641,389 | 7,301,792 | How set ticks invisible but leave tick-lables are visible | <p>I plot a clock panel as:</p>
<pre><code>import matplotlib.pyplot as plt
import numpy as np
# Create a polar coordinates
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(111, polar=True)
# set ticks and labels
angles = np.radians(np.linspace(0, 360, 12, endpoint=False))
labels = [str(l) for l in range(12)]
ax.... | <python><matplotlib> | 2023-03-05 09:55:51 | 1 | 22,663 | Wizard |
75,641,372 | 17,973,259 | Pygame resizable window when game is not active | <p>How can I make the window in my game resizable only when the game is not active, when self.stats.game_active is False in my code.
This is how i'm setting the window in the <strong>init</strong> of the main class:</p>
<pre><code>def __init__(self):
"""Initialize the game, and create game resources.... | <python><pygame> | 2023-03-05 09:51:49 | 3 | 878 | Alex |
75,641,287 | 18,877,953 | Using the right api_version of the azure SDK | <p>I am trying to verify the existence of some resources in my tenant.
I use the <code>ResourceManagementClient</code> to do so, either the <code>check_existence_by_id</code> method or <code>get_by_id</code> as described in <a href="https://github.com/Azure/azure-sdk-for-python/issues/2808" rel="nofollow noreferrer">th... | <python><azure><azure-sdk><azure-sdk-python> | 2023-03-05 09:36:28 | 1 | 780 | LITzman |
75,641,232 | 4,442,753 | Numba: difference between using a factory function vs `cache=True` | <p>Looking for using (and improving execution speed of) a jitted (numba) function having one or several other jitted functions as parameters, I could see in <a href="https://numba.readthedocs.io/en/stable/user/faq.html#programming" rel="nofollow noreferrer">numbas's FAQ</a> the following:</p>
<pre><code>dispatching wit... | <python><caching><numba> | 2023-03-05 09:23:26 | 1 | 1,003 | pierre_j |
75,640,960 | 5,695,336 | Run a coroutine in the background from a non-async function | <p>Here is a simplified version of what my code is doing, hope it is self-explanatory enough.</p>
<pre><code>def config_changed(new_config: Any):
apply_config(new_config)
start()
asyncio.create_task(upload_to_db({"running": True}))
async def upload_to_db(data: Any):
await some_db_code(data)
... | <python><python-asyncio> | 2023-03-05 08:24:05 | 2 | 2,017 | Jeffrey Chen |
75,640,922 | 2,908,017 | How to make a ReadOnly Edit in a Python FMX GUI App | <p>I made an <code>Edit</code> on a <code>Form</code> using the <a href="https://github.com/Embarcadero/DelphiFMX4Python" rel="nofollow noreferrer">DelphiFMX Python Library</a>, but how do I make an <code>Edit</code> that is read-only?</p>
<p>The user should be able to read text in the Edit, but not be able to enter th... | <python><user-interface><firemonkey> | 2023-03-05 08:15:34 | 1 | 4,263 | Shaun Roselt |
75,640,866 | 2,908,017 | How to add a border to a label in a Python VCL GUI App? | <p>I've made a simple <code>Hello World!</code> app in the <a href="https://github.com/Embarcadero/DelphiVCL4Python" rel="nofollow noreferrer">DelphiVCL GUI Library for Python</a>. "Hello World!" is shown on a <code>Label</code> on the <code>Form</code> as can be seen below with my code and screenshot:</p>
<p... | <python><user-interface><vcl> | 2023-03-05 08:02:29 | 1 | 4,263 | Shaun Roselt |
75,640,849 | 13,412,418 | How to Store file_paths for fast matching queries? | <p>I am trying to store the file path of all files in a <strong>BUCKET</strong>. In my case a bucket can have millions of files. I have to display that folder structure in a UI for navigation.</p>
<pre><code>
storage_folder:
- bucket_1
- bucket_files.txt
- bucket_metadata.txt
- bucket_2
- bucket_files.t... | <python><django> | 2023-03-05 07:59:02 | 1 | 1,888 | Abhishek Prajapat |
75,640,837 | 3,459,293 | Databricks to SQL connection Error : [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' | <p>I am trying to connect to Azure SQL from Databricks by using following</p>
<pre><code>import pyodbc
# Connect to Azure SQL database
server = 'xxxx.database.windows.net'
database = 'db-dev-xxxx'
username = 'abc'
password = 'xyz'
driver= '{ODBC Driver 17 for SQL Server}'
cnxn = pyodbc.connect('DRIVER='+driver+';SERV... | <python><sql-server><odbc><azure-databricks><databricks-sql> | 2023-03-05 07:53:54 | 1 | 340 | user3459293 |
75,640,781 | 1,872,639 | How to access environment variables in dbt Python model | <ul>
<li><a href="https://docs.getdbt.com/docs/build/environment-variables" rel="nofollow noreferrer">https://docs.getdbt.com/docs/build/environment-variables</a></li>
<li><a href="https://docs.getdbt.com/reference/dbt-jinja-functions/env_var" rel="nofollow noreferrer">https://docs.getdbt.com/reference/dbt-jinja-functi... | <python><snowflake-cloud-data-platform><dbt> | 2023-03-05 07:36:10 | 2 | 1,524 | Yohei Onishi |
75,640,477 | 3,783,002 | How to better visualize python file structure with VS 2022 | <p>In PyCharm, I can check the structure of my current file using the "Structure" window. The figure below shows this window circled in red.</p>
<p><a href="https://i.sstatic.net/IGHV3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IGHV3.png" alt="enter image description here" /></a></p>
<p>In... | <python><visual-studio><pycharm><ide><visual-studio-2022> | 2023-03-05 06:01:14 | 1 | 6,067 | user32882 |
75,640,466 | 11,586,653 | Change plot axis with bioinfokit | <p>I have the following code which produces a volcano plot using Bioinfokit:</p>
<pre><code>pip install bioinfokit
import pandas as pd
import numpy as np
import bioinfokit
from bioinfokit import analys, visuz
import random
lg2f = [random.uniform(-5,10) for i in range(0,4000)]
pad = [random.uniform(0.0000001,0.999) fo... | <python><pandas><plot><bioinformatics> | 2023-03-05 05:57:41 | 1 | 471 | Chip |
75,640,303 | 1,039,860 | problem settinfg column span (setSpan) in QTableWidget with Python | <p>I have my header information in HeaderCol objects (below) that hold the text, the actual row the text is to appear on (it is one of the first two rows) the start column, and the span (number of columns)</p>
<p>I have the following code:</p>
<pre><code>import sys
from PyQt5.QtWidgets import QTableWidget, QTableWidget... | <python><qt><qtablewidget> | 2023-03-05 05:04:39 | 1 | 1,116 | jordanthompson |
75,640,254 | 2,975,684 | How can I serialize / deserialize private fields in pydantic models | <p>I'm using pydantic to model objects which are then being serialized to json and persisted in mongodb
For better encapsulation, I want to some fields to be private
but I still want them to be serialized to json when saving to mongodb, and then deserialized back from json when I fetch the object from the db</p>
<p>how... | <python><json><serialization><pydantic> | 2023-03-05 04:48:07 | 1 | 443 | Nir Brachel |
75,640,162 | 16,853,253 | Django showing error 'constraints' refers to the joined field | <p>I have two models Product and Cart. Product model has <code>maximum_order_quantity</code>. While updating quantity in cart, I'll have to check whether quantity is greater than <code>maximum_order_quantity</code>at database level. For that am comparing quantity with <code>maximum_order_quantity</code> in Cart Model ... | <python><django><django-models><foreign-keys><django-validation> | 2023-03-05 04:17:54 | 1 | 387 | Sins97 |
75,640,152 | 10,570,372 | Child class with different signatures, how to reasonable resolve it without breaking the code? | <p>I am implementing machine learning algorithms from scratch using python. I have a base class called <code>BaseEstimator</code> with the following structure:</p>
<pre class="lang-py prettyprint-override"><code>from __future__ import annotations
from typing import Optional, TypeVar
import numpy as np
from abc import ... | <python><oop><design-patterns> | 2023-03-05 04:12:51 | 1 | 1,043 | ilovewt |
75,640,108 | 4,021,436 | Why does pdb sometimes skip stepping into multi-part conditional? | <p>I have a Minimal Working Example code :</p>
<p><code>test.py :</code></p>
<pre><code>a = 4
b = 6
l = [4, 6, 7, 8]
for t in l :
if t == a or t == b:
continue
print(t)
</code></pre>
<p>I am stepping through the code using <code>pdb</code> (<code>python-3.9.2</code>) :</p>
<pre><code>local: ~ $ python -... | <python><pdb> | 2023-03-05 03:59:27 | 1 | 5,207 | irritable_phd_syndrome |
75,640,079 | 4,212,875 | Removing rows in a pandas dataframe after groupby based on number of elements in the group | <p>I'm stuck trying to figure out the following: Given a pandas dataframe, I would like to group by by one of the columns, remove the first row in each group if the group has less than <code>n</code> rows, but remove the first and last row in each group if the group has <code>n</code> or more rows. Is there an efficien... | <python><pandas><dataframe> | 2023-03-05 03:46:59 | 2 | 411 | Yandle |
75,640,046 | 14,328,098 | How to use a fixed number of multi-processes in python? | <p>I want to analyze the results of different benchmark evaluations.
I have many benchmarks, and when running on the server, I want to evaluate 10 in parallel at a time. In my python script, there is a function that does the evaluation.</p>
<pre><code>def load_single_stat(benchmark,prefetcher, retry=False)
</code></pre... | <python><multiprocessing> | 2023-03-05 03:35:00 | 1 | 816 | Gerrie |
75,640,043 | 308,827 | Fill in using unique values in pandas groupby | <pre><code>df = pd.DataFrame({'value': [1, np.nan, np.nan, 2, 3, 1, 3, np.nan, 3], 'name': ['A','A', 'B','B','B','B', 'C','C','C']})
name value
0 A 1
1 A NaN
2 B NaN
3 B 2
4 B 2
5 B 2
6 C 3
7 C NaN
8 C 3
</code></pre>
<p>In the dataframe above, I wan... | <python><pandas> | 2023-03-05 03:33:25 | 1 | 22,341 | user308827 |
75,639,759 | 1,354,439 | Parallelize AsyncGenerators | <p>I am looking for a <code>asyncio.create_task</code> equivalent for <code>AsyncGenerator</code>. I want the generator to already start executing in the background, without awaiting results explicitly.</p>
<p>For example:</p>
<pre class="lang-py prettyprint-override"><code>async def g():
for i in range(3):
... | <python><asynchronous><python-asyncio><generator> | 2023-03-05 01:43:16 | 2 | 5,979 | Piotr Dabkowski |
75,639,679 | 3,566,606 | Type hint for a cast-like function that raises if casting is not possible | <p>I am having a function <code>safe_cast</code> which casts a value to a given type, but raises if the value fails to comply with the type at runtime:</p>
<pre class="lang-py prettyprint-override"><code>from typing import TypeVar
T = TypeVar('T')
def safe_cast(t: type[T], value: Any) -> T:
if isinstance(value... | <python><casting><mypy><python-typing> | 2023-03-05 01:16:08 | 2 | 6,374 | Jonathan Herrera |
75,639,455 | 16,009,435 | Modify the value of a multi-nested dictionary | <p>What is the best way to access a multi-nested dictionary by its value and modify its value? The way that the value is modified must be by its current value. To explain better, the below example array <code>myArr</code> has a nested dictionary with value <code>c2</code> how can I access that dictionary and modify <co... | <python> | 2023-03-05 00:04:25 | 2 | 1,387 | seriously |
75,639,294 | 2,908,017 | How to add a border to a label in a Python FMX GUI App? | <p>I've made a simple <code>Hello World!</code> app in the <a href="https://github.com/Embarcadero/DelphiFMX4Python" rel="nofollow noreferrer">DelphiFMX GUI Library for Python</a>. "Hello World!" is shown on a <code>Label</code> on the <code>Form</code> as can be seen below with my code and screenshot:</p>
<p... | <python><user-interface><firemonkey> | 2023-03-04 23:21:46 | 1 | 4,263 | Shaun Roselt |
75,639,160 | 2,908,017 | What is the absolute simplest way to make a Python FMX GUI App? | <p>I've got the following Python code to make the FMX GUI Form, but I'm trying to make the code shorter if possible. What is the least amount of code that is required to make only a <code>Form</code> and show it. Here's my current code:</p>
<pre><code>from delphifmx import *
class frmMain(Form):
def __init__(self,... | <python><user-interface><firemonkey> | 2023-03-04 22:49:26 | 1 | 4,263 | Shaun Roselt |
75,639,149 | 661,720 | Create a widget that acts as a terminal | <p>I need to write a Streamlit app that acts as a Terminal, meaning that it behaves exactly like the terminal would, including by asking the user for input() when required by the script.</p>
<p>The script "danse_macabre.py" is a command line text RPG, so the user needs to give regular inputs and get responses... | <python><subprocess><streamlit> | 2023-03-04 22:46:54 | 1 | 1,349 | Taiko |
75,639,090 | 3,316,136 | Reading a CSV file with quotation and backslashes not working correctly | <p>I am trying to read a <strong>CSV file</strong> containing the following lines into a Pandas DataFrame:</p>
<pre><code>103028,"Kinokompaniya \"Ego Production\"",[ru],,K5251,K5251,ef6ba1a20ed58265766c35d9e2823f17
60985,"Studio \"Orlenok\", Central Television USSR",[ru],,S3645,S... | <python><pandas> | 2023-03-04 22:33:58 | 2 | 333 | Alexander |
75,639,058 | 198,301 | Creating an OFX file which an be opened by Quicken (v6.12.3) for macOS | <p>I have some investment accounts which I am tracking with Quicken for <em>macOS</em>. However, I am using the Quicken feature to auto-download the status of the account. However, the company does not support downloading the individual transactions, which I would like to also track inside of Quicken. But, I do not wan... | <python><ofx><quicken> | 2023-03-04 22:27:22 | 1 | 8,782 | ericg |
75,639,004 | 16,009,435 | positional argument error when trying to send a post request | <p>I am trying to send a post request to a python backend running on a fast API server. The current method I am using below throws error <code>test() takes 0 positional arguments but 1 was given</code> but I haven't passed any arguments to the function <code>test</code>. Why is this happening and how can I fix it? Than... | <python><fastapi> | 2023-03-04 22:14:47 | 2 | 1,387 | seriously |
75,638,803 | 1,421,322 | google cloud. upsert large csv file by chunks start to take a lot longer than expected | <p>I have a large csv files of prices that I want to upsert to a postgres table. I am reading it with pandas by chunks then uploading it into a temp table, then copy the temp table into the prices table and finally dropping the temp table. Locally this is really fast. each chunk takes 18s, and the file of 18M rows take... | <python><pandas><google-cloud-platform><google-cloud-sql><google-cloud-run> | 2023-03-04 21:33:00 | 0 | 993 | Courvoisier |
75,638,799 | 19,694,624 | I run into a discord.gateway warning "Shard ID None heartbeat blocked for more than x seconds." | <p>my simple bot checks of it got a .json file from an API, if it did, then the bot outputs some info and then deletes that .json file. But if it did not, then it checks again until there is a .json file in that directory.</p>
<p>Bot actually works fine, but I get a warning <code>Discord.gateway warning "Shard ID ... | <python><discord.py> | 2023-03-04 21:32:32 | 1 | 303 | syrok |
75,638,561 | 11,741,232 | Shared Memory in Python doesn't work if used within a Class | <p>I'm using the <code>multiprocessing.shared_memory</code> module in Python to very rapidly send images between Python processes on the same computer. When I use the shared memory code raw, it works without any problem.</p>
<p>However, when I try to abstract it into a class, which would make it easier to use, it doesn... | <python><shared-memory><cpython> | 2023-03-04 20:46:28 | 0 | 694 | kevinlinxc |
75,638,498 | 7,265,114 | How to calculate cdf using scipy and xarray | <p>I want to fit a <code>gamma</code> distribution and get <code>cdf</code> from nd DataArray <code>test_data</code> below. Currently, I can do it with numpy.apply_along_axis function, but failed to implement on xarray.apply_ufunc(). I am not sure why it happened.</p>
<p>Here is sample code.</p>
<pre><code>import xarra... | <python><scipy><numpy-ndarray><python-xarray> | 2023-03-04 20:34:45 | 0 | 1,141 | Tuyen |
75,638,494 | 6,357,916 | Cupy API and elementwise kernel for faster neural network | <p>I know I can easily rewrite numpy dot product in cupy dot product by using corresponding API:</p>
<pre><code>import numpy as np
import cupy as cp
arr1 = np.array([[1, 2], [3, 4]])
arr2 = np.array([[5, 6], [7, 8]])
np.dot(arr1, arr2)
arr1_ = cp.asarray(arr1)
arr2_ = cp.asarray(arr2)
cp.dot(arr1_, arr2_)
</code></pr... | <python><numpy><neural-network><cupy> | 2023-03-04 20:33:50 | 0 | 3,029 | MsA |
75,638,453 | 19,425,874 | How to combine creds.json file into python script and create a gui? | <p>It's been a long road, but I had 4 separate python scripts I wanted to combine as one.</p>
<p>This is working and is listed below:</p>
<pre><code>import gspread
import requests
from bs4 import BeautifulSoup
import pandas as pd
from oauth2client.service_account import ServiceAccountCredentials
# Set up credentials... | <python><pandas><user-interface><python-requests><credentials> | 2023-03-04 20:25:45 | 1 | 393 | Anthony Madle |
75,638,331 | 11,092,636 | SQLAlchemy returns `list` instead of `Sequence[Row[_TP]]` | <p>The type-hinting of the method <code>sqlalchemy.engine.result.Result.fetchall()</code> suggests the method is supposed to return a <code>Sequence[Row[_TP]]</code> but when I print <code>print(type(result_1.fetchall()))</code>, I get a <code>list</code>.
<a href="https://i.sstatic.net/WAS2n.png" rel="nofollow norefer... | <python><sqlalchemy><python-typing> | 2023-03-04 20:00:15 | 2 | 720 | FluidMechanics Potential Flows |
75,638,222 | 1,315,621 | Sqlalchemy + psycopg: cannot use column reference in DEFAULT expression | <p>I am trying to create the following table with Sqlalchemy on Postgres db:</p>
<pre><code>from sqlalchemy import Column, DateTime, Float, Integer, String, func
from sqlalchemy.orm import declarative_base
Base = declarative_base()
class Test(Base):
__tablename__ = "tests"
id = Column(Integer, pr... | <python><postgresql><sqlalchemy> | 2023-03-04 19:40:03 | 1 | 3,412 | user1315621 |
75,638,209 | 15,222,211 | How to parse Fortigate config by python | <p>I need to parse the Fortigate config to find and change some commands by python, but I have not found good solution. Maybe someone has experience parsing the Fortigate configuration and can recommend a good tool for this task.</p>
<p>I have experience with the <a href="https://github.com/mpenning/ciscoconfparse" rel... | <python><parsing><fortigate><ciscoconfparse> | 2023-03-04 19:36:33 | 1 | 814 | pyjedy |
75,638,199 | 10,077,354 | Why is unpickling a custom class with a restricted Unpickler forbidden although it is allowed in find_class? | <p>I'm required to run some code repeatedly to train a model. I found that using pickle for saving my object after one iteration of the code was useful, and I could load it and use it in my second iteration.</p>
<p>But as pickle has the security issue, I wanted to use the <a href="https://docs.python.org/3/library/pick... | <python><python-3.x><pickle> | 2023-03-04 19:35:23 | 1 | 2,487 | Suraj |
75,638,100 | 6,840,039 | Python: how to calculate removal effect correctly using Markov Chains | <p>I have a bunch of path-to-purchase chains, and the more I have, the more I'm getting stuck about building the graph and calculating the removal effect.</p>
<p>Let's imagine we have 5 different chains:</p>
<ol>
<li>start -> facebook -> google -> remarketing -> conversion</li>
<li>start -> facebook ->... | <python><graph><markov-chains> | 2023-03-04 19:15:15 | 0 | 4,492 | Petr Petrov |
75,638,045 | 4,503,546 | How to loop through variables w/ trend trading system | <p>I built a simple moving average trading system like so:</p>
<pre><code>import pandas as pd
import numpy as np
def trendfunc(f1,fastnum,slownum):
f1['Change'] = f1['Close'].pct_change()
f1['Fast'] = f1['Close'].rolling(window=fastnum,center=False).mean()
f1['Slow'] = f1['Close'].rolling(window=slownum,c... | <python><pandas><dataframe><loops> | 2023-03-04 19:09:09 | 1 | 407 | GC123 |
75,637,997 | 4,792,565 | writing Yaml file in python with no new line | <p>Let's say I have the following snippet :</p>
<pre><code>import yaml
Key = ["STAGE0", "STAGE1"]
dict = {}
dict[Key[0]] = [' ']
dict[Key[1]] = [' ']
dict[Key[0]][0]="HEY"
dict[Key[0]][0]="WHY newline?"
with open("SUMMARY.YAML", "w") as file_yaml:
yaml.du... | <python><file><io><yaml><pyyaml> | 2023-03-04 19:02:32 | 2 | 525 | Ayan Mitra |
75,637,853 | 313,768 | Adapt von Mises KDE to Seaborn | <p>I am attempting to use Seaborn to plot a bivariate (joint) KDE on a polar projection. There is no support for this in Seaborn, and no direct support for an angular (von Mises) KDE in Scipy.</p>
<p><a href="https://stackoverflow.com/a/44783738">scipy gaussian_kde and circular data</a> solves a related but different c... | <python><numpy><scipy><seaborn><kernel-density> | 2023-03-04 18:41:20 | 2 | 16,660 | Reinderien |
75,637,814 | 3,747,724 | Overwrite Blender python class method? | <p>Not sure what the right words are but,
I'm using Python to edit a 3d object in Blender. I can change the position by using:</p>
<pre><code>some_3d_variable.obj.location = (0, 1, 0)
</code></pre>
<p>This moves the object to location (0, 1, 0) in meters i.e 100 centimeters:</p>
<p><a href="https://i.sstatic.net/tKgIS.... | <python><blender> | 2023-03-04 18:35:58 | 0 | 304 | nammerkage |
75,637,796 | 54,873 | In pandas, how do I get multiple slices of a MultiIndexed-dataframe at a time? | <p>In pandas, I'm familiar with how to slice a Multi-Index with a list to get multiple values, like such:</p>
<pre><code>(Pdb) df = pd.DataFrame({"A": range(0,10), "B": -1, "C": range(20,30), "D": range(30,40), "E":range(40,50)}).set_index(["A", "B",... | <python><pandas> | 2023-03-04 18:32:56 | 1 | 10,076 | YGA |
75,637,688 | 14,688,879 | How to evenly space the grid on a matplotlib log scale | <p>How can I set the scale of a log-scaled axis in matplotlib to show values less than base^1 and space them evenly?</p>
<p><strong>Example</strong>:</p>
<p>I have a scale that looks like this:</p>
<p><a href="https://i.sstatic.net/SMf5S.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/SMf5S.png" alt="ent... | <python><matplotlib><graph><logarithm> | 2023-03-04 18:15:56 | 1 | 342 | confusedandsad |
75,637,585 | 19,694,624 | The rest of the python code doesn't work with FastAPI | <p>I want to make a discord bot that would work with data that would be sent from a web application via POST request. So for that I need to make my own API containing that POST request with FastAPI.</p>
<p>My question is: how can make my API work with the rest of the code?</p>
<p>Consider this example:</p>
<pre><code>f... | <python><fastapi> | 2023-03-04 18:00:59 | 2 | 303 | syrok |
75,637,560 | 3,672,883 | Is this the correct way of use Protocol, and if it's why mypy fails? | <p>I have the following two classes:</p>
<pre><code>@runtime_checkable
class AbstractFolder(Protocol):
def __iter__(self) -> "AbstractFolder":
raise NotImplementedError
def __next__(self) -> AbstractFileReadable:
raise NotImplementedError
</code></pre>
<p>and their implementatio... | <python><python-typing><mypy> | 2023-03-04 17:57:11 | 1 | 5,342 | Tlaloc-ES |
75,637,544 | 5,356,096 | Type-hinting based on custom config file structure | <p>Is there a method in Python or PyCharm to produce attribute type hints for a class that dynamically loads the attributes from a file?</p>
<p>Consider the following <code>Settings</code> class:</p>
<pre class="lang-py prettyprint-override"><code>import re
class Settings:
"""
This class loads ... | <python><pycharm><type-hinting> | 2023-03-04 17:54:26 | 1 | 1,665 | Jack Avante |
75,637,511 | 17,082,611 | os.listdir returns the error: no such file or directory even though the directory actually exists | <p>This is my project files structure:</p>
<p><a href="https://i.sstatic.net/Jubqj.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Jubqj.png" alt="hierarchy" /></a></p>
<p>and this is my <code>main.py</code> script:</p>
<pre><code>if __name__ == '__main__':
leukemia_dir = "../dataset/leukemia&qu... | <python><directory><pycharm> | 2023-03-04 17:49:34 | 2 | 481 | tail |
75,637,278 | 8,667,071 | Why do small changes have dramatic effects on the runtime of my numba parallel function? | <p>I'm trying to understand why my parallelized numba function is acting the way it does. In particular, why it is so sensitive to how arrays are being used.</p>
<p>I have the following function:</p>
<pre><code>@njit(parallel=True)
def f(n):
g = lambda i,j: zeros(3) + sqrt(i*j)
x = zeros((n,3))
for i in pra... | <python><performance><numba> | 2023-03-04 17:11:44 | 1 | 366 | Cavenfish |
75,637,211 | 15,491,774 | python schedule package with init function | <p>I need to create a init function, which needs to run before the scheduler starts. I am using the schedule package.</p>
<p>Is there an easy way to add an init function, which runs before the scheduler starts.</p>
<pre><code>import schedule
def call_me():
print("I am invoked")
schedule.every(1).seconds.d... | <python><schedule> | 2023-03-04 17:00:53 | 1 | 448 | stylepatrick |
75,637,156 | 8,176,763 | sub count of column values after group by pandas | <p>I have a dataframe like this:</p>
<pre><code>df = pd.DataFrame({
'org':['a','a','a','a','b','b'],
'product_version':['bpm','bpm','bpm','bpm','ppp','ppp'],
'release_date':['2022-07','2022-07','2022-07','2022-07','2022-08','2022-08'],
'date_avail':['no','no','no','yes','no','no'],
'status':['green','green','... | <python><pandas> | 2023-03-04 16:50:18 | 4 | 2,459 | moth |
75,637,133 | 5,281,775 | Padding time dimension in softmax output for CTC loss | <p>Network:</p>
<pre><code>Input sequence -> BiLSTM---------> BiLSTM --------> Dense with softmax
Output shapes: (None, 5, 256) (None, 5, 128) (None, 5, 11)
</code></pre>
<p>Here is my CTC loss:</p>
<pre><code>def calculate_ctc_loss(y_true, y_pred):
batch_length = tf.cast(tf.shape(y_true)[0], dt... | <python><tensorflow><keras><loss-function><ctc> | 2023-03-04 16:46:33 | 0 | 2,325 | enterML |
75,636,887 | 1,663,762 | ModuleNotFoundError: No module named 'importlib.util' in | <p>I am trying to install a project I downloaded from github:</p>
<pre><code>jlinkels@schrans-pc:/tmp/subsai/src/subsai$ pip3 install -I git+file:///tmp/subsai
Collecting git+file:/tmp/subsai
Cloning file:///tmp/subsai to /tmp/pip-req-build-8znnvukr
Running command git clone -q file:///tmp/subsai /tmp/pip-req-build... | <python><python-3.x><pip> | 2023-03-04 16:06:34 | 1 | 353 | Johannes Linkels |
75,636,358 | 7,236,133 | Add a new column to Pandas data frame with aggregated data | <p>I implemented my own K-Fold cross validation (had a special case to deal with), and I need to save the predictions and its confidence as new columns.</p>
<p>1- In each iteration: <code>test_predictions = clf.predict(X_test)</code></p>
<p>2- Compare the perditions to ground truth:</p>
<pre><code>treatments = test_fol... | <python><pandas> | 2023-03-04 14:37:44 | 1 | 679 | zbeedatm |
75,636,356 | 1,946,052 | Get solution value of variable by name in pySCIPopt | <p>I want to get the solution value of a model variable by name in pySCIPopt.</p>
<p>It should be something like <code>model.getSolByName("x")</code>.</p>
<p>Is this possible? (I didn't find anything like this.) I wrote my own child class of Model to do this, but wonder if there is a built in method.</p>
<pre... | <python><pyscipopt> | 2023-03-04 14:37:29 | 1 | 2,283 | Michael Hecht |
75,636,205 | 9,859,642 | Merging series of 2D DataFrames to 3D xarray | <p>I have a series of 2D DataFrames that should be merged into a 3D xarray. The structure of DataFrames looks like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th></th>
<th>5 6 4</th>
<th>8 -1 3</th>
<th>angle</th>
</tr>
</thead>
<tbody>
<tr>
<td>5</td>
<td>105.87</td>
<td>459.62</td>... | <python><dataframe><python-xarray> | 2023-03-04 14:11:16 | 1 | 632 | Anavae |
75,636,154 | 1,727,657 | How do I append the index of a string to a list using extend() in python? | <p>I'm trying to look through a long string to find instances of a substring, then I want to create a list that has the index of each substring found and the substring found. But instead of the index in a readable form, I'm getting a reference to the object, such as <code> [<built-in method index of str object at 0... | <python> | 2023-03-04 14:02:56 | 3 | 477 | OutThere |
75,635,611 | 16,127,735 | Pacman game with Pygame | <p>I am making a pacman game with python. Currently, the player moves continuously if I hold a certain key. So, for example, if I hold the left key, the player moves continuously to the left.
But in the original pacman game, you can just press a key 1 time to move continuously instead of holding it.
So I want to make t... | <python><pygame> | 2023-03-04 12:16:33 | 0 | 1,958 | Alon Alush |
75,635,590 | 2,613,271 | Subplots with common x and y labels and a common legend under the x-axis | <p>I am trying to plot a subplot with a common legend displayed at the bottom of the figure below a common x axis label, and with a common y-axis label. I have two ways of almost getting it working, except the first has the common y-axis label overlapping the axis tick labels, while with the second I can't figure out ... | <python><matplotlib> | 2023-03-04 12:13:05 | 1 | 1,530 | Esme_ |
75,635,528 | 12,439,683 | Optuna sample fixed parameter depending on another parameter | <p>In my setting I have an abstract situation like the following, which shall only function as an example case:</p>
<pre class="lang-py prettyprint-override"><code>base = trial.suggest_int(1, 3)
power = trial.suggest_int(1, 10)
# value = base ** power
</code></pre>
<p>As when the <code>base == 1</code> the power parame... | <python><machine-learning><sampling><hyperparameters><optuna> | 2023-03-04 12:01:19 | 1 | 5,101 | Daraan |
75,635,119 | 363,028 | Set anchortype="paragraph" for image using odf.text | <p>I want to change <a href="https://github.com/turulomio/pdf2odt" rel="nofollow noreferrer">https://github.com/turulomio/pdf2odt</a> so that images are 21cm wide (that was easy) and so that images are anchored to paragraph instead of as-char, so that the image goes all the way to the edge of the page.</p>
<p>The ODT f... | <python><odf> | 2023-03-04 10:42:33 | 1 | 34,146 | Ole Tange |
75,634,747 | 1,815,739 | I want to get keys as integers using json serialization and deserialization and python | <p>I have this dict:</p>
<pre><code>d={0:[1,2,3,None,1],1:[1,2,4,0,3],2:[4,6,2,3,4],3:[4,2,6,1,2],4:[2,2,6,2,None]}
</code></pre>
<p>I save it:</p>
<pre><code>fo=open("test.json","w")
json.dump(d,fo, sort_keys=True, indent=2, separators=(',', ': '))
fo.close()
</code></pre>
<p>I restore it:</p>
<pre... | <python><json><dictionary><serialization><deserialization> | 2023-03-04 09:25:57 | 1 | 496 | The Dare Guy |
75,634,703 | 2,202,718 | csrf_exempt for class based views | <p>Code:</p>
<pre><code>class ErrorReportView(View):
def get(self, request, *args, **kwargs):
return HttpResponse('Hello, World!')
@method_decorator(csrf_exempt)
def post(self, request, *args, **kwargs):
return HttpResponse('Hello, World!')
</code></pre>
<p><a href="https://i.sstatic.net/C... | <python><django><django-views> | 2023-03-04 09:17:13 | 1 | 1,069 | Trts |
75,634,630 | 866,333 | pytest command reports "Exception ignored" and "OSError: [WinError 6] The handle is invalid" | <p>I found this error running pytest from the command line. All my tests still passed but it bothers me:</p>
<pre><code>Exception ignored in: <function Pool.__del__ at 0x000001F5C70214E0>
Traceback (most recent call last):
File "C:\Program Files\Python311\Lib\multiprocessing\pool.py", line 271, in __d... | <python><threadpool> | 2023-03-04 09:02:53 | 1 | 6,796 | John |
75,634,466 | 5,962,321 | Include or exclude (license) files from package data with pyproject.toml and setuptools | <h2>TL;DR</h2>
<p>How does one reliably include files from <code>LICENSES/</code> (REUSE-style) in source archive and wheels for a Python package with a <code>src/</code> layout? How does one exclude specific files?</p>
<h2>Details</h2>
<p>I have a project structure that looks like</p>
<pre><code>.
├── pyproject.toml
├... | <python><setuptools><python-packaging><python-wheel><pyproject.toml> | 2023-03-04 08:22:54 | 1 | 2,011 | Silmathoron |
75,634,357 | 3,368,201 | Dynamically modifying a class upon creation | <p>I have a <code>classmethod</code> that I want to be called automatically before or when any child of the class it belongs to gets created. How can I achieve that?</p>
<p>Since I understand this can be an XY problem, here is why I (think I) need it, and my basic implementation.</p>
<p>I have a class that gets inherit... | <python> | 2023-03-04 07:52:31 | 3 | 2,880 | frarugi87 |
75,634,294 | 4,473,615 | Pandas DataFrame header to html | <p>Unable to convert pandas header alone to html.
I have below code,</p>
<pre><code>df = pd.read_csv("Employees.csv")
df1= df.columns.to_frame()
df1.to_html("upload.html")
</code></pre>
<p>Result of the code is ,</p>
<p><a href="https://i.sstatic.net/jZvwh.png" rel="nofollow noreferrer"><img src="ht... | <python><html><pandas> | 2023-03-04 07:35:07 | 3 | 5,241 | Jim Macaulay |
75,634,191 | 761,069 | Django unions and temporary fields in serializers | <p>I have a DjangoRest view that finds several QuerySets of a Model (Item), calculates a "rank" for each item, and then passes the final list to a serializer.</p>
<p>My "rank" field is a temporary field added by the serializer.</p>
<p>When I try something like the this:</p>
<pre class="lang-py prett... | <python><django><django-rest-framework> | 2023-03-04 07:07:56 | 1 | 610 | tanbog |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.