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
βŒ€
77,198,520
17,365,694
Docker Error build during Deployment on Railway services
<p>please I had previously deployed my Django project on Railway which worked fine. Unfortunately, when I tried to add up SendGrid mail functionality by using <code>django-sendgrid-v5</code> package to help me handle that, everything worked pretty well in the development environment including SendGrid mails like Signup...
<javascript><python><django><docker><sendgrid>
2023-09-28 22:09:01
1
474
Blaisemart
77,198,484
819,417
Python regex to match string not preceded by another string, but with other words in between
<p>I tried the accepted answer to <a href="https://stackoverflow.com/questions/72741712/regex-match-word-not-immediately-preceded-by-another-word-but-possibly-preceded">Regex match word not immediately preceded by another word but possibly preceded by that word before</a> but that didn't work.</p> <pre class="lang-py p...
<python><regex><regex-lookarounds>
2023-09-28 21:55:45
1
20,273
Cees Timmerman
77,198,451
12,400,477
Is it possible to do infix function composition in python without wrapping your functions in some decorator?
<p>Title says it all. Seen lots of answers where folks have implemented <code>f @ g</code>, but this requires wrapping <code>f</code>, <code>g</code> in some <code>infix</code> decorator or class. Is it possible to get this to work? Maybe by patching some class that all functions are an instance of or something?</p> <p...
<python><functional-programming><dsl><infix-notation>
2023-09-28 21:49:27
2
615
Brendan Langfield
77,198,291
525,916
How do I concatenate columns values (all but one) to a list and add it as a column with polars?
<p>I have the input in this format:</p> <pre><code>import polars as pl data = {&quot;Name&quot;: ['Name_A', 'Name_B','Name_C'], &quot;val_1&quot;: ['a',None, 'a'],&quot;val_2&quot;: [None,None, 'b'],&quot;val_3&quot;: [None,'c', None],&quot;val_4&quot;: ['c',None, 'g'],&quot;val_5&quot;: [None,None, 'i']} df = pl.Data...
<python><python-polars>
2023-09-28 21:07:28
1
4,099
Shankze
77,198,268
3,270,427
gRPC - Keep a stream connection alive in Python
<p>I am trying to convert a C# app into a Python app and I am having issues with gRPC.</p> <p>I need to keep a stream connection alive while the application is running, this app receive broadcast messages from the service.</p> <p>This is the proto file:</p> <pre><code>syntax = &quot;proto3&quot;; import &quot;google/p...
<python><grpc><grpc-python>
2023-09-28 21:03:17
2
10,857
McNets
77,198,214
6,296,626
Python Flet have parent expand but child should not
<p>I am using <a href="https://flet.dev/docs/" rel="nofollow noreferrer">Flet</a> as the GUI library for my project. I have the following code:</p> <pre class="lang-py prettyprint-override"><code>MAIN_GUI = ft.Container( margin=ft.margin.only(bottom=40), expand=True, content=ft.Row([ ft.Card( ...
<python><flutter><user-interface><expand><flet>
2023-09-28 20:53:00
1
1,479
Programer Beginner
77,198,140
9,142,198
TypeError: _named_members() got an unexpected keyword argument 'remove_duplicate'
<p>I'm working on Supper resolution using GAN project and I'm trying to train SRGAN but I'm getting one error:</p> <pre><code>[TLX] Linear linear_1: 1 No Activation [TLX] Conv2d conv1_1: out_channels : 64 kernel_size: (3, 3) stride: (1, 1) pad: SAME act: ReLU [TLX] Conv2d conv1_2: out_channels : 64 kernel_size: (3, 3)...
<python><pytorch><generative-adversarial-network><vgg-net>
2023-09-28 20:40:57
1
504
krishna veer
77,198,126
22,466,650
How to pad 0s to garantee same length while iterating over two lists?
<p>My inputs are :</p> <pre><code>x = ['A', 'B', 'B', 'C', 'D', 'D', 'D'] y = [ 4 , 3 , 5 , 9 , 1 , 6 , 2 ] </code></pre> <p>And I'm just trying to make this dictionary.</p> <pre><code>{'A': [4, 0, 0], 'B': [3, 5, 0], 'C': [9, 0, 0], 'D': [1, 6, 2]} </code></pre> <p>The logic : we collect the values and pad <code...
<python><list><dictionary>
2023-09-28 20:39:08
2
1,085
VERBOSE
77,198,060
8,372,455
VOLTTRON set_point
<p>I am trying to use the actuator agent to write to a building automation point with <a href="https://volttron.readthedocs.io/en/stable/volttron-api/services/ActuatorAgent/actuator.agent.html#actuator.agent.ActuatorAgent.set_point" rel="nofollow noreferrer">set_point</a>. This is the a snip from my Python code:</p> <p...
<python><volttron>
2023-09-28 20:26:57
2
3,564
bbartling
77,197,977
5,197,034
Azure Functions Blob is triggered 5 times
<p>Since we switched to Azure Functions with the Python V2 programming model, we experience a lot more problems during and after deployment then before. One that keeps puzzling me is that a blob trigger function is executed 5 times every time a new file is added in blob storage. The triggers are always 10min apart.</p>...
<python><azure-functions><azure-blob-storage><azure-blob-trigger>
2023-09-28 20:10:48
2
2,603
pietz
77,197,942
901,426
Python method to multithread two vastly different timed functions for MQTT
<p>i have an application that samples two IOs at vastly different rates that need to operate within an MQTT reporting loop that sends messages every 5secs. one function <strong>must</strong> sample every 10ms and increments a counter based on it's IO port value. the other can run right before the MQTT message is sent...
<python><multithreading><mqtt>
2023-09-28 20:01:46
0
867
WhiteRau
77,197,889
7,800,726
How create hyperlinks in a loop? Tkinter widget, Python
<p>The following loop unintentionally associates all the links with the last link found in brand_url[i], how can this be corrected?</p> <pre><code>for i in databrand.index: brand_name = databrand['Brands'][i] brand_url = databrand['Url'][i] link_text = brand_name + &quot; &quot; + brand_url my_link = tk...
<python><tkinter>
2023-09-28 19:52:41
1
558
Ian Gallegos
77,197,792
3,398,271
How to debug python tests with vimspector?
<h3>Sample code</h3> <p><strong>main.py</strong></p> <pre><code>#!/usr/bin/python3 if __name__ == &quot;__main__&quot;: test = &quot;hello, world&quot; print(test) </code></pre> <p><strong>sometest.py</strong></p> <pre><code>import pytest def test_something(): print(&quot;running da test...&quot;) foo...
<python><debugging><vim><pytest><vimspector>
2023-09-28 19:36:31
1
1,732
Attilio
77,197,753
5,032,387
Why is ground_truth_key in AzureML text generation component required
<p>I'm not following why the <a href="https://github.com/Azure/azureml-assets/blob/main/assets/training/finetune_acft_hf_nlp/components/pipeline_components/text_generation/README.md" rel="nofollow noreferrer">ground_truth_key</a> in AzureML's text generation pipeline component is a required argument. I understand it ma...
<python><azure-machine-learning-service><azure-ml-pipelines><azure-ml-component>
2023-09-28 19:27:25
0
3,080
matsuo_basho
77,197,748
22,466,650
Aren't the values supposed to sum up for each bar?
<p>I was expecting for example the <code>F</code> bar to have <code>8+9=17</code> and not only <code>9</code> (the last value for <code>F</code>).</p> <pre><code>import matplotlib.pyplot as plt x = ['A', 'B', 'C', 'D', 'D', 'D', 'D', 'E', 'F', 'F'] y = [ 5 , 8 , 7, 9, 9, 2, 7, 8, 8, 9 ] fig, ax = plt....
<python><matplotlib>
2023-09-28 19:26:44
1
1,085
VERBOSE
77,197,729
2,410,605
Trying to set the Chrome download directory for Python Seleniumbase but it continues to use the default
<p>I'm still learning how to use Selenium Python and am having an issue changing the default download directory. I'm hoping a fresh or more experienced set of eyes can help.</p> <p>I'm rocking with Python 3.10.11 / Selenium 4.10 / Chrome (whatever latest version is)</p> <p>Below is the relevant code -- the entire scrip...
<python><selenium-webdriver><selenium-chromedriver><seleniumbase>
2023-09-28 19:23:29
1
657
JimmyG
77,197,723
7,120,031
How do I stream HuggingFacePipeline output to a LangChain Dataframe Agent?
<p>I'm trying to mimic the LangChain Agent + Streamlit demo outlined <a href="https://python.langchain.com/docs/integrations/callbacks/streamlit" rel="nofollow noreferrer">in this documentation</a>, except with a local HuggingFace model using the <code>HuggingFacePipeline</code> and Langchain Dataframe Agent.</p> <p>I ...
<python><huggingface-transformers><streamlit><langchain><huggingface>
2023-09-28 19:23:11
0
808
Burhan
77,197,671
7,472,392
Splitting a column with delimiter and place a value in the right column
<p>I have a data frame with a column that potentially can be filled with 3 options (a,b, and/or c) with a comma delimiter.</p> <pre><code>import pandas as pd df = pd.DataFrame({'col1':['a,b,c', 'b', 'a,c', 'b,c', 'a,b']}) </code></pre> <p>I want to split this column based on ','</p> <pre><code>df['col1'].str.split(','...
<python><pandas><dataframe>
2023-09-28 19:14:03
3
1,511
Yun Tae Hwang
77,197,648
21,575,627
'from . import XYZ'
<p>I've ran into the above line. I'm searching a codebase, <a href="https://github.com/gem5/gem5" rel="nofollow noreferrer">gem5</a> to find where occurences of <code>m5.defines</code> are coming from. Inside a directory named <code>m5</code>, in the <code>__init__.py</code>, I see <code>from . import defines</code>, b...
<python>
2023-09-28 19:09:43
1
1,279
user129393192
77,197,466
1,471,980
Omit data types when inserting Pandas data frame to SQL Server table?
<p>I am loading data from Excel to a SQL Server table. All SQL table columns data types set to <code>nvarvar</code>.</p> <p>In case I have &quot;na&quot; or empty cells, I am setting them to 'NULL' values in Pandas as below:</p> <pre><code>df=df.fillna(&quot;NULL&quot;) </code></pre> <p>It inserts some of the rows but ...
<python><sql-server><pandas>
2023-09-28 18:38:48
1
10,714
user1471980
77,197,439
4,431,535
What is the correct mypy annotation for a tuple where one member's type is conditioned on another member's value?
<p><strong>Update (2023-08-28 2:48 PM):</strong> Responding to Jason Harper's logical-but-sadly-not-working suggestion about using literals with more details and a better example.</p> <hr /> <p>I'm trying to create a rust-esque expectation tuple with two possible return values that will be returned from functions manip...
<python><types><mypy>
2023-09-28 18:34:55
0
514
pml
77,197,198
1,889,720
Why do I get an `npm ERR!` when running the Python quick start tutorial in Cloud Run?
<p>I am building my first job in Cloud Run. I am using Python. I am following the <a href="https://cloud.google.com/run/docs/quickstarts/jobs/build-create-python" rel="nofollow noreferrer">Quickstart</a>.</p> <p>I am able to successfully deploy and run the job from source, but the logs show me <code>npm ERR!</code>s ...
<python><npm><google-cloud-platform><google-cloud-run>
2023-09-28 17:48:29
1
7,436
Evorlor
77,196,777
4,701,426
x-axis shows 1970 as the starting year of time series dates
<p>The dataframe <code>df</code> has a datetime index ranging from 2019-12-02 to 2020-01-30 and I can plot it fine using mplfinance's plot function:</p> <p><a href="https://i.sstatic.net/S7RjK.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/S7RjK.png" alt="enter image description here" /></a></p> <p>But ...
<python><matplotlib><datetime><xticks><mplfinance>
2023-09-28 16:31:53
0
2,151
Saeed
77,196,766
3,177,186
could not find a writer for the specified extension in function 'cv::imwrite_' - filename HAS the correct extension - Python, CV2
<p>I originally tried holding the thumbnails in memory, but that didn't work and now I'm creating temporary thumbnail files in a nearby directory. Anyway, the image creation works for photos, but it's failing for mp4 video and I'm not sure why. This is the error:</p> <pre><code>'D:\\Stuff\\Pictures\\Transit\\20230729_0...
<python><opencv><mp4>
2023-09-28 16:29:57
1
2,198
not_a_generic_user
77,196,501
4,551,325
How to extract paragraphs from pdf?
<p>I have a pdf downloaded from SSRN here: <a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4337484" rel="nofollow noreferrer">https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4337484</a>. The default file name is &quot;SSRN-id4337484.pdf&quot;.</p> <p>I then extract the text from the downloaded file usi...
<python><parsing><pdf><nlp>
2023-09-28 15:54:45
1
1,755
data-monkey
77,196,497
8,037,595
How to connect from VS Code dev Container to Postgres in Docker
<p>I am trying to connect to a dockerized Postgres from Python. However, I have not managed to make it work the way I believe it should work. As I am just a beginner with Docker, I used first used the postgres-pgadmin yaml from the <a href="https://github.com/docker/awesome-compose/tree/master/postgre" rel="nofollow no...
<python><postgresql><docker><visual-studio-code>
2023-09-28 15:54:22
2
597
Peter K.
77,196,429
747,228
How to await on Future in from the different thread?
<p>I have a code that returns <code>Twisted</code> <code>Deferred</code> and I need to await on that deferred so I can use the usual <code>async-await</code> pattern further. So I am converting the <code>Deferred</code> returned from <code>Twisted</code> to A <code>Future</code>, like this:</p> <pre><code>future = twi...
<python><async-await><python-asyncio><twisted>
2023-09-28 15:43:31
1
2,028
unresolved_external
77,196,410
421,398
How can I set authentication options for an azure container app via Python SDK?
<p>We're using the Python ContainerAppsAPIClient library to deploy a container app to our azure estate, and it works great however I can't find any documentation on how to set the authentication on the container app either during or after it's been created. In the portal it's super easy to do, and there are some models...
<python><azure><active-directory><azure-container-apps>
2023-09-28 15:40:58
1
4,122
John Hunt
77,196,392
3,555,115
Find all lines that match specific format
<p>I have an output of lines that looks like below after reading the command file</p> <pre><code>fp2 = os.popen(command) data = fp2.read() fp2.close() print data data output: LineEntry: [0x0000000002758261-0x0000000002758268): /a/b/c:7921:14 LineEntry: [0x0000000002756945-0x0000000002756960): /f/b/c:6545:10 LineEntry...
<python>
2023-09-28 15:38:35
2
750
user3555115
77,196,314
317,779
TypeError: HybridTableMaskedLM.__init__() takes 1 positional argument but 2 were given
<p>Here I am asking about this recurrent, sometimes obvious, issue. I'm execution this <a href="https://colab.research.google.com/drive/1WTg-YnfNVX4M0P0m1mEJYDQVkWr4HKXl" rel="nofollow noreferrer">notebook</a>. However, I get the error :</p> <pre><code>TypeError Traceback (most recent ca...
<python>
2023-09-28 15:26:53
0
787
Rafael Angarita
77,196,148
4,716,625
Mutually Exclusive Geo-Spatial Markers with folium.LayerControl() in Python
<h2>Goal</h2> <p>I want to use a radio button to toggle the color and the pop-up of geo-spatial markers in a folium plot, using Python3.6 and folium version <code>0.9.0</code>. I am attempting this by creating two separate data frames that have different color values and adding them both to their own <code>folium.Featu...
<python><folium>
2023-09-28 15:02:59
1
1,223
bshelt141
77,196,111
1,380,613
Convert python post request to php/curl
<p>I have a python script I have modified and it is working correctly. It just posts an xml file to a url (using basic authentication) and saves the xml response.</p> <p>The environment that I need it on does not support python in that way (no cgi support, no system level access) so I am attempting to convert it to php...
<python><php><curl>
2023-09-28 14:57:02
1
412
Developer Gee
77,196,067
4,173,663
Is there a way to check all the python modules that are currently installed that can be accessed directly from the terminal?
<p>Some python modules like <code>pip, venv, streamlit, etc</code> can be accessed by directly typing them and hitting enter in the terminal.</p> <p>I recently started using <code>pip-tools</code> and although <code>pip-tools</code> can be seen listed in the output of <code>pip freeze</code>, the actual commands that c...
<python><pip><module><package>
2023-09-28 14:49:48
1
341
Piyush Ranjan
77,196,016
22,437,609
How can I sort this list by date?
<p>I have a problem to sort my list by date.</p> <p>Here is the code.</p> <pre><code>a = ['28/09 Fenerbahçe Başakşehir FK : 3.0 Normal', '29/09 Samsunspor Gaziantep FK : 2.25 Normal', '30/09 Sivasspor Hatayspor : 2.33 Normal', '30/09 İstanbulspor Antalyaspor : 2.17 Alt Degerli', '30/09 Trabzonspor Pendikspor : 2.67 Nor...
<python><python-3.x>
2023-09-28 14:43:13
3
313
MECRA YAVCIN
77,195,991
9,342,193
dd prefix to duplicate values AND add new rows with this values to a certain groups in pandas
<p>I have a df such as</p> <pre><code>Type Species Value Dog Species2 100 Dog Species1 200 Dog Species3 300 Dog Species3 900 ALL_ Species1 400 ALL_ Species2 500 ALL_ Species3 600 </code></pre> <p>how can I add rows to <code>ALL_</code> for each duplicated Species while also...
<python><python-3.x><pandas>
2023-09-28 14:38:47
1
597
Grendel
77,195,870
9,166,673
Gradio HTML component display mounted on FAST API
<p>I am trying to achieve HTML display message on webpage using gradio mounted on fastapi.</p> <pre class="lang-py prettyprint-override"><code>import gradio as gr from fastapi import FastAPI from starlette.middleware.sessions import SessionMiddleware import uuid app = FastAPI() def get_user_info(request: gr.Request):...
<python><fastapi><gradio>
2023-09-28 14:22:00
1
845
Shubhank Gupta
77,195,789
9,068,493
Python unions with typevars
<pre class="lang-py prettyprint-override"><code>import typing as t T = t.TypeVar(&quot;T&quot;) v = t.Union[int , T] a: v = &quot;g&quot; t.reveal_type(a) # Unknown | int </code></pre> <p>The above code passes the Pylance checks, however...it seems <em>illogical</em>. Did I discovered another &quot;feature&quot; of...
<python><python-typing>
2023-09-28 14:13:19
1
811
Felix.leg
77,195,453
18,377,883
Pixel Art Square
<p>I am creating a pixel art of a 64x64 Pixel image on my terminal using Python. The Problem is that it is ASCII and because of that the image always comes out as a rectangle and not as a square as you can see on the image. (I have checked and the characters are really 64x64)</p> <p><a href="https://i.sstatic.net/ENs7l...
<python><unicode><ascii><pixel>
2023-09-28 13:36:22
1
1,681
vince
77,195,372
7,112,039
python logging: replace values in dictconfig file using environment variables
<p>I am running a FastAPI app using uvicorn as server. To use less code as possible and to use tools that my environment already provides, I am passing logging configuration to uvicorn using the shell parameter during the run, as following:</p> <pre><code>uvicorn --reload --log-config=logging_conf.yaml main:app </code>...
<python><fastapi><uvicorn>
2023-09-28 13:25:10
1
303
ow-me
77,195,269
4,489,082
Storing a list in panda DataFrame
<p>I am trying to save a list in a pandas DataFrame, but I am not able to achieve that all the time.</p> <p>I will try to explain the issue with code.</p> <p>With the following code I can save a list in pandas DataFrame</p> <pre><code>import pandas as pd df1 = pd.DataFrame(index = ['R1'], columns = ['C1']) df1.loc['...
<python><pandas>
2023-09-28 13:10:11
2
793
pkj
77,195,224
8,741,562
How to get the cost details for a particular resource group from azure using python?
<p>I am using the below code to get the list of resource groups. But I need to check the cost details for the resource groups coming up for each of them. Which module will support for this and what are the permissions needed in order to achieve it?</p> <pre><code>from azure.identity import ClientSecretCredential import...
<python><python-3.x><azure><azure-active-directory><azure-web-app-service>
2023-09-28 13:03:33
2
1,070
Navi
77,194,999
1,800,515
Google sheets API: Service account authentication: Updating cell value fails with a 403 response, only reading is successful
<pre><code>from apiclient import discovery from google.oauth2 import service_account credentials = service_account.Credentials.from_service_account_file( os.path.join(os.getcwd(), 'app3-c1824-91dfa420b4a8.json'), scopes=['https://www.googleapis.com/auth/spreadsheets'] ) apiService = discovery.build('sheets', 'v4'...
<python><google-sheets><google-sheets-api><service-accounts>
2023-09-28 12:35:24
1
2,783
PrashanD
77,194,759
17,092,778
How to protect /docs endpoint in FastAPI using Azure AD (fastapi_msal)?
<p>How to connect the Authorize button in protect under <code>/docs</code> endpoint in FastAPI application to Azure AD?</p> <p>Is it possible to make Authorize button to trigger a popup for the sign in window? Similar to how its done in this example <a href="https://learn.microsoft.com/en-us/azure/active-directory/deve...
<python><swagger><fastapi><openapi><azure-ad-msal>
2023-09-28 12:00:36
0
313
starking
77,194,746
16,895,640
Transform data by grouping column value then getting all its grouped data using Panda DataFrame
<p>I got this structure of data from csv file.</p> <pre><code>string | group | datetime some_string1 apple 2023-09-20 17:20:19 some_string2 apple 2023-09-25 17:20:19 some_string3 apple 2023-09-21 17:20:19 some_string4 banana 2023-09-23 17:20:19 some_string5 cherry 2023-09-23 17:20...
<python><pandas><dataframe><list><dictionary>
2023-09-28 11:59:06
1
4,139
Marc Anthony B
77,194,570
5,663,844
"Warm Start" in combination with new data leads to broadcasting error when predicting with Random Forest
<p>I am trying to train a random forest model with <code>sklearn</code>. I have some original data (<code>x</code>, <code>y</code>) that I use to train the RF initially with.</p> <pre><code>from sklearn.ensemble import RandomForestClassifier import numpy as np x = np.random.rand(30,20) y = np.round(np.random.rand(30)) ...
<python><machine-learning><scikit-learn><random-forest>
2023-09-28 11:33:37
1
480
Janosch
77,194,543
6,401,758
FastAPI: how to return JSONResponse and StreamingResponse
<p>Is it possible to return both a json and a zip file at the same time with FastAPI ? This is the tentative endpoint but it doesn't work:</p> <pre class="lang-py prettyprint-override"><code>@app.post(&quot;/search&quot;) async def structure_search() json_response = {&quot;item1&quot;: result1, &quot;item2&quot;: r...
<python><python-3.x><fastapi>
2023-09-28 11:30:34
0
415
Gabriel Cretin
77,194,538
128,618
How can I merge two lists of dictionaries into 1, where numeric values for identical keys get added?
<p>I have two list of dictionaries:</p> <pre><code>list_of_dicts = [{'a': 1, 'name1': &quot;jane&quot;}, {'b': 2, 'name1': 'jack'}, {'c': 3, 'name1': 'nak'},{'d': 3, 'name1': 'nak'}] dict_to_check = [{'a': 1, 'name2': &quot;jone&quot;}, {'b': 2, 'name2': 'doe'}, {'d': 3, 'name2': 'nick'}] </code></pre> <p>I want to out...
<python><python-3.x><algorithm>
2023-09-28 11:29:52
3
21,977
tree em
77,194,300
9,139,930
Identify symlinked python files for import in VS Code
<p>I am working with a complex body of code where some python files get symlinked to a directory, from which I would like to import them. For example:</p> <pre><code>accessible_module | __init__.py | sourceA.py </code></pre> <p>The files <code>__init__.py</code> and <code>sourceA.py</code> are symlinked to source files...
<python><visual-studio-code><import><symlink><pylance>
2023-09-28 10:47:50
1
367
book_kees
77,194,220
6,619,692
Validate against enum values in Python
<p><strong>How can I validate a parameter passed by a user by ensuring it is one of the <em>values</em> of the members of an integer enum that already exists in my codebase?</strong></p> <p>I have the following <code>SamplingRateEnum</code>:</p> <pre class="lang-py prettyprint-override"><code>from enum import IntEnum, ...
<python><enums>
2023-09-28 10:38:33
1
1,459
Anil
77,194,214
21,346,793
How yo fix encoding by python.csv
<p>I have got a programm with making the report by python into csv. There is a function to do it:</p> <pre><code>def download_report(request, date): food_orders = FoodOrder.objects.filter(order__date__date=date) response = HttpResponse( content_type=&quot;text/csv&quot;, headers={&quot;Content-...
<python><excel><csv>
2023-09-28 10:37:16
0
400
Ubuty_programmist_7
77,193,917
2,467,772
Error in running C application with python
<p>I am running c application with python code and my code is as follows.</p> <pre><code>import subprocess import os sourcepath = '/home/atic/deepstream/videos' destpath = '/home/atic/deepstream/jsons' avi_files = [f for f in os.listdir(sourcepath) if f.endswith('.avi')] for file_ in avi_files: avi_file = os.path....
<python><subprocess>
2023-09-28 09:50:00
1
7,346
batuman
77,193,700
4,391,249
Why is my recursion limit not being respected?
<p>Consider this example:</p> <pre class="lang-py prettyprint-override"><code>import math import sys sys.setrecursionlimit(100) max_items = 10 def foo(ls): if -(len(ls) // -max_items) &gt;= sys.getrecursionlimit(): raise ValueError(&quot;List is too long. You'll hit the recusion limit&quot;) ls, ls_...
<python><recursion>
2023-09-28 09:18:54
3
3,347
Alexander Soare
77,193,676
15,825,321
Pandas merge data frames as of certain index
<p>I have two pandas data frames:</p> <p><strong>x_axis:</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>index</th> <th>date</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>01-01-2023</td> </tr> <tr> <td>2</td> <td>02-01-2023</td> </tr> <tr> <td>3</td> <td>03-01-2023</td> </tr> <tr...
<python><pandas><dataframe><join><concatenation>
2023-09-28 09:16:13
2
303
Paul1911
77,193,617
15,341,457
Replace ASCII HTML characters when loading JSON
<p>I'm loading a JSON file made up of yelp restaurant reviews so that it removes Unicode characters this way:</p> <pre><code>def parse_yelp_restaurant_api(self, response): jsonresponse = json.loads(response.text, strict=False) </code></pre> <p>Now I would like to also remove ASCII HTML characters. My JSON file...
<python><html><json><unicode><ascii>
2023-09-28 09:08:38
1
332
Rodolfo
77,193,572
1,128,648
Python logging configuration issue
<p>I have a main script called data.py, which will call <code>logger.py</code> (for log configuration) and <code>login.py</code> (for login)</p> <pre><code># data.py from logger import configure_logger from login import * if __name__ == &quot;__main__&quot;: script_name = (f&quot;C:\\datalog&quot;) #save logfile i...
<python><python-logging>
2023-09-28 09:02:40
1
1,746
acr
77,193,458
1,256,495
Download files from url using Python requests
<p>I have a generated url that will need to open up the browser to download the file from the server. I am trying to simulate this download using Python requests library</p> <p>import requests</p> <pre><code>url = r'https://www.filedownloadserver.com?docId=7700915281958&amp;projectNumber=aaa' resp = requests.get(url, ...
<python><python-requests>
2023-09-28 08:46:27
0
559
ReverseEngineer
77,193,397
9,756,752
Pandas read_csv with seperators in header names
<p>i've got a text file similar to this:</p> <pre><code>@ some comment @ some comment @ [...] @ some comment * NAME S BX BY bla foo bar foo &quot;ACF&quot; 1 2 3 &quot;BGB&quot; 4 5 6 &quot;CSD&quot; 7 8 9 </code></pre> <p>I'm using the following to read in the file. Automatic detection of the header se...
<python><pandas>
2023-09-28 08:36:31
3
705
Marvin Noll
77,193,349
507,852
Python TLS socket: how to detect connection closed by server due to certificate failure?
<p>Trying to write a TLS client using Python 3. Can't figure out what's the proper way to detect and handle connection rejected by server.</p> <p>If the TLS server requires client certificate but the client didn't call <code>SSLContext.load_cert_chain()</code> or assigned wrong certificate, the connection will be termi...
<python><ssl>
2023-09-28 08:27:41
0
1,982
RichardLiu
77,193,320
4,399,016
Applying a function to a Pandas Dataframe
<p>I have <a href="https://github.com/voice32/stock_market_indicators/blob/master/indicators.py" rel="nofollow noreferrer">this code</a> with me. And I need to pass a pandas data frame in it as a parameter. It returns errors.</p> <p>The <a href="https://download.esignal.com/products/workstation/help/charts/studies/acc_...
<python><pandas><technical-indicator>
2023-09-28 08:23:01
1
680
prashanth manohar
77,193,310
17,160,160
Insert series ending at last valid index in dataframe column. Pandas
<p>Given a dataframe that contains a combination of null and numeric values in which each series of numeric values is always located together and is never interspersed with nulls. Such as:</p> <pre><code>df1 = pd.DataFrame({ 'A': [1, 2, 3, np.nan, np.nan], 'B': [np.nan, np.nan, 1, 2, 3], 'C': [np.nan, 1, 2,...
<python><pandas>
2023-09-28 08:21:27
1
609
r0bt
77,193,264
10,916,136
How to make a tkinter appear and disappear based on a time condition
<p>The question is related to these questions:</p> <p><a href="https://stackoverflow.com/questions/22485225/how-do-i-get-rid-of-a-label-in-tkinter">How do I get rid of a label in TkInter?</a></p> <p><a href="https://stackoverflow.com/questions/34276672/how-to-make-a-label-appear-then-disappear-after-a-certain-amount-of...
<python><tkinter>
2023-09-28 08:15:05
1
571
Veki
77,193,088
292,502
How to perform inference with a Llava Llama model deployed to SageMaker from Huggingface?
<p>I deployed a Llava Llama Huggingface model (<a href="https://huggingface.co/liuhaotian/llava-llama-2-13b-chat-lightning-preview/discussions/3" rel="nofollow noreferrer">https://huggingface.co/liuhaotian/llava-llama-2-13b-chat-lightning-preview/discussions/3</a>) to a SageMaker Domain + Endpoint by using the deployme...
<python><amazon-sagemaker><huggingface><huggingface-hub>
2023-09-28 07:48:32
3
10,879
Csaba Toth
77,193,060
3,871,575
Parsing string that looks like a list using ConfigArgParse
<p>I am using Python 3.9.16 and <code>ConfigArgParse==1.7</code>.</p> <p>I have conf file like this:</p> <pre class="lang-ini prettyprint-override"><code>[conf] example = [something_in_brackets] </code></pre> <p>I am trying to parse the config like this:</p> <pre><code>import configargparse p = configargparse.ArgPars...
<python>
2023-09-28 07:43:40
1
568
Madoc Comadrin
77,193,055
2,153,235
Spyder Startup command creates SparkSession object and *two* Web UIs
<p>In my Spyder preferences, I have the following IPython console Startup command:</p> <pre><code> from pyspark.sql import SparkSession ; spark = SparkSession.builder.appName(&quot;SparkExamples.com&quot;).getOrCreate() </code></pre> <p>This launches <em>two</em> Web UIs on ports 4040 and 4041.</p> <p>When I comment o...
<python><apache-spark><pyspark><spyder>
2023-09-28 07:43:01
1
1,265
user2153235
77,192,757
9,166,673
Gradio pop up display on success
<p>Here is the below sample code for gradio app mounted on FAST API app.</p> <pre class="lang-py prettyprint-override"><code>import gradio as gr from fastapi import FastAPI from starlette.responses import RedirectResponse from starlette.requests import Request app = FastAPI() def submit(message): print(f&quot;Sa...
<python><fastapi><gradio>
2023-09-28 06:56:14
2
845
Shubhank Gupta
77,192,718
8,741,562
How to generate an auth token and list out the resource groups in azure using python?
<p>I have tried with the below code:</p> <pre><code>from azure.identity import ClientSecretCredential import requests subscription_id = 'MYSUBID' client_id = 'MYCLIENTID' client_secret = 'MYSECRETVALUE' tenant_id = 'MYTENANTID' # Create a ClientSecretCredential object credential = ClientSecretCredential(tenant_id=ten...
<python><python-3.x><azure><azure-active-directory><azure-web-app-service>
2023-09-28 06:49:07
1
1,070
Navi
77,192,651
19,130,803
Prevent ReferenceError in multi-page dash application
<p>I am developing a <code>multi-page</code> dash application. My project structure is as below:</p> <pre><code>- project/ - pages/ - home.py - graph.py - app.py - index.py </code></pre> <p>On <code>app.py</code> page, I have a theme switch button. The app gets loaded, When I change the theme color, The...
<python><plotly><plotly-dash>
2023-09-28 06:36:27
0
962
winter
77,192,262
5,131,394
Heroku Deployment: ocrmypdf.exceptions.MissingDependencyError: tesseract
<p>I'm trying to deploy a FastAPI application to Heroku that uses the ocrmypdf package for OCR (Optical Character Recognition). The application works fine locally, but on Heroku, I get a missing dependency error for tesseract.</p> <p>Here are the relevant logs:</p> <pre><code> 2023-09-28T04:57:02.190892+00:00 heroku...
<python><heroku><ocr><fastapi><tesseract>
2023-09-28 05:05:18
1
435
Norbert
77,192,092
1,100,652
Python Azure Function deployment (Oryx build) hangs on "Running pip install..." step
<p>I am attempting to deploy an Azure Function to production.</p> <p>Local environment:</p> <ul> <li>Windows 10</li> <li>VS Code 1.82.2</li> <li>Python 3.9.10</li> <li>Azure Function Core Tools 4.0.5390</li> </ul> <p>Azure environment:</p> <ul> <li>Two function apps (dev/prod)</li> <li>Both using runtime version ~4</li...
<python><azure><azure-functions><devops><azure-functions-core-tools>
2023-09-28 04:06:59
2
415
George
77,191,992
1,854,821
pydeck icon layer - are folium-style clustered icons possible?
<p>My question: is it possible to do folium-style icon clustering using pydeck?</p> <p>I'm making map visualizations for a dataset in which we've made measurements at a number of locations, returning to some locations many times across the past five years. I've mapped the measurement locations using folium's MarkerClu...
<python><deck.gl><pydeck>
2023-09-28 03:19:25
0
473
Timothy W. Hilton
77,191,878
4,443,378
How to select columns from a dataframe whose names are contained in another series?
<p>I have a series <code>A</code> that looks like:</p> <pre><code>data = {'Animal':['a.Bear', 'b.Elephant', '123.Giraffe', 'Kangaroo']} A = pd.DataFrame(data) Animal 0 a.Bear 1 b.Elephant 2 123.Giraffe 3 Kangaroo </code></pre> <p>And a dataframe <code>df</code> like:</p> <pre><code>column_names = ['Lion', ...
<python><pandas><dataframe>
2023-09-28 02:38:22
3
596
Mitch
77,191,791
5,003,606
Google Cloud Run Jobs logging splits Exception MESSAGES with multiple lines into multiple log entries
<p>Several days ago, a Python RuntimeError was raised in one of my company's Cloud Run jobs which stopped it.</p> <p>Cloud Run's logging, unfortunately, handled that RuntimeError in a bad way.</p> <p>It correctly put all the lines from the RuntimeError's stack trace in the first log entry.</p> <p>But the RuntimeError's...
<python><exception><logging><google-cloud-run><multiline>
2023-09-28 02:05:31
1
951
HaroldFinch
77,191,734
1,070,833
mypy raises Cannot assign multiple types to name
<p>This looks like a bug in mypy and a false positive. Below is a standard case where we pass an inherited class to a function to process it. Very explicit and simple code however mypy fails to parse it and forces us to declare the type before if statement like in c++</p> <p>the code below raises:</p> <p><code>25: erro...
<python><mypy>
2023-09-28 01:44:44
0
1,109
pawel
77,191,601
6,296,626
Have tabs in a row in Python Flet
<h1>The issue</h1> <p>I am using <a href="https://flet.dev/docs" rel="nofollow noreferrer">Flet</a> as the GUI library for my project. I am trying to create a page where its separated in two half (left and right), where on the left side, there are some content, and on the right side there are tabs and more content in t...
<python><flutter><user-interface><tabs><flet>
2023-09-28 00:42:00
1
1,479
Programer Beginner
77,191,349
22,407,544
How to make Django redirect after validating an uploaded file?
<p>Instead, the page just reloads. When I check my server logs nothing is happening. This tells me that either the page isn't uploading or my <code>views.py</code> has a problem but I'm not sure what that could be.</p> <p>Here is my code:</p> <p>HTML:</p> <pre><code>&lt;form method=&quot;post&quot; action=&quot;{% url ...
<javascript><python><html><django><file-upload>
2023-09-27 23:10:19
1
359
tthheemmaannii
77,191,297
7,339,624
How to remove margins padding around grouped matplotlib edges of the figure
<p>I want to create a grid of <code>matplotlib</code> subplots with no borders or whitespace around the edges of the figure (0 margin). I have tried various suggestions like <code>plt.tight_layout()</code>, <code>fig.subplots_adjust()</code>, and manually setting <code>fig.set_size_inches()</code>, and also <code>frame...
<python><matplotlib><plot>
2023-09-27 22:51:28
1
4,337
Peyman
77,191,238
4,792,022
Quickly removing a list of elements from lists in the column of a dataframe
<p>I have a dataframe with a column of the form of fruit</p> <pre><code>data = { 'fruit': [['apple', 'banana', 'cherry'], ['banana', 'orange'], None, [], ['cherry', 'grape'], ['apple']], 'location': ['New York', 'Los Angeles', 'Chicago', 'Miami', 'San Francisco', 'Seattle'] } df = pd.DataFrame(data) </code></pr...
<python><pandas><performance>
2023-09-27 22:32:56
2
544
Abijah
77,191,218
2,051,818
Building a customized Lasagne layer whose output is a matrix of the elementwise product (input x weight) and not the dot product
<p>I have an input sequence with shape (seq_length(19) x Features(21)), which I feed as an input to neural network.</p> <p>I need a layer to perform an elementwise multiplication on inputs with weights (Not dot product), so the output shape should be (#units, input_shape). Since, in my case Input_shape(19 x 21), the ou...
<python><neural-network><theano><lasagne>
2023-09-27 22:26:15
0
371
HATEM EL-AZAB
77,191,044
1,285,061
Numpy rotate and save 2D array to a CSV
<p>How can I save a 2D array into a CSV by rotating the array by 90 degree?</p> <p>I tried numpy np.rot90, it alters the position of the elements.</p> <pre><code>&gt;&gt;&gt; a = np.array([[88,87],[78,77],[68,67],[58,57]]) &gt;&gt;&gt; a array([[88, 87], [78, 77], [68, 67], [58, 57]]) &gt;&gt;&gt; ...
<python><numpy>
2023-09-27 21:38:15
2
3,201
Majoris
77,190,950
7,846,884
RuntimeWarning: divide by zero encountered in log in Max likelihood estimate python code
<p>i'm simulating the effect of log maximum likelihood estimate (for Bionomial distribution) as number of samples increases. I choose a true parameter value of 0.6 for bionomial distribution from which the responses are coming from.</p> <p>but i'm getting the error even when i remove 0 from the possible parameters i'm ...
<python><numpy><mle>
2023-09-27 21:16:49
1
473
sahuno
77,190,726
4,431,798
coremltools GPU usage with mlpackage on macOS, very slow inference/prediction
<p>for a project, i converted a Yolov8 segmentation .pt model to .mlpackage, so that i can run it. everything runs fine, items of interests are detected on the video, but inference speed is the problem. it takes like 280 ms per item, extremely slow. i run the same unconverted model as .pt on colab or on my laptop, take...
<python><macos><yolo><coremltools><yolov8>
2023-09-27 20:35:51
0
441
SoajanII
77,190,564
616,728
psycopg3 pool "connection is closed"
<p>I have set up a decorator to provide a db connection using psycopg3. Sometimes, the connection is closed and it is throwing the following error when I try to use it:</p> <blockquote> <p>the connection is closed</p> </blockquote> <p>Here is my implementation:</p> <pre class="lang-py prettyprint-override"><code>master...
<python><postgresql><fastapi><psycopg3>
2023-09-27 20:05:13
1
2,748
Frank Conry
77,190,562
1,769,172
Python Plotly Sunburst Coloring
<p>I have the following code to generate a sunburst plot using plotly in Google colab.</p> <pre><code>import plotly.express as px import matplotlib.pyplot as plt def generate_single_color_sunburst(person, color): color_hex = &quot;#{:02x}{:02x}{:02x}&quot;.format(int(color[0]*255), int(color[1]*255), int(color[2]*...
<python><plotly><google-colaboratory>
2023-09-27 20:04:25
1
609
Ken Reid
77,190,461
10,489,887
How to divide COCO dataset evenly?
<p>I have full COCO dataset I downloaded from <a href="https://cocodataset.org/" rel="nofollow noreferrer">here</a>. I need to modify the <code>instances_train2017.json</code> file a bit to get following:</p> <ul> <li>modify the annotations file, so it divides the full train dataset into <code>1/3</code> for all classe...
<python><json>
2023-09-27 19:45:24
1
2,184
mrconcerned
77,190,372
6,599,648
Cannot access Flask App running in Docker Container in my browser
<p>I'm trying to run a Flask app in a docker container and connect to it using my browser. I am not able to see the app and get an error <code>This site can’t be reached</code> when trying to go to <code>http://127.0.0.1:5000</code>. I've already followed the advice in these two questions (<a href="https://stackoverflo...
<python><docker><flask>
2023-09-27 19:27:21
2
613
Muriel
77,190,294
8,675,314
Pytest-Django Database access not allowed error when importing a form
<p>I've been having a problem trying to run some tests using Pytest in Django.</p> <p>I've been trying to test some forms, and I've just started by importing pytest and then from the forms file imported the form to be tested.</p> <p>The form in question has a MultipleChoiceField with a choices parameter that gets popul...
<python><django><pytest><pytest-django>
2023-09-27 19:13:59
1
415
Basil
77,190,152
247,542
How to change language in a Django+Selenium test?
<p>Why would Selenium not work with multiple languages?</p> <p>I'm trying to write a Selenium test for a multi-language Django app. Everything works, until I try to change the user's language.</p> <p>I have a <code>/set-language/</code> path, which calls:</p> <pre><code>@login_required def set_language(request): la...
<python><django><selenium-webdriver><internationalization>
2023-09-27 18:50:34
1
65,489
Cerin
77,190,107
2,530,859
How to properly terminate a process that is running in the background via subprocess?
<p>I have method that runs a bash script in the background via <code>subprocess.Popen()</code>:</p> <pre><code>def my_method(): try: process = subprocess.Popen([&quot;bash&quot;, &quot;my_script.sh&quot;, &quot;&amp;&quot; ], stdout=subprocess.PIPE, ...
<python><subprocess><terminate>
2023-09-27 18:42:43
0
445
amin
77,189,872
2,862,945
Tkinter's checkbutton makes checkmark invisible after changing background color
<p>I am using <code>tkinter</code> to create a simple GUI with python. I wanted to change the background and foreground color of a <code>Checkbutton</code> and while that works, it makes the checkmark itself invisible. It still works, tested with a simple function, but I seem to miss something. Here is the code:</p> <p...
<python><tkinter>
2023-09-27 18:01:08
1
2,029
Alf
77,189,868
19,675,781
How to rename pandas column names by splitting with space
<p>I have a dataframe like this:</p> <pre><code>index col A col B col C index1 3 1 2 index2 1 4 9 index3 5 1 2 index4 8 2 2 index5 2 1 6 </code></pre> <p>I want to rename columns by splitting them with space. I dont want to do it manually ...
<python><pandas><dataframe><multiple-columns>
2023-09-27 18:00:10
3
357
Yash
77,189,787
1,473,517
How to fix <iv=None> in numba?
<p>I have a dict that takes a tuple of ints as keys and a numpy array as values. Here is a MWE:</p> <pre><code>import numba as nb import numpy as np @nb.njit def make_dict(): d = {} A = (np.ones(10)) d[(1, 2, 3)] = A return d B = make_dict() print(repr(B)) </code></pre> <p>If I then look at B I get</p> ...
<python><numba>
2023-09-27 17:47:58
0
21,513
Simd
77,189,655
3,177,186
How do I pull a thumbnail from a JPG , convert to base64, then display that in Tkinter (Python)
<p>I'm trying to show a file listing with details of files including size, dimensions, and thumbnail. Most of this is pretty straightforward, but I've tried days of searching for various posts and guides and none of them seem to do the job. This is what I have so far:</p> <pre class="lang-py prettyprint-override"><code...
<python><tkinter><base64>
2023-09-27 17:25:57
1
2,198
not_a_generic_user
77,189,479
1,482,271
How to pass "Any" type parameter in SOAP request using zeep in Python
<p>I have a WSDL that uses the &quot;any&quot; type for the core element (Element) in all SOAP operations. Note that I have trimmed this down as it's quite big:</p> <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt; &lt;definitions targetNamespace=&quot;urn:xtk:queryDef&quot; xmlns=&quot;http:/...
<python><xml><soap><wsdl><zeep>
2023-09-27 16:55:46
1
335
mroshaw
77,189,430
8,189,123
PyMuPDF: It is possible to get a face value from a combobox widget?
<p>I am trying to extract a chosen value from a combobox widget using the following Python code:</p> <pre><code>#Extract data from combobox import fitz fileIN_Master = &quot;Mypdf.pdf&quot; with fitz.open(fileIN_Master) as doc: for page in doc: widgets = page.widgets() for widget in widgets: if widget.field_type_...
<python><pdf><pymupdf>
2023-09-27 16:48:07
1
437
Camilo
77,189,381
2,386,605
Docker multi-stage build package unrecognized
<p>I have a Dockerfile, where I want to run multistage builds, such that I can install python packages from Github (in <code>requirements.txt</code>) by using <code>slim</code> as <code>base</code> stage and then want to copy everything to an <code>alpine</code> image.</p> <pre><code># pull official base image FROM pyt...
<python><docker><docker-compose><dockerfile><uvicorn>
2023-09-27 16:40:31
1
879
tobias
77,189,266
11,829,398
Ways to check LLM output and retry if incorrect but return output if correct?
<p>I'm giving an LLM 37 categories and asking it to label pieces of text with the categories that apply to it (likely multiple for each text). I ask it to output its response as a markdown table.</p> <p>Problem: the LLM doesn't always return answers for all the categories.</p> <p>I want to check if all the categories h...
<python><langchain><large-language-model><py-langchain>
2023-09-27 16:20:41
1
1,438
codeananda
77,189,224
13,717,851
Modify Streamlit echarts inside loop without adding new chart
<p>I want to update my echart with dynamically fetched data, but when I run below code, it adds a new chart to my page. Unlike <code>t.text(markdown)</code> which doesn't add but modifies existing text which is what I want my echarts to be like.</p> <p>I am using python3.</p> <p>Is there any argument or API to overwrit...
<python><frontend><streamlit><echarts>
2023-09-27 16:14:40
2
876
Sayan Dey
77,189,121
4,115,123
Pip install subprocess to install build dependencies did not run successfully
<p>I've tried a few other questions here tied to updating setuptools first, but no dice.</p> <p>I have a machine that is going to ultimately be air-gapped. I'm trying to get the installation process down. As doing so, my procedure right now included going to the identical working machine and using <code>pip freeze</cod...
<python><pip><subprocess>
2023-09-27 15:58:31
1
1,057
Jibril
77,189,113
468,455
Setting up a Python environment to point to a modules directory on a Mac
<p>I'm trying to set up a local development environment for Python. We use BitBucket for source control of Python modules we've developed for our company. On my machine I have this folder/directory set up:</p> <pre><code>~/xxxxxxx/Development/Git/xxxxxx/modules/ </code></pre> <p>This serves as my local repo for the Bit...
<python><pythonpath><zshrc>
2023-09-27 15:57:01
0
6,396
PruitIgoe
77,188,750
1,422,096
How to store metadata into a PNG or JPG with cv2, and restore it later?
<p>How to save a string metadata to a PNG or JPG file written with <code>cv2</code>?</p> <p>It could be EXIF or any other format, as long as we can retrieve it later, like in the example below.</p> <p>Note: linked but not duplicate: <a href="https://stackoverflow.com/questions/9542359/does-png-contain-exif-data-like-jp...
<python><opencv><png><jpeg><exif>
2023-09-27 15:10:35
0
47,388
Basj