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,903,821 | 4,245,462 | Round Lists While Maintaining Sum Across ALL Lists | <p><a href="https://stackoverflow.com/questions/44737874/rounding-floats-while-maintaining-total-sum-equal/44740221#44740221">I have seen where we can round elements in a single list while maintaining overall list sum value.</a></p>
<p>However, what if I have multiple lists and am trying to round individual elements in... | <python> | 2023-04-01 01:26:03 | 1 | 1,609 | NickBraunagel |
75,903,571 | 10,308,255 | How to remove None from Column containing Lists ONLY IF the List contains another string? | <p>I have a dataframe with a column that contains lists. These lists can contain strings, <code>None</code>, or, my personal favorite <em>both</em> i.e <code>['ABCD', None]</code></p>
<p>I would really like to remove the <code>None</code> from the lists that are not empty, but keep it in the columns where the value is ... | <python><pandas><string><list> | 2023-04-01 00:02:19 | 2 | 781 | user |
75,903,541 | 23,512,643 | run .bat files for python libraries | <p>I have Windows OS (Operating System) and I am trying to install libpostal library <a href="https://github.com/openvenues/libpostal" rel="nofollow noreferrer">https://github.com/openvenues/libpostal</a></p>
<p>I want to take care of everything (installations) using a .bat script and then try to run an example.</p>
<p... | <python><windows><batch-file> | 2023-03-31 23:47:55 | 0 | 6,799 | stats_noob |
75,903,449 | 19,051,091 | How to predict custom image with PyTorch? | <p>Good evening everyone,
I'm trying to build multiple image classification with 4 classes with a custom Dataset
That's my model so Can someone please help me identify where the wrong because it always predicts class left at all images</p>
<pre><code>class TingVGG(nn.Module):
def __init__(self, input_shape: int, hi... | <python><pytorch> | 2023-03-31 23:25:06 | 0 | 307 | Emad Younan |
75,903,218 | 3,380,902 | geojson file doesn't plot points on mapbox in jupyter notebook | <p>I am running jupyter notebook on Databricks and attempting to render a map. I tried the example from the documentation to test and it doesn't plot the points.</p>
<pre><code>import mapboxgl
from mapboxgl.viz import *
from mapboxgl.utils import df_to_geojson
import matplotlib.pyplot as plt
from IPython.display import... | <python><jupyter-notebook><mapbox><mapbox-gl> | 2023-03-31 22:33:33 | 0 | 2,022 | kms |
75,903,174 | 4,045,275 | conda installed an older, unusable version of mamba and I can't update it | <h2>The issue</h2>
<p>I have Anaconda on two separate Windows PCs. On both, I installed mamba with</p>
<pre><code>conda install mamba -n base -c conda-forge
</code></pre>
<p>on one, it worked and it installed mamba 1.3.1. On the other, it installed mamba 0.1.0, which doesn't work - e.g. if I try
conda update pandas
I g... | <python><anaconda><conda><mamba> | 2023-03-31 22:21:23 | 0 | 9,100 | Pythonista anonymous |
75,903,154 | 4,386,541 | How to perform a cold reset on a smart card reader in python? | <p>I am brand new to python so I hope I am providing the right information.
I have a python script which imports the following:</p>
<pre><code>from smartcard.CardType import AnyCardType
from smartcard.CardRequest import CardRequest
from smartcard.util import toHexString
from smartcard.scard import (SCARD_UNPOWER_CARD, ... | <python><smartcard> | 2023-03-31 22:17:51 | 1 | 901 | Wayne Fulcher |
75,903,092 | 6,197,439 | Matplotlib show|keep visible annotation line that disappears during pan/zoom? | <p>Consider this code:</p>
<pre class="lang-py prettyprint-override"><code>import matplotlib as mpl
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.subplots()
ax.plot([1, 2, 3, 4], [0, 0.5, 1, 0.2])
ax.annotate("", xy=(0,0), xytext=(1,1), arrowprops=dict(facecolor='black'))
ax.set_ylabel('some ... | <python><matplotlib><clipping> | 2023-03-31 22:08:07 | 1 | 5,938 | sdbbs |
75,902,908 | 3,137,388 | fabric -- can't run mv command | <p>We need to transfer some files to remote machine using Fabric. But the requirement is while a file is being transferred, the first character of filename on the remote machine should be '.' (basically a hidden file). Once the transfer is done, we need to rename the file (I am using mv command for it). I am able to tr... | <python><fabric> | 2023-03-31 21:34:31 | 0 | 5,396 | kadina |
75,902,831 | 3,137,388 | Is it possible to pass multiple names to logging.getLogger()? | <p>We wrote a python script that involves AWS (getting file from s3 bucket, transfer the processed file to remote machine using fabric / paramiko). When I turn the logging at DEBUG level, many logs are getting printed on the console. I just wanted my python file to be at DEBUG level and external modules like AWS, Param... | <python><amazon-web-services> | 2023-03-31 21:22:17 | 1 | 5,396 | kadina |
75,902,704 | 280,002 | localstack 0.12.18 fails to install | <p>I am trying to install localstack <code>0.12.18</code> on a windows 10 Enterprise machine.</p>
<p>I'm running <code>Python 3.9.0</code> and <code>pip 23.0.1</code>.</p>
<p>I have downloaded the <code>.tar.gz</code> file directly from pypi.org and installing it via:</p>
<p><code>pip install C:\Users\me\Downloads\loca... | <python><pip><anaconda><setuptools><localstack> | 2023-03-31 21:00:17 | 1 | 1,301 | alessandro ferrucci |
75,902,682 | 19,325,656 | Use orjson/ujsonin drf | <p>Hi all im looking into faster ways of returning JSON data etc. I know that FastAPI uses</p>
<pre><code>ujson
orjson
</code></pre>
<p>Is there a way to replace the standard drf serializer to orjson?</p>
<p><strong>edit</strong>
Lets say i have this viewset</p>
<pre><code>class ProfileViewSet(viewsets.ModelViewSet):
... | <python><django><django-rest-framework><django-serializer> | 2023-03-31 20:54:56 | 2 | 471 | rafaelHTML |
75,902,554 | 4,045,275 | conda wants to remove half my packages if I try to update just one (on a fresh Anaconda installation) | <h1>The issue</h1>
<p>Today (31-Mar-2023) I downloaded Anaconda, uninstalled an older version and installed today's version on a Windows PC (private PC, no corporate firewall).</p>
<p>As suggested in another question <a href="https://stackoverflow.com/questions/75901180/conda-very-slow-and-downloading-only-from-conda-f... | <python><anaconda><conda><anaconda3><mamba> | 2023-03-31 20:33:56 | 1 | 9,100 | Pythonista anonymous |
75,902,530 | 9,900,084 | Polars: Expand dataframe so that each id vars have the same num of rows | <p>I have a dataframe that has id and week. I want to expand the dataframe so that each id have the same number of rows or four weeks.</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
data = {
'id': ['a', 'a', 'b', 'c', 'c', 'c'],
'week': ['1', '2', '3', '4', '3', '1'],
'num1': [1, 3... | <python><python-polars> | 2023-03-31 20:29:41 | 3 | 2,559 | steven |
75,902,475 | 1,142,728 | Setting initial value for a new foreign key on django admin | <p>I have the following django models:</p>
<pre><code>class ModelA(models.Model):
something = models.ForeignKey('Something')
extra_data = models.ForeignKey('ModelB')
class ModelB(models.Model):
something = models.ForeignKey('Something')
</code></pre>
<p>I have registered both models with django admin.</p>
<p>... | <python><django><django-admin> | 2023-03-31 20:19:44 | 1 | 1,231 | Alejandro Garcia |
75,902,366 | 975,199 | on_failure_callback is executed only at task level but not on DAG level | <p>This is a sample code, trying to test <code>on_failure_callback</code> at dag level. It works when I explicitly call out at task level but not at dag level.</p>
<p>following DAG level code doesn't call <code>on_failure_callback</code></p>
<pre><code>import sys
from datetime import datetime
from airflow import DAG
fr... | <python><airflow> | 2023-03-31 20:03:09 | 1 | 8,456 | logan |
75,902,268 | 14,676,485 | Filling NaN with object values throws an error: unhashable type: 'numpy.ndarray' | <p>I need to fill missing values with nemurical or categorical values (depending on column type). I wrote a function which calculates median for each year and fills missings with this value (numerical column) and for categorical columns - fills missings with most frequent value in each year. I prepared a test dataframe... | <python><pandas> | 2023-03-31 19:48:12 | 0 | 911 | mustafa00 |
75,902,255 | 4,944,986 | Spawn Python script on remote box using ssh from within python | <p>i am currently writing a script which is supposed to manage multiple servers. Basically I have a python script on my own machine which i will refer to as <strong>Host</strong> as well as multiple servers. When running my Host-Python script, I need to find a way to connect to my server via ssh and spawn a second pyth... | <python><bash><ssh> | 2023-03-31 19:45:59 | 2 | 945 | Finn Eggers |
75,902,183 | 19,438,577 | Since when is Python None equal to None? | <p>I always thought that Python nulls are not equal, as is common in many other languages and based on simple logic (if the value is unknown, how can it be equal to another unknown?).</p>
<p>However, recently I tried it, and discovered that:</p>
<pre><code>Python 3.10.2
>>> None == None
True
</code></pre>
<p>H... | <python><equality><nonetype> | 2023-03-31 19:36:05 | 3 | 542 | Dommondke |
75,901,930 | 6,395,388 | Pyre-check cannot located Typeshed | <p>I installed <code>pyre-check</code> on my Mac via <code>pip install</code>:</p>
<pre><code>> pip3 install pyre-check ✘ 127
Collecting pyre-check
Downloading pyre-check-0.9.18.tar.gz (18.0 MB)
━━... | <python><pyre-check> | 2023-03-31 19:04:07 | 2 | 4,457 | Derek Brown |
75,901,851 | 9,392,771 | Multiple Next Page Links on Same Page | <p>In python, how would you handle in a web scrape if the next page link shows up twice on the same page and you only want to grab one of them after you scrape the page?</p>
<p>Example <a href="https://www.imdb.com/search/title/?groups=top_100&sort=user_rating,desc&ref_=adv_prv" rel="nofollow noreferrer">https:... | <python><web-scraping> | 2023-03-31 18:52:06 | 2 | 301 | Sven |
75,901,770 | 11,286,032 | How do I check the version of python a module supports? | <p>I was wondering if there is a generic way to find out if your version of <code>python</code> is supported by a specific module?</p>
<p>For example, let us say that I have <code>python 3.11</code> installed on my computer and I want to install the modules <code>biopython</code> and <code>lru-dict</code>. Going to the... | <python><pypi> | 2023-03-31 18:41:36 | 3 | 2,942 | Marcelo Paco |
75,901,444 | 9,392,771 | Why does the while loop from scraper never ends? | <p>I have this code listed below that when it runs it is supposed to scrape data from an imdb site and go to the next page and do it again.</p>
<p>I am pieced this code together from bits of places from this site and it works just fine if I want just the first page (meaning remove the while true part and the nextpage l... | <python><web-scraping><beautifulsoup><while-loop> | 2023-03-31 17:58:57 | 2 | 301 | Sven |
75,901,378 | 11,666,502 | Fastest way to loop through video and save frames | <p>I need to extract frames and landmarks from a video in one process, and then perform operations of the frames and landmarks in another process. What is the most efficient way to do this?</p>
<p>Right now, I am storing frames as arrays in a list, and then pickling that list. Code below:</p>
<pre><code>frames, landmar... | <python><loops><opencv><computer-vision><pickle> | 2023-03-31 17:50:54 | 2 | 1,689 | connor449 |
75,901,180 | 4,045,275 | Conda very slow and downloading only from Conda-Forge | <h1>The issue</h1>
<p>I have recently installed Anaconda3 (as downloaded on 31-Mar-2023) onto a Windows PC. I chose the installation for my username only, which doesn't require admin rights. It's my private PC, so no corporate firewalls.</p>
<p>Quite simply, Conda doesn't work. Even a banal command like <code>conda upd... | <python><anaconda><conda><anaconda3> | 2023-03-31 17:23:31 | 1 | 9,100 | Pythonista anonymous |
75,900,997 | 9,105,621 | how to compare two dataframes and return a new dataframe with only the records that have changed | <p>I want to build a python script that will compare two pandas dataframes and create a new <code>df</code> that I can use to update my sql table. I create <code>df1</code> by reading the existing table. I create <code>df2</code> by reading the new data through an API call. I want to isolate changed lines and update th... | <python><pandas> | 2023-03-31 17:00:05 | 1 | 556 | Mike Mann |
75,900,837 | 10,234,248 | TDD modifying my test to make my code pass | <p>I'm learning Test Driven Development, i'm struggling a little bit, seems like my brain wants to build solution algorithm, and not the needed test to build my algorithm. I can barely formalize unit test, and i go back and forth to change my tests.
I come to a point where i make some adjustement in my code, and then i... | <python><flask><tdd> | 2023-03-31 16:34:56 | 3 | 447 | jmnguye |
75,900,701 | 11,021,252 | How to extract individual points from the shapely Multipoint data type? | <p>I am using shapely2.0; somehow, I can't iterate through individual points in the MULTIPOINT data type in this version.</p>
<p>I wanted to extract and plot individual points from the MULTIPOINT.
The MULTIPOINT is obtained from <code>line.intersection(circle_boundary)</code>, where I tried to get the intersection poin... | <python><gis><geopandas><shapely> | 2023-03-31 16:17:54 | 1 | 507 | VGB |
75,900,697 | 1,388,419 | Python win32serviceutil ModuleNotFoundError | <p>I created a Python win32serviceutil service following the excellent guide at <a href="https://thepythoncorner.com/posts/2018-08-01-how-to-create-a-windows-service-in-python/" rel="nofollow noreferrer">https://thepythoncorner.com/posts/2018-08-01-how-to-create-a-windows-service-in-python/</a>.</p>
<p>It will install ... | <python><python-3.x><windows-services><pywin32><win32serviceutil> | 2023-03-31 16:17:20 | 0 | 377 | Gotenks |
75,900,656 | 7,559,397 | Cannot check if item in listbox was clicked | <p>I am trying to check and see if an item in a listbox was selected and then enable another button if there is an item selected from the listbox.</p>
<pre><code>from tkinter import *
top = Toplevel()
top.geometry('255x135')
top.resizable(False, False)
guessbox = Listbox(master=top, selectmode=SINGLE)
guessbox.insert(... | <python><tkinter> | 2023-03-31 16:11:48 | 1 | 1,335 | Jinzu |
75,900,501 | 6,528,055 | How can I keep track of the number of epochs completed while training a Word2Vec model? | <p>I'm training my Word2Vec model for more than 12 hours for a corpus of more than 90k tweets (samples), ~10k unique words in the dictionary for a number of 5 epochs with my 8gb RAM laptop. Is it normal?</p>
<p>I want to track the progress of the training process which is why I want to keep track of the number of epoch... | <python><tensorflow><nlp><gensim><word2vec> | 2023-03-31 15:54:19 | 1 | 969 | Debbie |
75,900,386 | 305,883 | librosa y-axis spectrogram does not align properly | <p>How to align axis of spectrogram visualisations in Librosa or Matplotlib ?</p>
<p>Consider this example, <a href="https://librosa.org/doc/latest/generated/librosa.feature.spectral_rolloff.html" rel="nofollow noreferrer">from Librosa's documentation</a>:
<a href="https://i.sstatic.net/nmvkA.png" rel="nofollow norefer... | <python><matplotlib><librosa><spectrogram><acoustics> | 2023-03-31 15:41:03 | 1 | 1,739 | user305883 |
75,900,231 | 323,698 | Using python to generate a JWT raises ValueError "Could not deserialize key data" | <p>I am trying to generate a JWT for a Github app following these instructions <a href="https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-json-web-token-jwt-for-a-github-app" rel="nofollow noreferrer">https://docs.github.com/en/apps/creating-github-apps/authenticating-wi... | <python><python-3.x><jwt> | 2023-03-31 15:26:36 | 0 | 11,317 | Strong Like Bull |
75,900,223 | 1,747,493 | How to remove histogram bar labels for 0-values in matplotlib | <p>I'm creating histogram bar plots and I'm adding labels to the different categories with the value percentage. I wonder if it is possible to remove labels when the percentage value is 0, and if so, how?</p>
<p>For instance, the following script</p>
<pre><code>#!/usr/bin/env -S python
import pandas as pd
import numpy... | <python><numpy><matplotlib> | 2023-03-31 15:25:22 | 0 | 3,206 | Harald |
75,900,125 | 12,894,011 | How to store two separate variables of the same argument in Python? | <p>I am trying to write a function in Python which takes in a website name and simply returns two versions of it in two separate variables:</p>
<p>The first variable website should look like the original argument with no changes: <a href="http://example.com" rel="nofollow noreferrer">http://example.com</a></p>
<p>The s... | <python> | 2023-03-31 15:14:26 | 3 | 347 | Julius Goddard |
75,900,085 | 11,255,651 | Loss function giving nan in pytorch | <p>In pytorch, I have a loss function of <code>1/x</code> plus a few other terms. The last layer of my neural net is a sigmoid, so the values will be between 0 and 1.</p>
<p>Some value fed to <code>1/x</code> must get really small at some point because my loss has become this:</p>
<pre class="lang-bash prettyprint-over... | <python><pytorch> | 2023-03-31 15:09:45 | 2 | 826 | Mike |
75,900,056 | 12,860,924 | How to use K-Fold cross validation with DenseNet121 model | <p>I am working on classification of images breast cancer using <code>DensetNet121</code> pretrained model. I split the dataset into training, testing and validation. I want to apply <code>k-fold cross validation</code>. I used <code>cross_validation</code> from <code>sklearn</code> library, but I get the below error w... | <python><validation><keras><scikit-learn><k-fold> | 2023-03-31 15:07:41 | 1 | 685 | Eda |
75,899,931 | 11,268,057 | Create Stripe Payment Intent after purchasing | <p>I am using the Stripe Card Element for my website. The page that allows users to purchase a product is public-facing (you don't need to login) hence there is a lot of casual browsing.</p>
<p>I followed Stripe's <a href="https://stripe.com/docs/payments/card-element" rel="nofollow noreferrer">card element</a> docs fo... | <javascript><python><stripe-payments><payment-processing> | 2023-03-31 14:53:52 | 2 | 932 | abhivemp |
75,899,927 | 2,355,903 | Getting formatted traceback when overwriting sys.excepthook | <p>I am rewording this question, as it seems I had some issues in my initial question and it was too vague.</p>
<p>I am working on trying to build a replacement function for sys.excepthook to save errors to file when running a batch job. I have referenced several sources and and am specifically having trouble getting t... | <python><exception><logging><error-handling><unhandled-exception> | 2023-03-31 14:53:28 | 1 | 663 | user2355903 |
75,899,868 | 2,507,567 | Cannot install pyside6 from pip | <p>I'm looking at the Qt for Python<a href="https://doc.qt.io/qtforpython/quickstart.html" rel="nofollow noreferrer">1</a> documentation on how to install PySide6 and it should be simple enough:</p>
<pre><code>pip install pyside6
</code></pre>
<p>It doesn't work, though:</p>
<pre><code>ERROR: Could not find a version t... | <python><qt><pip> | 2023-03-31 14:46:38 | 3 | 1,986 | Romário |
75,899,862 | 14,728,691 | How to get files and filenames persisted in k8s volume that come from SFTP server? | <p>I have deployed an SFTP server in a pod where data is persisted in a persistent volume.</p>
<p>These files are sql dump files.</p>
<p>I would like to do the following in Kubernetes :</p>
<ol>
<li>Set up a Kafka producer and consumer in Python</li>
<li>Write a Python script to monitor the persistent volume for new du... | <python><kubernetes><sftp> | 2023-03-31 14:46:00 | 1 | 405 | jos97 |
75,899,840 | 12,760,550 | Create extra rows using date column pandas dataframe | <p>Imagine I have the following data:</p>
<pre><code>ID Leave Type Start Date End Date
1 Sick 2022-01-01 2022-01-01
1 Holiday 2023-03-28
2 Holiday 2023-01-01 2023-01-02
3 Work 2023-01-01 2023-01-01
</code></pre>
<p>I need to find a way to confirm Start Date and End Date hav... | <python><pandas><date><row> | 2023-03-31 14:43:47 | 3 | 619 | Paulo Cortez |
75,899,402 | 20,793,070 | Multi filter by 2 columns and display largest results with Polars | <p>I have df for my work with 3 main columns: cid1, cid2, cid3, and more columns cid4, cid5, etc. cid1 and cid2 is int, another columns is float.</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
df = pl.from_repr("""
┌──────┬──────┬──────┬──────┬──────┬──────┐
│ cid1 ┆ cid2 ┆ cid3... | <python><dataframe><python-polars> | 2023-03-31 14:00:01 | 2 | 433 | Jahspear |
75,899,314 | 2,386,605 | How can I serve ML models quickly and with a low latency | <p>Assume a user connects via a Websocket connection to a server, which serves a personalized typescript function based on a personalized JSON file</p>
<p>So when a user connects,</p>
<ul>
<li>the personalized JSON file is loaded from an S3-lile bucket (around 60-100 MB per user)</li>
<li>and when he types a Typescript... | <python><machine-learning><cdn><scalability><low-latency> | 2023-03-31 13:50:38 | 1 | 879 | tobias |
75,899,307 | 21,351,146 | How do I escape JSON strings in python mysql.connector? | <p>To clarify I am using Python 3.10.9 along with mysql.connector</p>
<p>I am trying to insert a JSON string into my DB but I get a syntax error</p>
<pre><code>func_locals -> {'protocol_id': '1',
'sock_object': '<create_socket.CreateSocket object at 0x7f8f3e1ae0>',
'sock': &quo... | <python><mysql><mariadb><mysql-python><mysql-connector> | 2023-03-31 13:50:05 | 0 | 301 | userh897 |
75,899,278 | 11,261,546 | Pybind11 default values for Custom type casters | <p>I have a function :</p>
<pre><code>void my_functions(int a, some_type b);
</code></pre>
<p>And I want to bind it using only the default argument for <code>b</code>:</p>
<pre><code> m.def("my_functions", &my_functions, pb::arg("a"), pb::arg("b") = function_that_returns_my_type()); ... | <python><c++><pybind11><default-arguments> | 2023-03-31 13:46:52 | 0 | 1,551 | Ivan |
75,899,186 | 34,935 | How to configure dependabot to check multiple files? | <p>The <a href="https://github.com/jazzband/pip-tools#cross-environment-usage-of-requirementsinrequirementstxt-and-pip-compile" rel="nofollow noreferrer">official recommendation from pip-tools for cross-compilation</a> is:</p>
<blockquote>
<p>As the resulting requirements.txt can differ for each environment, users must... | <python><github><dependabot> | 2023-03-31 13:37:23 | 1 | 21,683 | dfrankow |
75,899,158 | 8,801,879 | Shap summary plots for XGBoost with categorical data inputs | <p>XGBoost supports inputting features as categories directly, which is very useful when there are a lot of categorical variables. This doesn't seem to be compatible with Shap:</p>
<pre><code>import pandas as pd
import xgboost
import shap
# Test data
test_data = pd.DataFrame({'target':[23,42,58,29,28],
... | <python><xgboost><shap> | 2023-03-31 13:34:43 | 4 | 673 | prmlmu |
75,898,644 | 4,903,479 | Bayesian filtration technique for physics based model tuning | <p>I am new to Bayesian filtration techniques. It will be helpful, if you guide me on easy explainable terms the above concept.
I am seeking how to use Bayesian Filtration techniques for physics based model tuning.
Thanks in anticipation</p>
| <python><bayesian><kalman-filter><processmodel> | 2023-03-31 12:40:30 | 0 | 583 | shan |
75,898,563 | 10,522,495 | How to scrape only the text of reviews and avoid content from other elements? | <p>I am trying to extract reviews only from the webpages downloaded locally.</p>
<p>WebPage Link: <a href="https://www.airbnb.co.in/rooms/605371928419351152?adults=1&category_tag=Tag%3A677&children=0&enable_m3_private_room=false&infants=0&pets=0&search_mode=flex_destinations_search&check_in=... | <python><web-scraping><beautifulsoup> | 2023-03-31 12:32:13 | 1 | 401 | Vinay Sharma |
75,898,512 | 19,369,393 | How to instruct autopep8 to remove line breaks? | <p>How to instruct autopep8 python formatter to remove line breaks if the resulting line after removing the line breaks does not exceed the maximum allowed line length?
For example, I have the following code that was previously formatted with <code>--max-line-length 80</code>:</p>
<pre><code>def function(a, b, c):
... | <python><autopep8> | 2023-03-31 12:26:30 | 0 | 365 | g00dds |
75,898,501 | 8,081,597 | Is there an easy "tqdm like" way to make a for loop to run multiprocess? | <p>I have a for loop in Python that I want to run in multiple processes. I know I can use the <code>multiprocessing</code> module to achieve this, but I was wondering if there is a library that allows me to do this with a simple syntax similar to how <code>tqdm</code> works. Here is what I want to achieve:</p>
<pre cla... | <python><multithreading><multiprocessing> | 2023-03-31 12:25:33 | 1 | 306 | Adar Cohen |
75,898,467 | 4,336,593 | Transforming annotated csv (influxdb) to normal csv file using python script | <p>I have a <code>CSV</code> file that was downloaded from <code>InfluxDB UI</code>. I want to extract useful data from the downloaded file. A snippet of the downloaded file is as follows:</p>
<pre><code>#group FALSE FALSE TRUE TRUE FALSE FALSE TRUE TRUE TRUE TRUE TRUE
#datatype string lon... | <python><csv><influxdb><influxdb-python> | 2023-03-31 12:20:44 | 1 | 858 | santobedi |
75,898,276 | 3,018,860 | OpenAI API error 429: "You exceeded your current quota, please check your plan and billing details" | <p>I'm making a Python script to use OpenAI via its API. However, I'm getting this error:</p>
<blockquote>
<p>openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details</p>
</blockquote>
<p>My script is the following:</p>
<pre class="lang-py prettyprint-override"><code>#!/u... | <python><prompt><openai-api><completion><chatgpt-api> | 2023-03-31 11:58:04 | 5 | 2,834 | Unix |
75,898,130 | 21,787,377 | What is a better way to use 'request' in a ModelChoiceField | <p>Is there any way to use <code>user=request.user</code> inside <code>ModelChoiceField</code> when I use this method I got an error: <code>NameError: name 'request' is not defined</code>.</p>
<pre><code>class AlbumForm(forms.Form):
album = ModelChoiceField(queryset=Album.objects.filter(user=request.user)
</code></... | <python><django> | 2023-03-31 11:41:26 | 2 | 305 | Adamu Abdulkarim Dee |
75,898,107 | 17,596,179 | Getting result from select query with dbt jinja | <p>So I'm working with a duckdb database connected with dbt. Now I can execute my query and it can complete succesfully now the problem that I face is that I want to get the result from this query.
My sql file looks like the following.</p>
<pre><code>{%- call statement('all', fetch_result=True) -%}
select * from {{ so... | <python><sql><jinja2><dbt><duckdb> | 2023-03-31 11:39:34 | 1 | 437 | david backx |
75,898,033 | 19,003,861 | can only concatenate tuple (not "int") to tuple - sum up 2 variables after an if statement in django/python | <p>I am looking to sum 2 variables together and getting error: 'can only concatenate tuple (not "int") to tuple' (error edited since original post)</p>
<p>In summary, I have a sort of todo list. Every time an <code>action</code> is validated by creating an <code>Validation</code> object model, the <code>actio... | <python><django><django-views> | 2023-03-31 11:29:17 | 1 | 415 | PhilM |
75,898,010 | 6,734,243 | How sphinx decides which files should go in _source folder at build time? | <p>I want to use <code>html_show_sourcelink</code> and <code>html_copy_source</code> to display the rst sources of my documentation files. From what I understood the files are copied in a subdirectory <code>_source</code> of the <code>_build/html</code> directory.</p>
<p>How does Sphinx decide which file should go ther... | <python><python-sphinx> | 2023-03-31 11:27:15 | 0 | 2,670 | Pierrick Rambaud |
75,897,994 | 1,753,640 | Python Regex to extract text between numbers | <p>I'd like to extract the text between digits. For example, if have text such as the following</p>
<pre><code>1964 ORDINARY shares
EXECUTORS OF JOANNA C RICHARDSON
100 ORDINARY shares
TG MARTIN
C MARTIN
7500 ORDINARY shares
ARCO LIMITED
</code></pre>
<p>I want to produce a list of 3 elements, where each element is ... | <python><regex> | 2023-03-31 11:25:11 | 2 | 385 | user1753640 |
75,897,897 | 2,392,151 | pyarrow timestamp datatype error on parquet file | <p>I have this error when I read and count records in pandas using pyarrow, I do not want pyarrow to convert to timestamp[ns], it can keep in timestamp[us], is there an option to keep timestamp as is ?, i am using pyarrow 11.0,0 and python 3.10.Please advise</p>
<p>code:</p>
<pre><code>import pyarrow as pa
import pyar... | <python><pandas><parquet><pyarrow><fastparquet> | 2023-03-31 11:14:50 | 1 | 363 | Bill |
75,897,896 | 17,487,457 | IndexError: an index can only have a single ellipsis ('...') | <p>I have the following <code>numpy</code> 4D array:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
X = np.random.rand(5, 1, 10, 4)
# so for example, first 2 elements:
X[:2]
array([[[[0.27383924, 0.48908027, 0.64997038, 0.20394247],
[0.28361942, 0.33425344, 0.27687327, 0.2549442 ],
... | <python><arrays><numpy><multidimensional-array><numpy-ndarray> | 2023-03-31 11:14:49 | 1 | 305 | Amina Umar |
75,897,828 | 6,775,670 | Should I remove old python installation when I recompile it from sources | <p>Once I has installed python 3.7.1 from the sources. I need update a version of it between 3.7.1 and 3.7.5. And backwards.</p>
<p>I do not need both at the same time. I want to use the same directory for installed python. Should I remove the content from the folder I had before specified as ./configure --prefix=... w... | <python> | 2023-03-31 11:07:20 | 0 | 1,312 | Nikolay Prokopyev |
75,897,551 | 2,859,206 | Why is pandas.series.str.extract not working here but working elsewhere | <p>Why is a pandas.series.extract(regex) able to print the correct values, but won't assign the value to an existing variable using indexing or np.where.</p>
<pre><code>import pandas as pd
import numpy as np
df = pd.DataFrame(
[
['1', np.nan, np.nan, '1 Banana St, 69126 Heidelberg'],
['2', "Do... | <python><pandas><extract> | 2023-03-31 10:35:49 | 2 | 2,490 | DrWhat |
75,897,504 | 20,174,226 | How to find all instances of an unterminated percent sign in a batch file? | <p>I have a python function that looks through a batch file for potential errors, and the one that I am looking to resolve is to find any lines that have an unterminated percent sign. However, this function seems to be returning every <code>%</code> sign on every line that has a <code>%</code> sign.</p>
<p>Here is the... | <python><regex><batch-file> | 2023-03-31 10:32:09 | 1 | 4,125 | ScottC |
75,897,494 | 12,715,723 | How to expand value of 3d numpy array? | <p>Let say I have 3d array (<code>3x3x1</code>) like this:</p>
<pre class="lang-py prettyprint-override"><code>[[[149]
[121]
[189]]
[[ 32]
[225]
[ 44]]
[[ 33]
[133]
[ 11]]]
</code></pre>
<p>How can I expand all values so they can be the same in the deepest one (<code>3x3x3</code>) like this:</p>
<pre cl... | <python><arrays><numpy> | 2023-03-31 10:31:16 | 2 | 2,037 | Jordy |
75,897,342 | 6,151,828 | Concatenate results of `apply` in pandas | <p>I would like to apply a function to each element/row of a pandas Series/DataFrame and concatenate/stack the results into a single DataFrame.
E.g., I may start with a Series <code>s = pd.Series(["a", "b,c", "d,e,f"])</code>, and I would like to obtain as a final result <code>res = pd.Ser... | <python><pandas><dataframe><series> | 2023-03-31 10:13:54 | 1 | 803 | Roger V. |
75,896,928 | 7,745,011 | Is it possible print into one line per process in python? | <p>I haven't found a good solution for the following problem so far:</p>
<pre><code>def do_work() -> None:
print("Start work", end="")
# some long running operation
print("done")
def main():
with Pool(workers) as p:
for i in range(100):
p.apply_asy... | <python><multiprocessing> | 2023-03-31 09:34:15 | 1 | 2,980 | Roland Deschain |
75,896,800 | 595,305 | mariadb package installation difficulties | <p>This is in WSL (Ubuntu 20.04).</p>
<p>I've set up a Python VE with 3.10.10.</p>
<p>I've done <code>apt install</code> of python3.10-venv, python3.10-dev, python3.10-minimal and python3.10-distutils.</p>
<p>I've managed to activate the VE and do <code>pip install</code> with a few packages. But I'm having problems wi... | <python><pip><mariadb><version> | 2023-03-31 09:22:06 | 1 | 16,076 | mike rodent |
75,896,756 | 1,206,998 | spark addJar from hdfs in a jupyter python notebook | <p>We are running a jupyter notebook connected to a hdfs & spark cluster. Some user need to use a jar lib for a use case that we don't want to deploy for all notebooks. So we don't want to add this dependency to the global deployment of our solution.</p>
<p>We are looking for a way for spark to load the jar lib fro... | <python><apache-spark><jupyter-notebook><dependencies><hdfs> | 2023-03-31 09:16:02 | 1 | 15,829 | Juh_ |
75,896,736 | 11,113,553 | Bokeh: DataTable columns collasping when updating layout | <p>I noticed that when trying to update part of a Bokeh layout, the DataTable display changed (see attached picture) even though no modifications is made to the table explicitly in the code. The goal would be to update only one of the chart/table of the bokeh document, and not modifying the rest.</p>
<p><a href="https:... | <python><bokeh> | 2023-03-31 09:12:51 | 0 | 1,626 | K. Do |
75,896,565 | 221,270 | Find combination of two list in Pandas dataframe | <p>I have two lists:</p>
<pre><code>List1:
123
456
789
List2:
321
654
987
</code></pre>
<p>I want to find the combination of the 2 lists in a data frame but without combinations inside the lists:</p>
<pre><code>123-321
123-654
123-987
456-321
456-654
456-987
789-321
789-654
789-987
321-123
321-456
321-789
654-123
6... | <python><pandas> | 2023-03-31 08:49:42 | 2 | 2,520 | honeymoon |
75,896,561 | 6,803,114 | Not able to write spark dataframe. Error Found nested NullType in column 'colname' which is of ArrayType | <p>Hi I have a pandas dataframe named df , where few of the columns contain list of strings.</p>
<pre><code>id colname colname1
a1 [] []
a2 [] []
a3 [] ['anc','asf']
</code></pre>
<p>I want to write it into delta table. As per the schema of the table, the datatype of colname and c... | <python><pandas><apache-spark><pyspark><apache-spark-sql> | 2023-03-31 08:48:55 | 4 | 7,676 | Shubham R |
75,896,502 | 13,803,549 | AttributeError: 'submitButton' object has no attribute '_row' - Discord.py | <p>I keep getting this error for a Discord.py button and after searching the internet I still cant find out why it is happening.</p>
<p>Any help would be greatly appreciated.</p>
<p>Thanks!</p>
<p>AttributeError: 'submitButton' object has no attribute '_row'</p>
<pre class="lang-py prettyprint-override"><code> class... | <python><discord.py><discord-buttons> | 2023-03-31 08:40:36 | 1 | 526 | Ryan Thomas |
75,896,240 | 17,801,773 | How to create an image with intensities 0 to 255 with normal distribution? | <p>To solve my last question <a href="https://stackoverflow.com/questions/75884220/how-to-do-histogram-matching-with-normal-distribution-as-reference?noredirect=1#comment133860591_75884220">How to do histogram matching with normal distribution as reference?</a> I want to create an image with normal distribution. For th... | <python><image-processing><normal-distribution> | 2023-03-31 08:09:53 | 1 | 307 | Mina |
75,896,207 | 4,828,720 | Differences in timing between timeit.timeit() and Timer.autorange() | <p>I am trying to figure out how to use Python's <a href="https://docs.python.org/3/library/timeit.html" rel="nofollow noreferrer">timeit</a> module but I get vastly different timings between its <a href="https://docs.python.org/3/library/timeit.html#timeit.timeit" rel="nofollow noreferrer">timeit.timeit</a> method and... | <python><performance><profiling><timeit> | 2023-03-31 08:06:53 | 1 | 1,190 | bugmenot123 |
75,896,214 | 15,435,361 | Python: Chaining iterators without changing the original instance | <p>This questions goes in the direction of this question:
<a href="https://stackoverflow.com/questions/3211041/how-to-join-two-generators-or-other-iterables-in-python">How to join two generators (or other iterables) in Python?</a></p>
<p>But I'm searching for a solution that keeps the original instance of an iterator?<... | <python> | 2023-03-31 08:06:50 | 4 | 344 | B.R. |
75,896,149 | 8,547,986 | python using packages across virtual environment | <p>Apologies for the lack of better title..</p>
<p>I wanted to know if the following is possible?</p>
<p>So currently I am using vs-code for python work. In vs-code I install some packages related to vs-code extensions, for example I use <code>black</code> for formatting. The package <code>black</code> is installed in ... | <python><python-3.x><anaconda> | 2023-03-31 08:00:22 | 0 | 1,923 | monte |
75,896,102 | 8,667,243 | How can I generate documentation without writing any docstrings? | <p>How can I generate documentation without writing a single line of docstring? I simply want to have an API reference page.</p>
<p>Because as I think, if there are type annotations in functions, then we don't need docstrings to describe them.</p>
<p>For example, one of my source code functions:</p>
<pre class="lang-py... | <python><python-sphinx> | 2023-03-31 07:52:11 | 0 | 411 | yingshao xo |
75,896,095 | 1,142,881 | How to create a partitioned table with Peewee? | <p>When defining my data model with peewee, how can I make a table partitioned by a given field? I’m interested in partitioning a table by a date column, for example, by month of the year.</p>
<p>I see in Peewee’s documentation that I can add custom constraints as part of the Meta part of the data model, how can I then... | <python><postgresql><peewee> | 2023-03-31 07:51:07 | 1 | 14,469 | SkyWalker |
75,895,815 | 2,006,921 | Python import from central location | <p>I know that Python import strategy has been a matter of discussion in countless posts, but I have not yet found a satisfactory answer yet.</p>
<p>I am building a large Python project, where I try to group modules in subdirectories in a sensible way, thus creating a directory structure that becomes a few levels deep ... | <python><import> | 2023-03-31 07:16:23 | 1 | 1,105 | zeus300 |
75,895,583 | 2,833,774 | How to limit BigQuery job by slots | <p>I’d like to limit a BigQuery job (query) submitted with the Python SDK to use a certain amount of slots. For example, I have a provision with 400 slots in BigQuery (flat-rate). And let's say I've got a heavy query which uses 300 slots during execution (according to the statistics). I would like to define a lower lim... | <python><google-bigquery> | 2023-03-31 06:44:52 | 1 | 374 | Alexander Goida |
75,895,568 | 14,606,987 | Flask sessions not persisting on Google App Engine for a simple chess game | <p>I'm currently experiencing issues with Flask and sessions while developing a simple chess game. In this game, each time a new game starts, it is associated with a session. Everything works as expected when running the app locally. However, after deploying the app to Google App Engine, the current session gets remove... | <python><flask><google-app-engine><session> | 2023-03-31 06:42:31 | 0 | 868 | yemy |
75,895,405 | 10,396,491 | Copying and modifying weights with pytorch | <p>I am trying to copy weights from one net to another. When I do this, I can see the effect in the target net inside the sacAgent object:</p>
<pre><code>sacAgent.actor.latent_pi = copy.deepcopy(pretrained_actor.latent_pi)
</code></pre>
<p>When I try to copy the weights element-wise like so, I don't see any effect:</p>... | <python><pytorch> | 2023-03-31 06:19:53 | 0 | 457 | Artur |
75,895,105 | 2,825,403 | "Type variable has no meaning in this context" | <p>I have some machine learning model classes subclassed from XGBoost, Sklearn and TF and I have a factory method that takes a model name and returns a specific implementation and to have a correct return type from the factory I defined a TypeVar. Here MinXGBModel, MinRandomForestModel, MinDenseModel and MinMLPModel ar... | <python><type-variables> | 2023-03-31 05:22:06 | 1 | 4,474 | NotAName |
75,895,014 | 4,465,454 | How to get Column from Table using Bracket Notation in declarative SQLAlchemy 2.0 | <p>I use python SQLAlchemy 2.0 ORM in declarative style to define my tables like such:</p>
<pre><code>from sqlalchemy.orm import DeclarativeBase
from sqlalchemy import select
class Example(DeclarativeBase):
__tablename__ = 'example'
foo = mapped_column(Text, nullable=False)
</code></pre>
<p>I know that I can a... | <python><sqlalchemy><orm> | 2023-03-31 05:05:07 | 1 | 1,642 | Martin Reindl |
75,894,984 | 10,437,110 | Faster way to add a row in between a time series Python | <p>I have a dataframe that has one of the columns as 'date'.</p>
<p>It contains datetime value in the format <code>2020-11-04 09:15:00+05:30</code> for 45 days.</p>
<p>The data for a day starts at <code>9:15:00</code> and ends at <code>18:30:00</code>.</p>
<p>Apart from the date, there is an <code>x</code> column and a... | <python><python-3.x><pandas> | 2023-03-31 04:57:49 | 2 | 397 | Ash |
75,894,935 | 4,451,521 | A solution to pytest not finding a module to test | <p>This question is a follow up to <a href="https://stackoverflow.com/q/75894443/674039">this question</a> that was answered by the user @wim.</p>
<p>I have the same structure</p>
<pre><code> |
|-tests
| |----test_sum.py
|
|--script_to_test.py
|- pytest.ini
</code></pre>
<p>and the files
scri... | <python><pytest> | 2023-03-31 04:46:55 | 0 | 10,576 | KansaiRobot |
75,894,853 | 809,459 | Python Pandas Dataframe Multiplying 2 columns results replicated values of column A | <p>OK I am trying something I think should be very simple but it's doesn't seem to be working.</p>
<p>I have a Panda Dataframe which includes many columns. There are 2 which I want to multiply but instead of the resulting new column displaying the result of multiplying the two values, it shows the value in column A th... | <python><pandas><dataframe> | 2023-03-31 04:25:39 | 1 | 575 | Reg |
75,894,833 | 3,614,197 | repeat a sequence of numbers N times and incrementally increase the values in the sequence Python | <p>I have a number sequence as below</p>
<pre><code>sequence = (0,0,1,1,1,1)
</code></pre>
<p>I want the number sequence to repeat a specified number of times but incrementally increase the values within the sequence</p>
<p>so if n= 3 then the sequence would go 1,1,2,2,2,2,3,3,4,4,4,4,5,5,6,6,6,6</p>
<p>I can make a s... | <python><range><python-itertools> | 2023-03-31 04:20:57 | 5 | 636 | Spooked |
75,894,793 | 2,056,201 | Python 'NoneType' object has no attribute 'get' on a global variable | <p>I don't understand why I cannot set a global variable <code>driver</code> in Selenium</p>
<p>I get this error in the <code>Load()</code> function on <code>driver</code></p>
<pre><code>Exception has occurred: AttributeError
'NoneType' object has no attribute 'get'
File "D:\Code\edge_script.py", line xx, i... | <python><selenium-webdriver><edgedriver> | 2023-03-31 04:08:39 | 2 | 3,706 | Mich |
75,894,508 | 17,347,824 | TIMESTAMP and NULL in Postgresql table | <p>I am trying to populate a database table in postgresql and just keep getting errors. The data is a customer data set with 15 columns all of which are of object type. The table is set to the following:</p>
<pre><code>customer = ("""CREATE TABLE IF NOT EXISTS customer (
CustID INT PRIMARY KEY NOT NULL,
... | <python><postgresql> | 2023-03-31 02:59:24 | 1 | 409 | data_life |
75,894,443 | 4,451,521 | pytest finding and not finding modules to test | <p>I was going to post this question in code review because rather than a solution I wanted for python experts to check my code.
But while preparing the code I found some related issue so I finally decided to ask it here since it is not more just a code check</p>
<p>My question is how does pytest finds modules to test?... | <python><pytest> | 2023-03-31 02:43:01 | 2 | 10,576 | KansaiRobot |
75,894,421 | 6,197,439 | pip3 in venv refuses to install requested setuptools version | <p>I use the Python 3.10.10 in MINGW64, and I want to use a Python3 package that has not been updated in years, which I've installed successfully back in Python 3.7 on this platform - but of course, that is useless on Python 3.10.</p>
<p>Now I have to build this package again. It being old, it uses deprecated features ... | <python><pip><virtualenv><python-venv> | 2023-03-31 02:38:14 | 1 | 5,938 | sdbbs |
75,894,400 | 14,862,885 | Pymunk draw lines on space which falls due to gravity(do physics) | <p>I want to scrible on pymunk screen(pygame),which becomes a line like object and falls due to physics.</p>
<p>I tried to make the code for most part, now i am able to get the vertices of points on screen, I want the line to be drawn on screen joining these points and do physics:</p>
<pre><code>import pymunk
import py... | <python><pymunk> | 2023-03-31 02:32:43 | 0 | 3,266 | redoc |
75,894,373 | 1,857,373 | Lightgbm prediction issue TypeError: Unknown type of parameter:boosting_type, got:dict | <p><strong>Problem</strong></p>
<p>Build prediction accuracy model using lightgbm on New York Taxi Duration dataset. [Kaggle model:https://www.kaggle.com/code/mobilematthew/newyorkcitytaxidurationprediction/edit/run/123885887</p>
<p>Setting up Light Gradient Boost with one set of parameters, and two models, 1) use to L... | <python><machine-learning><lightgbm> | 2023-03-31 02:25:19 | 1 | 449 | Data Science Analytics Manager |
75,894,303 | 10,474,998 | Remove subfolders with the same name if empty | <p>Assuming I have a folder called trial that contains the following:
Folder1, Folder2, Folder3,...Folder5
And each of these folders has a subfolder called FF-15</p>
<p>Thus, the path is:
<code>'/Users/brianadams/school/trial/Folder1/FF-15'</code>, or <code>'/Users/brianadams/school/trial/Folder2/FF-15'</code>, and so ... | <python><python-3.x><jupyter-notebook> | 2023-03-31 02:06:29 | 2 | 1,079 | JodeCharger100 |
75,894,224 | 7,966,156 | How to match a changing pattern in python? | <p>So I have a collection of lyrics from different artists, but in the middle of all the lyrics there is always an advertisement I want to remove. It looks like this:</p>
<p>'lyric lyric See John Mayer LiveGet tickets as low as $53 lyric lyric'</p>
<p>More generally, the pattern is always: 'See ARTIST LiveGet tickets a... | <python><regex> | 2023-03-31 01:49:11 | 1 | 628 | Nova |
75,894,205 | 9,386,819 | How do I create a function that assembles data into a dictionary and then returns the values of a particular key, given as an argument? | <p>Suppose I have a function:</p>
<pre><code>def data_fetch():
# The function assembles this dictionary from various sources:
my_dict = {'a': [1, 2, 3],
'b': [4, 5, 6],
'c': [7, 8, 9]
}
</code></pre>
<p>And I want to be able to call the function with any combination of arguments <code... | <python><function> | 2023-03-31 01:45:50 | 2 | 414 | NaiveBae |
75,894,118 | 9,986,939 | Unpacking Nested Data with Pandas | <p>Hello I've got an icky list of dictionaries I want to put into a dataframe</p>
<pre><code>data = [
{
"name": "pod_name",
"type": "group",
"values": [
[
"7b977b5d68-mdwfc"
],
[
... | <python><pandas> | 2023-03-31 01:19:03 | 1 | 407 | Robert Riley |
75,893,863 | 10,891,491 | How can I mock/patch a method inside for specific method class? | <p><strong>Objective</strong>: I'm trying to do a end to end test in an application. So I would like to mock the external communications to test all flow.</p>
<p><strong>Business problem</strong>:</p>
<ul>
<li><p><code>Bar</code> class equivalent: I have a class that send requests.</p>
<ol start="2">
<li>bar_method -&g... | <python><mocking><pytest><python-unittest><pytest-mock> | 2023-03-31 00:15:43 | 1 | 436 | natielle |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.