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,884,925
6,005,206
Using pd.groupby() with pd.Grouper() consisting of date shows fewer groups
<p>In <code>pd.groupby()</code> using a <code>pd.Grouper()</code> along with a column <code>fruit</code> is showing less number of groups shown in <code>#4</code> below. There should have been <code>fruit</code> with other <code>dates</code> because those are there in the final output in <code>#5</code>.</p> <p>For exa...
<python><pandas><group-by><pd.grouper>
2023-03-30 06:47:44
1
1,893
Nilesh Ingle
75,884,747
11,162,983
ValueError: The last dimension of the inputs to `Dense` should be defined. Found `None`.....tensorflow==2.2
<p>I'm trying to run <a href="https://github.com/shamangary/FSA-Net/blob/master/demo/demo_FSANET_ssd.py" rel="nofollow noreferrer">this</a> code (this is the entire code that I've tried.):</p> <pre><code>import os import cv2 import sys sys.path.append('..') import numpy as np from math import cos, sin # from moviepy.ed...
<python><tensorflow>
2023-03-30 06:24:30
1
987
Redhwan
75,884,716
16,344,063
Torch in python unable to get some layers like add from model structure
<p>I have this simple code to write down structure of network.</p> <pre><code>model = torch.jit.load('best5.torchscript') file_object = open('sample.txt', 'a') for name, module in model.named_modules(): file_object.write(str(module)) </code></pre> <p>Problem is that some layers like &quot;add&quot; is not present<...
<python><deep-learning><pytorch><torch><yolo>
2023-03-30 06:19:25
1
301
Juraj Jakubov
75,884,707
19,723,806
How to get the PID of a PyWin32 PowerPoint process?
<p>At some point, I can't use <code>Quit()</code>. So, I need to find the PID and kill the process using <code>psutil</code> or <code>os.kill</code></p> <p>I already look at existing answers on StackOverflow but can't find them for PowerPoint. I already tried <a href="https://stackoverflow.com/questions/22785708/how-to...
<python><python-3.x><pywin32>
2023-03-30 06:18:41
0
354
Zigatronz
75,884,432
3,134,383
Python - how to get equivalent local time during DST transition
<pre class="lang-python prettyprint-override"><code>tz1 = pytz.timezone('UTC') dt1 = tz1.localize(datetime(2020, 10, 25,0,38,43,454000)) tz2 = pytz.timezone('Europe/London') dt2 = tz2.localize(datetime(2020, 10, 25,1,38,43,454000)) print(dt1) print(dt2) print(dt1==dt2) </code></pre> <p>It returns:</p> <pre class="la...
<python><datetime><timezone><timedelta><dst>
2023-03-30 05:32:14
1
887
xzk
75,884,399
13,000,378
ERROR: Could not find a version that satisfies the requirement en-core-web-sm==3.5.0
<p>I'm trying to upload my flask NLP app into the google cloud console. For the application, I'm using spacy and en_core_web_sm libraries.When I try to deploy the app using</p> <pre><code> gcloud app deploy </code></pre> <p>I get the below error</p> <pre><code>ERROR: Could not find a version that satisfies the requirem...
<python><google-cloud-platform><pip><nlp><spacy>
2023-03-30 05:23:52
0
661
Kavishka Rajapakshe
75,884,315
7,106,508
Configuring an existing interpreter for Pycharm
<p>I can't believe I've been using Pycharm for 8 years and I still can't reliably and easily configure an interpreter. In any case, when I click the following button no changes in Pycharm occur:</p> <p><a href="https://i.sstatic.net/jChkR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jChkR.png" alt="e...
<python><pycharm>
2023-03-30 05:07:31
1
304
bobsmith76
75,884,241
9,798,210
Convert the struct to double in MATLAB while reading it from CSV file
<p>I would like to read the CSV file in the MATLAB and slice the array.</p> <p>The link of the same file in CSV format: <a href="https://easyupload.io/kku924" rel="nofollow noreferrer">https://easyupload.io/kku924</a></p> <p>I am reading the CSV file using this code in Python:</p> <pre><code>import numpy as np df = np....
<python><matlab><csv><mat>
2023-03-30 04:52:26
1
1,835
merkle
75,884,220
17,801,773
How to do histogram matching with normal distribution as reference?
<p>I have an image and I want to do histogram matching with normal distribution as reference. I've seen this link: <a href="https://www.geeksforgeeks.org/histogram-matching-with-opencv-scikit-image-and-python/" rel="nofollow noreferrer">Histogram matching with OpenCV, scikit-image, and Python</a>. According to this lin...
<python><image-processing><scikit-image><histogram-equalization>
2023-03-30 04:47:12
1
307
Mina
75,884,091
11,255,651
Breaking a pytorch CNN classifier training process out of a local minimum
<p>I'm training an image classifier in PyTorch that is supposed to sort the images into 32 distinct groups that have similar size. The output is a one-hot vector where the 1 entry represents the chosen group and the other entries are 0. Here is my loss function:</p> <pre class="lang-py prettyprint-override"><code>favor...
<python><deep-learning><pytorch>
2023-03-30 04:20:04
0
826
Mike
75,884,015
16,853,253
Combining two models into one in django
<p>Is it possible to combine two models into one in django so that I can show all details of both table in django admin panel in one table.</p> <pre><code>class User(AbstractUser): first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) email = models.EmailField(unique=Tru...
<python><django>
2023-03-30 04:04:02
2
387
Sins97
75,883,985
7,797,210
Python scipy optimize calibration of two simultaneous function
<p>...... I've used python scipy optimize to solve; which is my go-to replacement for the equivalent of Excel solver. Right now, stumped, as somehow I cannot get my python code to work using two simultaneous equation. Fundamentally, my situation is</p> <ol> <li>I have a function, volatility_ = function(x1, x2, x3..., s...
<python><scipy-optimize><calibration><scipy-optimize-minimize>
2023-03-30 03:54:55
0
571
Kiann
75,883,889
2,056,201
Selenium Python Chrome unknown error: DevToolsActivePort file doesn't exist In Windows 10
<p>I cannot resolve this error, I tried everything that was suggested to start chrome webdriver with my current profile</p> <pre><code>Message: unknown error: Chrome failed to start: exited normally. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location C:\Program Files\Go...
<python><windows><google-chrome><selenium-webdriver>
2023-03-30 03:33:25
1
3,706
Mich
75,883,729
2,893,024
Trigger a mapper event in SQLAlchemy for a "soft delete" feature mixin class
<p>I'm implementing a <code>soft delete</code> mixin so that whenever I call <code>Object.delete()</code> it doesn't actually delete it, but rather sets a <code>deleted_at</code> column to the current time.</p> <p>Even though nothing actually gets deleted, I would like the app to act as if a deletion occurred and trigg...
<python><sqlalchemy>
2023-03-30 02:50:13
1
3,576
Michael Seltenreich
75,883,692
15,299,206
Error No file found while converting file present in s3 using boto3
<ul> <li>I have a csv files present in s3</li> <li>I am able to print bucket name, key and file content</li> <li>But while converting to json I am getting Error no file found</li> <li>There is only one csv file which is of 1 KB</li> </ul> <p>code is below</p> <pre><code>import boto3 import csv import json # set up S3 ...
<python><amazon-s3><boto3>
2023-03-30 02:39:26
2
488
sim
75,883,670
14,593,213
How to stop a thread that has a blocking function from easygui in python
<h1>Context</h1> <p>I am using the easygui library to make a simple interface for my program.</p> <p>In the program, I need to start a process that takes time and the user can cancel it if he is tired of waiting.</p> <h1>Code</h1> <p>Here is a minimal example code:</p> <pre><code>import easygui as eg import threading i...
<python><multithreading><easygui>
2023-03-30 02:34:43
1
355
Davi A. Sampaio
75,883,474
49,330
Pillow ImageEnhance Brightness and Contrast: what is the best order to apply these two filters?
<p>Looking at the Brightness and Contrast classes in ImageEnhance:</p> <p><a href="https://pillow.readthedocs.io/en/stable/reference/ImageEnhance.html" rel="nofollow noreferrer">https://pillow.readthedocs.io/en/stable/reference/ImageEnhance.html</a></p> <p>The image is in RGB mode, 8 bits per channel.</p> <p>I could ap...
<python><python-imaging-library><image-enhancement>
2023-03-30 01:45:19
1
1,143
Florin Andrei
75,883,361
3,066,571
Python how to access dataclass properties in list of dataclasses
<p>Using python 3.10.4</p> <p>Hi all, I'm putting together a script where I'm reading a yaml file with k8s cluster info, and I'd like to treat the loaded yaml as dataclasses so I can reference them with <code>.</code> properties.</p> <p>Example yaml:</p> <pre><code>account: 12345 clusters: - name: cluster_1 endpo...
<python><python-dataclasses>
2023-03-30 01:14:12
2
1,481
user3066571
75,883,272
5,212,614
How can we get latitude and longitude from street address?
<p>The code below works on my personal laptop but not on my work laptop.</p> <pre><code>import pandas as pd import folium import geopy from geopy.geocoders import Nominatim # Geocoding geolocator = Nominatim(user_agent=&quot;myGeolocator&quot;) location = geolocator.geocode(&quot;225 Baker St NW, Atlanta, GA 30313, Un...
<python><python-3.x><geocoding><reverse-geocoding>
2023-03-30 00:46:29
1
20,492
ASH
75,883,248
601,862
qt.qpa.xcb: could not connect to display localhost:17.0 DIFFERENT set up
<p>I run my Python code in VSCode on Windows 10 which ssh to the remote RPi 4. Got this error:</p> <pre><code>qt.qpa.xcb: could not connect to display :1 qt.qpa.plugin: Could not load the Qt platform plugin &quot;xcb&quot; in &quot;/home/pi/mambaforge/envs/mb/lib/python3.8/site-packages/cv2/qt/plugins&quot; even though...
<python><qt><visual-studio-code><raspberry-pi><x11>
2023-03-30 00:41:16
1
7,147
Franva
75,883,114
1,028,115
Recommended approach to importing and parsing GA4 BigQuery event data in SQL server
<p>We are using Python to connect to BigQuery to download daily events_YYYYMMDD.csv files. Those files contain a comma separated list of columns, and some of the columns contain .json data (some of which contain embedded .json as well).</p> <p>Each of those daily files contain approximately 1 million records.</p> <p>U...
<python><json><sql-server><google-analytics><google-analytics-4>
2023-03-30 00:04:48
1
1,044
Matthew Walk
75,883,001
3,986,055
How to include multiple diretories in the "archive_file" data source?
<pre><code>data &quot;archive_file&quot; &quot;zip_file&quot; { type = &quot;zip&quot; source_dir = [&quot;../src&quot;, &quot;../../common_lib&quot;] output_path = &quot;lambda-code.zip&quot; } </code></pre> <p>This script doesn't work because the <code>source_dir</code> only supports a single directory. I...
<python><lambda><terraform><zip><archive-file>
2023-03-29 23:34:39
1
1,484
Ken Zhang
75,882,725
1,185,242
Can you determine the number of output classes in a HuggingFace segmentation model?
<p>I am loading a model like this:</p> <pre><code>id2label = { 0: 'background', 1: 'cake', 2: 'donut', } model = Mask2FormerForUniversalSegmentation.from_pretrained(self.backbone, id2label=self.id2label, ignore_mismatched_sizes=True) model.load_state_dict(torch.load('checkpoint.pt', map_loca...
<python><pytorch><huggingface-transformers>
2023-03-29 22:36:30
1
26,004
nickponline
75,882,577
6,758,862
Overriden builtins affect live debugging
<p>I overrided <code>open</code> function, so that to bypass the file path length limitations in Windows, by providing the <code>\\?\</code> code before each path (no admin privileges to change <code>regedit</code>, and the code is distributable to multiple user, so no system changes are possible). The overriding is be...
<python><visual-studio-code><overriding><built-in>
2023-03-29 22:09:53
1
723
Vasilis Lemonidis
75,882,566
962,891
beancount not creating double entry transactions and postings to file
<p>I am using <a href="https://github.com/beancount/beancount/tree/2.3.5" rel="nofollow noreferrer">beancount 2.3.5</a> and I am trying to write a proof of concept file that does the following:</p> <ol> <li>Creates a simple chart of accounts</li> <li>Posts sample transactions into ledgers using double entry</li> </ol> ...
<python><beancount>
2023-03-29 22:07:48
2
68,926
Homunculus Reticulli
75,882,520
4,316,726
Allow a global variable modified in one class to be read by another class
<p>I've inherited a series of luigi tasks in a python script, and I am attempting to do some basic logging of the execution times within the various classes, but I'm having a hard time figuring out how to do that.</p> <p>The script itself contains four classes:</p> <pre><code>class Pull(luigi.Task): class Validate(luig...
<python><luigi>
2023-03-29 22:00:50
0
3,421
Brian Powell
75,882,512
18,769,241
combinations of all rows and cols from a dataframe
<p>Given a dataframe like this:</p> <pre><code>2 6 8 5 </code></pre> <p>I want to yield the following list of lists:</p> <pre><code>[ [[2],[6,5]], [[2],[6]], [[2],[5]], [[8],[6,5]], [[8],[6]], [[8],[5]], [[6],[2,8]], [[6],[8]], [[6],[2]], [[5],[2,8]], [[5],[2]], [[5],[8]], [[6,5],[2,8]] ] </code></pre> <p>I have ...
<python><pandas>
2023-03-29 21:59:17
1
571
Sam
75,882,435
8,053,785
Python error when trying to run docker-compose up
<p>I have installed docker-compose via ansible and I am trying to run a <code>docker-compose up</code> command but I am getting the error below:</p> <pre><code>sudo cd /etc/project/compose/ &amp;&amp; docker-compose up -vvv Traceback (most recent call last): File &quot;/usr/bin/docker-compose&quot;, line 7, in &lt;m...
<python><docker><python-2.7><docker-compose><pip>
2023-03-29 21:46:30
1
525
CPdev
75,882,413
1,366,734
Importing mayavi.mlab returns a type error
<p>I am rendering 3D surfaces. My program used to work but somewhere an update seems to have gone wrong.</p> <p>Using python3 if I execute</p> <pre><code>from mayavi import mlab </code></pre> <p>this responds with</p> <p>File &quot;/usr/lib/python3.10/re.py&quot;, line 209, in sub return _compile(pattern, flags).sub(re...
<python><import><mayavi.mlab>
2023-03-29 21:42:24
1
607
Keir
75,882,387
12,125,777
Django: Fields from Parent class don't include in the child class table
<p>I have three django models. A parent class and a two childs class. What I am missing to get the parent class fields appear in the childs class tables</p> <pre><code>class Parent(models.Model): advertiser = models.CharField('Advertiser', max_length=100) insertion_order = models.ForeignKey(UserInsertionOrder, ...
<python><django><django-rest-framework>
2023-03-29 21:38:22
1
542
aba2s
75,882,140
11,788,255
How to count total zeros according to criteria of another column of pandas dataframe?
<p>For a school activity to identify sensors in datasets that are working, I have the following dataframe:</p> <pre><code> # Import library import pandas as pd import numpy as np # Define dataframe df = pd.DataFrame({'ID': ['21F', '21F', '21F', '21F', '2H', '2H', ...
<python><pandas><for-loop>
2023-03-29 21:02:49
1
602
Jane Borges
75,882,136
64,351
How to find which code is changing the settings of the Decimal context in a long-running process?
<p>After scratching my head for days over a bizarre and intermittent problem in a Django app I'm responsible for, I eventually determined that the problem was that the configuration of the default Decimal context (the precision setting, in particular) is being altered without being altered back. I've worked around this...
<python><django>
2023-03-29 21:02:16
0
2,530
Alan Rowarth
75,881,982
16,344,063
Get all layers including operators from torch in python
<p>I want to get all layers like convolution etc... and operator like &quot;add&quot; in python but I really dont know how.</p> <p>This is my code</p> <pre><code>import torch # An instance of your model. model = torch.jit.load('best5.torchscript') # Print all the layers for name, param in model.named_parameters(): ...
<python><deep-learning><pytorch><torch><yolo>
2023-03-29 20:40:36
1
301
Juraj Jakubov
75,881,952
13,055,818
How numpy implements flatten ? Or generally strided array flattening
<p>I am trying to understand what is happening in python when you perform some operations. For instance, from <a href="https://stackoverflow.com/a/32034565/13055818">this reply</a>, I understand how strides are working and how it is important. But now, I would like to know, if after transpose, in the memory, the data h...
<python><arrays><numpy>
2023-03-29 20:37:07
2
519
Maxime Debarbat
75,881,821
6,626,531
How to get the output of a color from a LinearSegmentedColormap object
<p>python 3.9</p> <p>I'm using matplot lib to create a color. I want to add that color to a unit test, but I'm not sure how to get the color out of the object.</p> <pre class="lang-py prettyprint-override"><code>color1= LinearSegmentedColormap.from_list( &quot;COLOR1_CMAP&quot;, ( _normalize_rgb(*_rgb.B...
<python><matplotlib>
2023-03-29 20:18:46
1
1,975
Micah Pearce
75,881,657
558,972
Optional array in protobuf
<p>I have a protobuf message for a tree defined like so:</p> <pre><code>message TreeNode { uint32 id = 1; string name = 2; repeated TreeNode children = 3; } </code></pre> <p>I want to make children optional. But the compiler complains that we can't have optional with repeated.</p> <p>The JSON I get from Mes...
<python><protocol-buffers>
2023-03-29 19:58:57
1
22,072
vijayst
75,881,525
5,539,707
Is there a difference in returning a function or a lambda function?
<p>Is there a difference (even subtle) between those two following codes? (is there any special use case of second code?)</p> <ul> <li>code 1</li> </ul> <pre class="lang-py prettyprint-override"><code>def f(n): def g(x): return x * n return g </code></pre> <ul> <li>code 2</li> </ul> <pre class="lang-py ...
<python><function><closures>
2023-03-29 19:41:48
1
1,593
david
75,881,502
1,245,262
How can I reverse direction of Plotly's Colorbar, so that small values at top and large values at bottom
<p>I'm currently using the colorbar on <code>plotly</code> to indicate the depths at which underwater SONAR receivers have been placed. Currently, the colorbar looks like this:</p> <p><a href="https://i.sstatic.net/gFWyu.png" rel="noreferrer"><img src="https://i.sstatic.net/gFWyu.png" alt="Depths Colorbar" /></a></p> <...
<python><plotly>
2023-03-29 19:38:37
2
7,555
user1245262
75,881,479
4,913,254
How filter two specific values in one column that has a common value in another column
<h2>Question</h2> <p>The minimum reproducible example of my data frame looks like this</p> <pre><code>df = pd.DataFrame({'patient': ['patient1', 'patient1', 'patient1','patient2', 'patient2', 'patient3','patient3','patient4','patient4','patient4','patient4'], 'gene':['TYR','TYR','TYR','TYR','TYR','T...
<python><pandas>
2023-03-29 19:36:00
2
1,393
Manolo Dominguez Becerra
75,881,285
502,365
Deploying a spider with a git repo dependency fails eggification
<p>I have a Scrapy project (here after called <code>the_application</code>) that has a dependency on a library (here after called <code>the_library</code>) fetched from a git repository, and everytime I attempt to deploy the Scrapy project by running <code>scrapyd-deploy --include-dependencies</code> the command fails ...
<python><python-3.x><scrapy><scrapyd>
2023-03-29 19:14:25
0
2,956
Hrafn
75,881,082
417,896
Apache Arrow from C# to Julia or Python - footer issue
<p>I am writing a struct array in C# using the following code:</p> <pre><code> var structField = new StructType( new [] { new Field(&quot;field1&quot;, new StringType(), nullable: false), new Field(&quot;field2&quot;, new Int64Type(), nullable: false) ...
<python><c#><julia><apache-arrow>
2023-03-29 18:49:56
0
17,480
BAR
75,880,970
557,176
PyMuPDF (Fitz) QuadPoints for re-use in the Adobe Embed API
<p>I am trying to extract annotations from a PDF and then use that data to 'Cherry Pick' the annotations we require to display them in a clean version of the PDF using the Adobe Embed API. We are getting data fine from the PDF using PyMuPDF however when we apply the annotation to the clean PDF we are getting weird resu...
<python><pymupdf><adobe-embed-api>
2023-03-29 18:38:51
1
740
Justin Erswell
75,880,870
238,074
pip install modules/packages for AWS Lambda functions cross-platform
<p>I'm using pip 22.3.1 on a Windows host, but, of course similar issues are present on MacOS. When trying to assemble PyPI packages to be used in an AWS Lambda function, which executes in a Linux environment, one wants to be sure the correct packages are used for Linux.</p> <p>From my vantage point, over the years, pi...
<python><aws-lambda><pip>
2023-03-29 18:28:19
0
2,922
Kevin Buchs
75,880,362
593,487
How to slice a 3d numpy array into 2d using height from another array
<p>I have two arrays:</p> <pre class="lang-py prettyprint-override"><code>a.shape # (1024, 768, 100) heights.shape # (1024, 768) </code></pre> <p>I would like to extract a 2-dimensional image from <code>a</code> which would take a single element along the axis <code>2</code>, taking its index from <code>heights</code>....
<python><numpy>
2023-03-29 17:27:48
2
18,451
johndodo
75,880,333
4,404,805
Pandas: Insert rows from one dataframe into another at specific location based on condition
<p>I have two dataframes such as:</p> <pre><code>df1 = pd.DataFrame({'BarCode': ['12345678ABCD', '67890123ABCD', '12345678DEFG', '67890123DEFG'], 'Description': ['Apples', 'Milk', 'Oranges', 'Yoghurt'], 'Quantity': [99, 77, 10, 52], 'Price': [12.0, 10.5, 11.0...
<python><pandas><dataframe><optimization>
2023-03-29 17:25:21
2
1,207
Animeartist
75,880,253
8,939,181
Different results in R's `dtw` and Python's `dtw-python`
<p>I am exploring some alternatives to compute Dynamic Time Warping (DTW) distances in Python. And I am struggling with the limited documentation about the packages I am finding...</p> <p>I have explored <code>dtaidistance</code>'s <code>distance_fast</code> and <code>distance</code>; <code>fastdtw</code>'s <code>fastd...
<python><r><dtw>
2023-03-29 17:15:41
1
916
hamagust
75,880,172
10,687,615
Add Pie Chart to Subplot
<p>I created a dashboard of varying plots using the code below and would like to add a pie graph to the dashboard in the g11 spot.</p> <pre><code>fig=plt.figure(figsize=(35,30)) spec= fig.add_gridspec(26,2, wspace =0.1, hspace=2.50) g1 = fig.add_subplot(spec[0:2, 0:1]) g2 = fig.add_subplot(spec[0:2, 1:3]) .... g11 = f...
<python><pandas>
2023-03-29 17:07:42
0
859
Raven
75,880,165
2,698,266
Accessing Calls to Mocked Class functions
<p>I have written a custom class to mock a general API client in a codebase so that I can centrally and easily mock all of the class methods for unit testing. This is working great so far, however I am looking for a way to track individual calls to each class method. Right now that only trackable call via Mock is the i...
<python><django><unit-testing><mocking><python-mock>
2023-03-29 17:07:23
1
972
Wold
75,879,855
13,097,194
When using OSMnx, should I add the distance between the start/end points and their nearest nodes to the distance between those nodes?
<p>I am using OSMnx to calculate the walking distance between two points in a city. Since OSMnx's shortest_path() function calculates the distance between two nodes (which may be some distance from the actual points), I am adding the distance between each point and its nearest node to the distance returned by shortest_...
<python><osmnx>
2023-03-29 16:28:17
0
974
KBurchfiel
75,879,781
133,232
Is there a Selenium equivalent to Puppeteer's Page.exposeFunction()?
<p>For packaging reasons I am attempting to port a javascript using puppeteer to python using selenium.</p> <p>In the javascript there is function set up in the page to replace the function in a subsequent page load. This is to allow data in the loaded page to be replaced.</p> <p>Is there a selenium equivalent to this?...
<javascript><python><selenium-webdriver><puppeteer>
2023-03-29 16:19:40
0
755
regomodo
75,879,765
8,283,848
This account is not available: Unable to switch user in python alpine docker container
<p>I have a simple <code>Dockerfile</code></p> <pre><code>FROM python:3.10-alpine # Set environment variables ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 # Set arguments ARG USERNAME=jpg ARG USER_DIR=/home/$USERNAME ARG WORK_DIR=$USER_DIR/app # Creating a non-root user RUN adduser -S $USERNAME # Switching ...
<python><docker><alpine-linux>
2023-03-29 16:18:18
2
89,380
JPG
75,879,613
8,621,823
Why does adding duplicated features improve Logistic Regression accuracy?
<pre><code>from sklearn.datasets import load_iris from sklearn.linear_model import LogisticRegression X, y = load_iris(return_X_y=True) for i in range(5): X_redundant = np.c_[X,X[:,:i]] # repeating redundant features print(X_redundant.shape) clf = LogisticRegression(random_state=0,max_iter=1000).fit(X_red...
<python><scikit-learn><logistic-regression>
2023-03-29 16:04:16
1
517
Han Qi
75,879,479
12,981,397
trying to change the type of a column based on the column name
<p>I have a dataframe with columns such as 'ID', 'AGE', 'END_DATE', 'START_DATE' etc. I want to change the type of any column in my dataframe that has the word 'DATE' in it from a float to an integer (so columns like 'END_DATE', 'START_DATE' and others) .</p> <p>Currently the values in my columns that have 'DATE' in th...
<python><pandas><type-conversion>
2023-03-29 15:51:35
4
333
Angie
75,879,344
11,304,830
How to extract links from a website in python?
<p>I am trying to webscrape the below website. As a first step, I would like to get the links from which to extract the text. However, when I do the following, I get an empty list:</p> <pre><code>import pandas as pd from bs4 import BeautifulSoup url = 'https://www.federalreserve.gov/newsevents/speeches.htm' r = Beauti...
<python><pandas><web-scraping><beautifulsoup><python-requests>
2023-03-29 15:37:28
2
1,623
Rollo99
75,879,135
3,480,297
Factory Boy Base64 Encoded String Faker
<p>Is it possible to fake a base64 encoded string within factory-boy? For example, in a given factory, I'm able to fake (generate) a random name by doing <code>name = factory.Faker(&quot;name&quot;)</code>. In addition, I can fake an email by doing <code>email = factory.Faker(&quot;email&quot;)</code>.</p> <p>However, ...
<python><django><django-rest-framework><factory-boy>
2023-03-29 15:15:37
0
2,612
Adam
75,879,074
13,806,869
How to save the result of a SQL query as an integer in Python?
<p>I have a basic SQL query, which will always return a single number. I'd like to save this number as a python variable in integer format, so I can do some basic maths with it. Does anyone know how to do this please?</p> <p>This is my first attempt, using pandas:</p> <pre><code>my_variable = pd.read_sql_query( sql = ...
<python><pandas><sqlalchemy>
2023-03-29 15:09:52
2
521
SRJCoding
75,879,024
835,068
EOF when reading user input after reading from stdin
<p>I have the following python script which should optionally read text piped from stdin and appends it to a string, then enter a loop where it receives user input until the 'Q' character is read.</p> <pre><code>import sys def read_text_from_stdin(): if sys.stdin.isatty() or not sys.stdin.readable(): retur...
<python><file><command-line-interface><stdin>
2023-03-29 15:04:51
0
366
Nicholas McCarthy
75,878,935
11,257,395
Pandas efficiency issue with tolist
<p>I have a pandas dataframe like this:</p> <pre><code>&gt;&gt;&gt; df speed acc ids row_id 0.0 0.009766 0.004053 89806.0 8819.0 1.0 0.009766 0.001790 89886.0 8818.0 2.0 0.009766 0.000006 89886.0 8834.0 3.0 0.009766 0.003...
<python><pandas><performance>
2023-03-29 14:58:57
0
574
Andrea Barnabò
75,878,766
968,252
Python Sklearn auc_roc_curve and roc_curve functions don't seem to match
<p>I have the following Python code to compute both AUC and plot the ROC graphic:</p> <pre><code>import numpy as np import sklearn.metrics from sklearn.metrics import roc_curve from sklearn.metrics import roc_auc_score from matplotlib import pyplot testY = np.array([1., 1., 2., 1., 1., 1., 2., 1., 1., 1., 2., 2., 1.,...
<python><machine-learning><scikit-learn><roc><auc>
2023-03-29 14:43:41
1
398
hhaamm
75,878,665
7,057,547
python poetry (env use) not recognizing python version (windows)
<p>[Skip to the bottom for the workaround solution.] I have to work on windows for a python project. Got two versions of python installed (3.7 and 3.10), poetry is set up properly, but I cannot get poetry to work with python3.10:</p> <pre><code>PS &gt; poetry env use C:\Users\Foo\AppData\Local\Programs\Python\Python310...
<python><windows><powershell><path><python-poetry>
2023-03-29 14:35:16
0
351
squarespiral
75,878,536
15,724,084
python write a list of lists to multiple columns in excel(not in rows)
<p>I am trying to write many columns in excel. Trying to enter a <code>record</code> to columns. I have a list let's say as below</p> <pre><code>list1=[1,2,3,4,5] </code></pre> <p>the other list will be like</p> <pre><code>list2=['a','b','c'] </code></pre> <p>I will have many different sized(length) lists which is why ...
<python><excel><openpyxl>
2023-03-29 14:24:17
1
741
xlmaster
75,878,460
7,421,447
How to make formula differentiable for a binary classifier in PyTorch
<p>I am trying to create a custom loss function for a binary classifier case. I need the binary predictions as an input to the function. However, I am getting to a point where I am unable to create a the process differentiable. I get the raw output from the model which has autograd attached to it. It is as follows.</p>...
<python><machine-learning><pytorch><autograd>
2023-03-29 14:18:48
1
713
Alain Michael Janith Schroter
75,878,435
11,092,636
usecols keyword argument of pd.read_csv says it expects list[str] but the documentation says otherwise
<p>I'm using PyCharm 2022.3.3 (Professional Edition) and I have the following warning: <a href="https://i.sstatic.net/Jq4d5.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Jq4d5.png" alt="enter image description here" /></a></p> <p>MRE:</p> <pre class="lang-py prettyprint-override"><code>import pandas as...
<python><pandas>
2023-03-29 14:16:06
1
720
FluidMechanics Potential Flows
75,878,427
2,966,197
No output in finding all occurrences of a key in a nested python JSON
<p>I have this sample JSON which is complex and has many levels of nesting as well items in in:</p> <pre><code>{ &quot;resourceType&quot;: &quot;Single&quot;, &quot;type&quot;: &quot;transaction&quot;, &quot;entry&quot;: [ { &quot;fullUrl&quot;: &quot;urn:uuid&quot;, &quot;resource&quot;: { ...
<python><json><list><dictionary>
2023-03-29 14:15:32
2
3,003
user2966197
75,878,424
423,420
Why does QFileDialog.getOpenFileName ignore the dir argument on Fedora?
<p>I used to be able to set an initial directory for the native open-file dialog in PyQt5, PyQt6, PySide2 etc. using code like this:</p> <pre class="lang-py prettyprint-override"><code>QtWidgets.QFileDialog.getOpenFileName( self, 'Open file', '/home/michael/last_path', ) </code></pre> <p>where the 3d argume...
<python><qt><fedora><gnome>
2023-03-29 14:15:15
2
3,076
Michael Clerx
75,878,353
12,350,966
ipdb *** SyntaxError: multiple statements found while compiling a single statement
<p>When using ipython debugger (ipdb), sometimes I just want to paste something in the debugger to see if it works.</p> <p>This works for single line stuff and loops but if I paste something more that one line, for example:</p> <pre><code>test = 'foo' test2 = 'bar' </code></pre> <p>I get:</p> <pre><code>*** SyntaxError...
<python><debugging><ipython>
2023-03-29 14:09:46
0
740
curious
75,878,196
10,895,042
Python Plotly: zoom box focus with mutliple axes
<p>I'm creating a graph with double X and double Y axis. When using the zoom box, this only acts on one of the traces. How can I change the focus of the zoom box tool?</p> <p>It seems to focus on the last trace/axes combination added. In the example below, using the zoom box changes the range of second axis pair (x2, y...
<python><plotly>
2023-03-29 13:56:18
1
833
StephanT
75,877,916
525,865
Using Beautifulsoup To Scrape the data from a worldmap and store this into a csv-file
<p>try to scrape the data of the site <a href="https://www.startupblink.com/startups" rel="nofollow noreferrer">https://www.startupblink.com/startups</a> - in order to grab all the startups: well i think this is a good chance to do this with python and beautiful soup.</p> <p><strong>Technically</strong>, we could use P...
<python><html><pandas><beautifulsoup><python-requests>
2023-03-29 13:28:58
1
1,223
zero
75,877,721
9,929,725
Odoo 14 - Send Email Contact Form URL
<p>Here my code :</p> <pre><code> # Get partner partner_id = self.env['res.partner'].browse([vals['partner_id']]) # Get partner form url base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') url = f&quot;{base_url}/web#id={vals['partner_id']}&amp;action=77&amp;model=res.partner...
<python><python-3.x><odoo>
2023-03-29 13:11:47
1
321
PseudoWithK
75,877,712
3,146,491
Javascript and ajax issue in chromedriver
<p>I am using selenium version 4.8.3. I am trying to select a dropdown list in <a href="https://eservices.tn.gov.in/eservicesnew/land/areg.html" rel="nofollow noreferrer">https://eservices.tn.gov.in/eservicesnew/land/areg.html</a>. In normal chrome browser i can able to select district value from the drowpdown. During ...
<python><selenium-webdriver><selenium-chromedriver>
2023-03-29 13:10:34
1
349
Madusudhanan
75,877,643
5,140,756
How to implement more than one endpoint in a Google Cloud Function?
<p>My intention is to use a unique Google Cloud Function to accommodate a few endpoints.</p> <p>I do have a super simple code using the Python <code>functions-framework</code> to take an Id Token and validate whether it is valid. I'd like to add one more endpoint to revoke that Id Token. I haven't found any samples aro...
<python><google-cloud-platform><google-cloud-functions><gcloud><functions-framework>
2023-03-29 13:05:17
1
4,283
Augusto
75,877,615
19,079,397
How to zip two files in Databricks?
<p>I have two files stored in <code>'dbfs/tmp/folder/'</code> I am trying to zip the files, although the code runs with no error but the created .zip file cannot be seen in the folder. What is the best way to zip two files in Databricks?</p> <p>code:-</p> <pre><code>file_paths = ['/dbfs/dbfs/tmp/folder1/test1.parquet',...
<python><file><zip><databricks><parquet>
2023-03-29 13:03:11
1
615
data en
75,877,601
17,487,457
FFT: time-domain features to frequency domain
<p>I am not from Physics or electrical engineering, so the answers I read related to my only confused me the more. So I asked this case-specific question.</p> <p>I work with a sensor data (time series). The data consists of sensor values for 4 quantities (<code>4 features</code>), captured at 1 sample per second (<code...
<python><fft><time-frequency><frequency-domain>
2023-03-29 13:01:38
1
305
Amina Umar
75,877,444
11,092,636
mypy and "apply" of "Series" does not accept returns of an object of type set[Any]
<p>Here is a MRE:</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd data = {'list1': [1, 2, 3], 'list2': ['a', 'b', 'c'], 'list3': [True, False, True]} series_of_lists: pd.Series = pd.Series(data) series_of_lists = series_of_lists.apply(lambda x: set(x)) </code></pre> <p>The failure I get is the...
<python><pandas><mypy><typing>
2023-03-29 12:48:07
1
720
FluidMechanics Potential Flows
75,877,266
1,780,761
python - instance of class gets deleted once executed. cannot kill subprocess anymore
<p>I am trying to run Flask in a subprocess, so it gets its own core. so far so good. The code that starts flask in a subprocess is in my <code>flaskSubprocess.py</code> file, and can be seen below. In my main I import the flaskSubprocess file, and call it as seen below. Everything works, except the fact that the insta...
<python><flask><subprocess><instance><kill>
2023-03-29 12:33:05
1
4,211
sharkyenergy
75,877,243
15,414,616
spark --py-files is not working for zip made with python code but works with zip using mac
<p>I'm trying to use the flag <code>--py-files</code> with a zip file that include multiple python packages, since the machine that runs the spark can not pip install packages but it has access to S3.</p> <p>The package I'm trying to use is <code>hvac</code> so first I tried everything locally. I pip installed all of t...
<python><apache-spark><pyspark><compression>
2023-03-29 12:31:33
0
437
Ema Il
75,877,241
7,667,431
Track Azure Service Bus messages in Application Insights | Python
<p>I created Flask application that is tracked in Azure Application Insights, using OpenCensus package (mentioned in official docs: <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/app/opencensus-python" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/azure/azure-monitor/app/opencensus-python<...
<python><azure-application-insights><azureservicebus>
2023-03-29 12:31:23
2
324
Bartek Maciejewski
75,877,213
8,722,421
Hyperlink within .py to .docx (nominally Sphinx)
<p><strong>Context:</strong> I have requirements documents in .docx form, and I've made immutable bookmark tags and established hyperlinks through them, so can trace from user requirements through to software requirements.</p> <p>I would like to tag within the source code (.py) where I have implemented the solutions to...
<python><python-sphinx><docx><cross-reference>
2023-03-29 12:29:01
1
1,285
Amiga500
75,877,170
8,372,455
Pandas df with multiple operator OR statement
<p>I have a function where one passes a pandas df and it will return Boolean a 1 or 0 based on if some conditions are met.</p> <p>Can you use multiple OR statements using <a href="https://docs.python.org/3/library/operator.html#operator.or_" rel="nofollow noreferrer">Pythons built in operator</a>? For example I need to...
<python><pandas>
2023-03-29 12:24:10
2
3,564
bbartling
75,877,015
6,728,052
python threading Lock release method being called from other thread
<p>Initially I was under the impression that with Locks/Mutexes the same thread acquiring the lock should also release the lock to provide mutual exclusion based guarentees.</p> <p>After reading python threading docs about <a href="https://docs.python.org/3/library/threading.html#threading.Lock" rel="nofollow noreferre...
<python><locking><mutex><python-multithreading>
2023-03-29 12:10:32
0
741
Pranav Gupta
75,877,003
429,853
Reading strings with special characters in Python
<p>I have a string with special characters as follows</p> <pre><code>req_str = 'N\x08NA\x08AM\x08ME' ## If I print it I correctly get the word &quot;NAME&quot; print(req_str) &gt;&gt;&gt; print(req_str) NAME </code></pre> <p>Now I want to extract the string <code>NAME</code> from the string. I tried</p> <pre><code>''...
<python><python-3.x><string>
2023-03-29 12:09:18
1
1,082
sayan dasgupta
75,876,941
18,493,710
How can we send videos and GIFs with the preview in Bale messenger bot?
<p>I am creating a chatbot in Bale messenger using <a href="https://github.com/python-bale-bot/python-bale-bot" rel="nofollow noreferrer">this library</a>. Currently, the files and documents can be sent if the file_id is obtained before. The code below works perfectly fine.</p> <pre class="lang-py prettyprint-override"...
<python><bale-messenger><balebot>
2023-03-29 12:02:27
1
418
okaeiz
75,876,769
13,803,549
Return value from nested function 'not defined'
<p>I have a nested function that is returning two values. When I try to call those values I get an error saying its not defined.</p> <pre class="lang-py prettyprint-override"><code> async def wallet(self, interaction:discord.Interaction, button:discord.ui.Button): ### Blah blah blah ### @s...
<python><nested-function>
2023-03-29 11:46:02
2
526
Ryan Thomas
75,876,738
11,332,693
Selecting dataframe first row based on specific columns and removing rows if the column value in specific column appeared previously
<p>I have 3 dataframes</p> <p>df1</p> <pre><code>CAT1 CAT2 CAT3 ID_X A1 B C X1 A1 B C X2 A2 B C X3 A2 B C X4 A2 B C X5 A3 B C X6 A4 B C X7 </code></pre> <p>df2</p> <pre><code>CAT1 CA...
<python><pandas><dataframe><loops>
2023-03-29 11:42:24
1
417
AB14
75,876,679
287,964
How to split django app in multiple folder
<p>I like to split my django app here in my case it's called <code>Core</code> in multiple folders like in the picture. <a href="https://i.sstatic.net/iXj8b.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iXj8b.png" alt="enter image description here" /></a> Example</p> <pre><code>Bank ---views ---urls --...
<python><python-3.x><django><django-rest-framework>
2023-03-29 11:36:46
1
5,021
Rad
75,876,550
13,023,647
How to correctly receive responses from the ARP protocol
<p>I want to make a small script for monitoring the local network for the presence of devices in it. I am using <code>ARP protocol</code> <code>request and response</code>, here is my code:</p> <pre><code>import time import scapy.all as scapy import argparse import pandas as pd def get_arguments(): parser = argpa...
<python><python-3.x><scapy><arp>
2023-03-29 11:23:45
1
374
Alex Rebell
75,876,460
12,427,902
Plotly - Autorescaling y axis range when range slider used
<p>After a long search, I could not find any thread/discussion helping me to make <strong>autoscaling</strong> work with plotly.</p> <p>The idea would be that when I use the x-range slider to go through the data, the y-axis would be dynamically rescaled each time I move the slider.</p> <p>Currently, this is how it look...
<javascript><python><plotly><plotly.js>
2023-03-29 11:12:34
2
509
plonfat
75,876,390
17,973,259
Implementing game mode in a python
<p>I implemented a game mode in my alien onslaught game made with python and pygame and the concept is like this: Players are fighting aliens but each player has a limited number of bullets. When a player remains out of bullets he becomes inactive and, the game ends when both players run out of bullets. The method that...
<python>
2023-03-29 11:04:55
2
878
Alex
75,876,340
8,618,242
CMake can't find Python Development directory
<p>I want to install <code>librealsense v2.50</code> on <code>Jetson Xavier nx dev-kit</code> with <code>ubuntu 20.04</code> with python bindings as follows:</p> <pre><code>~/Downloads/librealsense-2.50.0/build$ cmake ../ -DFORCE_LIBUVC=true\ -DCMAKE_BUILD_TYPE=release \ -DBUILD_WITH_CUDA=true -DBUILD_PYTHON_BINDINGS=t...
<python><ubuntu><cmake><realsense>
2023-03-29 11:00:33
1
4,115
Bilal
75,876,210
14,457,833
Not able to run selenium in headless mode on linux server
<p><strong>Error:</strong></p> <pre><code>Message: unknown error: Chrome failed to start: exited abnormally. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) </code></pr...
<python><django><linux><selenium-webdriver><selenium-chromedriver>
2023-03-29 10:47:38
0
4,765
Ankit Tiwari
75,875,971
11,648,332
pip cannot install conda==4.8.3 from requirements.txt file
<p>I was asked to install the libraries contained in a requirements.txt file on a python 3.6 venv.</p> <p>I do so by executing the bash command:</p> <pre><code>./venv/bin/pip install -r ./ProjectFolder/requirements.txt --no-cache-dir </code></pre> <p>At a certain point the process runs into the following error:</p> <pr...
<python><python-3.x><anaconda><conda>
2023-03-29 10:24:13
1
447
9879ypxkj
75,875,915
7,797,146
mod_wsgi with a read only filesystem - webserver can’t start
<p>I’m using mod_wsgi to create a Python webserver. It has been Dockerized and deployed to kubernetes with readonlyfilesystem=true. The application can’t start because mod_wsgi tries to create files and folders in the tmp folder but it doesn’t have the permission. It’s possible to do it? There is eventually an alternat...
<python><docker><kubernetes><mod-wsgi>
2023-03-29 10:17:29
1
304
lordav
75,875,892
5,197,270
Can't create TIMESTAMP WITH TIMEZONE column in postgres due to SyntaxError
<p>I would like to create a table in postgres by running a DDL query using python, however I get a Syntax Error.</p> <p>My code:</p> <pre><code>query = &quot;&quot;&quot;CREATE TABLE data ( fire_date_utc TIMESTAMP, date_local TIMESTAMP WITH TIMEZONE, date_precision TEXT ); &quot;&quot;&quot; with db.con...
<python><postgresql><ddl>
2023-03-29 10:15:26
1
411
scott_m
75,875,801
8,477,566
Why is Tensor not a leaf tensor?
<p>I'm working on a program in which I initialise leaf node tensors (which require gradients) with the same values as existing tensors. As a simple example of such a program, I create 4 tensors as follows:</p> <pre class="lang-py prettyprint-override"><code>a = torch.tensor(4, dtype=torch.float32) b = a.detach().clone(...
<python><pytorch><tensor><autograd>
2023-03-29 10:07:06
1
1,950
Jake Levi
75,875,645
7,975,962
How can I make a newly installed package not to use cached version of another package?
<p>Title sounds too complicated but it goes like this. I'm using Kaggle notebook for a competition. I implemented an inference pipeline using external packages. Environment doesn't have internet connection. Packages I'm having trouble with are <code>transformers</code> and <code>open_clip</code>.</p> <p>Default version...
<python><jupyter-notebook><pip><huggingface-transformers><python-importlib>
2023-03-29 09:52:05
0
974
gunesevitan
75,875,628
4,495,790
How to insert new 2-level columns as mean of other 2-level columns in multiindex dataframe with Python?
<p>I have the following Pandas DF:</p> <pre><code> bar baz one two one two aaa 1 2 3 4 bbb 1 2 3 4 </code></pre> <p>I would like to have a new column <code>mean</code> per all 1-level group with the mea...
<python><pandas>
2023-03-29 09:49:52
1
459
Fredrik
75,875,600
3,624,000
User Defined Exceptions in Python
<p>I am learning on how to create a userdefined exceptions in python. I have created a exceptions with various types of exceptions and each one has its one error msg and must have a code to be sent as a response/error. After lot of reading, I am able to send error msg [custom msg] but struggling to send a code along wi...
<python><exception>
2023-03-29 09:45:44
0
311
user3624000
75,875,566
7,081,275
Python: Adding a zoom variable for matplotlib map
<p>I'm trying to add a zoom variable to the following code to increase / decrease the zoom (scale) of the map this code produces:</p> <pre><code>import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap latitudes = [24.49522] longitudes = [46.5057713] # Create a new Basemap instance with the desired map...
<python><python-3.x><matplotlib><matplotlib-basemap>
2023-03-29 09:42:09
0
809
Maverick
75,875,382
7,376,511
Replicate dataclasses-style __init__ autocreation from annotations
<pre><code>from dataclasses import dataclass @dataclass class A: number: int string: str default_not_hinted_arg = None A() # class A( # number: int, # string: str # ) </code></pre> <p>Is it possible to replicate this behavior, but for a custom non-dataclass model?</p> <p>Let's sa...
<python><type-hinting><mypy>
2023-03-29 09:24:56
0
797
Some Guy
75,874,745
1,961,574
compiling and installing with pip install vs python3 -m build
<p>I have a package that is giving me trouble (<em>netCDF4</em>). I found out that if I download and build the source code myself, it works fine.</p> <p>There are two ways to install this package from source. For the examples below, the source code is at <code>~/netcdf</code>.</p> <ol> <li><p>use <code>pip install ~/ne...
<python><pip><netcdf><python-packaging><netcdf4>
2023-03-29 08:20:09
0
2,712
bluppfisk