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,366,511
5,722,359
Why a function to customise ttk.Style() not work?
<p>I can't figure out the cause of why function <code>customise_ttk_widgets_style(ss)</code> is causing the <code>ttk.Button</code> and <code>ttk.Labels</code> to not appear correctly. Commenting out line <code># s = customise_ttk_style(s)</code> avoids the wrong widget appearances but I don't understand why this is so...
<python><tkinter><ttk>
2023-02-06 20:56:55
1
8,499
Sun Bear
75,366,396
5,613,367
Permission denied: calling a shell script from Python in a Jenkins job
<p>Trying to provide the minimal amount of information necessary here, so I've left a lot out. Lots of similar questions around, but the most common answer (use <code>chmod +x</code>) isn't working for me.</p> <p>I have a Python script and a shell script that sit next to each in a GitHub Enterprise repository:</p> <p><...
<python><bash><github><jenkins>
2023-02-06 20:44:55
1
898
Pat Jones
75,366,372
5,818,059
Why is `summary_col` ignoring the `info_dict` parameter?
<p>I need to run some linear regressions and output <code>Latex</code> code with <code>statsmodels</code> in <code>Python</code>. I am using the <code>summary_col</code> function to achieve that. However, there is either a bug or a misunderstanding from my side. Please see the following code:</p> <pre><code>import nump...
<python><python-3.x><latex><linear-regression><statsmodels>
2023-02-06 20:42:11
1
815
Raul Guarini Riva
75,366,367
4,542,117
numpy polyfit alternative for speed
<p>I am utilizing numpy's polyfit a numerous amount of times to run calculations and get the slope between two datasets. However, the speed at which it performs these calculations are not fast enough for what would be desired.</p> <p>Two things to note about the calculations:</p> <ol> <li><p>The value for x in the call...
<python><numpy>
2023-02-06 20:41:43
1
374
Miss_Orchid
75,366,330
1,990,200
Match statement case int 1 matches with boolean value True
<pre><code>a = True match a: case False: print(&quot;It is false&quot;) case 2: print('It is 2 true.') case 1: print('It is 1 true.') &gt;&gt;&gt; It is 1 true. </code></pre> <p>Why does the program execute the last case statement?</p>
<python><match><python-3.10><structural-pattern-matching>
2023-02-06 20:37:27
0
786
sp1rs
75,366,064
10,321,768
Should I use Integer to represent currency?
<p>I know that Decimal or a custom class is <a href="https://stackoverflow.com/questions/1406737/what-class-to-use-for-money-representation">generally is the preferred way of representing currency</a>, but I am asking if it can be also achieved using integer. If not possible, I would like to know why.</p> <p>I know we ...
<python><python-3.x><floating-point><integer>
2023-02-06 20:07:08
1
736
Eduardo Matsuoka
75,366,046
3,654,588
Cython: Overriding the `__cinit__` function with different parameters and signature
<p>I am interested in subclassing an existing Cython class (we'll call it <code>A</code>), which has say the following <code>__cinit__(self, int a, int b, *argv)</code> function signature.</p> <p>My new class <code>B</code> would have the following <code>__cinit__(self, int a, int c, *argv)</code>, where <code>b</code>...
<python><cython>
2023-02-06 20:05:07
1
1,302
ajl123
75,366,015
15,956,657
Python loop.sock_accept only accepts one connection
<p>My process is using <code>asyncio</code> and <code>socket</code> to communicate with other processes. It handles one client process connection perfectly, but when a second client tries to connect, it waits forever at the client's <code>connect_ex</code> method and the server's <code>sock_accept</code> method.</p> <...
<python><sockets><python-asyncio>
2023-02-06 20:01:34
0
363
alvrm
75,365,818
6,357,916
Group list of 4-strings into list of pairs
<p>I have following list of strings:</p> <pre><code>['word1 word2 word3 word4', 'word5 word6 word7 word8'] </code></pre> <p>(I have shown only two strings, but there can be many.) I want to create new list which should look like this:</p> <pre><code>['word1 word2', 'word3 word4', 'word5 word6', 'word7 word8'] </code></...
<python><python-3.x>
2023-02-06 19:39:16
4
3,029
MsA
75,365,737
1,276,506
When fine-tuning a pre-trained Model, how does tensorflow know that the base_model has been changed?
<p>Ng's Convolutional Neural Network class's Week 2 Lab on using Transfer Learning with MobileNetV2 (summary: <a href="https://github.com/EhabR98/Transfer-Learning-with-MobileNetV2" rel="nofollow noreferrer">https://github.com/EhabR98/Transfer-Learning-with-MobileNetV2</a>) and an additional tutorial (<a href="https://...
<python><tensorflow><keras><transfer-learning>
2023-02-06 19:28:40
2
39,963
boulder_ruby
75,365,729
554,421
Pytest plugin ignoring hooks for test run
<p>I am trying to add a plugin to eavesdrop on my pytest runs. from what I can find in code samples and documentation, this &quot;should&quot; work (emphasis on should)</p> <pre><code>&quot;&quot;&quot; to test scripted pytest control &quot;&quot;&quot; import sys import pytest class MyPytestPlugin: &quot;&q...
<python><plugins><pytest><hook>
2023-02-06 19:27:13
0
867
Reza
75,365,695
5,592,430
Update plot by new data instead of making new plot in Jupiter notebook
<p>I have some issue and I hope you can help me to resolve it. I need to create interactive plot with dropdown widget where I could select and plot the interested data. I doing it by following way:</p> <pre><code>import plotly.graph_objects as go import ipywidgets as widgets import pandas as pd df = pd.DataFrame( ...
<python><matplotlib><jupyter-notebook><plotly>
2023-02-06 19:22:26
2
981
Roman Kazmin
75,365,612
7,331,538
python string parsing issues when saving sql commands to file
<p>I have dicts data I am looping through to form <code>INSERT</code> commands for postgresql. where the parent keys of the dicts are the column names and the parent values are the column values:</p> <pre><code>data = { 'id': 45, 'col1': &quot;foo's&quot;, 'col2': {'dict_key': 5} } colum...
<python><sql-insert><psql>
2023-02-06 19:11:54
2
2,377
bcsta
75,365,463
17,047,177
Editorconfig for python docstring
<p>I am using the <code>pycharm</code> IDE and I would like to automatize the indentation of the python <code>docstrings</code> with the <code>.editorconfig</code> file. I get to control almost everything with the following configuration (just in case it is useful):</p> <pre><code>[{*.py,*.pyw}] ij_python_align_collect...
<python><pycharm><documentation><docstring><editorconfig>
2023-02-06 18:55:12
0
1,069
A.Casanova
75,365,406
15,239,717
How can I get a Field Id from a Related Django Model
<p>I am working on a Django project where and I want to get an ID of a Related model with a OneToOne attributed so I can edit the profile of the user with his related Profile but all I get in return is <strong>Field 'id' expected a number but got 'GANDE1'</strong>.</p> <p>Here are my Models:</p> <pre><code>class Profil...
<python><django><django-models><django-views><django-templates>
2023-02-06 18:46:50
1
323
apollos
75,365,231
12,226,377
Append multiple excel sheets and create a identifier column using pandas
<p>I am in a situation where I would like append multiple excel sheets coming from a single workbook on top of each other and build an identifier column. The identifier column will be built via extracting a word(within brackets of a column) from the column header, essentially creating a new column and storing that extr...
<python><pandas><merge><append>
2023-02-06 18:28:05
1
807
Django0602
75,365,158
8,968,801
Django: Unable to Apply Function View Decorator to Class Based View
<p>I'm migrating from regular function based views, to class based views. One of the things that I couldn't migrate were the decorators I used. The decorator in question checks if the credentials of the current user are valid and then executes the decorated function:</p> <pre class="lang-py prettyprint-override"><code>...
<python><django><django-views><django-queryset><django-class-based-views>
2023-02-06 18:20:26
2
823
Eddysanoli
75,365,126
12,014,637
The copy() method in Python does not work properly
<p>I have a pandas dataframe that I would like to make a duplicate of and do some operations on the duplicated version without affecting the original one. I use &quot;.copy()&quot; method but for some reason it doesn't work! Here is my code:</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd import...
<python><pandas>
2023-02-06 18:16:31
1
618
Amin Shn
75,365,121
6,929,467
FastAPI - Pydantic Query Parameter with Enum
<h3>Problem</h3> <p>I am unable to use Pydantic model as a query parameter and to support things like enum, it doesn't work. You can do a hacky way to use Pydantic for query parameters with <code>Depends</code> but it doesn't work as well as it should.</p> <p>This is a very big requirement in our company and I'm guessi...
<python><fastapi><pydantic>
2023-02-06 18:15:51
0
2,720
innicoder
75,365,105
6,423,456
Generic vs Specific MyPy types of functions
<p>I remember reading, or hearing somewhere that for a function, input types should be as generic as possible (<code>Iterable</code> over <code>list</code>), but return types should be as specific as possible.</p> <p>Is this written down somewhere official that I can reference when this comes up in team discussions? Or...
<python><mypy><typing>
2023-02-06 18:13:37
1
2,774
John
75,365,066
2,130,515
How to avoid click intercept while sending text to email field using Selenium in headless mode
<p>I want to connect <a href="https://app.wordtune.com/account/login?product=write&amp;platform=editor&amp;afterAuthRedirect=%2Feditor" rel="nofollow noreferrer">website</a>. I write the following code:</p> <pre><code>from time import sleep from fake_useragent import UserAgent from selenium.webdriver.support.ui import ...
<python><selenium><xpath><css-selectors><webdriverwait>
2023-02-06 18:09:46
2
1,790
LearnToGrow
75,365,019
15,317,733
Automatically set outline and fill color based on GeoJSON properties with geopandas
<p>I am making a program that retrieves GeoJSON data from past convective outlooks from the Storm Prediction Center (SPC) and plot it using geopandas. With my current code, it is able to plot outlooks correctly onto a map. However, the coloring isn't right. I noticed that the GeoJSON returned by the SPC included outlin...
<python><matplotlib><geojson><geopandas>
2023-02-06 18:06:53
1
394
Jellyfish
75,364,971
6,342,337
Issues compiling python3.10.9
<p>I have installed openssl version 1.1.1 on RHEL 7.9 and I am running the following commands</p> <pre><code>./configure --with-openssl=/opt/python/ssl --with-openssl-rpath=auto </code></pre> <pre><code>make -j8 </code></pre> <p>My gcc version is:</p> <pre><code>gcc --version gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)...
<python><cpython><rhel7><python-3.10>
2023-02-06 18:02:35
0
1,837
ScipioAfricanus
75,364,869
5,556,711
Can a Python module be multiple files?
<p>For years, I've known that the very definition of a Python module is as a separate file. In fact, even the <a href="https://docs.python.org/3/tutorial/modules.html" rel="nofollow noreferrer">official documentation</a> states that &quot;a module is a file containing Python definitions and statements&quot;. Yet, this ...
<python><module><package>
2023-02-06 17:52:50
3
706
David Cian
75,364,863
15,450,772
Folders included in the tar.gz, not in the wheel, setuptools build
<p>The automatic discovery of <code>setuptools.build_meta</code> includes top-level folders into the tarball that shouldn't be included.</p> <p>We were trying to build a <a href="https://gitlab.com/octopus-code/postopus" rel="noreferrer">python package</a> with <code>python3 -m build</code>. Our project has a <a href="...
<python><python-3.x><setuptools>
2023-02-06 17:52:13
1
451
KevinYanesG
75,364,827
12,458,212
Pickling/Unpickling vs Reading/Writing from txt - Memory Efficiency
<p>Recently I've been interested in optimizing data processing for a project where I send many API requests. Instead of saving the responses directly in console (ie. writing to a list), I instead write the returned data to a pickle file. It's my understanding that this is more efficient when considering memory limitati...
<python><memory><pickle>
2023-02-06 17:48:36
0
695
chicagobeast12
75,364,758
12,076,197
Split a bottom level column tuple into another level
<p>My current dataframe has two levels. I'm looking to add a third by splitting tuples, which are the names of the columns. See example:</p> <p>Original DF:</p> <pre><code>Category (A,Cat) (B,Dog) (B,Bird) (B,Frog) (HH,Lion) (HH,Tiger) 48 28 585 4 233 44 11 ...
<python><dataframe>
2023-02-06 17:41:17
1
641
dmd7
75,364,642
14,790,056
I want to groupby and drop groups if the shape is 3 and non of the values from a column contains zero
<p>I want to groupby and drop groups if it satisfies two conditions (the shape is 3 and column A doesn't contain zeros).</p> <p>My df</p> <pre><code>ID value A 3 A 2 A 0 B 1 B 1 C 3 C 3 C 4 D 0 D 5 D 5 E 6 E 7 E 7 F 3 F 2 </code></pre> <p>my desired df would be</p> <pre>...
<python><pandas><dataframe>
2023-02-06 17:28:57
1
654
Olive
75,364,539
2,890,093
How to run Python to reckognize module hierarchy for Airflow DAGs?
<p>A have several DAGs of similar structure and I wanted to use advice described in Airflow docs as <a href="https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/modules_management.html" rel="nofollow noreferrer">Modules Management</a>:</p> <blockquote> <p>This is an example structure tha...
<python><airflow><python-import>
2023-02-06 17:18:51
1
10,783
Kombajn zboΕΌowy
75,364,359
3,045,351
Using Selenium to run Javascipt and return the results
<p>I am trying to use Python Selenium to grab the data payload populating this <a href="https://www.route.org.uk/q42022-dashboard" rel="nofollow noreferrer">page</a>. Data seems to being fed in using Javascript from some Tableau API's. I'm not really a Javascript guy, but I've had a look in Chrometools and have found t...
<python><python-3.x><selenium>
2023-02-06 17:01:04
1
4,190
gdogg371
75,364,346
4,453,566
Using Custom Function with multiple parameters and partitioning/grouping by a column
<p>Is it possible to do something like the following in python polars:</p> <pre class="lang-py prettyprint-override"><code>import polars as pl import statsmodels.api as sm lowess = sm.nonparametric.lowess df = pl.DataFrame([pl.Series('x', ['a', 'a', 'a', 'b','b', 'b']), pl.Series('y', [1, 2, 3, 1, 2, 3]), pl....
<python><python-polars>
2023-02-06 16:59:40
1
1,364
troh
75,364,299
12,097,553
go.scatterpolar : trying to render radar graph with various lines color not working
<p>I am trying to build a radar chart where each line is of different color.</p> <p>I feel like I have followed the doc closely and I am now facing an error I can't seem solve, especially because NO ERROR is output!</p> <p>here is some dummy data I am working with :</p> <pre><code>r = [52,36,85] theta = [&quot;analytiq...
<python><plotly><plotly-dash>
2023-02-06 16:54:17
1
1,005
Murcielago
75,364,197
6,668,031
Adding multiple users to yammer group via PowerShell or Python
<p>Looking for a way through which I can add multiple users to a yammer group.</p> <p><a href="https://www.c-sharpcorner.com/blogs/how-to-add-user-to-yammer-group-using-powershell" rel="nofollow noreferrer">I tried this</a>, but it doesn't work.</p> <p>Is there any PowerShell scripts or an option available on the UI to...
<python><python-3.x><powershell><yammer><yammer-api>
2023-02-06 16:45:36
0
580
Joseph
75,364,155
4,115,123
Ansible + Python - Programmatically provide ansible-vault the vault password
<p>I followed the tutorial provided here : <a href="https://stackoverflow.com/questions/64705336/editing-ansible-vault-file-from-a-playbook">Editing Ansible vault file from a playbook</a> to create the ability to programmatically update my ansible vaults.</p> <p>Let's say though this is part of a much larger pipeline, ...
<python><ansible><ansible-vault>
2023-02-06 16:40:56
2
1,057
Jibril
75,364,133
653,770
How do I replace a string-value in a specific column using method chaining?
<p>I have a pandas data frame, where some string values are &quot;NA&quot;. I want to replace these values in a specific column (i.e. the 'strCol' in the example below) using method chaining.</p> <p>How do I do this? (I googled quite a bit without success even though this should be easy?! ...)</p> <p>Here is a minimal ...
<python><pandas><method-chaining>
2023-02-06 16:39:10
3
1,292
packoman
75,364,117
1,842,491
how can I narrow dataclass annotations (i.e., how can I update type hints after handling default None in post_init)?
<p>I have a dataclass that can take a keyword value, or, if no value is specified, infer a value from other attributes.</p> <pre><code>import dataclasses @dataclasses.dataclass class RelatedValues: primary: float _: dataclasses.KW_ONLY secondary: float | None = None def __post_init__(self): if self.se...
<python><mypy>
2023-02-06 16:37:36
1
1,509
Shay
75,364,099
12,596,824
Subtracting asctime from time module to get hours minutes and seconds in python
<p>How can I subtract end - start to get hours minutes and seconds of time completion in Python?</p> <p>I have some pseudocode here, I want to convert the print statement to what I said above.</p> <pre><code>start = time.asctime(time.localtime(time.time())) &lt; some code here&gt; end = time.asctime(time.localtime(ti...
<python>
2023-02-06 16:35:36
1
1,937
Eisen
75,364,001
7,800,760
Python: forcing imported string interpolation for SPARQL (not SQL)
<p>I use f-strings to build SPARQL queries with a variable and they work well as follows:</p> <pre><code>for label in longnames: sparqlquery = f&quot;&quot;&quot; PREFIX osr:&lt;http://dati.senato.it/osr/&gt; SELECT * WHERE {{ ?uri a osr:Senatore. ?uri rdfs:label &quot;{label}&quot;^^xsd:st...
<python><python-module><f-string>
2023-02-06 16:26:32
0
1,231
Robert Alexander
75,363,784
15,452,168
pivot data, in case of multiple values
<p>I have a pandas timeseries dataframe df with columns <code>date, week, week_start_date, country, campaign_name, active </code> for some date(s) we have multiple campaign information.</p> <p>for example</p> <pre><code>data = [[&quot;2023.01.02&quot;, 1, &quot;2023.01.01&quot;, &quot;BR&quot;, &quot;SALE-1&quot;, 1]...
<python><pandas><dataframe><pivot><data-cleaning>
2023-02-06 16:06:07
1
570
sdave
75,363,774
3,734,059
How to read top-level requirements (as from requirements.in) from setup.py and write back pinned requirements (as in requirements.txt)?
<p>I have a package with a <code>setup.py</code> file and want to use <code>pip-tools</code> to pin my dependencies for production.</p> <p>Let's say my <code>setup.py</code> looks as follows:</p> <pre><code>#!/usr/bin/env python import pathlib from setuptools import setup, find_packages setup( author=&quot;Foo&quo...
<python><pip-tools>
2023-02-06 16:05:22
2
6,977
Cord Kaldemeyer
75,363,758
15,991,297
Finding Last n Groups of Rows in Dataframe
<p>I have a large dataframe (1m+ rows) that contains test data. A snapshot of &quot;Events&quot; was taken at various times and up to three rows were added to the dataframe per snapshot. Eg, in the extract below the first snapshot for Event At223 was taken at 18/03/2016 18:10:45, the second at 21/03/2016 10:14:28, et...
<python><pandas>
2023-02-06 16:03:40
3
500
James
75,363,555
19,854,658
Calculating probability distribution of an image?
<p>I want to find the probability distribution of two images so I can calculate KL Divergence.</p> <p>I'm trying to figure out what probability distribution means in this sense. I've converted my images to grayscale, flattened them to a 1d array and plotted them as a histogram with bins = 256</p> <pre><code>imageone = ...
<python><math><image-processing>
2023-02-06 15:48:39
1
379
Jean-Paul Azzopardi
75,363,548
3,885,446
yolov8 predict show=True - Iamge kills notebook kernel
<p>I am testing yolov8 prediction using the following code:</p> <pre><code>from ultralytics import YOLO # Load a model model = YOLO(&quot;yolov8n.pt&quot;) # Use the model model.predict(source= &quot;bus.jpg&quot;,show=True) # predict on an image </code></pre> <p>This works perfectly in the Spyder IDE and the r...
<python><yolov5>
2023-02-06 15:48:14
1
575
Alan Johnstone
75,363,440
7,437,143
Plotly-Dash how to add an identifier to an Annotation?
<h2>Context</h2> <p>Suppose one has multiple sets of annotations, which are merged into 1 large <code>List</code> of annotations in the <code>fig.update_layout</code> of the <code>go.Figure</code> object in plotly/Dash. Since the annotations are created at different places, it may be somewhat tedious to keep track of t...
<python><plotly><annotations><plotly-dash><super>
2023-02-06 15:38:41
1
2,887
a.t.
75,363,115
112,871
Stacking to 100% with `seaborn.objects`
<p>I'm trying to make a plot with bars or areas rescaled to 100% with the new <code>seaborn.objects</code> interface and I can't seem to get <code>so.Norm()</code> to work, with or without <code>by</code>...</p> <p>Here's what I've got so far:</p> <pre class="lang-py prettyprint-override"><code>import seaborn as sns im...
<python><plot><seaborn><visualization><seaborn-objects>
2023-02-06 15:11:43
1
27,660
nicolaskruchten
75,363,020
5,539,674
Split string into functions on parantheses, but not subfunctions
<p>I am cleaning a data set that consists of concatenated function calls strings that look like this: <code>&quot;hello(data=x, capitalize = True)there()my(x = x)dear(x, 6L, ...)friend(x = c(1, 2, 3))&quot;</code>. The goal is to split such a string into separate list elements, so that every function stands on its own....
<python><regex>
2023-02-06 15:04:00
3
315
O RenΓ©
75,363,019
19,198,552
How to position the insertion cursor under the mouse pointer, after creating a tkinter text widget by a event?
<p>I want the user to be able to edit a canvas-text item. As the canvas-text item has less functionality than the text-widget, I want to use the text-widget for editing. So when the editing is started, by mouse double click event, I open a new canvas-window item over the canvas-text item and put a text-widget in it. Th...
<python><tkinter><mouseevent><text-widget>
2023-02-06 15:03:55
2
729
Matthias Schweikart
75,362,838
1,831,520
Sending slash on send_keys on Selenium Chrome Driver on Linux
<p>I have been trying to send a URL link to a text area. I am using python3 and Chrome Version 109.0.5414.119. It worked fine on my local OSX machine but when I tried to automate it on a Linux Machine. It started behaving weirdly. So I have this feeling that It can be a Chrome Driver-related issue.</p> <p>When I send a...
<python><python-3.x><selenium><selenium-chromedriver><automated-tests>
2023-02-06 14:47:12
1
7,590
sadaf2605
75,362,834
9,861,647
Python Pandas transpose Date Range of Values
<p>I have this Python data frame</p> <pre><code>year_month Type ID Values1 Values2 Values3 ... 2022-01 A 1 1 0 0 2022-02 A 1 3 4 6 2022-03 A 1 5 9 10 2022-01 B 2 ...
<python><pandas>
2023-02-06 14:47:05
1
1,065
Simon GIS
75,362,809
9,290,590
How to disable the Matplotlib navigation toolbar in a particular axis?
<p>I have a figure with different plots on several axes. Some of those axes do not play well with some of the navigation toolbar actions. In particular, the shortcuts to go back to the home view and the ones to go to the previous and next views.</p> <p>Is there a way to disable those shortcuts only for those axes? For ...
<python><matplotlib><user-interface><widget><interactive>
2023-02-06 14:45:06
3
419
Stefano
75,362,799
9,182,743
Pandas: i)groupby col_a ii) sort by col_b iii)sort df by col_b min value for each group
<p>given a dataframe:</p> <pre><code> col_a col_b 0 b 2022-01-01 1 a 2022-01-02 2 c 2022-10-03 3 b 2022-10-01 4 a 2022-10-03 5 c 2022-10-02 </code></pre> <p>I want to:</p> <ul> <li>groupby col_a</li> <li>within groups, values are sorted by col_b</li> <li>the groups are then sorted by order...
<python><pandas>
2023-02-06 14:44:03
1
1,168
Leo
75,362,419
1,325,133
What order does Pytest execute the tests
<p>Can anyone confirm the order in which pytest executes the tests? For basic tests (no fixture parameterization), it appears to perform the tests based on the sequential naming order of the test modules and then the order of test functions within the module. However, what is the order when you start to add in parametr...
<python><pytest>
2023-02-06 14:10:55
0
16,889
felix001
75,362,373
2,244,766
how to invalidate toxenv
<p>I have some tox project that processes some protobuf in the install-deps phase and outputs some <code>*pb.py</code> codecs (custom script executed as <code>install_command</code> option in the config). When I'm updating my workspace (and the protobuf files are updated), i would like to somehow mark the toxenv as inv...
<python><protocol-buffers><python-packaging><tox><protobuf-python>
2023-02-06 14:06:53
1
4,035
murison
75,362,342
3,760,875
Python entry_point in virtual environment not working
<p>I have a virtual environment where I am developing a Python package. The folder tree is the following:</p> <pre><code>working-folder |-setup.py |-src |-my_package |-__init__.py |-my_subpackage |-__init__.py |-main.py </code></pre> <p><code>main.py</code> contains a function <code>my_main</code>...
<python><package><virtualenv><setuptools><entry-point>
2023-02-06 14:04:40
1
2,569
aretor
75,362,059
2,727,655
Convert Tensoflow model to PyTorch model - model isn't learning
<p>I'm trying to port a tensorflow neural network to pytorch, as an exercise to familiarize myself with both / their nuances. This is the tensorflow network I'm porting to pytorch:</p> <pre><code>import pandas as pd import tensorflow as tf from tensorflow.keras.preprocessing import sequence from tensorflow.keras.models...
<python><tensorflow><keras><deep-learning><pytorch>
2023-02-06 13:40:37
2
554
lrthistlethwaite
75,361,952
7,980,206
Reassign the multiple column's value from other rows in a pandas dataframe
<p>Got a <code>dataframe</code>, CY (current year)- refers to 2022, PY (Previous Year) - refers to 2021, &amp; PPY (Prior to Previous year) refers to 2020. Want to collect this information as in a single row for a single id. Input dataframe looks like -</p> <pre><code>id Year Jan_CY Feb_CY Jan_PY Feb_PY Jan_PPY...
<python><pandas>
2023-02-06 13:32:15
2
717
ggupta
75,361,902
11,829,398
Is it ok to reference self.var in a parent class with the expectation it will be implemented in the child class?
<p>I have some classes that look like this.</p> <pre class="lang-py prettyprint-override"><code>class Parent: def f(self, x): # Is this bad practice? return x * self.number class Child(Parent): def __init__(self, number): # We create number in Child. self.number = number ch...
<python><oop><python-class>
2023-02-06 13:26:29
0
1,438
codeananda
75,361,896
5,675,325
Authentication using GitHub is not using the primary email
<p>Recently integrated GitHub authentication in my Django website and noticed that <a href="https://python-social-auth.readthedocs.io/en/latest/configuration/django.html" rel="nofollow noreferrer">Python Social Auth</a> is registering the users using a non-primary email address.</p> <p>How can that behaviour be modifie...
<python><django><authentication><github><python-social-auth>
2023-02-06 13:26:06
1
15,859
Tiago Peres
75,361,826
7,008,628
How to set the state of a past TaskInstance to success and continue the pipeline inside a airflow DAG?
<p>I'm trying to make a DAG with params that can be triggered with a dag_id/task_id. The goal of this DAG is to set the state of the last executed task to &quot;success&quot; and to continue the pipeline from this point.</p> <p>exemple of pipeline:</p> <p><a href="https://i.sstatic.net/HZc7q.png" rel="nofollow noreferr...
<python><airflow>
2023-02-06 13:18:16
2
1,689
Nicolas Menettrier
75,361,712
18,749,472
Python datetime.date.today() not formatting inside sqllite3
<p>In my database query which is executed with the <code>sqlite3</code> module I insert a new row of data which includes a date field.</p> <p>The problem is when getting todays date with <code>datetime.date.today().strftime('%Y-%m-%d')</code> which outputs <code>'2023-02-06'</code> (expected output), it changes inside ...
<python><sql><django><sqlite><datetime>
2023-02-06 13:07:00
1
639
logan_9997
75,361,554
3,575,623
Combine Binned barplot with lineplot
<p>I'd like to represent two datasets on the same plot, one as a line as one as a binned barplot. I can do each individually:</p> <pre><code>tobar = pd.melt(pd.DataFrame(np.random.randn(1000).cumsum())) tobar[&quot;bins&quot;] = pd.qcut(tobar.index, 20) bp = sns.barplot(data=tobar, x=&quot;bins&quot;, y=&quot;value&qu...
<python><matplotlib><seaborn><bar-chart><line-plot>
2023-02-06 12:52:20
1
507
Whitehot
75,361,535
5,901,870
Convert PySpark data frame to dictionary after grouping the elements in the column as key
<p>I have below PySpark data frame:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>ID</th> <th>Value</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>value-1</td> </tr> <tr> <td>1</td> <td>value-2</td> </tr> <tr> <td>1</td> <td>value-3</td> </tr> <tr> <td>2</td> <td>value-1</td> </tr> <tr> ...
<python><pandas><dataframe><pyspark>
2023-02-06 12:50:27
4
400
Mikesama
75,361,487
13,877,952
GroupBy and save each Occurence in Columns
<p>I have the following problem :</p> <pre><code>df Key1 Key2 Value1 Value2 FixedValue A A 12 32 15 A A 40 25 15 A A 13 12 15 A A 80 100 15 B A 0 1 ...
<python><pandas><group-by>
2023-02-06 12:45:58
1
564
Adept
75,361,467
6,071,697
Making a django model field readonly
<p>I am creating a django DB model and I want one the fields to be readonly. When creating a new object I want to set it, but later if someone tries to update the object, it should raise an error. How do I achieve that?</p> <p>I tried the following but I was still able to update the objects.</p> <pre><code>from django....
<python><django>
2023-02-06 12:44:12
1
622
Epic
75,361,423
10,270,590
How to use a python list as global variable python list with in @task.external_python?
<h2>GOAL:</h2> <ul> <li>Have a python list as a global variable between tasks.</li> <li>Currently it crashes at the 1st task.</li> <li>1.) I am trying to have a simple python list that is carried from 1 task to the next and append a few string values to it at task 2. So the goal is to have 1 shared list.</li> <li>2.) E...
<python><python-3.x><airflow><directed-acyclic-graphs><airflow-2.x>
2023-02-06 12:39:18
1
3,146
sogu
75,361,419
5,860,375
Python TypeHint Optional dataclass as None inside dataclass results in mypy error
<p>I am having a hard time to wrap my head around type hints for dataclasses. I have a dataclass Sudoku that creates another dataclass Grid with the method create_grid. The Grid class needs the size variable of the Sudoku in order to initialize correctly. Therefore i typehint the Grid dataclass as Grid | None and set i...
<python><type-hinting><mypy><python-dataclasses>
2023-02-06 12:38:56
0
801
ConSod
75,361,308
14,744,714
Configuration error at The Humanitarian Data Exchange (hdx API python)
<p>I'm trying to get data from a resource: <code>novel-coronavirus-2019-ncov-cases</code> from the site Humanitarian Data Exchang. Previously everything was fine, I updated the library <code>hdx-python-api==5.9.7</code> to the latest version and I get the following error:</p> <pre><code>Traceback (most recent call last...
<python><configuration><hdx>
2023-02-06 12:27:06
1
717
kostya ivanov
75,361,276
10,569,922
Reshape dataframe from long to wide
<p>my df:</p> <pre><code>d = {'project_id': [19,20,19,20,19,20], 'task_id': [11,22,11,22,11,22], &quot;task&quot;: [&quot;task_1&quot;,&quot;task_1&quot;,&quot;task_1&quot;,&quot;task_1&quot;,&quot;task_1&quot;,&quot;task_1&quot;], &quot;username&quot;: [&quot;tom&quot;,&quot;jery&quot;,&quot;tom&quot...
<python><pandas><dataframe><reshape>
2023-02-06 12:23:34
1
521
TeoK
75,361,253
11,611,246
Translate Matlab PLS Regression code to Python
<hr /> <p><strong>Matlab</strong></p> <p>I have some PLSR regression in Matlab that I need to translate to Python. The Matlab code is as follows:</p> <pre><code>% PLSR with 15 latent variables [~,~,~,~,~,MSEcv] = plsregress(X,y,15,&quot;cv&quot;,5,&quot;MCReps&quot;,100); rRMSE = 100*sqrt(MSEcv(2,:))/max(y)-min(y)); % ...
<python><matlab><scikit-learn><pls>
2023-02-06 12:20:36
1
1,215
Manuel Popp
75,361,162
12,436,050
Fetching triples using SPARQL query from turtle file
<p>I am new to SPARQL and currently struglling to fetch triples from a turtle file.</p> <pre><code>### https://ontology/1001 &lt;https://ontology/1001&gt; rdf:type owl:Class ; rdfs:subClassOf &lt;https://ontology/748&gt;; &lt;htt...
<python><sparql><rdflib><turtle-rdf>
2023-02-06 12:11:38
1
1,495
rshar
75,361,137
19,770,795
Bind inner class instance to an instance of its outer class
<h2>Code first</h2> <p>The goal is to design <code>OuterBase</code> such that the following passes:</p> <pre class="lang-py prettyprint-override"><code>class Outer(OuterBase): def __init__(self, foo: str) -&gt; None: self.foo = foo class Inner: outer: Outer def get_foo(self) -&gt; str:...
<python><inheritance><inner-classes>
2023-02-06 12:09:53
1
19,997
Daniel Fainberg
75,361,128
18,096,205
I want to download all the images of my boards on pinterest
<p>I am now trying to download all the images on the board using selenium.</p> <p>However, I am unable to log in. How should I click on this and enter my ID:Pass?</p> <pre><code>&lt;div data-test-id=&quot;login-button&quot;&gt; </code></pre>
<python><selenium><web-scraping><selenium-chromedriver>
2023-02-06 12:08:59
1
349
Tdayo
75,361,122
6,751,456
python add a list of variables as positional arguments for functions
<p>I have a list of variables that need to be passed in a couple of functions that take the same number of arguments.</p> <pre><code>a = 1 b = 'hello' c = 1.9 args = (a, b, c) op = func_a(args) if &lt;cond1&gt; else func_b(args) def func_a(a, b, c): ... def func_b(a, b, c): ... </code></pre> <p>But send...
<python><django><function><arguments>
2023-02-06 12:08:25
1
4,161
Azima
75,361,106
18,582,529
Best way to add run parallel proccesses in Python
<p>I have a telegram bot in aiogram and I need to run few tasks of checking google sheets in background. Here is my current code:</p> <pre><code>async def on_startup(_): asyncio.create_task(loop1()) asyncio.create_task(loop2()) asyncio.create_task(loop3()) if __name__ == '__main__': executor.start_poll...
<python><concurrency><parallel-processing><python-asyncio>
2023-02-06 12:06:55
0
663
lisa.smith
75,361,034
13,667,627
How to interpolate missing years within pd.groupby()
<p><strong>Problem:</strong></p> <p>I have a dataframe that contains entries with 5 year time intervals. I need to group entries by 'id' columns and interpolate values between the first and last item in the group. I understand that it has to be some combination of groupby(), set_index() and interpolate() but I am unabl...
<python><python-3.x><pandas><group-by><interpolation>
2023-02-06 11:59:26
2
1,562
Geom
75,361,001
1,502,991
Pandas slowness with dataframe size increased size
<p>I want to remove all url from a column. The column has string format. My Dataframe has two columns: <code>str_val[str], str_length[int]</code>. I am using following code:</p> <pre><code>t1 = time.time() reg_exp_val = r&quot;((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()&lt;&gt;]+|\(([^\s()&lt;&gt;]...
<python><pandas><dataframe>
2023-02-06 11:56:55
1
515
Maria
75,360,972
20,731,770
How to make a button with a command with the parameter/attribute of its name with tkinter?
<p>How to make a button with a command with the parameter/attribute of its name with tkinter?</p> <pre class="lang-py prettyprint-override"><code>from tkinter import * def openfile(name): print(name) for i in l: if num == 2: num = 0 y = y+100 x = 100 print(y) print(x) ...
<python><tkinter><tkinter-button>
2023-02-06 11:54:22
1
590
Adam Basha
75,360,942
2,607,447
unittest - skip folder/do not run tests inside folder automatically
<p>I have two folders with tests in this project:</p> <pre><code>/tests/... /tests_manual/... </code></pre> <p>I want <code>unittest</code> to skip <code>/tests_manual/...</code> folder, or, just discover tests in <code>/tests/...</code></p> <p>Tests inside <code>/tests_manual/...</code> should only be run manually th...
<python><unit-testing><python-unittest>
2023-02-06 11:51:35
0
18,885
Milano
75,360,898
14,808,637
Vectors Concatenation
<p>Suppose I have three vectors A, B, C</p> <blockquote> <pre><code>A vector size of 256 B vector size of 256 C vector size of 256 </code></pre> </blockquote> <p>Now I want to do concatenation in the following way:</p> <blockquote> <pre><code>AB= vector size will be 512 AC = vector size will be 512 BC = vector size wil...
<python><numpy><pytorch><torch>
2023-02-06 11:46:18
1
774
Ahmad
75,360,882
6,929,467
InfluxDB: How to deal with missing data?
<h4>Question Description</h4> <p>We are performing a lot of timeseries queries, these queries sometimes result in issues, they are usually performed through an API (Python) and sometimes result in complete failure due to data missing.</p> <p>Due to this situation we are not sure where to educate ourselves and get the a...
<python><time-series><influxdb>
2023-02-06 11:44:14
1
2,720
innicoder
75,360,686
15,178,267
Django: byte indices must be integers or slices, not str error
<p>I am trying to get some data from a payload using a webhook, in the response that I sent along side I added the meta data that should return with the payload and this is how I did it (<em>code below</em>), if you take a close look at the keys, there I one called <code>meta</code>, now I am trying to get some of the...
<python><django><django-rest-framework><django-views><django-queryset>
2023-02-06 11:25:29
2
851
Destiny Franks
75,360,667
3,767,820
How to use FilteredRelation with OuterRef?
<p>I'm trying to use Django ORM to generate a queryset and I can't find how to use an <code>OuterRef</code> in the joining condition with a <code>FilteredRelation</code>.</p> <p><strong>What I have in Django</strong></p> <p><em>Main queryset</em></p> <pre class="lang-py prettyprint-override"><code>queryset = LineOutlie...
<python><django><postgresql><django-orm>
2023-02-06 11:23:45
1
712
Xavier FRANCOIS
75,360,619
1,479,619
Python async socket - request trimmed (received partially)
<p>I have written a Python async socket server, basically listens on port and responds to it. However, sometimes I observe that the request is sent partially e.g. the Content-Length indicates that the length is X but actual request received is kinda trimmed halfway. What could go wrong here?</p> <pre><code>SERVER_HOST ...
<python><sockets>
2023-02-06 11:19:18
0
6,101
justyy
75,360,577
6,224,557
Create numpy array from panda daataframe inside a For loop
<p>Lets say that i have the following dataframe:</p> <pre><code>data = {&quot;Names&quot;: [&quot;Ray&quot;, &quot;John&quot;, &quot;Mole&quot;, &quot;Smith&quot;, &quot;Jay&quot;, &quot;Marc&quot;, &quot;Tom&quot;, &quot;Rick&quot;], &quot;Sports&quot;: [&quot;Soccer&quot;, &quot;Judo&quot;, &quot;Tenis&quot;,...
<python><pandas><numpy>
2023-02-06 11:14:31
3
305
Rolando Azevedo
75,360,558
7,800,760
Pylint disagrees with VSCode and python in imports
<p>I am not finding the way to properly code so that both pylint <strong>and</strong> the execution of the code (within VSCode or from the command line) would work.</p> <p>There are some similar questions but none seems to apply to my project structure with a src directory under which there will be multiple packages. H...
<python><pylint>
2023-02-06 11:11:56
1
1,231
Robert Alexander
75,360,489
20,646,427
How to connect multiple chained dropdown with django-forms-dynamic
<p>I have a form with counterparty, object and sections i connected them to each other with django-forms-dynamic package but object not connected to sections</p> <p>Counterparty connected to object form but sections are not connected to object how can i fix that?</p> <p>I guess that im wrong with 2 functions in forms.p...
<python><django>
2023-02-06 11:04:14
1
524
Zesshi
75,360,485
7,241,287
How to install Python or R in an apptainer?
<p>I am new to docker and using apptainer for that.</p> <p>the def file is: <strong><code>firstApp.def</code></strong>:</p> <pre><code>`Bootstrap: docker From: ubuntu:22.04 %environment export LC_ALL=C ` </code></pre> <p>then I built it as follows and I want it to be writable (I hope I am not so naive), so I can i...
<python><docker><apptainer>
2023-02-06 11:03:48
1
730
m.i.cosacak
75,360,284
11,409,379
Request for data that generates chart always empty
<p>I am trying to scrape data that generates a chart on a website using python's request module.</p> <p>My code currently looks like this:</p> <pre class="lang-py prettyprint-override"><code># load modules import os import json import requests as r # url to send the call to postURL = &lt;insert website&gt; # utiliz g...
<python><web-scraping><python-requests>
2023-02-06 10:46:21
1
1,816
fabla
75,360,256
5,349,291
Producing data for a cumulative distribution plot in bigquery
<p>I'd like to produce a cumulative plot that shows, for a given value, the percentage of data that is less than or equal to that value. In python / matplotlib / pandas, I can do this with the quantile function provided by pandas (and I guess numpy too):</p> <pre><code>import numpy as np import matplotlib.pyplot as pl...
<python><sql><pandas><google-bigquery>
2023-02-06 10:43:57
1
2,074
mchristos
75,360,210
11,016,652
TensorFlow classifiying integers for divisibility by 3 does not work
<p>I want to learn TensorFlow. I found a code which classifies integers for divisibility by 2 <a href="https://stackoverflow.com/a/54225144/11016652">here</a>. It works very well and accuracy is 100%. I only had to add an import command for numpy at the very beginning.</p> <p>Now I wanted to change it to classify for d...
<python><tensorflow><tensorflow2.0>
2023-02-06 10:40:10
1
2,424
zomega
75,360,160
9,113,910
pip: cannot install dependencies from wheel built by poetry if pyproject.toml contains dependencies from file
<p>Im using <code>poetry</code> in my project to manage dependencies, so my <code>pyproject.toml</code> contains all my dependencies. My goal is is to build a wheel from the current project and install them in another <code>virtualenv</code> using <code>pip</code>. But I'm facing an error:</p> <pre><code>pip._vendor.pk...
<python><pip><python-packaging><python-poetry><python-wheel>
2023-02-06 10:35:50
0
517
Andrej Vilenskij
75,360,093
2,924,453
derive path from adjacency matrix with numpy operations
<p>I need to derive a path from an adjacency matrix in a fast way (I have 40000 points).</p> <p>If a is the adjacency matrix:</p> <pre><code> a = array([[0., 0., 1., 0., 1.], [0., 0., 1., 1., 0.], [1., 1., 0., 0., 0.], [0., 1., 0., 0., 1.], [1., 0., 0., 1., 0.]]) </code></pre...
<python><numpy><graph-theory>
2023-02-06 10:29:23
2
3,801
GabyLP
75,360,070
11,311,927
Can you return a __str__ representation of an object within the __repr__ method at recursion level 1?
<p>I am looking for a way to implement a custom <code>__repr__</code> function in Python, that handles recursion Pythonically, while maintaining readability.</p> <p>I have two classes (Foo and Bar) that point to each other in their attributes. Of course, simply putting e.g.:</p> <pre><code>class Foo: def __init__(s...
<python><string><oop><recursion><repr>
2023-02-06 10:26:53
1
315
Sam
75,359,981
6,224,975
How does pickle.load work on class objects that have been modified and saved?
<p>Say I have four files <code>main_class.py</code>, <code>help_class.py</code>, <code>train.py</code> and <code>predict.py</code></p> <p><code>main_class.py</code> consists of</p> <pre class="lang-py prettyprint-override"><code>from help_class import HC class MC: hc = HC() def fit(self): self.hc.fit(...
<python><class><pickle>
2023-02-06 10:17:44
0
5,544
CutePoison
75,359,622
10,437,110
df.apply(hurst_function) gave TypeError: must be real number, not tuple in, Python
<p>I have a column in form of a data-frame that contains the ratio of some numbers. On that df col, I want to apply hurst function using df.apply() method.</p> <p>I don't know if the error is with the <code>df.apply</code> or with the <code>hurst_function</code>. Consider the code which calculates hurst exponent on a c...
<python><dataframe><math><apply>
2023-02-06 09:44:04
1
397
Ash
75,359,523
12,928,363
Django REST Framework JSON API show an empty object of relationships link when use relations.HyperlinkedRelatedField from rest_framework_json_api
<p>I'm create the REST API for space conjunction report, I want the conjunction to be a child of each report.</p> <p>My models:</p> <pre><code>from django.db import models from django.utils import timezone class Report(models.Model): class Meta: managed = False db_table = 'report' ordering = ['-id'] p...
<python><json><django><django-rest-framework><json-api>
2023-02-06 09:34:09
1
377
Paweenwat Maneechai
75,359,439
4,534,466
Tensorflow 2.10.0 not detecting GPU
<p>I've created a conda environment and installed tensorflow as such:</p> <pre><code>conda create -n foo python=3.10 conda activate foo conda install mamba mamba install tensorflow -c conda-forge mamba install cudnn cudatoolkit </code></pre> <p>This installed TensorFlow 2.10.0. I've installed CUDA 11.2 and cuDNN 8.1, a...
<python><tensorflow><gpu>
2023-02-06 09:25:50
3
1,530
JoΓ£o Areias
75,359,362
3,247,006
Can't I set the number with a decimal part to "MinMoneyValidator()" and "MaxMoneyValidator()" in "MoneyField()" with Django-money?
<p>I use <a href="https://github.com/django-money/django-money" rel="nofollow noreferrer">Django-money</a>, then I set <code>0.00</code> and <code>999.99</code> to <code>MinMoneyValidator()</code> and <code>MaxMoneyValidator()</code> respectively in <code>MoneyField()</code> as shown below:</p> <pre class="lang-py pret...
<python><django><django-models><django-money>
2023-02-06 09:17:25
1
42,516
Super Kai - Kazuya Ito
75,359,078
8,723,790
How to validate if a string field is all uppercase without custom validators
<p>In pydantic, is there a way to validate if all letters in a string field are uppercase without a custom validator?</p> <p>With the following I can turn input string into an all-uppercase string. But what I want is to validate the input so that no string with lower letters is allowed.</p> <pre><code>from pydantic imp...
<python><pydantic>
2023-02-06 08:47:56
1
301
Paul Chuang
75,359,058
755,640
lxml .text returns None when string contains tags
<p>I am a traversing complex XML file with millions of TU nodes and extracting strings from <code>&lt;seg&gt;</code> elements. Whenever <code>&lt;seg&gt;</code> element contains serialized tags, I get <code>None</code> object instead of a string.</p> <p>Code that returns <code>None</code>:</p> <pre><code>source_segment...
<python><xml><lxml>
2023-02-06 08:45:22
2
1,213
wilkas