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,375,058
12,436,050
Replace substring with multiple words in python3
<p>I am trying to replace a word in a string with multilple words and produce all the strings as an output.</p> <p>For example 'disease' in 'lysosome storage disease' should be replaced by 'disease' , 'diseases', 'disorder', 'disorders','syndrome','syndromes' and produce following output.</p> <pre><code>lysosome storag...
<python><python-3.x><replace>
2023-02-07 14:51:52
2
1,495
rshar
75,375,036
11,710,304
What is the alternative for iterrows in polars python?
<p>I want to detect rows with null values when they are mandatory. The column <code>mandatory</code> gives information about this. If the value <code>&quot;M&quot;</code> occurs, the row is mandatory. If this is the case, this row should be checked for null values. If there is at least one null value, this row should b...
<python><python-polars>
2023-02-07 14:49:57
1
437
Horseman
75,375,013
15,913,281
Calculate Mean By Two Columns in Dataframe
<p>Given the df extract below, how can I calculate the mean Prob per SelectionId per MarketId?</p> <p>I thought this would work but it doesn't:</p> <pre><code>df.groupby(['MarketId', 'SelectionId', ], as_index=False)['Prob'].mean() </code></pre> <p>Example df:-</p> <div class="s-table-container"> <table class="s-table"...
<python><pandas>
2023-02-07 14:48:01
1
471
Robsmith
75,374,936
14,606,987
Why are elements missing when calling `validation_step` in Pytorch Lightning?
<p>I have a dataset with 20 rows and I set</p> <pre class="lang-py prettyprint-override"><code>eval_batch_size=10 num_train_epochs=1 </code></pre> <p>Thats my validation_step</p> <pre class="lang-py prettyprint-override"><code>def validation_step(self, batch, batch_idx): print(len(batch[elements])) </code></pre> <p...
<python><pytorch-lightning>
2023-02-07 14:43:01
0
868
yemy
75,374,930
11,192,771
Most resource-efficient way to calculate distance between coordinates
<p>I am trying to find all observations that are located within 100 meters of a set of coordinates.</p> <p>I have two dataframes, Dataframe1 has 400 rows with coordinates, and for each row, I need to find all the observations from Dataframe2 that are located within 100 meters of that location, and count them. Ideally,<...
<python><pandas>
2023-02-07 14:42:37
2
425
TvCasteren
75,374,768
11,197,301
How to select in a numpy array all paris with a defined index difference?
<p>Let's say that I have this numpy array:</p> <pre><code>import numpy as np np.random.seed(0) data = np.random.normal(size=(5,5)) </code></pre> <p>which result in:</p> <p><a href="https://i.sstatic.net/CdCHF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CdCHF.png" alt="enter image description here" />...
<python><numpy><select><indexing>
2023-02-07 14:31:45
2
623
diedro
75,374,748
12,350,966
remove semicolon from end of string
<p>I want to remove semicolon from the end of a string in python:</p> <pre><code>mystring = 'NM_000106.5:c.985+39G&gt;A;c.886C&gt;T;c.1457G&gt;C;' </code></pre> <p>I tried something like this:</p> <pre><code>clean_end = mystring[:-1] if mystring.endswith(';') else mystring </code></pre> <p>However in this case, <code>...
<python>
2023-02-07 14:30:41
2
740
curious
75,374,667
1,007,566
Type hints when returning dynamically mixed generic types in Python
<p>I am writing a function that takes a tuple with an undetermined number of objects of the same class, but with varying generic types. The return values of this function will be a same-sized tuple with items of the specified types.</p> <p>How can I rewrite the <code>process</code> function below to make this work? Thi...
<python><generics><types>
2023-02-07 14:22:30
0
685
Wietse de Vries
75,374,582
10,270,590
How to use a python list as global variable pandas data frame with in @task.external_python?
<h2>Goal</h2> <ul> <li>I use the Docker 2.4.1 version of Airflow</li> <li>I use my external python virtual environment for each task</li> <li>I have a pandas data frame that I want to pass on from task to task.</li> <li>I my previosue question <a href="https://stackoverflow.com/questions/75361423/how-to-use-a-python-li...
<python><python-3.x><pandas><airflow><directed-acyclic-graphs>
2023-02-07 14:15:41
1
3,146
sogu
75,374,370
32,854
FastAPI python app error on Azure App Service
<p>I have a python web application that is using FastAPI. It works locally, but when I deploy it to a free linux Azure App Service (using GitHub Actions) and try to load the site it says &quot;Internal Server Error&quot;. When I pull up the application logs I see the following error message</p> <pre><code>2023-02-06T23...
<python><azure-web-app-service><github-actions><fastapi>
2023-02-07 13:56:41
1
4,788
Austin
75,374,337
4,244,609
Pybullet: limit joint torque in POSITION_COONTROL mode
<p>I'm working with a robot in Pybullet in POSITION_COONTROL mode (torque control is not convinient in my specific case). I would like to limit torque scalar on each joint. How can I achieve it without switching to torque control mode?</p>
<python><simulator><robotics><pybullet>
2023-02-07 13:54:50
1
1,483
Ivan Sudos
75,374,140
7,932,273
How to send followup message in Slack App using slack_bolt?
<p>I am building a bot that will answer a question asked in a slack App.</p> <p>I want to configure a followup question</p> <p><em>Note: Yes and No are radio buttons</em></p> <p>eg.</p> <pre><code>User: What is the event date? Bot: 22nd Feb, 2023 (after the answer bot will trigger followup question with radio buttons) ...
<python><chatbot><slack><slack-api><slack-bolt>
2023-02-07 13:36:44
1
13,436
Sociopath
75,374,097
1,143,558
Django (v4) request.META['REMOTE_ADDR'] not working anymore?
<p>I had been using for years (Django 1.9 &amp; Python 2.7) <code>request.META</code> dictionary and <code>['REMOTE_ADDR']</code> header to get client's IP address. I have recently moved to Django 4.1.5 and found out that my code is not able anymore to get client's IP address, so I had to use:</p> <pre><code>x_forwarde...
<python><django>
2023-02-07 13:33:55
1
842
Ljubisa Livac
75,374,063
14,359,801
Regression : how to handle multiple multivariate timeseries?
<p>I am trying to develop a model using machine learning that reproduces a biological behavior. My goal is to do a regression of timeseries e.g from multiple input each time_step predict multiple output and <strong>not forcasting</strong>.</p> <p>For this, I have :</p> <ul> <li>as input: N [640*30] (time_steps * featur...
<python><machine-learning><time-series><regression><multivariate-time-series>
2023-02-07 13:29:14
1
308
Ketchup
75,373,935
7,660,819
faster nested for loops for all pair of rows in a numpy array
<p>I have a numpy array, which is basically phase of oscillations recorded for 256 channels sampled at 1000 Hz for an hour. As a result, I have got a numpy array size of <code>256 x 5000000</code>. I want to calculate <code>Phase locking value</code> for all pair of channels (rows). Phase locking value is a measure of ...
<python><numpy><for-loop><signal-processing>
2023-02-07 13:18:38
1
305
deathracer
75,373,907
4,509,378
Retrieve data from multiple different Azure Tables asynchronously with Azure Tables client library
<p>Is it possible with the <a href="https://learn.microsoft.com/en-us/python/api/overview/azure/data-tables-readme?view=azure-python" rel="nofollow noreferrer">Azure Tables client library for Python</a> to retrieve data from multiple tables asynchronously? Let's say I have table A and B in different storage accounts, i...
<python><azure><asynchronous><python-asyncio><azure-table-storage>
2023-02-07 13:15:59
1
749
Peter Lawrence
75,373,444
7,376,511
Mypy: using TypedDict as both kwargs for __init__ and as annotations for the class itself
<p>I am trying to have a class with dynamic properties that are pre-written inside a TypedDict, that is then passed as kwargs. Perhaps this is impossible to properly type with mypy, however I was thinking that I might be following the wrong approach. This is my attempt so far:</p> <pre><code>from typing import NotRequi...
<python><python-typing><mypy>
2023-02-07 12:34:19
0
797
Some Guy
75,373,381
11,705,021
How I can compare two folders with multi-volume .7Z archive files, and get the output files/folders where the difference is more than 1GB
<p>I have 2 paths where each one them has multi-volume .7Z archive files.</p> <p>Path A contains 4 files: <code>example1.7z.001, example1.7z.002, example1.7z.003, example1.7z.004</code> (Total size of all is 15 GB). Once you extract you get one 7z file of 20GB, and once your extract that one, you get folder of 40 GB. I...
<python><python-3.x><7zip><python-magic><py7zr>
2023-02-07 12:29:11
0
1,428
arielma
75,373,325
6,268,900
Reduce the Loop processing time in panda
<p>Concept : Count number of transition between two time and add the count as column in data frame. The Start time and End is first two Column in the data frame</p> <p>Sample date</p> <pre><code> Time_Completed Time_of_Fetch Base Number of event 03-06-2022 14:56 03-06-2022 14:14 Q112 12 ...
<python><pandas><dataframe><lambda><apply>
2023-02-07 12:24:55
1
354
Praveen DA
75,373,164
75,103
Is there something like python setup.py --version for pyproject.toml?
<p>With a simple <code>setup.py</code> file:</p> <pre><code>from setuptools import setup setup( name='foo', version='1.2.3', ) </code></pre> <p>I can do</p> <pre><code>$&gt; python setup.py --version 1.2.3 </code></pre> <p>without installing the package.</p> <p>Is there similar functionality for the equivalent ...
<python><pyproject.toml>
2023-02-07 12:10:42
1
27,572
thebjorn
75,373,139
14,606,987
Why is Pytorch Lightning `validation_step` executed more oftener than defined in `val_check_interval`?
<p>I have a dataset with 20 rows and want to have four times a <a href="https://pytorch-lightning.readthedocs.io/en/stable/common/trainer.html#:%7E:text=trainer%20%3D%20trainer(val_check_interval%3D0.25)" rel="nofollow noreferrer">Pytorch Lightning</a> <code>validation_step</code> called on this dataset. I am setting m...
<python><pytorch-lightning>
2023-02-07 12:09:00
1
868
yemy
75,373,084
14,790,056
groupby and drop groups if the sender is not in the list of receiver list in pandas
<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-07 12:03:24
2
654
Olive
75,373,069
9,861,647
Formatting issues with Python amd GSpread
<p>I have this panda Data Frame (DF1).</p> <pre><code>DF1= DF1.groupby(['Name', 'Type', 'Metric']) DF1= DF1.first() </code></pre> <p>If I output to df1.to_excel(&quot;output.xlsx&quot;). The format is correct see bellow :</p> <p><a href="https://i.sstatic.net/8xhh8.png" rel="nofollow noreferrer"><img src="https://i.sst...
<python><pandas><google-sheets><google-sheets-api><gspread>
2023-02-07 12:01:34
1
1,065
Simon GIS
75,373,002
163,573
Mocking pyodbc without unixODBC installed
<p>My python app uses pyodbc to connect to the database. I would like to mock the database in my tests.</p> <p>When running tests on the build server <code>import pyodbc</code> throws <code>ImportError: libodbc.so.2: cannot open shared object file: No such file or directory</code> because unixODBC is not installed.</p>...
<python><mocking><pyodbc><python-unittest>
2023-02-07 11:55:13
1
6,869
rickythefox
75,372,901
13,566,716
how to get unique pairs of items present in the same id with SQL
<p><strong>The initial table is like below:</strong></p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>session_id</th> <th>item</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>t-shirt</td> </tr> <tr> <td>1</td> <td>trousers</td> </tr> <tr> <td>1</td> <td>hat</td> </tr> <tr> <td>2</td> <td>bel...
<python><sql><python-3.x><sqlalchemy>
2023-02-07 11:45:04
1
369
3awny
75,372,835
3,249,000
Poetry add dependency that uses cython
<p>I have a project which needs to depend on the latest commit of <a href="https://github.com/pysam-developers/pysam" rel="nofollow noreferrer">pysam</a>, because I'm working in python 3.11.</p> <p>This means building the package from source, so I do the following:</p> <p><code>poetry add git+https://github.com/pysam-d...
<python><cython><python-packaging><python-poetry>
2023-02-07 11:38:57
1
2,182
Theolodus
75,372,764
6,871,867
Automate login to a website through Gmail using python selenium
<p>I am trying to automate login to <a href="https://secure.indeed.com/auth?hl=en_US&amp;co=US&amp;continue=https%3A%2F%2Fwww.indeed.com%2F&amp;tmpl=desktop&amp;service=my&amp;from=gnav-util-homepage&amp;jsContinue=https%3A%2F%2Fwww.indeed.com%2F&amp;empContinue=https%3A%2F%2Faccount.indeed.com%2Fmyaccess&amp;_ga=2.361...
<python><selenium><selenium-webdriver>
2023-02-07 11:31:36
1
462
Gopal Chitalia
75,372,758
6,068,731
Matplotlib fill area between contour lines where one contour line is made of two disjoint curves
<p>I have a function <code>f</code> and I would like to color-fill between two contours. One contour is shown in blue in the figure on the left. The contour consists in two <strong>disjoint</strong> curves. Another contour is shown in green in the middle figure, and consists in a single curve. Both contours are shown t...
<python><numpy><matplotlib>
2023-02-07 11:31:08
1
728
Physics_Student
75,372,522
16,622,985
Stateful DoFn with Side Input - DirectRunner issue?
<p>I have a stateful DoFn with a <code>beam.pvalue.AsSingleton</code> side input. When I was trying to write a test for this DoFn, I've noticed a strange behavior: Sometimes the execution fails with an <code>ValueError</code> stating that the stateful DoFn requires a key-value pair as input, i.e.</p> <pre><code>Traceba...
<python><google-cloud-dataflow><apache-beam>
2023-02-07 11:10:39
1
1,176
CaptainNabla
75,372,344
15,488,129
list of dictionaries to pd dataframe with a single row
<p>I have a list of dictionaries and I'm trying to create a pd.DataFrame with a single row where the key of the dictionary is a column and the value of the dictionary is its row.</p> <p>Here is a sample:</p> <pre><code>list_of_dicts = [{'key1': 'value1'}, {'key2':'value2'}] </code></pre> <p>Output DataFrame should look...
<python><pandas><dictionary>
2023-02-07 10:52:54
3
321
Girolamo
75,372,319
12,206,537
How to solve "ImportError: DLL load failed while importing `something`: The filename or extension is too long." while pip installing in a long path
<p>When I am trying to pip install some packages for a python project in a directory with a long path name an error pops up. It has more to do with Windows than Python as it is a DLL file load error.</p> <pre><code> File &quot;C:\wgyikhefghwefuyhedg\ausyfgyhfhbsdguifhlygsfkugysfsdfukysdgfksd\jsgkasdfhkghksduyfgsajkfgu...
<python><windows><pip>
2023-02-07 10:51:33
0
301
Sharath Cherian Thomas
75,372,064
7,766,024
How can I "broadcast" negative sampling using NumPy?
<p>I'm currently trying to perform negative sampling where I have an array of integers and a certain number of positive sample integers contained within this range. My current algorithm is as follows:</p> <pre><code>total = 50000 positive_samples = np.random.choice(np.arange(total), size=(30000,), replace=False) def g...
<python><numpy>
2023-02-07 10:29:23
1
3,460
Sean
75,372,032
330,867
In Python, what is the difference between `async for x in async_iterator` and `for x in await async_iterator`?
<p>The subject contains the whole idea. I came accross code sample where it shows something like:</p> <pre class="lang-py prettyprint-override"><code>async for item in getItems(): await item.process() </code></pre> <p>And others where the code is:</p> <pre class="lang-py prettyprint-override"><code>for item in awai...
<python><python-3.x><asynchronous><python-asyncio>
2023-02-07 10:26:26
2
40,087
Cyril N.
75,372,008
15,479,269
Python scraper won't complete
<p>I am using this code to scrape emails from Google search results. However, it only scrapes the first 10 results, despite having 100 search results loaded.</p> <p>Ideally, I would like for it to scrape all search results.</p> <p>Is there a reason for this?</p> <pre><code>from selenium import webdriver import time imp...
<python><pandas><selenium-webdriver><web-scraping>
2023-02-07 10:23:09
3
703
someone
75,372,002
10,071,473
Release redis lock if process die
<p>I'm using redis distributed locks to make sure some celery tasks don't run concurrently. For managing locks with redis I'm using the python <a href="https://pypi.org/project/redis/" rel="nofollow noreferrer">redis</a> library version <strong>4.0.0</strong> (which specifies that any deadlock problems should be handle...
<python><redis><concurrency><celery><locking>
2023-02-07 10:22:41
1
2,022
Matteo Pasini
75,371,946
2,439,278
Unable to install R 4.1.3 in fastapi Docker image
<p>I'm using a dockerfile which uses tiangolo/uvicorn-gunicorn-fastapi:python3.8-slim-2021-06-09 as base image and installs the required linux package and also installs r-recommended and r-base. Earlier below dockerfile works fine. But when I tried to update the image with tiangolo/uvicorn-gunicorn-fastapi:python3.8-sl...
<python><r><docker>
2023-02-07 10:18:03
0
1,264
user2439278
75,371,811
82,511
ActiveMQ Stomp python client NACK consumes message
<p>I'm using ActiveMQ classic v5.16.3 and experimenting with NACK. My expectation is that if the client sends a NACK then the message will remain on the queue and be available for another client. My code is below. I set a prefetch of 1, and ack mode of client-individual.</p> <p>If I omit the conn.nack() call then I see...
<python><activemq-classic><stomp>
2023-02-07 10:06:42
1
56,147
djna
75,371,780
7,357,166
pop method for Django queryset?
<p>I am having a data model where the model contains a members field to relate to objects of the same type. the idea is that each objects can also be a group of objects. Groups can contain groups etc.</p> <pre><code>class MyObject(CommonModel): name = models.CharField(max_length=255, unique=False, null=True, blank=...
<python><django><django-rest-framework><django-filters>
2023-02-07 10:04:45
2
422
Empusas
75,371,726
16,405,935
How to read all tables with read_html
<p>I'm trying to extract a table from link but I can not do it. This is how table show on web:</p> <p><a href="https://i.sstatic.net/iSRvL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iSRvL.png" alt="enter image description here" /></a></p> <p>I used below code to read html:</p> <pre><code>import requ...
<python><html><pandas><web-scraping>
2023-02-07 10:00:47
1
1,793
hoa tran
75,371,648
16,027,663
Compare Datetime Columns in Dataframe with Criteria
<p>In a dataframe with two datetime columns is it possible to retun only rows where ATime is no more than 1 minute before BTime? Note it should also return rows where ATime is greater than BTime.</p> <p>Original:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Atime</th> <th>BTime</th> </tr...
<python><pandas>
2023-02-07 09:55:48
1
541
Andy
75,371,594
10,737,147
Populating NumPy array with most performance
<p>I want to populate a matrix by function <code>f()</code> which consumes arrays <code>a</code>, <code>b</code>, <code>c</code> and <code>d</code>:</p> <p><a href="https://i.sstatic.net/dAkY9.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dAkY9.png" alt="enter image description here" /></a></p> <p>A ne...
<python><arrays><numpy><matrix>
2023-02-07 09:51:35
2
437
XYZ
75,371,577
3,592,342
Infill image gaps after Morph Open opencv
<p>I have an input signature for which I want to remove the gridlines of same color. <a href="https://i.sstatic.net/FJYO6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/FJYO6.png" alt="enter image description here" /></a></p> <p>So far I am using this <a href="https://stackoverflow.com/a/58002605/359234...
<python><opencv><image-processing><computer-vision>
2023-02-07 09:50:26
0
949
anonR
75,371,273
16,665,831
Snapchat Marketing API Does Not Return for List Values Requests
<p>I am trying to build a pipeline on <a href="https://marketingapi.snapchat.com/docs/#organizations" rel="nofollow noreferrer">Snapchat Marketing API</a> to fetch campaign insight data under the ad account but when I want to run the following python script, It returns the response only with country dimension (do not r...
<python><json><python-requests><snapchat>
2023-02-07 09:25:54
1
309
Ugur Selim Ozen
75,371,271
4,996,021
Compute on all other values except the current row using a window function in Polars?
<p>For each row, I'm trying to compute the standard deviation for the other values in a group excluding the row's value. A way to think about it is &quot;what would the standard deviation for the group be if this row's value was removed&quot;. An example may be easier to parse:</p> <pre class="lang-py prettyprint-overr...
<python><dataframe><window-functions><python-polars>
2023-02-07 09:25:44
3
610
pwb2103
75,371,133
14,125,436
How to add dropout layers automatically to a neural network in pytorch
<p>I have a neural network in <code>pytorch</code> and make each layer automatically via the following structure:</p> <pre><code>class FCN(nn.Module): ##Neural Network def __init__(self,layers): super().__init__() #call __init__ from parent class self.activation = nn.Tanh() self.loss_fu...
<python><deep-learning><pytorch><neural-network><dropout>
2023-02-07 09:14:45
2
1,081
Link_tester
75,371,106
13,803,549
Close Discord message on button click
<p>I have a select menu with a submit button. When submit is clicked I want to close the current message, submit the data and then open a new select menu but I am having trouble figuring out how to have the message close.</p> <p>How can I have the current menu and button close when the submit button is clicked?</p> <p>...
<python><discord><discord.py>
2023-02-07 09:13:14
1
526
Ryan Thomas
75,370,815
3,842,788
Pylint: Specifying exception names in the overgeneral-exceptions option without module name is deprecated
<blockquote> <p>pylint: Command line or configuration file:1: UserWarning: Specifying exception names in the overgeneral-exceptions option without module name is deprecated and support for it will be removed in pylint 3.0. Use fully qualified name (maybe 'builtins.BaseException' ?) instead.</p> </blockquote> <p>Getting...
<python><pylint>
2023-02-07 08:41:32
2
6,957
Aseem
75,370,436
8,971,938
Keras CategoryEncoding layer with time sequences
<p>For a LSTM, I create time sequences by means of <code>tensorflow.keras.utils.timeseries_dataset_from_array()</code>. For some of the features, I would like to do one-hot encoding by means of Keras preprocessing layers.</p> <p>I have the following code:</p> <pre><code>n_timesteps = 20 n_categorical_features = 1 from...
<python><keras><encoding><one-hot-encoding>
2023-02-07 08:05:39
1
597
Requin
75,370,330
12,435,792
TypeError: 'return_type' is an invalid keyword argument for split()
<p>I have a df with start and end time columns. Since these columns might have gibberish values, I have put in try and except blocks. I'm trying to pad the times to make them consistent and then finally save them as pandas datetime.time values. Here's the code:</p> <pre><code> for i in range(df.shape[0]): try: ...
<python><pandas><dataframe><split>
2023-02-07 07:52:37
1
331
Soumya Pandey
75,370,203
9,748,823
Pandas: Filter DataFrame by two conditions
<p>How do you filter a DataFrame if two conditions must apply in connection with not separately? I tried to do this with a left outer join but I was wondering if there was a simpler approach:</p> <pre class="lang-py prettyprint-override"><code>dataset = pd.DataFrame( { &quot;count&quot;: [2, 1, 1, 2, 1], ...
<python><pandas>
2023-02-07 07:40:48
2
381
Blob
75,370,020
9,668,481
Is there any way to use regular expression in NO_PROXY environment variable?
<p>I want to bypass proxy for domains like:</p> <pre><code>http://server-1:5000 http://server-2:5000 </code></pre> <p><code>NO_PROXY=server-1, server-2</code></p> <p>server-1 and server-2 are basically services attached to kube pods, so they can change dynamically during runtime.</p> <p>I want to bypass proxy for any d...
<python><kubernetes><python-requests><proxy>
2023-02-07 07:22:36
2
846
Saurav Pathak
75,369,745
496,837
How to scrape the extract number of Likes of a tweet via selenium
<p>I need to scrape the number 21,633. It is the hover text when I move the mouse to <code>21.6K Likes</code>. Please have a look at the below image.</p> <p><a href="https://i.sstatic.net/C3dod.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/C3dod.png" alt="enter image description here" /></a></p> <p>I s...
<python><selenium><beautifulsoup>
2023-02-07 06:49:00
1
4,030
John
75,369,743
3,713,236
How to remove 1 element in a list without Python returning "None"?
<p>All the other posts out there currently address the &quot;why&quot; but not the &quot;how&quot;.</p> <p>I have a list created from a dataframe's index called <code>df.index.to_list()</code>. Its contents are:</p> <pre><code>['ScreenPorch', 'BsmtFinSF2', 'EnclosedPorch', 'LotArea', 'MasVnrArea', '2ndFlrSF', '1s...
<python><list>
2023-02-07 06:48:34
1
9,075
Katsu
75,369,695
16,124,033
How do I let Python know that these two words are the same?
<p>I have a <code>.csv</code> file. Here is an example:</p> <p>Table format:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>A</th> <th>AA</th> </tr> </thead> <tbody> <tr> <td>BB</td> <td>B</td> </tr> <tr> <td>C</td> <td>CC</td> </tr> <tr> <td>D D</td> <td>D DD</td> </tr> </tbody> </table> ...
<python>
2023-02-07 06:42:16
5
4,650
My Car
75,369,610
8,971,938
Keras timeseries_dataset_from_array with multiple column types?
<p>For a LSTM, I would like to use <code>tensorflow.keras.utils.timeseries_dataset_from_array()</code> to create sequences of training data samples. My training data contains multiple data types (numerical, categorical) which I would like to preprocess by means of Keras' preprocessing layers within the neural network. ...
<python><keras><types><time-series><generator>
2023-02-07 06:30:57
1
597
Requin
75,369,517
1,991,502
Can you directly alter the value of a non-list argument passed to a function?
<p>This snippet of python code</p> <pre><code>def changeValue(x): x = 2*x ...
<python><function>
2023-02-07 06:16:01
1
749
DJames
75,369,462
11,023,647
How to disable syslogger when running tests in GitLab pipeline?
<p>I have defined tests running in GitLab cicd pipeline. I also have <code>syslog-ng</code> set up for logging. The whole app is runnning with <code>docker-compose</code>. I have defined my syslogger like this:</p> <pre><code>import logging from logging.handlers import SysLogHandler def get_logger(name): syslog = ...
<python><gitlab-ci><syslog-ng>
2023-02-07 06:08:49
1
379
lr_optim
75,369,456
3,169,868
Get unique values and column names from a data frame
<p>I have a data frame with the following columns</p> <pre><code>col1 col2 col3 a b b c d e e a b </code></pre> <p>I need to make a new data frame with the unique values and corresponding column names (keep set(list) of column names where value occurs in multiple columns). So o...
<python><pandas><dataframe>
2023-02-07 06:08:09
1
1,432
S_S
75,369,151
1,530,405
How to use an async timer
<p>I have a Python Server running on Win10, communicating with an Android App (written in JavaScript) as a Client, using Sockets.</p> <p>While the App is in the foreground everything works OK. Once the App is sent to the background (depending on available memory in the mobile), communication stops, and the Server hangs...
<python><android><asynchronous>
2023-02-07 05:14:27
1
455
user1530405
75,369,045
1,900,384
If a timestamp is anchored in UTC, why isn't Python's `fromtimestamp` timezone-aware?
<p><strong>To my knowledge:</strong> Python's <code>datetime</code> can be &quot;naive&quot; (if no timezone-info is available) or &quot;timezone-aware&quot;. In contrast, a timestamp is well-defined to be anchored in UTC, i.e. a timestamp <code>0</code> corresponds to <code>1970-01-01 00:00:00+00:00</code> (no matter ...
<python><datetime><timestamp><timezone>
2023-02-07 04:53:21
0
2,201
matheburg
75,369,034
3,793,935
None Exception rasied in try except block
<p>I use a simple function:</p> <pre><code>def is_float(value): try: float(value) #float(value if value else &quot;&quot;) return True except ValueError: return False </code></pre> <p>to check if an value is float or not. Now, even though the check is in an try except block, this error i...
<python><python-3.x>
2023-02-07 04:50:53
2
499
user3793935
75,368,963
1,361,802
Call overridden base class method without triggering the base class decorator
<p>I have a base class like</p> <pre><code>class BaseTest: @setup_test(param='foo') def test_something(): do stuff </code></pre> <p>I now want to override the param to the decorator</p> <pre><code>class NewTest: @setup_test(param='different value') def test_something(): super().test_something() </code><...
<python><inheritance><decorator><python-decorators>
2023-02-07 04:32:50
1
8,643
wonton
75,368,945
13,316,831
VSCode requires me to re-select my python interpreter each time it starts
<p>[edited!] Everytime I start Microsoft Visual Code, I get the following alert:</p> <p><a href="https://i.sstatic.net/11uA1.png" rel="noreferrer"><img src="https://i.sstatic.net/11uA1.png" alt="enter image description here" /></a></p> <p>This behavior started a few days ago (after a windows's update). I can select the...
<python><visual-studio-code>
2023-02-07 04:24:56
1
567
Mark Ryan
75,368,928
1,096,949
unable to install mkl mkl-service using conda in docker
<p>I have docker file like below:</p> <pre><code>FROM continuumio/miniconda3 RUN conda update -n base -c defaults conda RUN conda create -c conda-forge -n pymc3_env pymc3 numpy theano-pymc mkl mkl-service COPY ./src /app WORKDIR /app CMD [&quot;conda&quot;, &quot;run&quot;, &quot;-n&quot;, &quot;pymc3_env&quot;, &q...
<python><linux><docker><anaconda><conda>
2023-02-07 04:20:39
1
655
MD. Jahidul Islam
75,368,912
13,176,726
Fixing a NoReverseMatch in a Django Project for Registration
<p>Hi I keep getting NoReverseMatch at /users/register/ however I am have followed the step by step for fixing this error:</p> <p>Here is the urls.py</p> <pre><code>app_name = 'tac' urlpatterns = [ path('terms-and-conditions/', TermsAndConditionsView.as_view(), namespace='terms_and_conditions'), path('user-agr...
<python><django>
2023-02-07 04:15:35
1
982
A_K
75,368,897
17,696,880
How to place within a list the elements captured by capture groups within a string?
<pre><code>import re input_text = &quot;((PERS) Tomás), ((PERS) Kyara Gomez) y ((PERS) Camila) fueron a ((VERB) caminar) y ((VERB) saltar) ((PL_ADVB) en la montaña)(2023_-_02_-_05(00:00 am))((PL_ADVB) ((NOUN)en el parque amplio y naranja) por el otoño)&quot; #Initialize empty sub-lists list_of_persons, list_of_action...
<python><python-3.x><regex><list><regex-group>
2023-02-07 04:12:18
1
875
Matt095
75,368,892
3,763,616
How to make a new date column off of a integer representation using python polars?
<p>I have a python polars dataframe that is quite large where Pandas runs into memory errors. I want to use python polars but am running into an issue of taking a integer representation of date to make two new columns: PeriodDate, and LagDate. I can do this on a sample in Pandas using the following:</p> <pre><code>df[...
<python><pandas><python-polars>
2023-02-07 04:11:07
1
489
Drthm1456
75,368,713
18,096,205
[Selenium]I want to save all images from my pinterest boards
<p>I would like to save all images from a pinterest board. I am having trouble writing the process to go back to the board and go to the next image after downloading the image, and I would appreciate it if you could help me out.</p> <p>Board example:<a href="https://www.pinterest.jp/aku_ma/%E3%82%A2%E3%83%8B%E3%83%A1%E...
<python><selenium><selenium-webdriver><web-scraping>
2023-02-07 03:34:38
1
349
Tdayo
75,368,589
4,755,567
pySpark check Dataframe contains in another Dataframe
<p>Assume I have two Dataframes:</p> <p>DF1: DATA1, DATA1, DATA2, DATA2</p> <p>DF2: DATA2</p> <p>I want to exclude all existence of data in DF2 while keeping duplicates in DF1, what should I do?</p> <p>Expected result: DATA1, DATA1</p>
<python><apache-spark><pyspark>
2023-02-07 03:07:00
2
549
TommyQu
75,368,573
5,617,371
How to determine the operating system of google compute engine is linux or windows?
<p>I use python sdk of gcp to get compute engine list and I want to judge the the operating system of google compute engine is linux or windows, but there is no any operating system informatioin in all fields of compute engine.</p> <pre><code>import sys import json from google.oauth2 import service_account from googl...
<python><google-cloud-platform>
2023-02-07 03:02:21
1
1,215
leo
75,368,552
2,893,585
How can I clean this string and leave only text (Python)
<p>I have the following string in python:</p> <pre><code>&quot;\n[[[\&quot;guns\&quot;,0,[143,362,396,357],{\&quot;zf\&quot;:33,\&quot;zl\&quot;:8,\&quot;zp\&quot;:{\&quot;gs_ss\&quot;:\&quot;1\&quot;}}],[\&quot;china chinese spy balloon\&quot;,0,[143,362,396,357],{\&quot;zf\&quot;:33,\&quot;zl\&quot;:8,\&quot;zp\&quot...
<python>
2023-02-07 02:58:11
1
438
Sundios
75,368,490
8,571,154
Keras LSTM None value output shape
<p>this is my data <code>X_train</code> prepared for LSTM of shape (7000, 2, 200)</p> <pre><code>[[[0.500858 0. 0.5074856 ... 1. 0.4911533 0. ] [0.4897923 0. 0.48860878 ... 0. 0.49446714 1. ]] [[0.52411383 0. 0.52482396 ... 0. 0.48860878 1. ]...
<python><tensorflow><keras><lstm>
2023-02-07 02:45:45
1
893
Adrian Kurzeja
75,368,450
112,871
Bin and aggregate with `seaborn.objects`
<p>Is there a way to both bin and aggregate (with some other function than <code>count</code>) in <code>seaborn.objects</code>? I'd like to compute the mean per bin and right now I'm using the following:</p> <pre class="lang-py prettyprint-override"><code>import seaborn.objects as so import pandas as pd import seaborn ...
<python><plot><seaborn><visualization><seaborn-objects>
2023-02-07 02:35:55
1
27,660
nicolaskruchten
75,368,373
5,383,071
How to integrate a progress bar in a pandas iterrows for loop
<p>I acknowledge that using iterrows in pandas is bad practice, but this is what I'm dealing with from previous projects leftovers...</p> <p>I am using a for loop like so to iterate through a pandas data frame for some data manipulation (on mobile so forgive my poor formatting) -</p> <pre><code>for index, row in df_tem...
<python><pandas><dataframe><for-loop><progress-bar>
2023-02-07 02:15:29
2
656
2Xchampion
75,368,170
12,695,210
float32 vs. float64 python checking equality
<p>In the below code, checking equality between float64 fails due to binary representation issue, as I would expect. However, I don't understand why float32 as no problem with this. My understanding is that it should be susceptable to the same binary representation issues, and has precision much lower than 0.0003. Why ...
<python><binary><precision>
2023-02-07 01:30:40
2
695
Joseph
75,368,099
14,109,040
Finding an element and clicking on it to navigate to another webpage using selenium
<p>I'm trying to use selenium to open up this webpage (<a href="https://app.powerbi.com/view?r=eyJrIjoiMzE2ZDIyN2YtODY1Yy00ZGY0LWE4YTktNDcxOTcwYWQyMjM5IiwidCI6IjcyMmVhMGJlLTNlMWMtNGIxMS1hZDZmLTk0MDFkNjg1NmUyNCJ9" rel="nofollow noreferrer">https://app.powerbi.com/view?r=eyJrIjoiMzE2ZDIyN2YtODY1Yy00ZGY0LWE4YTktNDcxOTcwYW...
<python><selenium><web-scraping>
2023-02-07 01:17:44
1
712
z star
75,367,832
744,351
How can I get a Containerized Jupyter Notebook to run code within Azure ML
<p>I'm not an expert in Azure ML but I'll give as much detail as I can or understand. The task I've been given is probably overkill for Azure Machine Learning, but I have a Jupyter Notebook that I have parameterized with Papermill. There is NO training needed. It reads data from varying sources, processes it with par...
<python><azure><docker><jupyter-notebook><azure-machine-learning-service>
2023-02-07 00:19:19
1
1,791
Antebios
75,367,828
4,700,367
RuntimeError: reentrant call inside <_io.BufferedWriter name='<stdout>'>
<p>I'm writing a program which starts one thread to generate &quot;work&quot; and add it to a queue every N seconds. Then, I have a thread pool which processes items in the queue.</p> <p>The program below works perfectly fine, until I comment out/delete line #97 (<code>time.sleep(0.5)</code> in the main function). Once...
<python><python-3.x><python-multithreading>
2023-02-07 00:18:54
1
438
Sam Wood
75,367,823
12,044,155
ValueError: Shapes (None,) and (None, 150, 150, 6) are incompatible
<p>I am building an image classification model using Keras, SGD, and Softmax activation. The training dataset consists of RGB images with dimensions of 512x384.</p> <p>To do so, I have followed Keras &quot;Getting Started&quot; guide. However, when I tried to train the model, I got the error mentioned in the title. Thi...
<python><tensorflow><machine-learning><keras>
2023-02-07 00:18:05
1
2,692
Allan Juan
75,367,781
881,150
Get Blob Storage version enabled setting using Python SDK
<p>when running the azure CLI command:</p> <pre><code>az storage account blob-service-properties show --account-name sa36730 --resource-group rg-exercise1 </code></pre> <p>The output json contains the filed <code>isVersioningEnabled</code>. I am trying to get this field using python sdk.</p> <p>I wrote this code but th...
<python><azure>
2023-02-07 00:07:54
2
1,114
abhinav singh
75,367,749
6,202,327
Scipy/numpy how to compute function as vector?
<p>I am trying to use <code>solve_bvp</code> from scipy. To that effect I need to create the RHS function, which on paper I ahve as</p> <p><code>(1+y^2) / 2(1-x)</code></p> <p>I am not sure how to define the function that takes the vecotrs as inputs and rewrite it for my case.</p> <p>I.e. I am trying to rewrite the fun...
<python><numpy><math><scipy><differential-equations>
2023-02-07 00:01:22
2
9,951
Makogan
75,367,671
3,533,030
StableBaselines3 / steps vs. total_timesteps vs. number of times environment is solved during training
<p><code>model.learn(total_timesteps=20)</code> takes much longer than I expected, so I'm trying to understand if I should:</p> <ol> <li>Be frugal with time steps</li> <li>Speed up my environment <code>env.step(action)</code></li> <li>Train even more time steps</li> </ol> <hr /> <p>Consider a simple environment:</p> <u...
<python><reinforcement-learning><stable-baselines>
2023-02-06 23:43:20
1
449
user3533030
75,367,625
14,414,944
python-polars: is there an established way to construct a DataFrame with a custom Iterable?
<p>I'm trying out <code>polars</code> for the first time. I'm interested in using the lib to improve a developer API that (ironically) uses a Redis Cluster as its primary data layer. I'd like to implement something like <code>hybrid-streaming</code> for a custom <code>Iterable</code> over collections in the Redis Clust...
<python><python-polars>
2023-02-06 23:36:04
0
1,011
lmonninger
75,367,602
7,984,318
How to convert a float date to days and hours
<p>I have a Dataframe ,you can have it ,by runnnig:</p> <pre><code>import pandas as pd from io import StringIO df = &quot;&quot;&quot; case_id duration_time other_column 3456 1 random value 1 7891 3 ddd 1245 0 fdf 9073 null ...
<python><pandas><dataframe><python-datetime>
2023-02-06 23:32:23
2
4,094
William
75,367,550
2,153,636
Appropriate python project setup for accessing paths relative to the project root folder out of a module in src
<p>Example project structure:</p> <pre><code>|-setup.toml |-README.md |-tests/... |-data/... |-src/ |-package1 |-package2 |-module1.py |-package3 |-subpackage4 |-module2.py </code></pre> <p>In reality, I have many more folders and files scattered around them and I need to be a...
<python><setuptools><python-packaging><python-poetry>
2023-02-06 23:22:43
0
3,316
rudolfovic
75,367,473
3,371,941
Comparing rows from a Pandas DataFrame depending on certain attribute
<p>The task is to compare two production lines A and B with respect to a performance indicator called OEE. I suspect that there is an impact by the article and line, so I want to compare only articles that have been produced at least once on both lines (here: hammer, drill, pliers, widget). This may later enable to tel...
<python><pandas><dataframe><iteration>
2023-02-06 23:09:34
2
349
RogerWilco77
75,367,378
562,769
Is it possible to shrink botocore within site-packages?
<p>I've just seen that my web applications docker image is enormous. A 600-MB reason is the packages I install for it. The biggest single offender is botocore with 77.7 MB.</p> <p>Apparently this is known behavior: <a href="https://github.com/boto/botocore/issues/1629" rel="noreferrer">https://github.com/boto/botocore/...
<python><amazon-web-services><docker><botocore>
2023-02-06 22:54:31
1
138,373
Martin Thoma
75,367,291
4,042,278
How can I use alpha with seaborn.pointplot?
<p>I guess it's changed recently since I saw several code which use alpha with pointplot (<a href="https://stackoverflow.com/questions/70688084/pointplot-and-scatterplot-in-one-figure-but-x-axis-is-shifting">Pointplot and Scatterplot in one figure but X axis is shifting</a> or <a href="https://stackoverflow.com/questio...
<python><matplotlib><seaborn>
2023-02-06 22:38:46
0
1,390
parvij
75,367,137
20,358
How to find and replace values between specific characters in a string?
<p>I am trying to find the most efficient way natural to Python, to find all instances of a string within another string surrounded by a <code>$$</code> sign and replace it with another value in another variable.</p> <p>The string in question is like this <code>&quot;$$firstOccurance$$ some other words here then $$seco...
<python>
2023-02-06 22:15:12
2
14,834
user20358
75,367,132
17,724,172
Writing to a text file, last entry is missing
<p>This code calls no errors, but my text file is not getting betty and her grade. It's only getting the first three out of the four combinations. What am I doing wrong? Thanks!</p> <pre><code>students = ['fred','wilma','barney','betty'] grades = [100,75,80,90] for i in range(4): file = open(&quot;grades3.txt&quot;...
<python><file><text>
2023-02-06 22:14:50
3
418
gerald
75,367,078
2,989,642
beautifulsoup to get both link and link text inside an HTML table
<p>I am dealing with HTML table data consisting of two fields: First, a field that holds a hyperlinked text string, and second, one that holds a date string. I need the two to be extracted and remain associated.</p> <p>I am catching the rows in the following fashion (found from another SO question):</p> <pre><code>pg ...
<python><beautifulsoup>
2023-02-06 22:08:00
1
549
auslander
75,367,068
7,429,447
DeprecationWarning: headless property is deprecated, instead use add_argument('--headless') or add_argument('--headless=new') on Selenium 4.8.0 Python
<p>I am trying to execute a basic program using <em><strong>Selenium 4.8.0</strong></em> Python clients in <em><strong>headless</strong></em> mode:</p> <pre><code>from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service options = Options...
<python><selenium><selenium-webdriver><selenium-chromedriver><headless>
2023-02-06 22:06:47
2
194,394
undetected Selenium
75,367,027
19,916,174
perf_counter()-start giving weird result
<p>I was building my own version of the timeit function, which returns the amount of time it takes to run a function <code>n</code> times. However, when I ran it with a sample input, I received the following output, which doesn't seem right, as it ran very quickly.</p> <pre><code>9.400071576237679e-06 </code></pre> <p>...
<python><function><time><timeit>
2023-02-06 22:01:05
1
344
Jason Grace
75,366,985
2,100,039
Create a Pandas Dataframe Date Column to Day of Year
<p>I know this should be easy but for some reason, I cannot get the result that I need. I have data that looks like this where 'raw_time' is read into a df in the date format yyyy-mm-dd hh:mm:ss. It looks like this:</p> <p>dfdates =</p> <pre><code>1429029 1992-01-03 02:00:00 1429030 1992-01-03 01:00:00 1429031 19...
<python><pandas><datetime><days>
2023-02-06 21:56:27
3
1,366
user2100039
75,366,974
8,354,766
OpenCV Mat cpp operation only on condition
<p>Having a hard time figuring out how to do this python operation in c++ without looping.</p> <p>The goal is to perform an operation only on a part of the cv::Mat that meets a condition.</p> <p>In this case, scaling values of the image that were originally between -5 and 5..</p> <pre><code>image[-5&lt;image&lt;5] = im...
<python><c++><opencv><matrix><indexing>
2023-02-06 21:55:11
1
488
Alberto MQ
75,366,940
2,999,349
How to get OpenAI/baselines to work on MacOS Monterey, M1 Pro?
<p>I've been struggling for days trying to get any repo implementing PPO running on my Macbook, so I was wondering what's the trick? I'm currently trying to get the OpenAI/Baselines repo to work, carefully following their README, and after having solved various undocumented issues ( different tensorflow pkg sources, mi...
<python><macos><openai-api>
2023-02-06 21:50:29
0
879
user2999349
75,366,936
1,258,509
Django Rest Framework - How to use url parameters in API requests to exclude fields in response
<p>Let's say I have an API that returns some simple list of objects at the <code>/users</code> endpoint</p> <pre><code>{ &quot;count&quot;: 42, &quot;results&quot;: [ { &quot;name&quot;: &quot;David&quot;, &quot;age&quot;: 30, &quot;location&quot;: &quot;Alaska&quot; }, ......
<python><django><django-rest-framework>
2023-02-06 21:50:09
1
1,467
Brian C
75,366,866
9,758,352
Converting fields inside a Serializer in django
<p>I have a project where one model, called <code>Request</code>, has two fields (<code>source</code>, <code>dest</code>) that contain two <code>id</code>s which are not known to the user. However, each one is connected to another model <code>User</code>, who let's say that they have one field, <code>username</code>, w...
<python><django><django-rest-framework><django-serializer>
2023-02-06 21:42:15
1
457
BillTheKid
75,366,764
11,380,243
Finding the index of the element, for each column in a dataframe, that is the closest to a given defined number and plot in a heatmap
<p>I am basically loading a dataframe from a .csv file in which as the index, I have the motion amplitude values and in the column names, I have the motion frequency values. Filling the column and rows I have the velocity values correspondent to the motion of each frequency and amplitude. What I am planning to achieve ...
<python><pandas><dataframe><heatmap>
2023-02-06 21:29:22
2
438
Marc Schwambach
75,366,567
1,497,199
How do I use a custom pip.conf in a docker image?
<p>How can I configure a Docker container to use a custom pip.conf file?</p> <p>This does not (seem to) work for me:</p> <pre><code>from python:3.9 COPY pip.conf ~/.config/pip/pip.conf </code></pre> <p>where <code>pip.conf</code> is a copy of the pip configuration that points to a proprietary package repository.</p>
<python><docker><pip>
2023-02-06 21:04:48
1
8,229
Dave