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 ⌀ |
|---|---|---|---|---|---|---|---|---|
76,267,519 | 3,772,517 | What is the proper type annotation for any object that can be unpacked with the ** operator? | <p>I have a function that looks like this:</p>
<pre><code>from pandas import Series
def my_function(unpackable: dict | Series) -> None:
{**unpackable}
</code></pre>
<p>I would actually like to type hint for any object that can be unpacked with the <code>**</code> operator while excluding those that cannot. I tho... | <python><python-typing> | 2023-05-16 22:42:30 | 2 | 864 | michen00 |
76,267,445 | 665,335 | String type in Python but with warning of "Number stored as text" in Excel xlsx file | <p>I need to create an Excel xlsx file from a Pandas data frame.</p>
<p>The Pandas data frame contains a column of Object type in Python. Each cell of the column is string type. On the Excel file, the column has warnings of "Number stored as text".</p>
<p>Why is it? Is it possible to remove the warning? It is... | <python><xlsxwriter> | 2023-05-16 22:26:15 | 0 | 8,097 | Pingpong |
76,267,373 | 5,352,674 | Cannot import module projectname.appname when reading CSV | <p>I have a django project named <code>localassets</code> and in turn have an app called <code>assetlist</code>.
I have a directory named <code>scripts</code> at the root of my project (same level of manage.py) in which I have the following script to read data from a csv:</p>
<p><strong>load_csv.py</strong></p>
<pre><c... | <python><django><django-models> | 2023-05-16 22:10:27 | 0 | 319 | Declan Morgan |
76,267,153 | 6,273,496 | 'IntegerArray' object has no attribute 'reshape' | <p>I'm trying to run a linear regression on a small dataframe I'm getting from an SQL query.</p>
<p>When running the example below (with a dummy dataset) everything is working fine:</p>
<pre><code># initialize list of lists
data = [['tom', 10, 20], ['nick', 15, 40], ['juli', 14, 70]]
# Create the pandas DataFrame
df... | <python><pandas><dataframe><jupyter-notebook> | 2023-05-16 21:25:50 | 2 | 2,904 | Simon Breton |
76,267,022 | 2,228,592 | Django Grab Only First of Each Primary Key in Query | <p>I have a model as below. I want to query it and fetch only the first (newest) row of each <code>tagid</code>.</p>
<p>So I do something like this</p>
<pre class="lang-py prettyprint-override"><code>tag_ids = [list of tagid]
q = Q(tagid__in=tag_ids, dataintegirty=192)
items = get_model().objects.filter(q).order_by('-... | <python><django> | 2023-05-16 21:00:17 | 2 | 9,345 | cclloyd |
76,266,985 | 7,987,455 | How to click on the age verification popup window in Selenium? | <p>I am trying to use Selenium to search something in Aliexpress, but when I search for some products, for example, when I type "test," I will have a popup window that requests my age verification, as shown below:
<a href="https://i.sstatic.net/dILhY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.... | <python><selenium-webdriver><web-scraping><webdriver> | 2023-05-16 20:54:59 | 1 | 315 | Ahmad Abdelbaset |
76,266,927 | 214,296 | Invalid Argument Error After Moving Code Block to Function | <p>I have this code that works fine when it's defined altogether, but if I move a portion of the code to its own function, I get an <code>OSError: [Errno 22] Invalid argument</code>.</p>
<pre class="lang-py prettyprint-override"><code>from ctypes import create_string_buffer, addressof
from struct import pack, unpack
i... | <python><invalidargumentexception> | 2023-05-16 20:45:53 | 2 | 14,392 | Jim Fell |
76,266,920 | 3,042,850 | Having Trouble with a DateTime format - need to set first entry then calculate based on time | <p>Now I converted 2 columns that were originally '%H:%M' format toDatetime and it defaulted the Y:M:D to 1900-01-01. How would I be able to name the first row date and then it calculate the date for the rest of the column. I have multiple days in the Actual Time column, so I would need something that adds the next day... | <python><pandas><datetime> | 2023-05-16 20:44:31 | 1 | 309 | user3042850 |
76,266,770 | 165,658 | Conda not working after reinstall - zstandard issue | <p>A few days ago I started having problems in my Windows 10 machine with installing packages with conda. It was giving me an error message <code>UserWarning: zstandard could not be imported. Running without .conda support.</code></p>
<p>I did some Googling and tried to reinstall Anaconda. I could not do anaconda--clea... | <python><anaconda><windows-10><conda> | 2023-05-16 20:15:39 | 3 | 1,311 | Gregory Saxton |
76,266,695 | 6,824,121 | Can't install PyQt5 using pip on alpine docker | <p>Here is my Dockerfile:</p>
<pre><code>FROM python:3.11-alpine AS app
RUN apk update && apk add make automake gcc g++ subversion python3-dev gfortran openblas-dev
RUN pip install --upgrade pip
WORKDIR /srv
</code></pre>
<p>When I connect to my container and I launch: <code>pip install pyqt5</code></p>
<p>I... | <python><docker><pip><pyqt><pyqt5> | 2023-05-16 20:05:15 | 1 | 1,736 | Lenny4 |
76,266,682 | 8,283,848 | How to raise custom exceptions in a FastAPI middleware? | <p>I have a simple FastAPI setup with a custom middleware class inherited from <a href="https://www.starlette.io/middleware/#basehttpmiddleware" rel="nofollow noreferrer"><strong><code>BaseHTTPMiddleware</code></strong></a>. Inside this middleware class, I need to terminate the execution flow under certain conditions. ... | <python><python-3.x><fastapi><middleware><starlette> | 2023-05-16 20:03:33 | 2 | 89,380 | JPG |
76,266,681 | 2,236,794 | kubernetes service not working with nginx and uwsgi | <p>I have a working Flask app running uwsgi in Docker. I am trying to migrate this application to Kubernetes. I have the following Nginx configmap. I have created the following service and deployment created. I am missing something to make this work and cant seem to figure out that it is. From the logs of Nginx it... | <python><kubernetes><nginx><flask> | 2023-05-16 20:03:13 | 1 | 561 | user2236794 |
76,266,492 | 5,838,295 | Tensorflow + Keras CPU Utilization Question | <p>A data science team is using Keras to train a model using Sequential. They want me to give them a GPU so they can speed up their model training, because they estimate it will take an obscenely long time to train using the current infra (like 6 months). The issue is that when I look at the CPU utilization of their mo... | <python><tensorflow><keras><openshift><cpu> | 2023-05-16 19:32:00 | 0 | 531 | transposeglobal |
76,266,392 | 17,396,945 | Type hints for 'Sequence of ParamSpec' | <p>I have a working function that looks something like this:</p>
<pre class="lang-python prettyprint-override"><code>from time import monotonic
from itertools import chain
from datetime import timedelta
from typing import Callable, Sequence, Any, ParamSpec
P = ParamSpec('P')
def test_function(
func: Callable[P, ... | <python><python-typing> | 2023-05-16 19:14:47 | 2 | 499 | Олексій Холостенко |
76,266,167 | 2,391,795 | Using Pandas to read XLSX file from Google Drive: "The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()." | <p>I'm trying to read a file downloaded from Google Drive using Pandas, in Python.
I'm running the code under Python 3.9, using Pipedream.</p>
<p>Using the following code:</p>
<pre><code>import pandas as pd
import openpyxl
def handler(pipedream: "pipedream"):
# Reference data from previous steps
#pri... | <python><pandas><google-sheets><pipedream> | 2023-05-16 18:39:19 | 0 | 18,227 | Vadorequest |
76,266,112 | 21,107,707 | Why are question marks highlighted specially in python raw string literals in VS Code? | <p>I am working with some raw strings to avoid escape characters and came across this funny syntax highlighting on VS Code. I apologize if this is a bad question; I am merely curious regarding the reason behind the question marks being highlighted (comparing <code>s1</code> and <code>s2</code>). If it helps, I am using... | <python><visual-studio-code> | 2023-05-16 18:30:01 | 2 | 801 | vs07 |
76,266,090 | 6,398,487 | Python Formatting Float Decimal Digits with Separation (grouping) e.g., Underscore | <p>If it's possible to print float number like this in Python 3.8:</p>
<pre><code>4321.000056 → 4_321.000_056
</code></pre>
<p>I know we have underscore separation (grouping) for integer part, e.g., <code>1_000_000</code>, but I searched around, really couldn't find how to achieve that for the decimal part in float.</p... | <python><python-3.x><printing><format><numbers> | 2023-05-16 18:27:07 | 1 | 3,574 | Jason |
76,266,024 | 12,076,570 | DefinedName Unexpected Keyword Argument Value | <p>I've been trying to make DefinedName work but I have not been able to by following the documentation. I'm trying to programmatically create two dropdowns filled up with a list and filter. Where the second dropdown value changes based on the selection of the first one. Below is the code I have so far, my current issu... | <python><excel><openpyxl> | 2023-05-16 18:16:57 | 0 | 335 | Jonathan Sandler |
76,266,006 | 1,068,689 | convert string represented as unicode code points to utf-8 characters | <p>I have a file that contains ASCII lines like</p>
<p><code> "\u0627\u0644\u0625\u062f\u0627"</code></p>
<p>(including the quote marks). I want to output these lines with the actual UTF-8 characters, like</p>
<p><code> "الإدا"</code></p>
<p>(These happen to be Arabic, but a solution would pre... | <python><utf-8> | 2023-05-16 18:13:58 | 1 | 665 | Mike Maxwell |
76,265,969 | 16,389,095 | Creating a package of a Python/Kivy/KivyMd app with PyInstaller: kivy.factory.FactoryException - No class <MDTopAppBar> in module <kivymd.uix.toolbar> | <p>I'm trying to create a package of a <a href="https://kivymd.readthedocs.io/en/1.1.1/" rel="nofollow noreferrer"><strong>Python/KivyMD</strong></a> app with <a href="https://pyinstaller.org/en/stable/index.html" rel="nofollow noreferrer"><strong>PyInstaller</strong></a> for Windows systems.
After having modified the ... | <python><kivy><pyinstaller><kivy-language><kivymd> | 2023-05-16 18:08:25 | 0 | 421 | eljamba |
76,265,884 | 10,309,712 | sklearn: ValueError: multiclass format is not supported | <p>Answers to similar question exist, none worked to me, so I am posting this.</p>
<p>Using the <a href="https://rasbt.github.io/mlxtend/" rel="nofollow noreferrer">mlxtend</a> package to do a sequential forward feature selection. I am working on a multiclass (5 class) problem, and a random forest estimator.</p>
<pre c... | <python><machine-learning><scikit-learn><feature-selection><mlxtend> | 2023-05-16 17:55:39 | 1 | 4,093 | arilwan |
76,265,834 | 3,755,861 | plotly polarplot - moving position of radialaxis labels | <p>I am using plotly for polar plots with pretty standard settings for radial and angular axis, but instead of plotting the ticklabels of the radialaxis onto the 270 degree axis, I would like to plot them onto the 180 degree axis. How can I do that?</p>
<p>Here some snippets of my code:</p>
<pre><code>fig.update_layou... | <python><plotly> | 2023-05-16 17:47:35 | 1 | 452 | Pugl |
76,265,747 | 11,622,176 | Computing the Cosine Similarity of Embeddings Generated by the Dolly Model on the Hugging Face Hub | <p>In Python, I have a text query variable and a dataset structured as follows:</p>
<pre><code>text = "hey how are you doing today love"
dataset = ["hey how are you doing today love", "I am doing great", "What about you?"]
</code></pre>
<p>I am trying to use the following pipelin... | <python><numpy><huggingface-transformers><valueerror> | 2023-05-16 17:34:27 | 1 | 527 | john_mon |
76,265,651 | 2,543,666 | get bytes representation of number as a decimal string without intermediate string object in python | <p>If I have <code>x = 123</code>, I would like to generate the bytes object <code>b'123'</code>.</p>
<p>I know I can accomplish this with <code>str(x).encode('ascii')</code> or <code>bytes(str(x), 'ascii')</code>.</p>
<p>My question is, is it possible to do this without having to create an intermediate <code>str</code... | <python> | 2023-05-16 17:19:11 | 2 | 7,080 | Thayne |
76,265,631 | 791,793 | ChromaDb add single document, only if it doesn't exist | <p>I'm working with langchain and ChromaDb using python.</p>
<p>Now, I know how to use document loaders. For instance, the below loads a bunch of documents into ChromaDb:</p>
<pre><code>from langchain.embeddings.openai import OpenAIEmbeddings
embeddings = OpenAIEmbeddings()
from langchain.vectorstores import Chroma
db... | <python><langchain><chromadb> | 2023-05-16 17:15:52 | 3 | 721 | user791793 |
76,265,589 | 5,089,311 | Python update multilevel dictionary subitems having specific attribute/key | <p>Assume I have database-like dictionary, where each item is also dictionary.<br />
For example:</p>
<pre><code>{
'peter' : { 'age' : 28, 'department' : 3857 },
'helga' : { 'department' : 57, 'occupancy' : 'graphics' },
'eugene' : { 'age' : 48, 'department' : 12, 'role' : 'teamlead' }
}
</code></pre>
<p>I want upd... | <python><dictionary> | 2023-05-16 17:08:22 | 1 | 408 | Noob |
76,265,574 | 9,386,819 | Why am I able to use datetime in pandas without importing datetime? | <p>I don't quite understand when I must import datetime and when it's not necessary. For example:</p>
<pre><code>import pandas as pd
df['date_string_col'] = pd.to_datetime(df['date_string_col'])
df['datetime_year_col'] = df['date_string_col'].dt.year
</code></pre>
<p>Why does this work without importing <code>datetime... | <python><pandas><datetime> | 2023-05-16 17:06:53 | 2 | 414 | NaiveBae |
76,265,477 | 9,403,794 | How to get logical mask of two lists if lists contain np.NaN | <p>Logical OR and logical AND seems do not work when list have np.NaN. I produced simple example:
If I will have ndarray filled with np.NaN, it do not work correctly:</p>
<pre><code>import numpy as np
m =10
l1, l2 = np.array([np.NaN] * m), np.array([np.NaN] * m)
l1[3] = 5
l2[3] = 5
l1[5] = 6
l2[5] = 6
l2[7] = 7
l1[8] =... | <python><numpy><numpy-ndarray><logical-operators> | 2023-05-16 16:53:13 | 3 | 309 | luki |
76,265,464 | 876,375 | Getting Reverse for 'app_list' not found on custom Admin in Django | <p>My code is as follows:</p>
<p>admin.py:</p>
<pre><code>from django.contrib.admin import AdminSite
from copy import copy
from django.apps import apps
from django.contrib import admin
from .models.badge import *
class MyAdminSite(AdminSite):
site_header = 'Monty Python administration'
admin_site = MyAdminSite(n... | <python><django> | 2023-05-16 16:50:04 | 1 | 1,123 | Lenka Pitonakova |
76,265,221 | 1,264,018 | Retrieving Keras Layer Properties from a tf.keras.Model | <p>I use the following example to make my question clear:</p>
<pre><code>
class Encoder(K.layers.Layer):
def __init__(self, filters):
super(Encoder, self).__init__()
self.conv1 = Conv2D(filters=filters[0], kernel_size=3, strides=1, activation='relu', padding='same')
self.conv2 = Conv2D(filte... | <python><tensorflow><keras> | 2023-05-16 16:20:35 | 1 | 11,853 | feelfree |
76,265,049 | 552,236 | Airflow s3 list and copy files from one bucket to another bucket | <p>New to Airflow here. I am trying to do few things to get my self comfortable with Airflow. As part of this, I tried to list all the files in a s3 bucket and copy them one by one to another bucket.</p>
<p>Here</p>
<pre><code> from airflow.models import DAG
from airflow.decorators import task
from datetime import d... | <python><airflow> | 2023-05-16 16:01:09 | 1 | 4,259 | Vivekh |
76,265,030 | 3,541,631 | Using a dynamic priority dict or list to remove possible duplicate elements in a complex dict(keep it only for the biggest priority element/key) | <p>I have a complex dict, with many elements, simplifying looks like this:</p>
<pre><code>grouped = {
"ca": {"k_a": 32, "k_d": 34},
"ct": {"p_a": 98, "k_d": 34},
"cd": {"k_a": 32, "c_a": 12},
}
</code></pre>
<p>and a l... | <python><python-3.x> | 2023-05-16 15:59:27 | 1 | 4,028 | user3541631 |
76,264,999 | 2,835,684 | How to replace "/" with "\/" in python when writing to a file | <p>I want to replace <code>/</code> with a <code>\/</code> in a string. For an example</p>
<pre><code>original_string="https://stackoverflow.com/questions/"
modified_string="https:\/\/stackoverflow.com\/questions\/"
</code></pre>
<p><code>modified_string</code> is the required output. I tried the fo... | <python><character-encoding> | 2023-05-16 15:55:52 | 1 | 541 | nrnw |
76,264,990 | 8,465,299 | Agumentation of Tabular Dataset | <p>I am trying to increase the size of a numeric dataset that I have been working with. The dataset comprises the columns: <strong>[‘Name’, ‘O3_1hr’, ‘O3_4hr’, ‘O3_8hr’, ‘PM10 1 hr’, ‘PM10’, ‘AQI_O3_1hr’, ‘AQI_O3_4hr’, ‘AQI_PM10’, ‘AQI_Site’, ‘Date’, ‘Time’, ‘Latitude’, Longitude’]</strong>.</p>
<p>Previously, I attemp... | <python><keras><generative-adversarial-network><data-generation> | 2023-05-16 15:54:27 | 0 | 733 | Asif |
76,264,923 | 13,234,892 | Group dicts and sum attribute | <p>I have following list of dicts:</p>
<pre><code>presets = [{'proportion': 1, 'filter': {'tagger_mood': ['sad', 'party']}},
{'proportion': 1, 'filter': {'vocal_instrumental': 1}},
{'proportion': 1, 'filter': {'vocal_instrumental': 2}},
{'proportion': 1.1, 'filter': {'tagger_mood': ['sad', 'party']}},
{'proportion': 1.... | <python> | 2023-05-16 15:43:38 | 3 | 466 | Andrey Ivanov |
76,264,903 | 19,189,069 | Cannot install Parsivar normalizer on Google Colab | <p>When I want to install Parsivar normalizer on Google Colab, I get this error.
This is my installation code:
I use pip to install Parsivar normalizer. This error occurs for about two weeks. before that time I didn't have any problem to install Parsivar.</p>
<pre><code>!pip install parsivar
from parsivar import Normal... | <python><google-colaboratory> | 2023-05-16 15:41:51 | 1 | 385 | HosseinSedghian |
76,264,896 | 11,871,647 | Is there way to debug a Python 2.7 app that has been created with Buildout in vscode? | <p>I have a legacy system that uses Python 2.7. The application gets built using <a href="https://www.buildout.org/en/latest/contents.html#" rel="nofollow noreferrer">Buildout</a> and I run the application as <code>bin/django runserver 0.0.0.0:8000</code> oppose to <code>python manage.py runserver 0.0.0.0:8000</code>. ... | <python><python-2.7><visual-studio-code><debugging><vscode-debugger> | 2023-05-16 15:41:09 | 1 | 323 | KED |
76,264,728 | 2,500,344 | Unable to install facebook prophet library in Databricks using Python | <p>I installed the facebook prophet on Databricks and it was working fine till yesterday. I installed it using the following commands:</p>
<p><code>%pip install pystan==2.19.1.1</code><br />
<code>%pip install fbprophet</code></p>
<p>However, it is not working now. It gives me the following error:</p>
<p><code>Command ... | <python><databricks><facebook-prophet> | 2023-05-16 15:22:27 | 1 | 4,062 | Enayat |
76,264,600 | 6,379,348 | How to plot a dodged barplot with dual axis | <p>I need to plot two sets of barplots side by side with their values on two separate y-axis.</p>
<p>In the example code below, my population bar is in different scale with income. It's not working with just one axis.</p>
<p>Here is what I need:</p>
<ol>
<li>I need plot three bars for income of each region. Also I need... | <python><matplotlib><seaborn> | 2023-05-16 15:07:55 | 0 | 11,903 | zesla |
76,264,523 | 11,923,747 | PyQt : Qt Designer doesn't directly create the GridLayout. Why? | <p>Why Qt Designer create a general widget and then create GridLayout object child object ?</p>
<pre><code>self.gridLayoutWidget = QWidget(self.centralwidget)
self.gridLayout = QGridLayout(self.gridLayoutWidget)
</code></pre>
<p>Can i directly create a child GridLayout object ?</p>
<pre><code>self.main_layout = QtWidge... | <python><qt><user-interface><pyqt><pyqt6> | 2023-05-16 15:00:06 | 0 | 321 | floupinette |
76,264,504 | 1,422,096 | Bottle server with WebSocket (without other third-party libraries) | <p>I have read <a href="https://stackoverflow.com/questions/10316374/bottle-websocket">Bottle + WebSocket</a> and the Github project <a href="https://github.com/zeekay/" rel="nofollow noreferrer"><code>bottle-websocket</code></a>, but they all use <code>gevent</code>, or other third party tools.</p>
<p>Question: nowada... | <javascript><python><websocket><wsgi><bottle> | 2023-05-16 14:58:26 | 0 | 47,388 | Basj |
76,264,426 | 8,206,522 | How to use django-rules predicates with nested serializers | <p>I have a few models in my application which use <a href="https://github.com/dfunckt/django-rules" rel="nofollow noreferrer">django-rules</a> to define permissions. More precisely, I have <code>predicates</code> which are used in the <code>rules_permissions</code> (inside the model's <code>Meta</code>) dictionary, un... | <python><django><django-rest-framework><django-rules> | 2023-05-16 14:50:43 | 0 | 1,377 | Kacperito |
76,264,399 | 7,408,462 | HTTP Post Headers not arriving in nifi | <p>I'm quite new to NiFi.</p>
<p>I am sending an HTTP post containing a file and some headers to Nifi, using Python:</p>
<pre><code> headers = {
"filename": "Filename",
"response_url": "https://...",
"file_id": "123"}
requests.post(NIFI_URL, f... | <python><apache-nifi> | 2023-05-16 14:47:21 | 1 | 3,072 | Florian H |
76,264,347 | 8,248,194 | Using f-string inside a method | <p>I have code that looks like this:</p>
<pre class="lang-py prettyprint-override"><code>from dataclasses import dataclass
@dataclass
class Example:
a: str
b: str
c: str
def repeated_code(self):
if self.c == 'A':
if self.a != "":
print(f"as {self.... | <python><f-string> | 2023-05-16 14:41:15 | 1 | 2,581 | David Masip |
76,264,271 | 14,309,411 | Is Django 4 async faster then sync queries | <p>I'm trying to do an exercise to evaluate the value of upgrading to Django 4 and changing some of the queryset to async.</p>
<p>To try and assess performance, I've created a couple of views to assess sync vs async and at present I can't see any performance improvement when communicating with the database.</p>
<p>Firs... | <python><django> | 2023-05-16 14:34:36 | 0 | 490 | Salaah Amin |
76,264,205 | 9,052,139 | In Langchain, why ConversationalRetrievalChain not remembering the chat history and Entering new ConversationalRetrievalChain chain for each chat? | <p>I am trying to create an customer support system using langchain. I am using text documents as external knowledge provider via TextLoader</p>
<p>In order to remember the chat I using ConversationalRetrievalChain with list of chats</p>
<p>My problem is, each time when I execute <code>conv_chain({"question":... | <python><openai-api><langchain><large-language-model> | 2023-05-16 14:26:49 | 3 | 1,004 | RagAnt |
76,264,194 | 2,112,406 | Finding frequency of characters in a very large file | <p>I have a text file that is ~4G big. I want to get the frequency of each character. Some lines start with a special character and they will be ignored. What is the fastest way to do this in python? I am trying the following:</p>
<pre><code>import time
letters = {"A":0, "G": 0, "T":0, &qu... | <python><file-io> | 2023-05-16 14:25:56 | 3 | 3,203 | sodiumnitrate |
76,264,176 | 4,646,416 | Odoo POS - Closing session gives bad query SQL error | <p>I am trying to close a session in Odoo 13 but I am getting the following error:</p>
<p><a href="https://i.sstatic.net/HkquI.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HkquI.png" alt="Model: Payments (account.payment), Field: Payment Method (payment_method_id)', None) " /></a></p>
<p>I checked the... | <python><session><odoo><point-of-sale> | 2023-05-16 14:23:54 | 1 | 731 | Hassan Yousuf |
76,263,997 | 3,247,006 | How to leave the 1st inline object when trying to delete all inline objects on "Change" page in Django Admin? | <p>I have <code>Person</code> model and <code>Email</code> model which has the foreign key of <code>Person</code> model as shown below:</p>
<pre class="lang-py prettyprint-override"><code># "models.py"
class Person(models.Model):
name = models.CharField(max_length=20)
def __str__(self):
retu... | <python><django><django-models><django-admin><admin> | 2023-05-16 14:05:44 | 1 | 42,516 | Super Kai - Kazuya Ito |
76,263,735 | 294,930 | iterator yielding n-tuples from an iterator as oneliner expression | <p>What I'm looking for is a oneliner-variant of the function <code>batched(iterable, n)</code> described in the code section of <a href="https://docs.python.org/3/library/itertools.html#itertools-recipes" rel="nofollow noreferrer">Itertools Recipes</a> that will batch data into tuples of a certain length.</p>
<p>Assum... | <python><generator><one-liner> | 2023-05-16 13:40:06 | 1 | 976 | antiplex |
76,263,618 | 1,952,636 | How conf VS Code for correct lib resolving when works with several venv? | <p>We use python 3.11, poetry and VS Code.</p>
<p>I have ~/workspace folder where store two services. Each service has own in-project poetry venv, and all service's specified modules doesn't correctly identified by VS Code.</p>
<p>How make correct linking?</p>
<p><a href="https://i.sstatic.net/Ojba8.png" rel="nofollow ... | <python><visual-studio-code><python-poetry> | 2023-05-16 13:29:23 | 1 | 605 | Gulaev Valentin |
76,263,483 | 162,059 | use_2to3 is invalid WITH a downgraded setuptools<58.0 | <p>I am facing an issue which has been discussed at length, and in many many forums, github issues, stack overflow questions, and so on.</p>
<p>To name a few:</p>
<p><a href="https://stackoverflow.com/questions/72414481/error-in-anyjson-setup-command-use-2to3-is-invalid">Error in anyjson setup command: use_2to3 is inva... | <python><setuptools> | 2023-05-16 13:17:26 | 2 | 1,021 | Fotis Paraskevopoulos |
76,263,424 | 3,112,724 | In wagtail, how to include a ForeignKey for a snippet with a panel that lets you add/create new items? | <p>Having a snippet "Scientist" and another snippet "Country". When editing Scientist, it shows a dropdown with all the countries.
I'm trying to find a way to also show an "Add new" so the editor can add a new country directly from the Scientist's change form.</p>
<p>Currently, they should... | <python><django><wagtail> | 2023-05-16 13:11:23 | 0 | 1,206 | Pere Picornell |
76,263,419 | 11,065,874 | how fastapi async works? | <p>I have this small fastapi application</p>
<pre><code># run_sync_8001.py
import time
import uvicorn
from fastapi import FastAPI, Query
app = FastAPI()
@app.get("/")
def sleep(n: int = Query()):
time.sleep(n)
return "Done"
def main():
uvicorn.run(
"run_sync_8001:app&q... | <python><asynchronous><python-asyncio><fastapi> | 2023-05-16 13:11:03 | 1 | 2,555 | Amin Ba |
76,263,405 | 3,515,174 | ParamSpec types PEP 612 | <p>With Python 3.11</p>
<p>Taking the example here, <a href="https://peps.python.org/pep-0612/#semantics" rel="nofollow noreferrer">https://peps.python.org/pep-0612/#semantics</a></p>
<pre class="lang-py prettyprint-override"><code>P = ParamSpec("P")
U = TypeVar("U")
class Y(Generic[U, P]):
f: Ca... | <python><type-hinting> | 2023-05-16 13:09:50 | 0 | 4,502 | Mardoxx |
76,263,364 | 4,744,224 | What would be the simplest way to gather all database queries run during a single HTTP request? | <p>We're using SQLAlchemy and FastAPI. Because of fast moving requirements and some lax practices, we have a few endpoints that are running way more queries than needed (the classic n+1 problem, basically), with all the consequences for performance we all know about. I'd like to tackle this problem, but as usual, good ... | <python><sqlalchemy><fastapi> | 2023-05-16 13:05:38 | 0 | 386 | Nacho |
76,263,300 | 5,618,251 | Convert time from NetCDF to decimal years in Python | <p>I have a NetCDF file with time in units 'hours since 1990-01-01T00:00:00Z'. I have managed to transform these data into table format (YYYY,MM,DD,hh,mm,ss). How can I transform these data in a data array with decimal years? Thanks</p>
<pre><code># Extract time variable
time_gmb = dataset['time'][:]
time_gmb.data;
# C... | <python><date><datetime><time> | 2023-05-16 12:59:05 | 0 | 361 | user5618251 |
76,263,069 | 3,341,533 | python logging with custom handler for Azure Blob Storage on the root logger | <p>I'm having a problem adding a custom logging Handler using an Azure Blob Storage append blob when I try to add this to the root logger. It works fine if I add this to a separate named app logger instead of the root logger, but then my imported module loggers will not propagate to that application level logger.</p>
... | <python><logging><azure-blob-storage> | 2023-05-16 12:31:41 | 1 | 1,032 | BioData41 |
76,262,967 | 1,205,158 | pandas & excel: keeping trailing zero in number stored as string | <p>I have a small Excel spreadsheet I'm reading in a Python script using the pandas package. There is a column with what can look like a number (such as "1.10") that's stored as string and when I access the cell in the Python script, it's extracted as a float and the trailing zero is not present:</p>
<pre><c... | <python><pandas><excel> | 2023-05-16 12:19:28 | 1 | 339 | John |
76,262,928 | 1,593,077 | How to run pip on system with no outgoing DNS or HTTP access? | <p>I'm working on a machine M1 on which I need to install some python stuff using pip. This system is on an internal network. For reasons, it doesn't have a DNS server configured, nor can it open connections to arbitrary machines on the Internet. It can basically just connect to the machine I'm contorlling it from, M2,... | <python><installation><pip><proxy><tunnel> | 2023-05-16 12:15:21 | 2 | 137,004 | einpoklum |
76,262,913 | 386,861 | How to change background of Altair plot in VSCode | <p>I have a plot created using pandas and altair using the following code in VSCode</p>
<pre><code>alt.Chart(df).mark_point().encode(
alt.X("fertility"),
alt.Y("cluster")
)
</code></pre>
<p>How do I change the background colour? I'd rather like the background white or off-white.</p>
<p><a hr... | <python><pandas><altair> | 2023-05-16 12:13:30 | 1 | 7,882 | elksie5000 |
76,262,881 | 13,038,144 | Unpacking multi-level python dictionary into a list of dictionaries | <p>I have a multi-level dictionary as my input. The first level of the dictionary represents a coordinate (e.g. <code>x</code>, <code>y</code>, <code>angle_z</code>, ...). The second level represents all the possible values for that coordinate. The following level represents all the other coordinates whose value should... | <python><list><dictionary><recursion> | 2023-05-16 12:10:35 | 1 | 458 | gioarma |
76,262,837 | 21,420,742 | Creating a column with sum of multiple columns grouped by name in panda | <p>I have a dataset and I need to get the sum from two other columns and group them by name.</p>
<p>DF</p>
<pre><code> a b c
Joe 1 0
Joe 1 0
Joe 0 1
Adam 1 0
Adam 0 1
Adam 0 0
</code></pre>
<p>Desired Output:</p>
<pre><code> a b ... | <python><python-3.x><pandas><dataframe><group-by> | 2023-05-16 12:04:41 | 1 | 473 | Coding_Nubie |
76,262,812 | 5,140,756 | Error in Python lib argparse method parse_args() | <p>I am writing my Integration Tests code then I have a Parent <code>BaseTestClass</code> class to be extended to the children's classes. The Parent Base Class should read dynamic properties from the resource <code>yaml</code> files to be easy to change the environment etc. The test framework to be used is <code>pytest... | <python><pytest><argparse> | 2023-05-16 12:01:51 | 1 | 4,283 | Augusto |
76,262,801 | 6,535,324 | Pycharm find usages of duck typed property | <p>Consider the following (meaningless) minimal example:</p>
<pre class="lang-py prettyprint-override"><code>class MyClass:
def __init__(self, some_list):
self._some_list = some_list
def __len__(self):
return len(self._some_list)
@property
def get_len(self):
return len... | <python><pycharm> | 2023-05-16 12:00:59 | 1 | 2,544 | safex |
76,262,545 | 10,131,952 | How to combine AND and OR conditions in django ORM | <p>I have one sql query:</p>
<pre class="lang-sql prettyprint-override"><code>select * from sample_table where (istatus = 1 AND ((iCategory = 2 and iType=1) or (iType in (2,3,5)));
</code></pre>
<p>How can I write the same in Django ORM using filter?</p>
| <python><django><django-views><orm> | 2023-05-16 11:33:34 | 1 | 413 | padmaja cherukuri |
76,262,494 | 8,930,395 | Pydantic Reponse Model for List of dictionary and Integer | <p>I am migrating to Fastapi from Flask and want to create a pydantic Reponse Model. Below is the response.</p>
<pre><code>[
[
{
"prob": 0.504382973684,
"server": "sdkjfhkjsdjh1223"
},
{
"prob": 0.378097465773,
"server": "... | <python><fastapi><pydantic> | 2023-05-16 11:27:56 | 1 | 4,606 | LOrD_ARaGOrN |
76,262,205 | 18,091,040 | Error upgrading pip [Errno2] No such file or directory | <p>I am trying to upgrade pip by doing:</p>
<pre><code>pip install --upgrade pip
</code></pre>
<p>And I got:</p>
<pre><code>Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /home/VICOMTECH/bdacosta/.local/lib/python3.8/site-packages (22.0.4)
Collecting ... | <python><pip> | 2023-05-16 10:54:22 | 2 | 640 | brenodacosta |
76,262,104 | 13,392,257 | Can't install pybind on macOS | <p>I am learning pybind and follwing this tutorial <a href="https://pybind11.readthedocs.io/en/stable/installing.html" rel="nofollow noreferrer">https://pybind11.readthedocs.io/en/stable/installing.html</a></p>
<p>My actions</p>
<pre><code>python3.10 -m venv venv
source venv/bin/activate
pip install pybind11
</code></p... | <python><c++><pybind11> | 2023-05-16 10:42:15 | 1 | 1,708 | mascai |
76,262,087 | 3,067,485 | How to get fields name from Django QuerySet, even when it's an empty set? | <p>A cool binding between Django and Pandas is the ability to construct a <code>DataFrame</code> directly from a <code>QuerySet</code> using:</p>
<pre><code>queryset = models.A.objects.filter(...).annotate(...)
frame = pd.DataFrame(queryset.values())
</code></pre>
<p>Which wonderfully works as long as there is at least... | <python><django><pandas><django-queryset> | 2023-05-16 10:41:05 | 1 | 11,564 | jlandercy |
76,262,051 | 7,064,415 | How to set the facecolor of a plot for saved figures | <p>I am working with some code that uses <code>matplotlib v.3.1.2</code> on Docker (<strong>I can't change this</strong>), and I can't figure out how to set the background color of my saved plots to a different color than white (while keeping the <code>fig</code> background white).</p>
<p>Looking for a solution, I foun... | <python><matplotlib> | 2023-05-16 10:38:21 | 1 | 732 | rdv |
76,262,005 | 14,860,526 | Azure access token and ID token, verification | <p>i'm having problems understanding the verification and validation of a token.</p>
<p>I have a server running that is registered on Azure with Application id = SERVER_ID</p>
<p>I also have a client application registered on azure with Application id = CLIENT_ID</p>
<p>In python with msal library, I can acquire a toke... | <python><azure-active-directory><access-token><azure-ad-msal> | 2023-05-16 10:33:34 | 1 | 642 | Alberto B |
76,261,714 | 7,848,740 | Correctly organize time series data on InfluxDB | <p>I'm super new to time series database and I've just approached the use of InfluxDB with Python.</p>
<p>I'm trying to understand <strong>what's the best way to organize data</strong>.</p>
<p>The system I need to monitor is basically a <strong>cluster of sensors</strong>. The data acquisition will be in real-time but ... | <python><time-series><influxdb> | 2023-05-16 09:59:00 | 1 | 1,679 | NicoCaldo |
76,261,685 | 1,680,859 | TypeError for get_nasdaq_symbols() | <p>When writing:</p>
<pre><code>from pandas_datareader.nasdaq_trader import get_nasdaq_symbols
traded_symbols = get_nasdaq_symbols()
</code></pre>
<p>it gives "TypeError: read_csv() takes 1 positional argument but 2 positional arguments (and 3 keyword-only arguments) were given":</p>
<pre><code>65 # For p... | <python><stock><pandas-datareader><asset-management> | 2023-05-16 09:56:26 | 1 | 1,194 | user1680859 |
76,261,677 | 12,774,913 | ChatGPT API - creating longer JSON response bigger than gpt-3.5-turbo token limit | <p>I have some use case for ChatGPT API which I don't know how to handle.</p>
<p>I'm creating Python app and I have method which creates request with some instructions and some data to rewrite for ChatGPT. It looks like this (instructions and data are just some samples in this example):</p>
<pre><code>openai.ChatComple... | <python><openai-api><chatgpt-api> | 2023-05-16 09:55:40 | 1 | 379 | hvma411 |
76,261,635 | 14,010,653 | How to get user defined input for defining threshold in python script | <p>Here basically I'm read a file of <code>h5ad</code>file format of a single cell data.</p>
<p>What I'm doing is to read the files and define a filter which I can do manually mean hardcoded which works.</p>
<p>My objective is build a function kind of where user just gives a <code>h5ad</code> file as input then define ... | <python><scanpy> | 2023-05-16 09:52:07 | 0 | 1,016 | PesKchan |
76,261,597 | 5,707,440 | PyCharm does not find installed submodule | <p>I am trying to use DISK feature matching in my application: <a href="https://github.com/cvlab-epfl/disk" rel="nofollow noreferrer">https://github.com/cvlab-epfl/disk</a><br />
I setup my PyCharm project locally on Windows 10 in C:/Workspace/SFM.
DISK is recursively cloned into C:/Workspace/SFM/disk and I ran <code>p... | <python><module><pytorch><pycharm> | 2023-05-16 09:46:55 | 1 | 941 | Grillteller |
76,261,400 | 12,876,940 | Irregular WSGI daemon timeouts in remote Django server | <p>I'm hosting a Django server on a virtual machine with Apache, and running into some odd timeouts. Specifically, every so often, the server will drop, with logs only displaying <code>Timeout when reading response headers from daemon process 'XXX-0.0.86': /mypath/myproject/wsgi.py</code>.</p>
<p>I'm certain that this ... | <python><django><apache><mod-wsgi><wsgi> | 2023-05-16 09:25:09 | 0 | 795 | Destaq |
76,261,336 | 9,879,869 | How to write a file directly to Django FileField? | <p>Is there a way in Python / DJango to write directly to a model's file field?</p>
<p>Suppose I have this model</p>
<pre><code># models.py
class Registry(models.Model):
name = models.CharField(max_length=50, blank=True)
form = models.FileField(
upload_to='registryform',
null=True,
blank... | <python><django> | 2023-05-16 09:19:31 | 3 | 1,572 | Nikko |
76,261,304 | 12,883,179 | Average distance within group in pandas | <p>I have a dataframe like this</p>
<pre><code>df = pd.DataFrame({
'id': ['A','A','B','B','B'],
'x': [1,1,2,2,3],
'y': [1,2,2,3,3]
})
</code></pre>
<p><a href="https://i.sstatic.net/Ho6Xb.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Ho6Xb.png" alt="enter image description here" /></a></p>
... | <python><pandas><group-by><euclidean-distance> | 2023-05-16 09:15:40 | 1 | 492 | d_frEak |
76,261,177 | 17,596,179 | pytest not collecting test from other folders | <p>I have the following file structure.</p>
<pre><code>- tests
-unit_tests
- jobs
- bronze
- __init__.py
- test_test.py
__init__.py
test_tradebook.py
test_extract_bronze.py
test_extract_silver.py
test_load_bronze.py
test_portfolio.py
test_urlbuilder.... | <python><pytest> | 2023-05-16 09:04:34 | 0 | 437 | david backx |
76,261,152 | 9,671,120 | airflow db reset fails to drop table | <p>The problem manifest itself when running <code>airflow db init</code> and appeared overnight (no change in setup). Is it a broken dependency?</p>
<p>The <a href="https://sqlalche.me/e/14/e3q8" rel="nofollow noreferrer">link</a> suggests disconnection - but the error itself looks
more a failed table drop when running... | <python><airflow> | 2023-05-16 09:01:37 | 1 | 386 | C. Claudio |
76,260,962 | 4,913,254 | Keep rows that values in a column is found in another column | <p>I have a data frame with many column but I show relevant columns only</p>
<pre><code>IGV_table[["Revel_Transcripts", "Ensembl"]].head(30).to_dict()
# Converted to dict so that you can use this two-column dataframe
{'Revel_Transcripts': {0: 'ENST00000438426',
1: 'ENST00000438426',
2: 'ENST000... | <python><pandas> | 2023-05-16 08:40:54 | 2 | 1,393 | Manolo Dominguez Becerra |
76,260,918 | 531,971 | Extract text from HTML, handling whitespace and <p> and <br> tags like a browser | <p>I am trying to extract text from an XHTML table, as plain text, but preserving the line breaks that would appear <em>if the document were rendered in an HTML renderer</em>. I don't want to preserve the line breaks in the actual raw XML file.</p>
<p>The raw table cells contain lots of superfluous whitespace that HTML... | <python><html><beautifulsoup><text-extraction> | 2023-05-16 08:36:00 | 1 | 3,876 | Hydrargyrum |
76,260,714 | 3,302,016 | psycopg2.errors.DeadlockDetected: deadlock detected | <h2>PROBLEM</h2>
<p>I have a batch Job that runs when user updates a row the UI. User is allowed to update multiple rows simultaneously which will trigger multiple batch jobs each with a unique <code>run_id</code> .</p>
<p>This job creates a CSV file and inserts the values into a table (<code>allocations_update</code>)... | <python><postgresql><psycopg2><deadlock><database-deadlocks> | 2023-05-16 08:11:57 | 1 | 4,859 | Mohan |
76,260,670 | 8,602,080 | How to create a python package specifically for cp39 and windows 10 with pip wheel | <h2>Problem</h2>
<p>I have created a python package with binary components and depending on windows 10 platform. I used various classifiers to specify the target platform and environment:</p>
<pre><code> classifiers=(
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
... | <python><pip><python-wheel> | 2023-05-16 08:07:09 | 1 | 1,366 | Georg W. |
76,260,552 | 11,198,558 | How can the app inside Docker container get data from SQL Server located on Window host | <p>I have a problem to deploy my app for reading data located on Window host. Specifically, my situation is on the same machine:</p>
<ol>
<li>The SQL Server installed and managed on Window host,</li>
<li>Docker app using engine of wsl2, I'm running a container on it</li>
<li>The app running inside the container cannot ... | <python><sql-server><docker> | 2023-05-16 07:52:39 | 0 | 981 | ShanN |
76,260,455 | 8,323,701 | Use a formula(contaning calculation involving column names) present in one of the columns of dataframe to perform the actual calculation | <p>I have a dataframe which looks like this:</p>
<pre><code>df = pd.DataFrame({'col1':[1,3,5,7],'col2':[2,4,6,8],'col3':['(col1*(1+col2))*col1','col1+col2','col1/col2','col1-col2']})
df
col1 col2 col3
0 1 2 (col1*(1+col2))*col1
1 3 4 col1+col2
2 5 6 col1/col2
3 7 8 col1-col2
</code></pre>
... | <python><pandas><dataframe> | 2023-05-16 07:41:14 | 2 | 323 | bakas |
76,260,387 | 5,783,373 | Delete the zip file from the server after the user downloads the file in Django | <p>I want to delete the generated zipfile from the server, after the end user downloads it into the local system in Django Python web application.</p>
<p>My question is similar to <a href="https://stackoverflow.com/questions/58581479/destroying-file-after-http-response-in-django">this</a> question asked already by anot... | <python><django> | 2023-05-16 07:32:28 | 1 | 345 | Sri2110 |
76,260,344 | 10,970,202 | Create train and valid dataset in petastorm | <p>Versions : Python3.7.13, Tensorflow-2.9.1, Petastorm-0.12.1</p>
<p>In petastorm it seems as if only way to train model using dataset created from petastorm is to <code>fit</code> the model within <code>Reader</code> context manager like below as done in <a href="https://github.com/uber/petastorm/blob/master/examples... | <python><tensorflow><petastorm> | 2023-05-16 07:26:17 | 1 | 5,008 | haneulkim |
76,260,160 | 12,711,193 | how to extract text from rolling credits video & save output in text file? | <p>video contains frames,& if we extracted each frame & apply ocr,it will giving same txt results, i want final output contains all credits.</p>
<p>i tried easyocr to extract txt ,i got text files contins txt, but almost all files are similar so my goal to get uniueq txt from rolling video</p>
<pre><code>import... | <python><artificial-intelligence><ocr> | 2023-05-16 07:01:47 | 0 | 528 | Akash Desai |
76,259,807 | 6,223,346 | Generate json schema and validate json against the schema | <p>How do I generate a JSON schema in Python for the below JSON and validate every json against the schema?</p>
<p>Requirements:</p>
<ul>
<li>There is a type which can be CSV or JSON or JSON</li>
<li>There is a list of properties.</li>
<li>Each property has a key which is a column name and the value is a dict which def... | <python><json><jsonschema><jsonschema2pojo><python-jsonschema> | 2023-05-16 06:01:53 | 2 | 613 | Harish |
76,259,504 | 85,248 | Translation from R to Python (data.table -> pandas): how to replace with values from another column? | <p>I am translating R code to Python. The R code performs a transformation on a <code>data.table</code> object. The typical datasets processed by this code are ~30k rows. My initial attempt fell short, or so I thought, so for testing, I have created a small <code>data.table</code> that is easier to work with, with the ... | <python><r><pandas><dataframe><data.table> | 2023-05-16 04:54:40 | 0 | 8,807 | James Adams |
76,259,451 | 132,438 | Incompatible version of 'pyarrow' installed, how to fix? | <p>At first I got the error <code>UserWarning: You have an incompatible version of 'pyarrow' installed (7.0.0), please install a version that adheres to: 'pyarrow<6.1.0,>=6.0.0; extra == "pandas"'</code></p>
<p>Then I followed the advice on <a href="https://stackoverflow.com/questions/63953939/snowflake... | <python><snowflake-cloud-data-platform><pyarrow> | 2023-05-16 04:40:24 | 2 | 59,753 | Felipe Hoffa |
76,259,007 | 4,281,353 | spacy - how to load a downloaded pretrained pipeline | <p>How to load the downloaded pretrained pipeline and where is it explained in the document?</p>
<pre><code>import spacy
spacy.cli.download("en_core_web_sm", False, False, "--target", "/tmp/spacy")
nlp = spacy.load("/tmp/spacy/en_core_web_sm")
</code></pre>
<pre><code>-----------... | <python><spacy-3> | 2023-05-16 02:30:27 | 0 | 22,964 | mon |
76,258,950 | 8,081,835 | How to create mini-batches of predefined sizes from a sparse 2D matrix in Python? | <p>I have a sparse 2D matrix saved on a disk (<code>.npz</code> extension) that I've created in preprocessing step with <code>scipy.sparse.csr_matrix</code>. It is a long sequence of piano-roll (a numerical form of MIDI representation) format 1-channel image. I cannot convert whole matrix to dense representation - it w... | <python><matrix><scipy><sparse-matrix><mini-batch> | 2023-05-16 02:13:20 | 0 | 771 | Mateusz Dorobek |
76,258,913 | 10,610,620 | Recursive N-nested for loops with N assignments | <p>I'm trying to do bitwise logical operations over a series of vectors. I think I need recursion, but I'm not sure how to get the recursion implemented and assign the values I need during recursion.</p>
<p><em>Note: I know this is terribly slow and the complexity is not good, I'm researching probabilities of vector be... | <python><numpy><recursion><bitwise-operators> | 2023-05-16 02:02:58 | 0 | 446 | Yume |
76,258,816 | 6,457,407 | Numpy array indexing in C | <p>Is there a simple way to do simple array indexing of a possibly multi-dimensional numpy array in C?</p>
<p>My use case is very simple. I have a <code>PyArrayObject *array</code>, and I want the value of <code>array[0]</code>. If the array is one-dimensional, then I want the item at that index. If the array is mult... | <python><numpy> | 2023-05-16 01:23:01 | 0 | 11,605 | Frank Yellin |
76,258,778 | 8,481,155 | Python Unit Test Mock for Pandas max variable | <p>I have a function which throws an exception when the max of column A is equal to a number (say 5). I want to unittest this function to check if it throws the Exception.</p>
<p>main.py</p>
<pre><code>import pandas as pd
class DuplicateRunError(Exception):
def __init__(self, value):
self.value = value
de... | <python><python-3.x><pandas><python-unittest><python-unittest.mock> | 2023-05-16 01:06:45 | 1 | 701 | Ashok KS |
76,258,771 | 10,441,038 | How to write "set batch operation" in Python? | <p>I'm a beginner in Python.</p>
<p>The codes that works is following:</p>
<pre><code>a_set = set('a', 'b', 'c')
result_set = set()
for str1 in a_set:
res = 'prefix-' + str1
result_set.add(res)
</code></pre>
<p>The codes I want is similar to:</p>
<pre><code>a_set = set('a', 'b', 'c')
result_set = set('prefix-' ... | <python><set><union> | 2023-05-16 01:04:24 | 2 | 2,165 | Leon |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.