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,390,823
881,150
Iterating through Azure ItemPaged object
<p>I am calling the <code>list</code> operation to retrieve the metadata values of a blob storage. My code looks like:</p> <pre><code>blob_service_list = storage_client.blob_services.list('rg-exercise1', 'sa36730') for items in blob_service_list: print((items.as_dict())) </code></pre> <p>What's happening in this ca...
<python><python-3.x><azure>
2023-02-08 19:28:24
1
1,114
abhinav singh
75,390,668
5,257,286
Conditions in panda dataframe when multiplying with multiple columns
<p>I originally had the following that works:</p> <pre><code>df = df.replace({np.nan: 0}) df[new_cols] = df[cols].multiply(df[&quot;abc&quot;], axis=&quot;index&quot;) </code></pre> <p>But I need a more exact condition. So if any of the values in a column in [cols] are NULL, then the column in [new_cols] is also NULL, ...
<python><pandas><null><multiplication>
2023-02-08 19:13:36
0
1,192
pymat
75,390,666
8,578,337
How to resolve openssl not found error while installing new Python version with Pyenv on M1 Mac OS Ventura 13.1?
<p>The system is M1 processor on MacOS Ventura 13.1. While installing a new version with <code>pyenv</code>, it throws following error regarding <code>openssl</code> not found on the system. <code>openssl</code> is already installed with the version number <code>LibreSSL 3.3.6</code></p> <pre><code>Traceback (most rece...
<python><macos><terminal><openssl><apple-m1>
2023-02-08 19:13:32
2
421
Divyesh Parmar
75,390,544
14,033,226
Passing partial=True down to nested serializer in DRF
<p>I have two serializers organised like this:</p> <pre><code>class OuterSerializer(): inner_obj = InnerSerializer(many=True, required=False) other fields ...... </code></pre> <pre><code>class InnerSerializer(): field_1 = CharField() field_2 = CharField() </code></pre> <p>Now my use case is to partial update th...
<python><django><django-rest-framework><django-queryset><django-serializer>
2023-02-08 19:01:34
1
312
njari
75,390,522
9,318,372
Type Hint `Callable[[int, ...], None]` using `ParamSpec`?
<p>Similar to <a href="https://stackoverflow.com/questions/66961423/python-type-hint-callable-with-one-known-positional-type-and-then-args-and-kw">Python type hint Callable with one known positional type and then *args and **kwargs</a>, I want to type hint a <code>Callable</code> for which is known:</p> <ol> <li>It mus...
<python><python-typing><mypy><python-3.11>
2023-02-08 18:59:40
1
1,721
Hyperplane
75,390,402
1,255,042
Unexpected Doctest result for an output including a backslash
<p>This doctest fails with an output shown at the bottom. Why does Pytest change the doctest to <code>strip_special_chars( &quot;c:\abcDEF1 23-_@.sql&quot;)</code> with a single backslash leading to the unintended expected result? How do I change its behavior?</p> <pre><code>def strip_special_chars(input_text, re_strin...
<python><doctest>
2023-02-08 18:46:07
1
3,370
Jason O.
75,390,017
1,468,810
Filtering a pandas dataframe based presence of substrings in column
<p>Not sure if this is a 'filtering with pandas' question or one of text analysis, however:</p> <p>Given a df,</p> <pre><code>d = { &quot;item&quot;: [&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;], &quot;report&quot;: [ &quot;john rode the subway through new york&quot;, &quot;sally...
<python><pandas><list><dataframe>
2023-02-08 18:08:25
4
721
Benjamin
75,390,001
8,512,262
How can I impose server priority on a UDP client receiving from multiple servers on the same port
<p>I have a client application that is set to receive data from a given UDP port, and two servers (let's call them &quot;primary&quot; and &quot;secondary&quot;) that are broadcasting data over that port.</p> <p>I've set up a UDP receiver thread that uses a lossy queue to update my frontend. Lossy is okay here because ...
<python><sockets><tkinter><udp>
2023-02-08 18:07:00
1
7,190
JRiggles
75,389,906
4,411,666
asyncio.gather doesn't execute my task in same time
<p>I am using asyncio.gather to run many query to an API. My main goal is to execute them all without waiting one finish for start another one.</p> <pre><code>async def main(): order_book_coroutines = [asyncio.ensure_future(get_order_book_list()) for exchange in exchange_list] results = await asyncio.gather...
<python><python-asyncio>
2023-02-08 17:58:14
1
1,073
Valentin Garreau
75,389,896
14,790,056
groupby and only keep rows if the value from a column appears on a different column
<p>I have exchange data. A transaction initiator sends USD and will receive Euro in return. I want to make sure that each transaction contains the correct information about the initiator. The way to ensure that is that the one who is sending money to the exchange always appear in <code>to</code> as well within the same...
<python><pandas><dataframe>
2023-02-08 17:56:45
1
654
Olive
75,389,801
18,476,381
Python groupby/convert join table to triple nested dictionary
<p>From a SQL stored procedure that performs a join on 3 tables I get the data below.</p> <pre><code> data = [ {&quot;so_number&quot;: &quot;ABC&quot;, &quot;po_status&quot;: &quot;OPEN&quot;, &quot;item_id&quot;: 0, &quot;part_number&quot;: &quot;XTZ&quot;, &quot;ticket_id&quot;: 10, &quot;ticket_month&quot...
<python><pandas><nested>
2023-02-08 17:47:35
1
609
Masterstack8080
75,389,759
3,620,605
Find blas calls happening under the hood when running inference
<p>I have a trained model saved with <code>tf.saved_model.save</code>; loaded back with <code>tf.saved_model.load</code> . Now I'd like to know what blas routines are called when I run inference on this model. I'm curious about what's going on under the hood; I would like to run the inference manually i.e. go through i...
<python><tensorflow><tensorflow2.0><blas>
2023-02-08 17:43:21
0
1,158
Effective_cellist
75,389,737
243,796
Replacing elements of a Python dictionary using regex
<p>I have been trying to replace integer components of a dictionary with string values given in another dictionary. However, I am getting the following error:</p> <pre><code>Traceback (most recent call last): File &quot;&lt;string&gt;&quot;, line 11, in &lt;module&gt; File &quot;/usr/lib/python3.11/json/__init__.py...
<python><regex><dictionary>
2023-02-08 17:41:21
2
2,270
Sumit
75,389,678
3,725,599
Call function on pandas df with lagged values calculated in the previous row/loop
<p>I am calling a function rowise on a pandas data frame using lagged values (for <code>Q</code> and <code>S</code>) that were calculated for the previous row. The first row already has values for <code>Q</code> and <code>S</code> so it starts on the second row. It works fine in a for loop but the df I'm ultimately ap...
<python><pandas><dataframe><rolling-computation>
2023-02-08 17:36:02
1
475
Josh J
75,389,651
8,285,736
How to make a Python function run concurrently or sequentially depending on the number of function calls and function arguments?
<p>I have the following sample function:</p> <pre><code>def set_value(thing, set_quantity): set_function(thing, set_quantity) #sets &quot;thing&quot; to the desired quantity read_value = read_function(thing) #reads quantity of &quot;thing&quot; if read_value != set_quantity: raise Exception('Values...
<python><concurrency><python-asyncio>
2023-02-08 17:33:22
1
643
ATP
75,389,630
6,727,914
Why does the Knapsack Problem DP using tabular method discretize the capacity?
<p>I am trying to learn different aspect of DP and the first thing that pops on google search for &quot;Knapsack 0-1&quot; is this</p> <p><a href="https://www.geeksforgeeks.org/python-program-for-dynamic-programming-set-10-0-1-knapsack-problem/" rel="nofollow noreferrer">https://www.geeksforgeeks.org/python-program-for...
<python><algorithm><optimization><dynamic-programming>
2023-02-08 17:32:04
0
21,427
TSR
75,389,463
8,869,570
Using attr.ib() for class member variables
<p>I'm not well versed with Python (mostly use C++) and the <code>attr</code> module. I'm looking through my codebase at work, and I often see class attributes created as follows:</p> <pre><code>import attr class my_class: first_member_var = attr.ib() second_member_var = attr.ib() def func(): self.third_mem...
<python><attr>
2023-02-08 17:20:32
0
2,328
24n8
75,389,357
9,357,484
Feature importance with logistic regression with feature names
<p>I want to find the feature-importance using logistic regression.</p> <p>My model trained with the code block</p> <pre><code>LR = LogisticRegression(multi_class='multinomial', random_state=1, max_iter=1000) LR.fit(X_train, y_train) R_y_pred = LR.predict(X_test) target_names = ['No', 'Yes'] print(classification_report...
<python><pandas><logistic-regression><feature-selection>
2023-02-08 17:12:50
0
3,446
Encipher
75,389,254
12,919,727
Numpy: Function to take arrays a and b and return array c with elements 0:b[0] with value a[0], values b[0]:b[1] with value a[1], and so on
<p>Say I have two arrays:</p> <pre><code>a = np.asarray([0,1,2]) b = np.asarray([3,7,10]) </code></pre> <p>Is there a fast way to create:</p> <pre><code>c = np.asarray([0,0,0,1,1,1,1,2,2,2]) # index 3 7 10 </code></pre> <p>This can be done using a for loop but I wonder if there is a fast internal...
<python><arrays><numpy>
2023-02-08 17:05:10
1
491
McM
75,389,211
4,079,144
How to get the if statement right for boto3
<p>I created a dynamodb table with two records in there. One is the ARN of the rds and one is date field name last_reported. Now i am trying to run lambda function which should fetch that record. If there is data in the table it should execute the value of the table / item, if there is no data in the table, it should e...
<python><amazon-dynamodb><boto3>
2023-02-08 17:01:59
1
559
srk786
75,389,208
2,725,742
Hiding Empty ttk Notebook Tabs with Grid vs Pack
<p>At <a href="https://github.com/muhammeteminturgut/ttkScrollableNotebook" rel="nofollow noreferrer">https://github.com/muhammeteminturgut/ttkScrollableNotebook</a> there is a lovely demo of effectively adding scrolling tabs at the top of a notebook. But there is actually a notebook elements, one on top of the other....
<python><tkinter><ttk>
2023-02-08 17:01:40
0
448
fm_user8
75,389,166
7,259,176
How to match an empty dictionary?
<p>Python supports <a href="https://peps.python.org/pep-0636/" rel="nofollow noreferrer">Structural Pattern Matching</a> since version <code>3.10</code>. I came to notice that matching an empty <code>dict</code> doesn't work by simply matching <code>{}</code> as it does for <code>list</code>s. According to my naive app...
<python><dictionary><python-3.10><structural-pattern-matching>
2023-02-08 16:57:37
3
2,182
upe
75,389,050
3,521,180
How to add dummy record to the existing column in pyspark?
<p>I have a data frame where I want to add one dummy record each. So, to do that, I read a dataframe from a parquet file, and created a list out of them., and then used python dict(zip()) to add them. Below is the code snippet.</p> <pre><code>prem_df = read_parquet_file(folder_path, logger) row_list = prem_df.select(co...
<python><pyspark>
2023-02-08 16:47:36
1
1,150
user3521180
75,388,887
20,959,773
Regex works in regex101, but not in python code
<p>I have this text:</p> <pre><code>a href=&quot;#&quot; class=&quot;s-navigation--item js-gps-track js-products-menu&quot; aria-controls=&quot;products-popover&quot; data-controller=&quot;s-popover&quot; data-action=&quot;s-popover#toggle&quot; data-s-popover-placement=&quot;bottom&quot; data-s-popover-toggle-class=&q...
<python><html><regex>
2023-02-08 16:33:42
0
347
RifloSnake
75,388,867
649,749
Keras model with multiple categorical outputs of different shapes
<p>I have a keras model here which looks as follows: <a href="https://i.sstatic.net/GyEbY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/GyEbY.png" alt="Keras Model" /></a></p> <p>As you can see, an intent (four classes) is predicted and each word of the sentence is tagged (choce of 10 classes). I'm now...
<python><tensorflow><keras><artificial-intelligence>
2023-02-08 16:32:17
1
506
Martin Horvath
75,388,644
17,160,160
Fill NA values over varied data frame column slices in Pandas
<p>I have a Pandas data frame similar to the following:</p> <pre><code>pd.DataFrame({ 'End' : ['2022-03','2022-05','2022-06'], '2022-01' : [1,2,np.nan], '2022-02' : [np.nan,3,4], '2022-03' : [np.nan,1,3], '2022-04' : [np.nan,np.nan,2], '2022-05' : [np.nan,np.nan,np.nan], '2022-06' : [np.nan,...
<python><pandas>
2023-02-08 16:14:16
3
609
r0bt
75,388,487
5,695,336
Use a single ClientSession instead of creating one for every request slowed down my HTTP calls
<p>My python program makes HTTP requests to several different sites once every few hours. At first, I didn't know the recommended way to use <code>aiohttp</code> is to create only one <code>ClientSession</code> and use it for every request in the program's lifetime. So I create a new <code>ClientSession</code> for ever...
<python><aiohttp>
2023-02-08 16:01:41
1
2,017
Jeffrey Chen
75,388,277
12,924,562
Python Mysql Queary not returning results
<p>I have a DB and when I query a table I get 67 results. The SQL is:</p> <pre><code>SELECT lower(UserName) from Participants ; </code></pre> <p>I try to connect to the DB, and I get no connection errors.</p> <pre><code>def db_connect (): ...
<python><mysql><sql><mysql-connector>
2023-02-08 15:46:43
1
386
Rick Dearman
75,388,263
9,262,339
FastAPI: url_for in Jinja2 template does not work with https
<p>Everything was running fine until I switched the application to use https. All the links that the <code>url_for</code> function generates in the templates now look like this <a href="https://ibb.co/N3cJ9V4" rel="nofollow noreferrer">https://ibb.co/N3cJ9V4</a></p> <p><strong>Problem:</strong></p> <pre><code>Mixed Con...
<python><nginx><https><fastapi><starlette>
2023-02-08 15:45:53
0
3,322
Jekson
75,388,232
9,475,509
Install Python package inside a Jupyter Notebook kernel
<p>Inside a Jupyter Notebook I have managed to install a Python kernel with</p> <pre><code>!python -m ipykernel install --user --name other-env --display-name &quot;Python (other-env)&quot; </code></pre> <p>as informed <a href="https://ipython.readthedocs.io/en/stable/install/kernel_install.html" rel="nofollow noreferr...
<python><pip><jupyter-notebook><python-venv><jupyter-kernel>
2023-02-08 15:43:33
3
789
dudung
75,388,146
12,829,151
Using sample_weight param with XGBoost through a pipeline
<p>I want to use the <code>sample_weight</code> parameter with XGBClassifier from the <code>xgboost</code> package.</p> <p>The problem happen when I want to use it inside a <code>pipeline</code> from <code>sklearn.pipeline</code>.</p> <pre><code>from sklearn.preprocessing import MinMaxScaler from sklearn.pipeline ...
<python><machine-learning><scikit-learn><pipeline><xgboost>
2023-02-08 15:36:59
1
1,885
Will
75,388,099
8,971,938
Split tensorflow BatchDataset for LSTM with multiple inputs
<p>I construct a LSTM model with two inputs: one for categorical variables, one for numerical variables:</p> <pre><code>model = Model(inputs = [cat_input, num_input], outputs = x, name = &quot;LSTM&quot;) </code></pre> <p>The input data for the LSTM is generated by means of <code>tensorflow.keras.utils.timeseries_datas...
<python><tensorflow><keras><time-series><lstm>
2023-02-08 15:32:35
1
597
Requin
75,388,072
5,181,219
Given two numpy arrays, how to split one into an array of lists based on the second
<p>I have two numpy arrays: one containing arbitrary values, and one containing integers larger than 1. The sum of the integers is equal to the length of the first array. Sample:</p> <pre class="lang-py prettyprint-override"><code>values = np.array([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;, &quot;e&qu...
<python><arrays><numpy><performance>
2023-02-08 15:30:48
1
1,092
Ted
75,388,064
10,178,162
predict_proba version issue
<p>I want to get probability of each class in the following code,</p> <pre><code># example making new probability predictions for a classification problem from keras.models import Sequential from keras.layers import Dense from sklearn.datasets import make_blobs from sklearn.preprocessing import MinMaxScaler # generate ...
<python><tensorflow><keras>
2023-02-08 15:30:02
1
399
Phoenix
75,388,032
11,006,089
How to Load the Earnings Calendar data from TradingView link and into Dataframe
<p>I want to load the Earnings Calendar data from TradingView link and load into Dataframe.</p> <pre><code>Link: https://in.tradingview.com/markets/stocks-india/earnings/ Filter-1: Data for &quot;This Week&quot; </code></pre> <p><a href="https://i.sstatic.net/eMAzl.png" rel="nofollow noreferrer"><img src="https://i.sst...
<python><python-3.x><pandas><selenium-webdriver><web-scraping>
2023-02-08 15:28:07
1
465
Rohit
75,387,992
10,112,162
How to activate virtual environment withing npm script in package.json
<p>How do i activate a virtual environment within a npm script?</p> <pre><code> &quot;scripts&quot;: { &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;, &quot;dev&quot;: &quot;virtualenv ../Scripts/venv &amp;&amp; nodemon server.js&quot; }, </code></pre> <p>I tried ...
<python><node.js><virtualenv>
2023-02-08 15:25:20
1
365
Elias Knudsen
75,387,979
11,574,636
Artifactory aql search error: "Props Authentication Token not found" 403
<p>I have a pipeline running in GitLab. I want it to do an aql search for Artifactory to collect information about my images.</p> <p>For this I send a POST request to</p> <pre><code>https://{url}/artifactory/api/search/aql </code></pre> <p>with my aql request in the body and this header:</p> <pre><code>headers = {'X-JF...
<python><gitlab-ci><artifactory>
2023-02-08 15:24:28
0
326
Fabian
75,387,921
5,353,753
Remove non numeric rows from dataframe
<p>I have a dataframe of patients and their gene expressions. I has this format:</p> <pre><code>Patient_ID | gene1 | gene2 | ... | gene10000 p1 0.142 0.233 ... bla p2 0.243 0.243 ... -0.364 ... p4000 1.423 bla ... -1.222 </code></pre> <p>As you see, that dataframe...
<python><pandas><dataframe><performance>
2023-02-08 15:20:22
1
40,569
sagi
75,387,904
6,734,243
how to exclude "tests" folder from the wheel of a pyproject.toml managed lib?
<p>I try my best to move from a <code>setup.py</code> managed lib to a pure <code>pyproject.toml</code> one. I have the following folder structure:</p> <pre><code>tests └── &lt;files&gt; docs └── &lt;files&gt; sepal_ui └── &lt;files&gt; pyproject.toml </code></pre> <p>and in my <code>pyproject.toml</code> the following...
<python><setuptools><pyproject.toml>
2023-02-08 15:19:03
4
2,670
Pierrick Rambaud
75,387,825
4,495,790
How to replace column values to most frequent in groups in Pandas?
<p>I have the following Pandas DF like this:</p> <pre><code>ID category ----------- 1 A 1 A 1 B 1 A 2 A 2 A 2 B 2 B 3 B 3 B 3 C 3 A </code></pre> <p>Now I would like to get a version of it where <code>category</code> column values are updated to the most frequent per <code>ID</code>. So the desired output i...
<python><pandas>
2023-02-08 15:13:39
0
459
Fredrik
75,387,809
11,692,124
Python sockets cant connect to the server
<p>I cant connect to the server with client over the internet both on different windows machines. here is the server's side code:</p> <pre><code>import socket def getPublicIP(): import requests response = requests.get(&quot;https://api.ipify.org&quot;) return response.text serverAddressPublic = getPublicIP(...
<python><sockets><server><client>
2023-02-08 15:12:42
0
1,011
Farhang Amaji
75,387,776
3,672,883
unrecognized option attr-defined in mypy
<p>Hello I am using oracledb.NUMBER, etc... and when I execute mypy I got the following error:</p> <pre><code>Module has not attribute &quot;NUMBER&quot; </code></pre> <p>I set into mypy.ini the following options in order to skip that error, but didn't work.</p> <pre><code>[mypy] disable-error-code = attr-defined [myp...
<python><mypy>
2023-02-08 15:10:24
0
5,342
Tlaloc-ES
75,387,765
10,007,302
Trying to rearrange multiple columns in a dataframe based on ranking row values
<p>I'm working on a matching company names and I have a dataframe that returns output in the format below.</p> <p>The table has an original name and for each original name, there could be N number of matches. For each match, there are 3 columns, match_name_0, score_0, match_index_0 and so on up to match_name_N.</p> <p>...
<python><pandas><dataframe>
2023-02-08 15:09:42
1
1,281
novawaly
75,387,685
12,430,026
Files not being included by hatchling when specified in pyproject.toml
<p>I am trying to package my tool with <code>Hatch</code> and want to include some extra files found in <code>/docs</code> in the below directory tree:</p> <pre><code>this_project │ .gitattributes │ .gitignore │ LICENSE │ MANIFEST.in │ pyproject.toml │ README.md │ ├───docs │ default.primers │ └───ribd...
<python><pip><hatch>
2023-02-08 15:03:50
1
1,577
Lamma
75,387,495
10,357,604
How to solve the Import Error of cv2 module
<p>I know that there are many questions and answers regarding this. But I couldn't solve it. I get</p> <blockquote> <p>ImportError: DLL load failed while importing cv2: The specified module could not be found.</p> </blockquote> <p>I have Windows 11, Python 3.9.12</p> <p>opencv-python and opencv-contrib-python 4.6.0.66<...
<python><python-3.x><opencv>
2023-02-08 14:49:55
1
1,355
thestruggleisreal
75,387,407
7,376,511
classmethod with different overloaded signature between instance and base class
<p>I am trying to write a class with an additional constructing method that accepts extra values. These extra values are expensive to compute, and are saved at the end of the program, so <code>.initialize()</code> effectively serves as an injection to avoid recomputing them again at subsequent runs of the program.</p>...
<python><python-typing><mypy><class-method>
2023-02-08 14:42:34
2
797
Some Guy
75,387,344
5,152,424
use the result of YOLOv8 for pyzbar
<p>I want to pass the result from the YOLOv8 to the decode function so that the barcodes are read from it.</p> <p>My program code is:</p> <pre><code>model = YOLO(&quot;yolov8n.pt&quot;) cap = cv2.VideoCapture(0) while True: ret, frame = cap.read() results = model.predict(source=frame, show=True, conf=0.70, str...
<python><opencv><yolo>
2023-02-08 14:37:25
1
533
AS400
75,387,254
6,729,591
Python's dynaconf does not merge multi-file settings correctly
<p>I am using <a href="https://www.dynaconf.com/configuration/" rel="nofollow noreferrer">dynaconf</a> to manage my programs' settings. But i often need to switch between debugging and regular run profile.</p> <p>In <code>default.yaml</code> I have:</p> <pre class="lang-yaml prettyprint-override"><code>SETTINGS: RUN...
<python><python-3.x><configuration>
2023-02-08 14:30:03
1
1,404
Dr. Prof. Patrick
75,386,804
16,389,095
Kivy MD DropDownItem: how to set the item of a dropdownitem into another dropdownitem
<p>I'm trying to developed a simple GUI in Kivy MD / Python. Originally, I modified the <a href="https://github.com/kivymd/KivyMD/wiki/Components-DropDownItem" rel="nofollow noreferrer">example code</a>:</p> <pre><code>from kivy.lang import Builder from kivy.metrics import dp from kivymd.uix.list import OneLineIconList...
<python><drop-down-menu><kivy><kivy-language><kivymd>
2023-02-08 13:55:01
1
421
eljamba
75,386,721
283,538
Sagemaker HyperparameterTuner and fixed hyper parameters (StaticHyperParameters)
<p>I used to use this type of hyper parameter (optimisation) specification:</p> <pre><code> &quot;OutputDataConfig&quot;: {&quot;S3OutputPath&quot;: output_path}, &quot;ResourceConfig&quot;: {&quot;InstanceCount&quot;: 1, &quot;InstanceType&quot;: &quot;ml.m4.xlarge&quot;, &quot;VolumeSizeInGB&quot;: 3}, &quot;...
<python><amazon-sagemaker><amazon-sagemaker-studio>
2023-02-08 13:46:43
1
17,568
cs0815
75,386,643
315,168
multiprocessing.Manager() hangs Popen.communicate() on Python
<p>The use of <code>multiprocessing.Manager</code> prevents clean termination of Python child process using <code>subprocess.Process.Popen.terminate()</code> and <code>subprocess.Process.Popen.kill()</code>.</p> <p>This seems to be because <code>Manager</code> creates a child process behind the scenes for communicating...
<python><python-multiprocessing>
2023-02-08 13:40:29
1
84,872
Mikko Ohtamaa
75,386,552
4,267,439
python logging in AWS Fargate, datetime duplicated
<p>I'm trying to use python logging module in AWS Fargate. The same application should work also locally, so I'd like to use a custom logger for local use but to keep intact cloudwatch logs. This is what I'm doing:</p> <pre><code>if logging.getLogger().hasHandlers(): log = logging.getLogger() log.setLevel(loggi...
<python><amazon-ecs><aws-fargate><amazon-cloudwatchlogs><python-logging>
2023-02-08 13:33:04
2
2,825
rok
75,386,541
13,609,298
Panel ordered logit in Python
<p>I am looking to run a panel ordered logit model on Python. I am aware that this question has already been asked <a href="https://stackoverflow.com/questions/28035216/ordered-logit-in-python">here</a>, however, this is not for panel data. What I am looking for is something equivalent to the &quot;<a href="https://cra...
<python><logistic-regression><glm><panel-data>
2023-02-08 13:32:26
0
311
Carl
75,386,477
4,296,426
Enable web access or interactive shell for PipelineJob tasks for Vertex AI
<p>I am trying to debug a <code>PipelineJob</code> that I launch on Vertex AI. Is there a way to <a href="https://cloud.google.com/vertex-ai/docs/reference/rest/v1/CustomJobSpec" rel="nofollow noreferrer">enable web access</a> on the components like you can when you launch Custom Jobs? This way, I could ssh into the ru...
<python><google-cloud-vertex-ai><kfp>
2023-02-08 13:27:32
1
1,682
Optimus
75,386,359
12,416,164
Athena AWS python client get query size
<p>Is there any way to get the query size using the <code>query_execution_id</code> without downloading the csv file?. Using the <a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/athena.html" rel="nofollow noreferrer">boto3</a> client.</p>
<python><amazon-web-services><amazon-athena>
2023-02-08 13:16:01
0
682
Andrex
75,386,342
4,225,972
django channels with redis in WSL2
<p>I have a redis installation running inside the windows subsystem for linux. It is working finde, but I cannot connect to it from django-channels. In my WSL I started redis and when using a normal terminal and python in Windows I can do for example:</p> <pre><code>import redis c = redis.Redis(&quot;localhost&quot;, 6...
<python><django><django-channels>
2023-02-08 13:14:24
1
1,400
xtlc
75,386,327
3,459,293
Transform rows categories to column while preserving rest of the data frame python
<p>I have data frame as below</p> <pre><code> Time Groups Entity GC Seg Category Year Quarter IndicatorName Value 0 2021-06-01 KRO CO P_GA None Model_Q2_2021 2021 2 yhat 568759.481223 1 2021-07-01 KRO CO P_GA None Model_Q2_2021 2021 3 yhat 586003....
<python><pandas><data-wrangling>
2023-02-08 13:13:34
2
340
user3459293
75,386,255
784,433
using jax.vmap to vectorize along with broadcasting
<p>Consider the following toy example:</p> <pre><code>x = np.arange(3) # np.sum(np.sin(x - x[:, np.newaxis]), axis=1) cfun = lambda x: np.sum(np.sin(x - x[:, np.newaxis]), axis=1) cfuns = jax.vmap(cfun) # for a 2d x: x = np.arange(6).reshape(3,2) cfuns(x) </code></pre> <p>where <code>x-x[:,None]</code> is the broadca...
<python><jax>
2023-02-08 13:06:52
1
1,237
Abolfazl
75,386,166
17,897,456
Why does `discord.utils.sleep_until` sleeps forever?
<p>I have defined a periodic task in a Cog that does something every 60 seconds. I want that task to start at the very beginning of a minute, so I added a <code>before_loop</code> decorator to it.</p> <pre class="lang-py prettyprint-override"><code>import discord from discord.ext import commands from discord.ext import...
<python><datetime><discord.py><sleep>
2023-02-08 12:58:57
0
710
Mateo Vial
75,386,165
5,777,827
Building one file eel python aplication with pyinstaller
<p>After building distributable binary with PyInstaller</p> <pre><code>python.exe -m eel --onefile c:\Users\Darek\PycharmProjects\eelTest\web\ c:\Users\Darek\PycharmProjects\eelTest\eelTest.py </code></pre> <p>When I try run app I got this error</p> <pre><code>Failed to extract C:\Users\Darek\PycharmProjects\eelTest\...
<python><pyinstaller><eel>
2023-02-08 12:58:53
0
375
ssnake
75,386,117
7,800,760
Python: json.dumps with ensure_ascii=False and encoding('utf-8') seems to convert string to bytes
<p>I am generating a Python dictionary as follows:</p> <pre><code>placedict = { &quot;id&quot;: geonames.geonames_id, &quot;info&quot;: json.dumps(jsoninfo), } </code></pre> <p>where id is a string and info a valid and readable JSON string:</p> <pre><code>'{&quot;geonamesurl&quot;: &quot;http://geonames.org/31085...
<python><json><mongodb><utf-8>
2023-02-08 12:54:37
1
1,231
Robert Alexander
75,386,096
10,982,755
What is the best way to build a Document Management System in python using GCS or AWS S3?
<p>I'm building a tool where users in a particular account/tenant can upload images/videos (CREATE/DELETE) and also create/delete folders to organize those images. These images/videos can later be dragged and dropped onto a page. This page will be accessible to everyone in that account. So I have thought of 2 architect...
<python><amazon-s3><architecture><google-cloud-storage><system-design>
2023-02-08 12:53:19
1
617
Vaibhav
75,385,976
12,814,680
Search values in dataframe by condition on another column
<p>I need to get the value in column A for the closest value in column B for each multiple of 'trigger'</p> <p>for instance, in the dataframe below :</p> <pre><code>import random trigger = 100 info2 = {'A': [0]*100,'B': [0]*100} dfA = pd.DataFrame(info2) for i in range(1, len(dfA)): dfA.loc[i,'B'] = i*3.78 ...
<python><pandas><dataframe>
2023-02-08 12:43:52
4
499
JK2018
75,385,850
2,558,671
Sort list of dictionaries based on the order given by another list
<p>There are a lot of <a href="https://www.google.com/search?q=python%20sort%20list%20of%20dicts%20based%20on%20another%20list%20site:stackoverflow.com" rel="nofollow noreferrer">similar questions</a> on Stack Overflow but not exactly this one.</p> <p>I need to sort a list of dictionaries based on the values of another...
<python><sorting>
2023-02-08 12:33:22
1
1,503
Marco
75,385,554
4,358,785
Python set ONNX runtime to return tensor instead of numpy array
<p>In python I'm loading my predefined model (super-gradients, yolox-s):</p> <pre><code>onnx_session = onnxrt.InferenceSession(&quot;yolox_s_640_640.onnx&quot;) </code></pre> <p>Then I load some data and run it:</p> <pre><code>dataset = MyCostumeDataset(args.path, 'val') val_dataloader = DataLoader(dataset, batch_size=...
<python><pytorch><onnx><onnxruntime>
2023-02-08 12:03:54
1
971
Ruslan
75,385,512
872,616
How to use a Python generator function in tkinter?
<p>Generator functions promise to make some code easier to write. But I don't always understand how to use them.</p> <p>Let's say I have a Fibonacci generator function <code>fib()</code>, and I want a <code>tkinter</code> application that displays the first result. When I click on a button &quot;Next&quot; it displays ...
<python><tkinter>
2023-02-08 12:00:34
2
5,507
Andreas Haferburg
75,385,497
14,625,546
InvalidArgumentError: slice index 1 of dimension 2 out of bounds when training GRU RNN
<p>I'm a newbie in the world of recurrent neural networks and I am trying to follow a <a href="https://www.tensorflow.org/tutorials/structured_data/time_series" rel="nofollow noreferrer">TensorFlow tutorial</a>. This tutorial makes forecasting on weather time series data, and trains a LSTM model for it also. I want to ...
<python><tensorflow><keras><recurrent-neural-network>
2023-02-08 11:59:24
0
321
Zoltán Orosz
75,385,262
1,017,373
How to add a new column in pandas Dataframe if the string or object value of column 1 is repeated in three consecutive rows
<p>Say, I have a dataframe like this,</p> <pre><code>import pandas as pd df = pd.DataFrame({'ID': ['p1305', 'p1305', 'p1305', 'p1307', 'p1307', 'p1307', 'p1301', 'p1301', 'p1301', 'p1340', 'p1340', 'p1340','P569','P987','P569']}) </code></pre> <p>I need to add a column y if the values in ID are the same for three conse...
<python><pandas><dataframe>
2023-02-08 11:39:45
1
2,100
ARJ
75,385,179
15,239,717
Django Create Model Instance from an Object
<p>I am working on a Django Daily Saving App where Staff User can create Customer Account, and from the list of the Customer Accounts there is link for Deposit where staff user can add customer deposit. The issue is that after getting the customer id to the customer deposit view, I want to create get the customer detai...
<python><django>
2023-02-08 11:32:15
1
323
apollos
75,384,989
1,283,776
Can I avoid getting pylint errors from not having __init__.py without disabling rules?
<p>This is my project</p> <pre class="lang-none prettyprint-override"><code>root ├── main.py └── utils └── tool.py </code></pre> <p>This is my main</p> <pre><code>from utils.tool import some_func </code></pre> <p>It works but I'm getting <code>Pylint(E0611:no-name-in-module)</code>. I'm pretty new to Python so I do...
<python><python-import><pylint>
2023-02-08 11:16:50
0
22,194
user1283776
75,384,958
5,305,512
Prophet fit RuntimeError: Error during optimization
<p>This is how my dataframe looks like:</p> <p><a href="https://i.sstatic.net/TP28d.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TP28d.png" alt="enter image description here" /></a></p> <p>Then when I try to fit a prophet model, I get this error:</p> <pre><code>&gt;&gt;&gt; from prophet import Prophet...
<python><time-series><facebook-prophet>
2023-02-08 11:13:27
1
3,764
Kristada673
75,384,957
3,381,215
Current Python version (3.9.7) is not allowed by the project (^3.11)
<p>We have a poetry project with a pyproject.toml file like this:</p> <pre class="lang-ini prettyprint-override"><code>[tool.poetry] name = &quot;daisy&quot; version = &quot;0.0.2&quot; description = &quot;&quot; authors = [&quot;&quot;] [tool.poetry.dependencies] python = &quot;^3.9&quot; pandas = &quot;^1.5.2&quot; ...
<python><python-poetry>
2023-02-08 11:13:14
2
1,199
Freek
75,384,939
939,451
Loading custom MapBox GL JS tile source generated with Python tornado async RequestHandler
<p>I created custom tile source provider with python running tornado web server. On the server I generate on the fly the specific tile and output it as a &quot;image/png&quot; header format. To prevent blocking I did all the server stuff in async mode. Now I see that I get some errors on the server: &quot;Task was dest...
<python><tornado><mapbox-gl-js><requesthandler>
2023-02-08 11:12:02
0
361
toni
75,384,751
353,337
Use --config-setting in tox
<p>In <a href="https://github.com/tox-dev/tox" rel="nofollow noreferrer">tox</a>, I'd like to build my package with a certain <a href="https://github.com/pypa/build" rel="nofollow noreferrer">pypa-build</a> <a href="https://pypa-build.readthedocs.io/en/stable/#python--m-build---config-setting" rel="nofollow noreferrer"...
<python><tox>
2023-02-08 10:55:31
0
59,565
Nico Schlömer
75,384,689
6,535,324
How apply optimization flag for run but not debug for default configurations?
<p>I would like to modify the default run (not debug) behavior in Pycharm to include the <code>-O</code> flag, as indicated in this <a href="https://stackoverflow.com/a/75384534/6251742">answer</a>.</p> <p>The information in this <a href="https://stackoverflow.com/questions/36211994/pycharm-add-o-flag-to-configuration"...
<python><pycharm>
2023-02-08 10:49:18
1
2,544
safex
75,384,665
10,568,883
How to remove dotted box around focused item in QTableView in PyQt5
<p>I am writing a simple PyQt5 app, which uses <code>QTableView</code> widget. What I want to do is to remove the dotted box around the focused item in <code>QTableView</code>. For minimal working example I use this code:</p> <pre class="lang-py prettyprint-override"><code>import sys from PyQt5 import QtCore, QtGui, Q...
<python><qt><pyqt><pyqt5><qt5>
2023-02-08 10:48:01
0
499
Евгений Крамаров
75,384,590
18,321,042
Why can't my Gitlab pipeline find python packages installed in Dockerfile?
<p>My file structure is as follows:</p> <ul> <li><code>Dockerfile</code></li> <li><code>.gitlab-ci.yml</code></li> </ul> <p>Here is my <code>Dockerfile</code>:</p> <pre><code>FROM python:3 RUN apt-get update &amp;&amp; apt-get install make RUN apt-get install -y python3-pip RUN pip3 install --upgrade pip RUN pip3 inst...
<python><docker><gitlab>
2023-02-08 10:41:18
0
575
Liam
75,384,531
2,751,394
How can I check that my application is shutdown with QFTest?
<p>I check a Java application with <strong>QFTest</strong>. I need to prove that the HMI is stopped at Shutdown. In <strong>QFTest</strong>, I created a <strong>Jython</strong> procédure which try to send a socket to the HMI, if it can't, then it means that the HMI is stopped and then the test is OK. here is the <stron...
<python><java><jython><javaagents><qf-test>
2023-02-08 10:37:01
1
601
Skartt
75,384,503
12,913,047
Arranging data for Heatmap Visualization with Seaborn
<p>I am trying to create a heatmap, with the y Axis with the Criteria Column, as seen below, and the x, with all the other columns (Robustness, Stability, etc.) However, most of the tutorials I come across just use 1 column, i.e., the common flights example with prices and years. I basically just want there to be 1 col...
<python><numpy><seaborn>
2023-02-08 10:34:36
0
506
JamesArthur
75,384,464
6,535,324
Unexpected PyCharm run vs debug behavior for __debug__
<p>I have the following python code:</p> <pre class="lang-py prettyprint-override"><code>def main(): if __debug__: print(&quot;debug mode&quot;) else: print(&quot;non debug&quot;) if __name__ == '__main__': main() </code></pre> <p>No matter whether I run the file or debug it, it always pri...
<python><pycharm>
2023-02-08 10:31:50
1
2,544
safex
75,384,141
1,901,071
Python Polars find the length of a string in a dataframe
<p>I am trying to count the number of letters in a string in Polars. I could probably just use an apply method and get the <code>len(Name)</code>. However, I was wondering if there is a polars specific method?</p> <pre class="lang-py prettyprint-override"><code>import polars as pl df = pl.DataFrame({ &quot;start_d...
<python><string><dataframe><python-polars>
2023-02-08 10:04:19
1
2,946
John Smith
75,384,124
9,099,959
How to initialize named tuple in python enum
<p>I have a Enum which is used as a column datatype in SqlALchemy. But I need more properties of the Enum to make it accessible for the code's other functionality.</p> <p>This is what I have created till now:</p> <pre><code>class ServerHealth(Enum): &quot;&quot;&quot;Status of Server health.&quot;&quot;&quot; Heal...
<python><python-3.x><sqlalchemy><enums>
2023-02-08 10:03:17
1
1,406
Akash Kumar
75,384,112
19,369,310
Retrieve last row of data with conditions
<p>I have the following large dataset recording the result of a math competition among students in descending order of date: So for example, student 1 comes third in Race 1 while student 3 won Race 2, etc.</p> <pre><code>Race_ID Date Student_ID Rank 21 1/1/2023 1 3 21...
<python><python-3.x><pandas><dataframe>
2023-02-08 10:02:31
2
449
Apook
75,383,917
7,800,760
How to use Poetry to install MongoDB database
<p>I am writing my first python script which would use the pymongo library to persist data into a MongoDB NOSQL database. This script is running within a Poetry managed virtual environment and therefore pyproject.toml declares the following dependencies:</p> <pre><code>[tool.poetry.dependencies] python = &quot;^3.10&qu...
<python><mongodb><pymongo><python-poetry>
2023-02-08 09:47:26
1
1,231
Robert Alexander
75,383,908
12,814,680
dataframe apply lambda function that requires value from row n+1
<p>I have a dataframe and geopy to calculate distances between two geo coordinates as follows :</p> <pre><code>import geopy.distance distCalcExample = geopy.distance.geodesic((49.18443, -0.36098), (49.184335, -0.361185)).m r = {'poly':[(49.419453, 0.232884),(49.41956, 0.23269),(49.41956, 0.23261),(49.41953, 0.23255),...
<python><pandas><dataframe>
2023-02-08 09:46:35
1
499
JK2018
75,383,879
1,432,980
get certain keys from the dictionary and spread remaining into another dictionary
<p>I have a dictionary that looks like this</p> <pre><code>{ &quot;name&quot;: &quot;id&quot;, &quot;data_type&quot;: &quot;int&quot;, &quot;min_value&quot;: &quot;10&quot;, &quot;max_value&quot;: &quot;110&quot; } </code></pre> <p>I want to convert it into a tuple where the first two parameters are val...
<python><dictionary>
2023-02-08 09:44:43
1
13,485
lapots
75,383,858
2,164,904
Regex to replace between second occurance of symbol A and symbol B
<p>I have an example string to match:</p> <p><code>s = 'https://john:ABCDE@api.example.com'</code></p> <p>I am trying to replace the string <code>ABCDE</code> between the 2nd colon and the first occurrance of <code>@</code>. So my desired output is:</p> <p><code>s_out = 'https://john:REPLACED@api.example.com'</code></p...
<python><regex><python-re>
2023-02-08 09:42:41
1
1,385
John Tan
75,383,742
31,130
What is the type of a Logger function like Logger.info?
<p>How do I type annotate a Logger function like Logger.info? Using reveal_type returns this:</p> <pre><code>Revealed type is &quot;def (msg: builtins.object, *args: builtins.object, *, exc_info: Union[None, builtins.bool, Tuple[Type[builtins.BaseException], builtins.BaseException, Union[types.TracebackType, None]], Tu...
<python><type-hinting><mypy>
2023-02-08 09:34:31
1
2,263
nagul
75,383,700
14,494,483
Streamlit dynamic UI to generate dynamic input widgets depending on value from a different input widget
<p>I want to open this post as I can't find anything on the official documentation from streamlit or any resources that mentioned how to do this. After some trial and error I have figured out a way, and will post the answer below. This is a function that in R shiny is called dynamic UI, here's the question.</p> <p>How ...
<python><streamlit><variable-variables><dynamic-ui>
2023-02-08 09:31:37
2
474
Subaru Spirit
75,383,587
2,119,336
how to manage scrollbar with not visible items in PySimpleGUI
<p>i have developed a PySimpleGUI application and i must show a list of items depending from the number of rows readed from a file. I know that is not possible to create components dinamically in PySimpleGUI, so i've defined a max number of components and set they as not visible until the file is readed.</p> <p>After t...
<python><layout><scrollbar><pysimplegui>
2023-02-08 09:22:10
1
778
Tirrel
75,383,559
10,967,961
Colors problem in plotting figure with matplotlib in python
<p>I am trying to plot a bipartite graph to highlight the differences between two rankings. I am doing so by connecting the city in the left list to the same city on the right list with a colored arrow. The color should be proportional to the difference in rankings.</p> <p>Here is a MWE:</p> <pre><code>import matplotli...
<python><matplotlib><networkx>
2023-02-08 09:20:17
1
653
Lusian
75,383,459
12,814,680
Set values in dataframe A by iterating from values on dataframe B
<p>Dataframe A is similar to this :</p> <pre><code>info2 = {'speed': [None]*80} dfA = pd.DataFrame(info2) dfA </code></pre> <p><a href="https://i.sstatic.net/qZAwr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qZAwr.png" alt="enter image description here" /></a></p> <p>Dataframe B is similar to this :...
<python><pandas><dataframe>
2023-02-08 09:11:03
2
499
JK2018
75,383,260
20,740,043
Export dataset haveing more than 1048576 rows, in multiple sheets of single excel file, in Python
<p>I have a dataset given as such:</p> <pre><code>import numpy as np import pandas as pd ## Create an array data = np.arange(7152123) print(data) ## Dataframe df = pd.DataFrame(data) print(&quot;\n an df = \n&quot;, df) ## Load the data in excel sheet df.to_excel('df.xlsx', index=False,header=False) </code>...
<python><python-3.x><excel><pandas><dataframe>
2023-02-08 08:49:30
3
439
NN_Developer
75,383,244
9,418,052
Navigation Timeout Exceeded: 30000 ms exceeded while using Nbconvert
<p>I am using the following command : <strong>jupyter nbconvert --to webpdf --allow-chromium-download PNM.ipynb</strong>, to convert Jupiter notebook to a pdf file.</p> <p>However, there is a timeout error. According to the documentation: &quot;The timeout option can also be set to None or -1 to remove any restriction...
<python><nbconvert>
2023-02-08 08:48:06
1
404
Ankit Tripathi
75,383,045
2,919,052
Emit python list in Signal to Qml ui
<p>I am trying to communicate a python script to a qml ui using signal/slot and, while it works for some types (str) it seems to not be working when I try emitting a list:</p> <p><strong>Python:</strong></p> <pre><code>from PySide6.QtCore import QObject, Signal, Slot from PySide6.QtGui import QGuiApplication from PySid...
<python><qml><pyside6>
2023-02-08 08:28:38
1
5,778
codeKiller
75,383,010
1,619,432
Python D-Bus: Subscribe to signal and read property with dasbus
<p>How to monitor and read Ubuntu's &quot;Night Light&quot; status via D-Bus using Python with <a href="https://dasbus.readthedocs.io/en/latest/" rel="nofollow noreferrer">dasbus</a>? I can't figure out the API docs on how to read a property or subscribe to a signal.<br /> Likely candidates:</p> <ul> <li><a href="https...
<python><linux><dbus>
2023-02-08 08:25:25
1
6,500
handle
75,382,794
10,062,025
Why is request returning must provide query string when scraped?
<p>I am trying to scrape <a href="https://www.sayurbox.com/category/vegetables-1-a0d03d59?selectedCategoryType=ops&amp;touch_point=screen_CATEGORY_sembako-1-e6a33b51&amp;section_source=shop_list_slider_navigation_category_vegetables-1-a0d03d59" rel="nofollow noreferrer">https://www.sayurbox.com/category/vegetables-1-a0...
<python><web-scraping><python-requests>
2023-02-08 08:00:10
2
333
Hal
75,382,768
1,367,705
Python with -c flag, input from user and if/else inside - shows syntax error
<p>I need a simple one-liner in Python: ask user for choice and then print a message depending on what user chose. Here's my attempt:</p> <p><code>python3 -c &quot;ans=input('Y/N?'); if ans == 'Y': print('YES') else: print('NO');&quot;</code></p> <p>And errors of course:</p> <pre><code> File &quot;&lt;string&gt;&quot;...
<python>
2023-02-08 07:57:09
3
2,620
mazix
75,382,639
12,478,660
Join and get queryset accordring to many to many field
<p>I have MyUser model with ForeignKey and ManyToMany related fields city and skills:</p> <pre><code>class MyUser(AbstractBaseUser): email = models.EmailField() skills = models.ManyToManyField('jobs.Skill') class Skill(models.Model): name = models.CharField() </code></pre> <p>suppose this my table data in...
<python><django><django-models><django-views><django-queryset>
2023-02-08 07:41:27
2
618
ShiBil PK
75,382,340
19,950,360
python pandas read_excel error "Value must be either numerical or a string containing a wild card"
<p>I dont know why this error occurs.</p> <pre><code>pd.read_excel('data/A.xlsx', usecols=[&quot;B&quot;, &quot;C&quot;]) </code></pre> <p>Then I get this error:</p> <pre><code>&quot;Value must be either numerical or a string containing a wild card&quot; </code></pre> <p>So i change my code use nrows all data</p> <pre>...
<python><excel><pandas>
2023-02-08 07:02:00
4
315
lima