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,913,144
3,325,586
Databricks Python SQL connector certificate verify failed error
<p>I am connecting to databricks SQL warehouse for the first time on my local machine (MacOS Venture 13.2.1) via Python 3.11</p> <pre><code>from databricks import sql import os connection = sql.connect( server_hostname = &quot;hostname&quot;, http_path = &quot;http path&...
<python><databricks>
2023-04-02 16:06:49
1
1,223
somethingstrang
75,912,950
13,606,345
Catching IntegrityError vs filtering before object creation?
<p>I have a development task. And at some point of this task, I need to create DB objects with a function which takes multiple json objects returning from third-party client request. I am for looping through json objects and calling <code>_create_db_object</code> method to create them one-by-one.</p> <p>Sample model:</...
<python><django>
2023-04-02 15:30:03
0
323
Burakhan Aksoy
75,912,710
21,346,793
Try to make fine-tuning of model gpt like
<p>I try to make fine tuning on essays, my datset looks like:</p> <pre><code>[ { &quot;topic&quot;: &quot;Мы были достаточно цивилизованны, чтобы построить машину, но слишком примитивны, чтобы ею пользоваться». (Карл Краус)&quot;, &quot;text&quot;: &quot;Высказывание Карла Крауса, австрийского писателя,...
<python><nlp><kaggle>
2023-04-02 14:44:41
1
400
Ubuty_programmist_7
75,912,664
19,553,193
Insert multiple list in database using python django
<p>Im confused on how can I insert multiple list bycolumn using a loop, let say the output what I want in database is something like this</p> <pre><code>name percentage is_fixed_amount PWD 20 0 Senior 20 0 OPD 6 0 Corporato...
<python><django><database>
2023-04-02 14:34:58
1
335
marivic valdehueza
75,912,627
17,487,457
Multidimentional array to pandas dataframe
<p>Suppose I have the following 4D array:</p> <pre class="lang-py prettyprint-override"><code>A = np.array([ [[[0, 1, 2, 3], [3, 0, 1, 2], [2, 3, 0, 1], [1, 3, 2, 1], [1, 2, 3, 0]]], [[[9, 8, 7, 6], [5, 4, 3, 2], ...
<python><pandas><dataframe><numpy><numpy-ndarray>
2023-04-02 14:27:15
1
305
Amina Umar
75,912,548
15,776,933
Python character with hex value
<p>Python have an escape sequence in which \x is there and if we write two integers after \x and print it, it gives us a character for e.g- <code>print(&quot;\x48&quot;)</code> gives us letter H. I want a list that shows which number is assigned to which character.</p> <p>The hexadecimal numbers 48 and 46 are assigned ...
<python>
2023-04-02 14:11:54
1
955
Anubhav
75,912,547
3,398,324
How get predictions from a specific PyTorch model
<p>I would like to obtain the prediction values from this PyTorch model (<a href="https://github.com/allegro/allRank" rel="nofollow noreferrer">https://github.com/allegro/allRank</a>) but when I run:</p> <pre><code> model(val_dl) </code></pre> <p>I get this error:</p> <pre><code>TypeError: LTRModel.forward() missing 2 ...
<python><pytorch><pytorch-dataloader>
2023-04-02 14:11:45
2
1,051
Tartaglia
75,912,013
1,627,466
Taking the mean of a row of a pandas dataframe with NaN and arrays
<p>Here is my reproducible example:</p> <pre><code>import pandas as pd import numpy as np df = pd.DataFrame({'x' : [np.NaN, np.array([0,2])], 'y' : [np.array([3,2]),np.NaN], 'z' : [np.array([4,5]),np.NaN], 't' : [np.array([3,4]),np.array([4,5])]}) </code></pre> <p>I would like to compute the mean array for each row exc...
<python><arrays><pandas><dataframe><numpy>
2023-04-02 12:26:33
2
423
user1627466
75,911,989
4,358,785
Python unicode internalerror message during testing only
<p>I have a test that (among other things) reads a json. When I read this file normally, everything is ok, but if I read it when during python's <code>Unitest.TestCase</code>, I get a strange error message:</p> <pre><code>INTERNALERROR&gt; self.message('testStdErr', name=testName, out=out, flowId=flowId) INTERNALER...
<python><unicode><python-unittest>
2023-04-02 12:22:55
1
971
Ruslan
75,911,976
10,358,059
Gmail removing hyperlinks from email. Why?
<p>My application is expected to send email verification link to user.</p> <p>When I open such an email in Gmail, the links are not shown, Gmail removes them.</p> <p>If I select [Show original] option, I can see that the links are there.</p> <ul> <li><p>Why is it so?</p> </li> <li><p>How can I fix this ?</p> </li> </ul...
<python><django><hyperlink><gmail>
2023-04-02 12:19:08
1
880
alv2017
75,911,809
1,651,481
svg2rlg converting svg to png only part of the image with percentage size
<p>My svg image: <a href="https://pastebin.com/raw/EeptY1C8" rel="nofollow noreferrer">https://pastebin.com/raw/EeptY1C8</a></p> <p>My code:</p> <pre><code>from svglib.svglib import svg2rlg from reportlab.graphics import renderPM drawing = svg2rlg(&quot;qr_code.svg&quot;) renderPM.drawToFile(drawing, &quot;temp.png&qu...
<python><tkinter><svg>
2023-04-02 11:44:15
1
612
XuMuK
75,911,755
219,976
How do I emulate long-running cpu-bound function in python?
<p>I want to make some experiments with threads and multiprocessing in Python. For that purpose I need a function which emulates long-running cpu-bound process. I want to manually set process time to about 5 secs. The function I created:</p> <pre><code>def long_running_cpu_bound_function(): print(f&quot;Started at ...
<python><multithreading><gil>
2023-04-02 11:31:33
1
6,657
StuffHappens
75,911,580
1,175,065
Multiprocessing in OpenAI Gym with abseil
<p>I am struggling with multiprocessing in OpenAI Gym with the abseil library. Basically, the gym.make seems working. However, I am trying to use <a href="https://github.com/Kautenja/gym-super-mario-bros/tree/master" rel="nofollow noreferrer">gym-super-mario-bros</a> which is not working. Below is a minimal working exa...
<python><pytorch><openai-gym><abseil>
2023-04-02 10:55:08
0
6,358
ravi
75,911,568
1,473,517
Can numba use long doubles?
<p>In numpy float128 is typically a long double (not a 128 bit float). But I can’t tell if numba has support for this. The docs don’t seem to mention long doubles or the numpy type float128.</p>
<python><numba>
2023-04-02 10:51:37
1
21,513
Simd
75,911,472
572,575
Django cannot query data from another table by using OneToOneField
<p>I create django model like this which api_key of Setting table is OneToOneField to Key table.</p> <pre><code>class Key(models.Model): api_key=models.CharField(max_length=100,unique=True) api_key_name=models.CharField(max_length=100) def __str__(self): return self.api_key class Setting(...
<python><django>
2023-04-02 10:33:10
2
1,049
user572575
75,911,397
1,627,466
Select and/or replace specific array inside pandas dataframe
<p>Here is my reproducible example:</p> <pre><code>import pandas as pd import numpy as np df = pd.DataFrame({'x' : [np.zeros(2), np.array([1,2])], 'y' : [np.array([3,2]),0], 'z' : [np.array([4,5]),np.zeros(2)], 't' : [np.array([3,4]),np.array([4,5])]}) </code></pre> <p>My goal is to change <code>np.zeros(2)</code> to <...
<python><arrays><pandas><dataframe><numpy>
2023-04-02 10:15:31
1
423
user1627466
75,911,387
9,104,399
My python module shows error that it does not have the attribute called for
<p>I am trying to install my own python package/module. I wrote some functions in a file namely <code>utils.py</code>, put it in the src folder. I also created the <code>__init__.py</code> and <code>setup.py</code>. I installed it from Pycharm's terminal, and it is installed. The package is installed with a name &quot;...
<python><package>
2023-04-02 10:14:09
0
325
Alam
75,911,335
1,470,314
See Pylint warnings visually in PyCharm
<p>I would like to use PyLint as an automatic code inspection in PyCharm, as in VSCode. (Marking with errors with red underscores and the like)</p> <p>I found a way to <a href="https://stackoverflow.com/questions/38134086/how-to-run-pylint-with-pycharm?rq=4">run pylint in PyCharm</a> as an external tool, but that was n...
<python><pycharm><pylint><code-inspection>
2023-04-02 10:03:35
1
1,012
yuvalm2
75,911,268
11,630,148
DRF ManyToMany Field getting an error when creating object
<p>I have a <code>Rant</code> model with <code>Category</code> linked to it using <code>ManyToManyField</code>. I've serialized it but the problem is this error:</p> <pre class="lang-json prettyprint-override"><code>{ &quot;categories&quot;: [ &quot;Expected a list of items but got type \&quot;str\&quot;.&quot; ...
<python><django><django-rest-framework><django-queryset>
2023-04-02 09:49:53
3
664
Vicente Antonio G. Reyes
75,911,233
1,954,677
Cancel common factors from two polynomials without merging them into a ration function expression
<p>I'd like to cancel a rational function <code>f1(z)=p1(z)/q1(z)</code> given by two polynomial expressions <code>p1,q1</code>.</p> <p>An almost complete solution would be the following</p> <pre><code>import sympy as sp z = sp.symbols('z') p1 = z**2 - 1 q1 = z**2 - z f1 = p1/q1 f2 = f1.cancel() # -&gt; (z + 1)/z </cod...
<python><sympy><symbolic-math><fractions>
2023-04-02 09:43:30
0
3,916
flonk
75,911,104
788,153
Error during Recursive feature elimination using Histogram based GBM
<p>I am implementing Recursive Feature Elimination using the HistGradientBoostingClassifier, but for some reason keeps on getting the following error:</p> <p>ValueError: when <code>importance_getter=='auto'</code>, the underlying estimator HistGradientBoostingClassifier should have <code>coef_</code> or <code>feature_i...
<python><machine-learning><classification><xgboost><cross-validation>
2023-04-02 09:18:32
1
2,762
learner
75,910,985
1,720,897
How to extract text using PyPDF2 without the verbose output
<p>I want to copy the contents from a PDF into a text file. I am able to extract the text using the following code:</p> <pre><code>from PyPDF2 import PdfReader infile = open(&quot;input.pdf&quot;, 'rb') reader = PdfReader(infile) for i in reader.pages: text = i.extract_text() ... </code></pre> <p>However, I do ...
<python><pypdf>
2023-04-02 08:55:09
1
1,256
user1720897
75,910,679
1,033,591
How to reference an object's attribute as both obj and attribute are variables?
<p>I have code as below:</p> <pre><code> {% for entry in qs %} {% for field_name in field_names %} &lt;span&gt;{{entry.field_name}}&lt;/span&gt; {%endfor%} {%endfor%} </code></pre> <p>But nothing will show up inside span tag. Then I change back to</p> <pre><code> {{entry.name}} </code></pre> <p>which &quot;n...
<python><django>
2023-04-02 07:36:25
1
2,147
Alston
75,910,641
9,727,704
Flask session variable doesn't persist between requests
<p>How do I save my session values between requests? I followed the guidelines here:</p> <ul> <li><a href="https://pythonbasics.org/flask-sessions/#Session-object" rel="nofollow noreferrer">https://pythonbasics.org/flask-sessions/#Session-object</a></li> <li><a href="https://flask.palletsprojects.com/en/2.2.x/api/#sess...
<python><flask><session-cookies>
2023-04-02 07:23:51
3
765
Lucky
75,910,549
3,682,549
Create a multi-index data-frame
<p>I have the following code to create a multi-indexed data frame:</p> <pre><code>import pandas as pd import numpy as np # Define the data data = { ('rf', 'wv_pretrained'): (0.7392722279437006, 0.7412604086615894), ('rf', 'wv_custom'): (0.7746309646412634, 0.7762235207436783), ('rf', 'glove_pretrained'): (...
<python><multi-index>
2023-04-02 06:58:33
1
1,121
Nishant
75,910,162
10,868,426
Regex Expression in Sparql - Mixed text and numbers
<p>I have some resources that are identified by <a href="http://myexample.org/NNNN" rel="nofollow noreferrer">http://myexample.org/NNNN</a> where NNNN is any number, for example, one resource may be <a href="http://myexample.org/9890" rel="nofollow noreferrer">http://myexample.org/9890</a>. I am using SPARQL and Python...
<python><regex><sparql><rdflib>
2023-04-02 04:46:38
0
609
User 19826
75,910,116
4,717,149
AttributeError: module 'scipy.stats' has no attribute 'itemfreq'
<p>I am getting error like - <code>AttributeError: module 'scipy.stats' has no attribute 'itemfreq'</code> while I am trying to use <code>stats.itemfreq</code> method from <code>scipy</code> as shown in the example <a href="https://www.geeksforgeeks.org/scipy-stats-itemfreq-function-python/" rel="nofollow noreferrer">h...
<python><scipy>
2023-04-02 04:25:30
1
506
Md Aman Ullah
75,910,045
11,462,274
How to send a large list created in Python as a parameter when making a request to a Google Apps Script Web App to update a Google Sheet?
<p>Initial important information, in my tests I tried to use both methods and both generate the same error:</p> <p>GET:</p> <pre><code># PYTHON web_app_response = requests.get( webAppsUrl, headers=headers, params=params, timeout=360 ) // Google Apps Script function doGet(e) {} </code></pre> <p>POST:</p> <pre><code...
<python><google-apps-script><google-sheets>
2023-04-02 03:56:18
1
2,222
Digital Farmer
75,909,965
6,176,440
Python using Pandas - Retrieving the name of all columns that contain numbers
<p>I searched for a solution on the site, but I couldn't find anything relevant, only outdated code. I am new to the Pandas library and I have the following <code>dataframe</code> as an example:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>A</th> <th>B</th> <th>C</th> <th>D</th> <th>E</t...
<python><pandas><dataframe>
2023-04-02 03:23:03
5
490
Adrian
75,909,937
17,801,773
Displaying a RGB image in float64
<p>I have an image with data type uint8. I want to convert it to the data type float64 and display it. I expected to see the image as I displayed it with data type uint8. But the result is this: <a href="https://i.sstatic.net/45Hht.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/45Hht.png" alt="enter ima...
<python><image><matplotlib><image-processing><imshow>
2023-04-02 03:13:21
1
307
Mina
75,909,808
5,212,614
AttributeError: 'CountVectorizer' object has no attribute 'get_feature_names' -- Topic Modeling -- Latent Dirichlet Allocation
<p>I'm trying to follow the example from the link below.</p> <p><a href="https://medium.datadriveninvestor.com/trump-tweets-topic-modeling-using-latent-dirichlet-allocation-e4f93b90b6fe" rel="nofollow noreferrer">https://medium.datadriveninvestor.com/trump-tweets-topic-modeling-using-latent-dirichlet-allocation-e4f93b9...
<python><python-3.x><topic-modeling><countvectorizer><latentdirichletallocation>
2023-04-02 02:21:38
2
20,492
ASH
75,909,708
610,569
How to raise meaningful import errors from users' casing typos?
<p>Given a library that allows this import:</p> <pre><code>from thislibrary import FooBar </code></pre> <p><strong>Is there a way to figure out the casing of the characters in <code>FooBar</code>?</strong></p> <p>Motivation: This is because users of <code>thislibrary</code> usually misspell the object and does</p> <ul>...
<python><importerror><modulenotfounderror><python-importlib>
2023-04-02 01:41:04
2
123,325
alvas
75,909,676
14,154,784
Only render part of django template if objects.all is not empty
<p>I only want to render part of a django template if objects.all is not empty. Normally this is done like:</p> <pre><code>&lt;ul&gt; {% for thing in things.all %} &lt;li&gt;{{ thing.name }}&lt;/li&gt; {% empty %} &lt;li&gt;Sorry, nothing to see here&lt;/li&gt; {% endfor %} &lt;/ul&gt; </code></pre> <p>But what...
<python><django><django-templates><django-template-filters>
2023-04-02 01:23:01
1
2,725
BLimitless
75,909,672
16,922,748
Generating new a column in dataframe given value falls within a certain range of another column value
<p>Given the following dataframe:</p> <pre><code>df = pd.DataFrame({'A':[random.randrange(0, 9, 1) for i in range(10000000)], 'B':[random.randrange(0, 9, 1) for i in range(10000000)]}) </code></pre> <p>That may look like this:</p> <pre><code> A B 0 8 3 1 3 0 2 8 4 3 6 5 4 8 2...
<python><pandas><dataframe>
2023-04-02 01:22:27
2
315
newbzzs
75,909,654
8,713,442
Pivot data in pyspark
<p>I want to pivot data based on the column name. Column name before <code>_</code> will become provider name in output, and the remaining part of that column name becomes the new column name. This is just an example as the real time scenario is much more complicated than this (some columns are present only for one pro...
<python><apache-spark><pyspark>
2023-04-02 01:16:04
2
464
pbh
75,909,635
14,154,784
Render Submit Button in Same Row as Form Field in Django Crispy Forms
<p>I'm using Django Crispy Forms, and rather than have the Submit button render below the rest of the fields, I want to move it to the same row as another field. My current Form code follows:</p> <pre><code>class SetForm(forms.ModelForm): class Meta: model = Set fields = ['exercise', 'actual_weight'...
<python><django><django-forms><django-templates><django-crispy-forms>
2023-04-02 01:02:04
1
2,725
BLimitless
75,909,606
8,342,978
How to add Azure Digital Twins Data Owner Role via Azure Python SDK
<p>Using the Azure Python SDK, I have been able to instantiate a resource group and a digital twin within using the following code:</p> <pre class="lang-py prettyprint-override"><code>from azure.identity import AzureCliCredential, DefaultAzureCredential from azure.mgmt.resource import ResourceManagementClient from azu...
<python><azure><azure-digital-twins>
2023-04-02 00:52:13
1
765
cozek
75,909,573
12,103,619
Can't pip install tensorflow with python 3.8 64bit
<p>I have a conda config file and I can't seem to create an environment with tensorflow and python=3.8</p> <p>Here is my config file</p> <pre><code>name: proj1 channels: - defaults dependencies: - python=3.7 - pip - pip: - matplotlib - tensorflow - tensorflow-probability </code></pre> <p>Here is the...
<python><tensorflow><pip><conda>
2023-04-02 00:39:15
0
394
Aydin Abiar
75,909,497
12,103,619
ResolvePackageNotFound on python dependency when building conda environment from config file
<p>I am working on an old project and I am trying to build a conda environment based on a config file. It used to work well few months ago but now I run into some issues, here is my file</p> <pre><code> name: proj1 channels: - defaults dependencies: - python=3.7 - pip - pip: - matplotlib - tensorflow ...
<python><conda>
2023-04-02 00:06:15
0
394
Aydin Abiar
75,909,386
14,503,336
VSCode not detecing functions from wildcard import
<p>I have some Python files in a directory.</p> <pre><code>my-project/ utils/ a.py b.py __init__.py main.py </code></pre> <p>They all run from <code>main.py</code>, but files inside the <code>utils</code> folder all import from one another.</p> <pre><code># a.py from .b import * function_from_b() </cod...
<python><python-3.x><visual-studio-code><import><python-import>
2023-04-01 23:26:26
1
599
Anonyo Noor
75,909,156
219,976
FastAPI - why can server handle several requests at the same time in synchronous mode
<p>I run the following program:</p> <pre><code>import time from datetime import datetime from fastapi import FastAPI app = FastAPI() @app.get(&quot;/&quot;) def root(): print(f&quot;Started at {datetime.now()}&quot;) time.sleep(30) print(f&quot;Executed at {datetime.now()}&quot;) return {&quot;messag...
<python><asynchronous><fastapi><uvicorn>
2023-04-01 22:24:24
1
6,657
StuffHappens
75,909,141
19,051,091
How to improve PyTorch model with 4 classes?
<p><strong>Edit Update:</strong></p> <p>After I made the Batch_Size = 128 and I added new Layer</p> <pre><code> self.conv_block3 = nn.Sequential(nn.Conv2d(in_channels=hidden_units,out_channels=hidden_units,kernel_size=3,stride=1,padding=1), nn.ReLU(), nn.Conv2d(in_channels=hidden_units, out_channels=hidden_u...
<python><pytorch>
2023-04-01 22:18:38
2
307
Emad Younan
75,909,139
11,462,274
Correct formatting to send a list in Python as a parameter to the Google Web App in order to send the data to Google Sheets
<p>I have a Python code in which I want to pass a DataFrame Pandas as a parameter and a URL also as a parameter in my request to the Web App of Google Apps Script:</p> <pre class="lang-python prettyprint-override"><code>import pandas as pd import requests UAGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit...
<python><google-apps-script><google-sheets>
2023-04-01 22:17:57
1
2,222
Digital Farmer
75,909,124
7,764,497
Building correct response to login to Twitter
<p>I'm trying to login to twitter using just requests but I don't think I'm building the correct login response. I pass in the guest token but am I missing anything else? Am I using the correct URL? What am I doing wrong? And also <s>how would I tell if I successfully login this way -</s> with my current iteration I ge...
<python><web-scraping><twitter><python-requests>
2023-04-01 22:14:26
1
356
hwhat
75,909,116
1,082,410
Python how identify if an instance has been changed without making a copy?
<p>I'm trying to write a function to determine if an object has been modified at one point during the execution of the program.</p> <p>I don't want to duplicate the object because this will take a lot of memory.</p> <p>My object is a dataclass and has a few lists of dataclasses that might have nested dataclasses within...
<python><hash>
2023-04-01 22:11:50
3
879
Tolure
75,909,103
5,074,226
Tflite-model-maker is downloading several files endless
<p>I'm trying to install TensorFlow using this <a href="https://www.tensorflow.org/lite/models/modify/model_maker/image_classification" rel="nofollow noreferrer">tutorial</a>. So, when I run the following command on my terminal:</p> <p>$ pip install -q tflite-model-maker</p> <p>This command starts to download several f...
<python><bash><tensorflow><ubuntu><installation>
2023-04-01 22:08:42
3
364
Ítalo De Pontes Oliveira
75,908,794
2,312,801
Split a csv file into multiple files based on a pattern
<p>I have a csv file with the following structure:</p> <pre><code>time,magnitude 0,13517 292.5669,370 620.8469,528 0,377 832.3269,50187 5633.9419,3088 20795.0950,2922 21395.6879,2498 21768.2139,647 21881.2049,194 0,3566 292.5669,370 504.1510,712 1639.4800,287 46709.1749,365 46803.4400,500 </code></pre> <p>I'd like to s...
<python><csv><unix><split>
2023-04-01 20:53:07
4
2,459
mOna
75,908,335
16,383,578
What is a better way to get filenames of downloaded mods from nexusmods download history?
<p>I have downloaded many mods from NexusMods, currently my download history tells me that I have downloaded 150 different mods. Because I have downloaded so many mods I literally have no idea which file is from which mod for which game...</p> <p>If you have used NexusMods, you know its download history tab only shows ...
<python><python-3.x><selenium-webdriver><web-scraping><firefox>
2023-04-01 19:14:39
1
3,930
Ξένη Γήινος
75,908,271
262,875
How to make a Cog a prefix command group?
<p>I'm trying to make a Cog the &quot;root group&quot; for the commands it provides. The following is a pseudo example and doesn't actually work, but hopefully illustrates what I am trying to do:</p> <pre><code>from discord.ext import commands class MyCog(commands.GroupCog, name='cog'): def __init__(self, bot): ...
<python><discord><discord.py>
2023-04-01 19:00:55
0
11,089
Daniel Baulig
75,908,169
1,845,408
Generating a column showing the number of distinct values between consecutive days
<p>I have a pandas dataframe with the following format:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>UserId</th> <th>Date</th> <th>BookId</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>2022-07-15</td> <td>10</td> </tr> <tr> <td>1</td> <td>2022-07-16</td> <td>11</td> </tr> <tr> <td>1</td...
<python><pandas><dataframe>
2023-04-01 18:38:10
3
8,321
renakre
75,907,744
2,438,993
regex parsing of text and numbers blocks
<p>I am stuck on this regex. I would like to extract a single string for each chunk starting at AELIST and ignore the SET1 (or any other header) chunks. The + indicates a continuation of the single array. The blocks can be split by words that are all CAPS or lines that dont end in + or lines that dont start with +</p> ...
<python><regex><nastran>
2023-04-01 17:18:09
1
1,367
nagordon
75,907,716
7,676,920
Add column with current date and time to Polars DataFrame
<p>How can I add a column to a Polars DataFrame with current date and time as value on every row?</p> <p>With Pandas, I would do something like this:</p> <pre class="lang-py prettyprint-override"><code>df[&quot;date&quot;] = pd.Timestamp.today() </code></pre>
<python><python-polars>
2023-04-01 17:12:48
1
1,383
basse
75,907,677
11,529,057
float value for the number of items for each cell in confusion matrix in Azure ML
<p>I work with Azure Machine Learning Service for modeling. To track and analyze the result of a binary classification problem, I use a method named <strong>score-classification</strong> in <em>azureml.training.tabular.score.scoring</em> library. I invoke the method like this:</p> <pre><code>metrics = score_classificat...
<python><azure><confusion-matrix><azure-machine-learning-service>
2023-04-01 17:04:53
1
361
elldora
75,907,486
7,644,562
Django: Combine multiple forms into single one
<p>I'm working with a django(4) project, Where I have two forms and want to combine them into one to display in my template with custom html not by sing <code>{{form}}</code> syntax.</p> <p>Here's my <code>forms.py</code>:</p> <pre><code>class UserUpdateForm(forms.ModelForm): email = forms.EmailField() class M...
<python><python-3.x><django><django-forms><django-4.1>
2023-04-01 16:37:29
2
5,704
Abdul Rehman
75,907,395
9,300,627
Keeping the input provided to a generator
<p>Assume I have a generator <code>gen</code> that produces items, and another generator <code>trans</code> that transforms the items and returns one output item per input item, and assume that both generators are expensive and I can't change either of them. Both generators may have additional arguments. The output of ...
<python><python-3.x><generator>
2023-04-01 16:17:43
1
3,033
haukex
75,907,394
6,709,460
What is the difference between Security and Depends in FastAPI?
<p>This is my code:</p> <pre><code>from fastapi import FastAPI, Depends, Security from fastapi.security import HTTPBearer bearer = HTTPBearer() @app.get(&quot;/&quot;) async def root(q = Security(bearer)): return {'q': q} @app.get(&quot;/Depends&quot;) async def root(q = Depends(bearer)): return {'q': q,} </...
<python><fastapi>
2023-04-01 16:17:42
1
741
Testing man
75,907,379
11,940,581
Can a multi core processor make parallel network connections?
<p>I am currently having a use case wherein need to hit a a REST endpoint with some data(~20 MB) present in a file and upload it(HTTP POST). The machine that I am using for this action is of the type <em>Intel(R) Xeon(R) Silver 4114 CPU @ 2.20GHz (40 cores, 375 GB RAM)</em> . The problem now is that I would need to mak...
<python><multithreading><multiprocessing><network-programming><python-asyncio>
2023-04-01 16:15:43
1
371
halfwind22
75,907,222
7,089,108
Jupyterlab extension gives a function not found error
<p>I have issues with jupyter extensions on ArchLinux. In particular, I get the following error:</p> <pre><code>[W 2023-04-01 18:34:36.504 ServerApp] A `_jupyter_server_extension_points` function was not found in jupyter_nbextensions_configurator. Instead, a `_jupyter_server_extension_paths` function was found and will...
<python><jupyter-notebook><jupyter-lab>
2023-04-01 15:43:22
1
433
cerv21
75,907,167
76,701
Something like `click_shell` for Typer
<p>I recently started using the Typer framework for command line programs in Python. It's pretty good. When I used Click, I would use the <code>click_shell</code> plugin to automatically make an interactive shell for my command line apps, so I could launch them without arguments and get a shell where I could run my com...
<python><typer>
2023-04-01 15:31:33
1
89,497
Ram Rachum
75,907,155
15,170,662
Is asyncio affected by the GIL?
<p>On <a href="https://superfastpython.com/asyncio-vs-threading/" rel="noreferrer">this</a> page I read this:</p> <blockquote> <p>Coroutines in the asyncio module are not limited by the Global Interpreter Lock or GIL.</p> </blockquote> <p>But how is this possible if both the <code>asyncio</code> event loop and the <cod...
<python><multithreading><python-asyncio><gil>
2023-04-01 15:29:27
2
415
Meetinger
75,907,063
1,391,466
Remove all text from a html node using regex
<p>Is it possible to remove all text from HTML nodes with a regex? This very simple case seems to work just fine:</p> <pre class="lang-py prettyprint-override"><code>import htmlmin html = &quot;&quot;&quot; &lt;li class=&quot;menu-item&quot;&gt; &lt;p class=&quot;menu-item__heading&quot;&gt;Totopos&lt;/p&gt; &lt;p...
<python><html><beautifulsoup>
2023-04-01 15:13:26
2
2,087
chhenning
75,906,985
16,389,095
Python/Kivy: How to pass arguments to a class when it is called by a screen manager
<p>I developed an UI with Python/Kivy/KivyMD. It is a simple app in which three screens are defined by three different classes: <strong>View1</strong>, <strong>View2</strong> and <strong>View3</strong>. In the class <em>'MainApp'</em> a screen manager is defined and used to switch between screens. The switch between sc...
<python><kivy><kivy-language><kivymd>
2023-04-01 14:56:42
1
421
eljamba
75,906,827
4,859,268
GitLab CI python subprocess.Popen permission denied
<p>I'm running a GitLab-CI job which runs a python script which starts a <code>subprocess.Popen(...)</code>.</p> <pre><code>def main(): proc = subprocess.Popen(&quot;./../binary_file --args value&quot;, stdout=subprocess.PIPE) </code></pre> <p>The problem is that I'm getting</p> <blockquote> <p>PermissionError: [Errn...
<python><gitlab><gitlab-ci>
2023-04-01 14:26:45
1
1,447
Bob
75,906,819
303,513
Simple linear regression in pyTorch - why loss is increasing with each epoch?
<p>I'm trying to make a simple linear regression model with PyTorch to predict the perceived temperature <code>atemp</code> based on actual temperature <code>temp</code>.</p> <p>I cannot understand why this code results in loss increasing with each epoch, instead of decreasing. And all predicted values are very far fro...
<python><machine-learning><deep-learning><pytorch><linear-regression>
2023-04-01 14:25:59
2
46,260
Silver Light
75,906,590
21,787,377
How can I allow user to submit a form
<p>When I try to submit <code>Table</code> model to the database using <code>create_table</code> view, it throws me an error: <code>NOT NULL constraint failed: audioApp_table.user_id</code> after I do my own research I found out it was because I didn't add user to the form, so I try to add it by adding: <code>table = T...
<python><django>
2023-04-01 13:46:45
1
305
Adamu Abdulkarim Dee
75,906,560
3,825,996
Can we use Python 4's end keyword in Python 2.7?
<p>Because of my ancient animation pipeline, I am stuck with python 2.7. I saw that python 4 will have an end keyword which can already be used in python 3 with pyend (<a href="https://pypi.org/project/pyend/" rel="nofollow noreferrer">https://pypi.org/project/pyend/</a>). I am using that in some python 3 projects alre...
<python><auto-indent>
2023-04-01 13:41:37
1
766
mqnc
75,906,408
14,514,276
Dimensions error using BCEWithLogitsLoss PyTorch
<p>I have a problem with dimensions which appear in this line of code <code>loss = self.cross_entropy(preds, labels)</code>. Error looks like this: <code>RuntimeError: output with shape [32, 1] doesn't match the broadcast shape [32, 2]</code>.</p> <p>I don't know what is wrong because when I do: <code>labels.shape</cod...
<python><deep-learning><pytorch><neural-network>
2023-04-01 13:13:33
0
693
some nooby questions
75,906,407
14,014,925
How to interpret the model_max_len attribute of the PreTrainedTokenizer object in Huggingface Transformers
<p>I've been trying to check the maximum length allowed by emilyalsentzer/Bio_ClinicalBERT, and after these lines of code:</p> <pre><code>model_name = &quot;emilyalsentzer/Bio_ClinicalBERT&quot; tokenizer = AutoTokenizer.from_pretrained(model_name) tokenizer </code></pre> <p>I've obtained the following:</p> <pre><code>...
<python><nlp><huggingface-transformers><huggingface-tokenizers><huggingface>
2023-04-01 13:13:27
1
345
ignacioct
75,906,272
5,916,316
How to resolve this problem with RecycleView in Kivy?
<p>I am trying to pass data from <code>Menu class</code> to <code>Container class</code> but I am having an exception <code>TypeError: Container.__init__() missing 2 required positional arguments: 'source' and 'mipmap'</code> I think the problel is not in Container class and <code>rv</code>. My app is so simple but I a...
<python><kivy><kivymd>
2023-04-01 12:49:47
1
429
Mike
75,906,239
11,092,636
ERROR: No matching distribution found for torchvision==0.8.2
<p>torchvision 0.8.2 <a href="https://pypi.org/project/torchvision/0.8.2/" rel="nofollow noreferrer">exists</a></p> <p>But when running <code>pip install torchvision==0.8.2</code>, I get the following error:</p> <pre><code>ERROR: Could not find a version that satisfies the requirement torchvision==0.8.2 (from versions:...
<python><pip><torchvision>
2023-04-01 12:43:22
0
720
FluidMechanics Potential Flows
75,906,153
1,262,480
Aws Moto redshift statements assertions (Python)
<p>Considering an AWS lambda written in Python that uses boto3 as client to AWS Redshift service.</p> <p>Considering the following example:</p> <pre class="lang-py prettyprint-override"><code> import boto3 import moto def lambda_handler(event, context): session = boto3.session.Session() redshift_data_service...
<python><amazon-web-services><testing><boto3><moto>
2023-04-01 12:21:07
1
822
Yak O'Poe
75,905,984
13,903,942
Python types.SimpleNamespace is it thread safe?
<p>Is <a href="https://docs.python.org/3/library/types.html#types.SimpleNamespace" rel="nofollow noreferrer">types.SimpleNamespace</a> in Python thread-safe?</p> <p>Giving a object of type <code>types.SimpleNamespace</code> with fix attributes, updates from one thread to another is it atomic?</p> <p>Example of a possib...
<python><multithreading><object><thread-safety><atomic>
2023-04-01 11:45:45
0
7,945
Federico Baù
75,905,879
8,350,828
Python binance - get futures position information
<p>I would like to retrieve future position histroy from the Binance API, just like it is on the dashboard.</p> <p>I need this data to then later display on a spreadsheet.</p> <p><a href="https://i.sstatic.net/ZQpgp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZQpgp.png" alt="position history" /></a><...
<python><binance-api-client><python-binance>
2023-04-01 11:27:18
1
813
Jože Strožer
75,905,778
9,728,885
Concat keys in PCollection
<p>Im trying to concat/join the values of 2 keys in apache beam to get a new list composed of all items in the two keys.</p> <p>Suppose I have a PCollection as follows:</p> <pre><code>( &quot;Key1&quot;: [file1, file2], &quot;Key2&quot;: [file3, file4], ) </code></pre> <p>How do I achieve a PColletion which looks l...
<python><concatenation><apache-beam>
2023-04-01 11:02:08
1
591
Manuel
75,905,765
5,302,323
Identify Potential Duplicates in Two Dataframes Even if Dates are Not the Same (7d range)
<p>I have two datasframes with repeated transactions but the same transaction may have two different dates in each (appears within a 7d time window).</p> <p>I am trying to isolate repeated transactions based on a date range of +/- 7d but am not able to do it.</p> <p>The code below simply looks at 'Date', 'Amount' and (...
<python><loops><python-datetime>
2023-04-01 10:59:13
1
365
Cla Rosie
75,905,744
6,619,692
Understanding slicing behavior in custom PyTorch Dataset class with tuple return type in __getitem__ method
<p>I wrote the following dataset class:</p> <pre><code>from torch.utils.data import Dataset import json def read_dataset(path: str) -&gt; tuple[list[list[str]], list[list[str]]]: tokens_s, labels_s = [], [] with open(path) as f: for line in f: data = json.loads(line) assert len...
<python><pytorch>
2023-04-01 10:55:27
1
1,459
Anil
75,905,638
3,251,645
FastAPI responds with required field is missing
<p>I'm following a simple tutorial from the FastAPI docs. I was already using SQLAlchemy in this project just added the fastapi dependency and trying to run it, here's my code:</p> <pre><code>import re import json import copy import traceback import urllib.parse from models import * from mangum import Mangum from datet...
<python><fastapi><starlette>
2023-04-01 10:32:03
3
2,649
Amol Borkar
75,905,429
4,876,058
Django - Insert data into child table once the parent record is created
<p>I am using <code>Django REST Framework</code> and facing a problem during inserting data into the child table. There are 2 models named <code>Card</code> and <code>ContactName</code> that have the following fields. The <code>Card</code> has a relation with <code>ContactName</code> via a foreign key field name <code>...
<python><django><django-rest-framework>
2023-04-01 09:49:13
1
1,019
Ven Nilson
75,905,258
10,620,788
Speeding up for loops in pySpark
<p>I need a hand at solving this problem. I have a for loop that iterates on a list and builds a linear model for each item on that list. I have built a python for loop, but my list of items can get very lengthy and I know I am probably not taking advantage of all Spark has to offer. So here is my code:</p> <pre><code>...
<python><apache-spark><pyspark><databricks><linear-regression>
2023-04-01 09:12:57
1
363
mblume
75,905,219
839,837
How to send a data from ESP8266 (Arduino) to PC (Python) over Wifi
<p>I have an ESP8266 measuring a voltage via its Analog port (1). I have the ESP8266 successfully connecting to my local WiFi network. I can successfully command the ESP8266 over the local WiFi with Python using simply requests.get commands. Which I can then action.</p> <pre><code>import requests try: r = requests...
<python><python-3.x><arduino><esp8266><arduino-esp8266>
2023-04-01 09:07:03
1
727
Markus
75,905,137
728,438
Measuring the dB of a frequency after FFT
<p>I have a wavfile that is read and fft'd. Sampling frequency is 22050Hz.</p> <pre><code>fs, y = scipy.io.wavfile.read('StarWars60.wav') N = len(y) yf = rfft(y) xf = rfftfreq(N, 1/fs) </code></pre> <p>y is int16 and takes range [-32768,32767] yf has abs values that are typically around 2000000</p> <p>for each of the y...
<python><audio><signal-processing><fft>
2023-04-01 08:52:21
0
399
Ian Low
75,905,030
20,443,528
How to filter a QuerySet based on whether the objects in it are present in another model?
<p>I have a QuerySet called time_slots which contains objects of model class TimeSlot.</p> <pre><code>time_slots = &lt;QuerySet [ &lt;TimeSlot: Room: Number: 1, category: Regular, capacity: 4, advance: 12, manager: anshul, from: 01:00:00, till: 02:00:00&gt;, &lt;TimeSlot: Room: Number: 1, category: Regular, capacity: 4...
<python><django><django-models><django-queryset>
2023-04-01 08:29:42
1
331
Anshul Gupta
75,904,876
4,045,275
conda warns me I should update conda, but the update keeps failing
<h2>The issue</h2> <p>I have an Anaconda distribution installed on a Windows PC about 18 months ago. I updated the whole package with conda update --all but conda remains stuck at version 4.12.0 When using conda, I often get the message that</p> <pre><code>==&gt; WARNING: A newer version of conda exists. &lt;== curre...
<python><anaconda><conda>
2023-04-01 07:50:08
1
9,100
Pythonista anonymous
75,904,821
7,745,011
Max retries exceeded with url: / (Caused by SSLError(FileNotFoundError(2, 'No such file or directory'))) only during debug
<p>I am using minio as follows (example):</p> <pre><code>minio_client = Minio( endpoint=&quot;my.minio.com:10092&quot;, access_key=&quot;minio&quot;, secret_key=&quot;minio123!&quot; ) buckets = minio_client.list_buckets() for bucket in buckets: print(bucket.name) </code></pre> <p>Debugging the code above with VSC...
<python><visual-studio-code><vscode-debugger><minio><urllib3>
2023-04-01 07:36:07
1
2,980
Roland Deschain
75,904,795
17,580,381
Performance of reversed() function compared to reversing slice
<p>This is very similar to <a href="https://stackoverflow.com/questions/74998392/python-reverse-vs-1-slice-performance">this question</a> but there's a slight difference in my question.</p> <p>I have two functionally identical functions as follows:</p> <pre><code>def count1(text): c = 0 for i, j in zip(text, re...
<python><performance>
2023-04-01 07:28:45
1
28,997
Ramrab
75,904,780
11,746,588
Takes long time while building image on python wit messaage : Building wheel for pandas (pyproject.toml): still running
<p>i have problem while building docker image on python : below execution process takes long time around 20 minutes:</p> <pre><code>Building wheel for pandas (pyproject.toml): still running... Building wheel for pandas (pyproject.toml): still running... Building wheel for pandas (pyproject.toml): still running... Build...
<python><pandas>
2023-04-01 07:23:41
1
427
wahyu eko hadi saputro
75,904,709
972,202
Method to Sort 3d data
<p>Is there a method in numpy that allows me to sort these 3d vectors in ascending order?</p> <p>For example; I have the following input array and I'd like the following output:</p> <pre><code>input_arr = np.array( [ [[255,0,3], [255,4,100], [255,2,3], [255,3,3], [0,1,3], ] ] , dtype='uint8') #...
<python><numpy>
2023-04-01 07:02:32
1
26,168
sazr
75,904,692
3,423,825
How to avoid IntegrityError issue with update_or_create?
<p>I would appreciate it if someone could explain why I'm having <code>IntegrityError</code> exception being thrown here, and how to avoid it.</p> <p>When an object already exists, isn't the <code>update_or_create</code> method supposed to update it ?</p> <p><strong>models.py</strong></p> <pre><code>class OHLCV(Timesta...
<python><django>
2023-04-01 06:58:25
1
1,948
Florent
75,904,509
10,755,032
Network Analysis using textnets - ValueError: negative dimensions are not allowed
<p>I am trying to perform network analysis on some text data after I did some sentiment analysis on it. I am using <code>textnets</code> documentation for reference. I am getting the above mentioned error after running the following line:</p> <pre><code>t = tn.Textnet(corpus.tokenized()) </code></pre> <p>Here is my ful...
<python><nlp><network-analysis>
2023-04-01 05:56:22
1
1,753
Karthik Bhandary
75,904,500
3,782,963
Unable to build wheels in pipenv
<p>I have recently moved to <code>pipenv</code> from using the traditional <code>requirements.txt</code> file and its not going too well. I am trying to build wheels for one of my Python modules and I always get an error while doing so. The error is:</p> <pre><code>$ pipenv run python -m build --wheel * Creating virtua...
<python><pipenv>
2023-04-01 05:52:57
0
2,835
Akshay
75,904,487
1,260,682
is there a magic method for logical and and or in python?
<p>I thought they are <code>__and__</code> and <code>__or__</code> but turns out they are for bitwise comparisons not logical ones. Are there such methods for the logical comparators?</p>
<python>
2023-04-01 05:46:56
0
6,230
JRR
75,904,348
10,086,964
Django Debug toolbar is not showing though `view page source` is showing debug tool's html
<p>I am a beginner at Django. Django-debug-tool is not showing. I have gone through the official documentation step by step. But It did work for me. I have seen lots of existing answers as well seems it doesn't work. Interestingly from the browser when I go to <code>view page source</code> it shows the debug tool's HTM...
<python><django><debugging><django-debug-toolbar>
2023-04-01 04:57:39
0
328
S. S. Saruar Jahan
75,904,337
139,150
Not able to return source code of any function
<p>I am not able to get the source code of any function in python. Do I need to reinstall python? Does python looks OK in this case?</p> <pre><code># python Python 3.7.6 | packaged by conda-forge | (default, Mar 23 2020, 22:25:07) [GCC 7.3.0] on linux Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or...
<python>
2023-04-01 04:53:10
2
32,554
shantanuo
75,904,222
5,539,782
scraping odds with selenium after mouse over
<p>from the webpage of oddsportal, I want to scrape the odds of <strong>Pinnacle</strong> bookmaker only: <a href="https://www.oddsportal.com/football/russia/premier-league/spartak-moscow-akhmat-grozny-dI0Fo2oa/#1X2;2" rel="nofollow noreferrer">https://www.oddsportal.com/football/russia/premier-league/spartak-moscow-ak...
<python><selenium-webdriver><web-scraping>
2023-04-01 04:09:07
1
547
Khaled Koubaa
75,904,146
6,296,626
Removing ANSI escape sequence in Python
<p>I am trying to remove ANSI escape sequences from a string.</p> <p>I have tried all solutions proposed in <a href="https://stackoverflow.com/questions/14693701">this post</a> but none of them worked, thus I concluded that my case is a bit different.</p> <p>I have the following code that should have replaced all ANSI ...
<python><regex><escaping><ansi-escape>
2023-04-01 03:39:09
1
1,479
Programer Beginner
75,904,104
11,299,809
Panda value_counts index output looks weird
<pre><code>df = pd.read_csv('./data/flights_2015.csv', low_memory=False) print('Dataframe dimensions:', df.shape) </code></pre> <pre><code>Dataframe dimensions: (5819079, 31) </code></pre> <p>I tried to count how many flights there for each <code>airport</code> in the entire dataset using</p> <pre><code>count_flights =...
<python><pandas>
2023-04-01 03:16:57
1
353
mario119
75,903,962
1,457,672
Return list of sentences with a particular subject
<p>I am exploring a small corpus of texts, and one of the things I am doing is examining the actions associated with various subjects. I have already inventoried how many times, for example, &quot;man&quot; is the subject of a sentence in which the verb is &quot;love&quot;: that work was done with subject-verb-object t...
<python><nlp><nltk><pos-tagger>
2023-04-01 02:21:30
1
407
John Laudun
75,903,895
9,727,704
adding cookie to a flask function that returns a redirect
<p>The flask documentation for <a href="https://flask.palletsprojects.com/en/2.2.x/api/#flask.make_response" rel="nofollow noreferrer">setting a header</a> suggests the following:</p> <pre><code>def index(): response = make_response(render_template('index.html', foo=42)) response.headers['X-Parachutes'] = 'para...
<python><flask><cookies>
2023-04-01 02:00:57
1
765
Lucky
75,903,878
5,516,760
Use custom transformer for albumentations
<p>I want to use the following custom <code>albumentation</code> transformer</p> <pre class="lang-py prettyprint-override"><code>import albumentations as A from albumentations.pytorch import ToTensorV2 class RandomTranslateWithReflect: &quot;&quot;&quot;Translate image randomly Translate vertically and horizon...
<python><pytorch><albumentations>
2023-04-01 01:51:21
1
2,790
Marzi Heidari
75,903,837
7,705,108
Why does GET Details returns all Null and Delete Details returns "detail": "Method \"GET\" not allowed." when using objects.filter?
<p>I built a rest framework in Django. When I do getAll, I get all the data from my database (no problem). The problem is when I do GET details and DELETE details. For the get and delete, I need to return and delete multiple objects (not just one and not all). In my case the problem is using objects.filter(). When I tr...
<python><python-3.x><django><django-rest-framework><django-views>
2023-04-01 01:34:01
1
381
ananvodo