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,340,220
3,798,292
pgf backend in matplotlib - "input stack size" capacity exceeded with pdflatex and lualatex
<p>I'm trying to use the pgf backend in matplotlib to create figure files for a manuscript, following the example in the matplotlib docs <a href="https://matplotlib.org/stable/tutorials/text/pgf.html" rel="nofollow noreferrer">here</a>. I don't have xelatex so I've tried using pdflatex and lualatex. However, if I try t...
<python><matplotlib><tex>
2023-02-03 19:28:23
1
351
PeterW
75,340,187
5,718,264
How to run second vertex ai pipeline after first one is completed successfully?
<p>I have a certain scenario where I want to deploy two vertex ai pipelines, where the second one is dependent on the first run. Is there a way I can run the second vertex ai pipeline only after first one is completed?</p>
<python><google-cloud-platform><google-cloud-vertex-ai>
2023-02-03 19:24:34
1
834
Shadab Hussain
75,339,760
1,075,996
Postfix: Python Milter not able to change email header
<p>I have some servers that create automated emails which all pass through a Postfix MTA. The software that generates the email does not strictly follow RFCs, and sometimes generates emails with duplicate message-ID headers. The software cannot be changed, so I am trying to intercept and fix these messages on their way...
<python><postfix-mta><mta><milter>
2023-02-03 18:34:41
0
453
btongeorge
75,339,741
7,437,143
Plotly Dash change networkx node colours in based on user input?
<p>After creating the minimal working example below, I tried to change the color of the nodes in the graphs based on user input. Specifically, I have <code>n</code> lists of colors (one color per node), and I would like the user to be able to loop (ideally forward and backwards) through the node color lists. (In essenc...
<python><colors><plotly><networkx><plotly-dash>
2023-02-03 18:32:12
2
2,887
a.t.
75,339,687
11,099,153
Python's standard hashing algorithm
<p>Python documentation describes hashing procedure of fractions (and ints, and floats) <a href="https://docs.python.org/3/library/stdtypes.html" rel="nofollow noreferrer">here</a>.</p> <p>I understand the approach as far as 'treat fractions as mod P' and 'inverses mod P are easyish to compute'. Afterwards encode sign ...
<python><hash>
2023-02-03 18:25:37
0
349
Radost Waszkiewicz
75,339,598
19,504,610
Using SQLModel to have multiple tables with same columns
<p>Let's say I have two SQL tables <code>address</code> and <code>email</code> tables.</p> <p>For the <code>address</code> table I may have the following generic fields:</p> <ol> <li><code>postal_code</code></li> <li><code>street_name</code></li> </ol> <p>and additionally, I would want the following two fields:</p> <ol...
<python><fastapi><pydantic><sqlmodel>
2023-02-03 18:14:14
1
831
Jim
75,339,463
371,683
Read columns from Parquet in GCS without reading the entire file?
<p>Reading a parquet file from disc I can choose to read only a few columns (I assume it scans the header/footer, then decides). Is it possible to do this remotely (such as via Google Cloud Storage?)</p> <p>We have 100 MB parquet files with about 400 columns and we have a use-case where we want to read 3 of them, and s...
<python><pandas><google-cloud-storage><parquet><pyarrow>
2023-02-03 17:57:18
1
1,999
Niklas B
75,339,340
14,791,134
How to use Machine Learning in Python to predict a binary outcome with a Pandas Dataframe
<p>I have the following code:</p> <pre class="lang-py prettyprint-override"><code>import nfl_data_py as nfl pbp = nfl.import_pbp_data([2022], downcast=True, cache=False, alt_path=None) </code></pre> <p>which returns a dataframe of every play that occurred in the 2022 NFL season. The columns I want to train it on are <c...
<python><pandas><dataframe><machine-learning><artificial-intelligence>
2023-02-03 17:47:44
1
468
earningjoker430
75,339,183
2,868,899
rows of columns to column
<p>Would I need to use pivot to make a row of columns into one column? I have a dataset like the one shown but within each row are 8 separate rows. I need to make each cell its own row.</p> <p>This would be an example of what i would start with:</p> <pre><code>d = {'col1':[1,9,17],'col2':[2,10,18],'col3':[3,11,19],'col...
<python><pandas>
2023-02-03 17:33:04
2
2,790
OldManSeph
75,339,171
3,852,723
how to connect application running on localhost from docker container
<p>I am trying to connect the application (which is not running on docker)<a href="https://i.sstatic.net/9SB7m.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9SB7m.jpg" alt="enter image description here" /></a></p> <ul> <li><p>i am trying to run this docker image with the help of docker compose.</p> </l...
<python><docker><docker-compose>
2023-02-03 17:31:44
1
453
Ganesh Pol
75,339,122
14,141,126
Return value of key in nested dict when key not present in all nested dicts
<p>Trying to get the values of a particular key from nested dictionaries, but the key is not always present. The key in question is 'action'. I tried several ways but can't get it right. I either get an error saying the key doesnt exist, or I get a partial return. My latest attempts are as follows.</p> <pre><code>def e...
<python>
2023-02-03 17:25:59
2
959
Robin Sage
75,339,092
12,907,088
Why is the left number inclusive and the right number exclusive when using the colon operator in Python arrays/strings?
<p>I was just confused why in the following example the number on the left is included, while the number on the right isn't:</p> <pre class="lang-py prettyprint-override"><code>a = &quot;0123456789&quot; a[:] # &quot;0123456789&quot; a[1:] # &quot;123456789&quot; -&gt; includes the 1 # and this confuses me: a[:5] # ...
<python><slice>
2023-02-03 17:22:50
1
694
MoPaMo
75,339,087
10,852,841
Fill facecolor in convex hulls for custom seaborn mapping function
<p>I'm trying to overlay shaded convex hulls to the different groups in a scatter <code>seaborn.relplot</code> using Matplotlib. Based on this <a href="https://stackoverflow.com/questions/29968097/seaborn-facetgrid-user-defined-plot-function">question</a> and the <a href="https://seaborn.pydata.org/tutorial/axis_grids....
<python><matplotlib><seaborn>
2023-02-03 17:22:06
1
2,379
m13op22
75,339,009
15,549,110
Python | traverse every element from a list in another for loop
<p>Want to traverse each element from below list one by one in next for loops.</p> <p>How should i do it? how can i fit in one more for loop in it.</p> <p>currently i am calling accessing <strong>summaryList[1]</strong> only one element</p> <pre><code>summaryList=['hi','bye','hello'] def list(path): result = [] ...
<python><python-3.x><list><dictionary><for-loop>
2023-02-03 17:14:08
2
379
pkk
75,338,989
10,853,071
how to filter / query data from Python SASPY to_df function
<p>I am working on python on some data get from a SAS server. I am currently using SASPY to_df() function to bring it from SAS to local pandas.</p> <p>I would like to know if its possible to filter/query the data that is being transferred so I could avoid bringing unneeded that and speeding up my download.</p> <p>I cou...
<python><pandas><saspy>
2023-02-03 17:11:59
1
457
FábioRB
75,338,898
7,089,108
How do I calculate the matrix exponential of a sparse matrix?
<p>I'm trying to find the matrix exponential of a sparse matrix:</p> <pre><code>import numpy as np b = np.array([[1, 0, 1, 0, 1, 0, 1, 1, 1, 0], [1, 0, 0, 0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0...
<python><scipy><sparse-matrix>
2023-02-03 17:03:15
1
433
cerv21
75,338,840
4,506,929
Using `xarray.apply_ufunc` with `np.linalg.pinv` returns an error with `dask.array`
<p>I get an error when running the following MWE:</p> <pre class="lang-py prettyprint-override"><code>import xarray as xr import numpy as np from numpy.linalg import pinv import dask data = np.random.randn(4, 4, 3, 2) da = xr.DataArray(data=data, dims=(&quot;x&quot;, &quot;y&quot;, &quot;i&quot;, &quot;j&quot;),) da...
<python><dask><python-xarray>
2023-02-03 16:56:43
1
3,547
TomCho
75,338,838
6,263,317
JAX best way to iterate RNGKeys?
<p>In JAX I find myself needing a <code>PRNGKey</code> that changes on each iteration of a loop. I'm not sure of the best pattern. I've considered</p> <p>a) <code>split</code></p> <pre class="lang-py prettyprint-override"><code>for i in range(N): rng, _ = jax.random.split(rng) # Alternatively. rng = jax.random.s...
<python><jax>
2023-02-03 16:56:34
1
4,499
Jon Deaton
75,338,703
8,781,465
How can I explain a part of my predictions as a whole with SHAP values? (and not every single prediction)
<p><strong>Background information</strong></p> <p>I fit a classifier on my training data. When testing my fitted best estimator, I predict the probabilities for one of the classes. I order both my X_test and my y_test by the probabilites in a descending order.</p> <p><strong>Question</strong></p> <p>I want to understan...
<python><shap>
2023-02-03 16:44:45
1
1,815
DataJanitor
75,338,668
10,795,473
Why does mypy complain about my dictionary comprehension?
<p>I'm trying to do an update of a dictionary with a dictionary comprehension. My code works fine, but mypy raises an error while parsing the types.</p> <p>Here's the code:</p> <pre class="lang-py prettyprint-override"><code>load_result = {&quot;load_code&quot;: &quot;something&quot;} load_result.update({ quality_r...
<python><mypy>
2023-02-03 16:41:55
1
309
aarcas
75,338,615
9,850,681
How can I test an Exception inside an async with?
<p>in my tests I did a coverage and I end up with untested parts inside an async with, what the coverage sees is the part about exceptions, my code is like this:</p> <pre class="lang-py prettyprint-override"><code> @classmethod async def update_eda_configuration( cls, configuration: Configurati...
<python><pytest><coverage.py>
2023-02-03 16:36:49
0
460
Plaoo
75,338,450
5,810,060
FuzzyWuzzy on 2 col from different DataFrames
<p>I have a very easy but not simple(to me at least!) question I have 2 DFs:</p> <pre><code>df1: Account_Name samsung tesla microsoft df2: Company_name samsung electronics samsung Ltd tesla motors Microsoft corporation </code></pre> <p>all I am trying to do is to find the best match for every row in df1 from df2 and ...
<python><python-3.x><dataframe><similarity>
2023-02-03 16:23:21
1
906
Raul Gonzales
75,338,336
1,864,294
subprocess stdout without colors
<p>I am running a command line tool that returns a coloured output (similar to <code>ls --color</code>). I run this tool via <code>subprocess</code>:</p> <pre><code>process = subprocess.run(['ls --color'], shell=True, stdout=subprocess.PIPE) process.stdout.decode() </code></pre> <p>But the result is, of course, with th...
<python><encoding><colors><subprocess>
2023-02-03 16:12:56
2
20,605
Michael Dorner
75,338,329
13,285,583
How to handle unexpected fatal error with signal?
<p>My goal is to handle unexpected fatal error with signal. However, none of the signal is triggered. For example, <code>AttributeError</code>. The example is trivial. What I want is to execute a function i.e. <code>camera.stop()</code> before closing the app regardless of how bad it is. Otherwise, I will need to reboo...
<python>
2023-02-03 16:12:35
0
2,173
Jason Rich Darmawan
75,338,231
1,960,266
What is the use of the next() function for printing the size of an array?
<p>I have been reading about how to use Pytorch for the MNIST character recognition, so far the code is the following:</p> <pre><code>import torch import torchvision train_loader=torch.utils.data.DataLoader(torchvision.datasets.MNIST('/files/',train=True, download=True, ...
<python><pytorch>
2023-02-03 16:03:01
1
3,477
Little
75,338,157
1,581,090
How to read a binary file and append them to a new file?
<p>I read data from a file as binary data like</p> <pre><code>with open(filename, &quot;rb&quot;) as filein: content = filein.read() print(type(content[0])) </code></pre> <p>and I expected the data type of the data read to be <code>byte</code>, but I get <code>int</code>.</p> <p>How to read data from a file as type...
<python><byte>
2023-02-03 15:57:03
1
45,023
Alex
75,337,910
20,266,647
Issue with the aggregation function in the pipeline during online ingest
<p>I see issue in the aggregation function (part of pipeline) during the online ingest, because aggregation output is invalid (output is different then expectation, I got value 0 instead of 6). The pipeline is really very simple:</p> <p><a href="https://i.sstatic.net/2tqaT.png" rel="nofollow noreferrer"><img src="https...
<python><pipeline><mlops><feature-store><mlrun>
2023-02-03 15:35:11
1
1,390
JIST
75,337,685
3,575,623
Lineplot above clustermap
<p>Based on <a href="https://stackoverflow.com/a/66296010/3575623">this answer</a>, I can use <code>.fig.subplots_adjust()</code> to shift my clustermap to the bottom half of my final figure. I'd like to plot a line above it representing some associated data, but I can't seem to change its size. Most solutions I've see...
<python><seaborn>
2023-02-03 15:17:04
0
507
Whitehot
75,337,665
3,433,875
Dynamic SQL queries with SQLite3
<p>I would like to allow users to query a sql database. The database is <a href="https://github.com/Curbal-Data-Labs/python-bites/tree/main/Data" rel="nofollow noreferrer">here</a></p> <p>So the user will be able to enter the queries they want:</p> <pre><code>csr_city= input(&quot;Enter a city &gt;&gt;&quot;).lower().s...
<python><python-3.x><sqlite><sqlite3-python>
2023-02-03 15:15:11
1
363
ruthpozuelo
75,337,606
18,758,062
Optuna HyperbandPruner not pruning?
<p>My study is setup to use the Hyperband pruner with 60 trials, 10M max resource and reduction factor of 2.</p> <pre class="lang-py prettyprint-override"><code> def optimize_agent(trial): # ... model = PPO(&quot;MlpPolicy&quot;, env, **params) model.learn(total_timesteps=2000000) study = optuna.create_st...
<python><stable-baselines><optuna>
2023-02-03 15:10:46
1
1,623
gameveloster
75,337,401
10,353,865
Is the any-call on a boolean series/array efficient?
<p>Say we have a call like:</p> <pre><code>ser = pd.Series([1,2,3,4]) ser[ser&gt;1].any() </code></pre> <p>Now my question is: Is pandas &quot;smart enough&quot; to stop computation and spit out the &quot;true&quot; when it encounters the 2 or does it really go through the whole array first and checks the any() afterwa...
<python><pandas>
2023-02-03 14:53:19
1
702
P.Jo
75,337,352
20,266,647
How to identify different type of exit 'shutdown', 'restart', 'kill', 'kill -x' in python?
<p>Is it possible to identify in the python application type of external exit/break? I would like to do different actions (release sources slow &amp; correct/complex or fast &amp; partly/dirty) based on different external exit reasons e.g. 'shutdown', 'restart', 'kill', 'kill -x'?</p> <p>I used simple code with <strong...
<python><exit><kill><restart><shutdown>
2023-02-03 14:49:22
1
1,390
JIST
75,337,266
7,077,532
How is the LRU deleted in this LRUCache implementation?
<p>I'm going over the optimal Leetcode solution for LRU Cache LeetCode Medium question. The original problem can be found here: <a href="https://leetcode.com/problems/lru-cache/description/" rel="nofollow noreferrer">https://leetcode.com/problems/lru-cache/description/</a></p> <p>I'm confused by a specific portion of ...
<python><doubly-linked-list>
2023-02-03 14:41:22
1
5,244
PineNuts0
75,337,193
13,231,896
How to draw polygons in python (giving cordenates) and number its edges?
<p>I have a list of agroforestry plots (polygons) in python. Every polygon es represented as latitude/longitude.</p> <pre><code> polygon1_coords = [ (11.946898956, -86.109286248), (11.947196373, -86.109159886), (11.947092456, -86.108962101), (11.946897164, -86.10886504), (11.946898956, -86.109286248...
<python><python-imaging-library><gis>
2023-02-03 14:35:48
1
830
Ernesto Ruiz
75,337,122
658,209
Automatically sync new files from google drive to google cloud storage
<p>I want to automatically sync new files that are added to google drive to google cloud storage. I have seen various people asking this on the web and most of them suggest something along the lines of:</p> <ul> <li>Develop an app to poll for new files in the drive</li> <li>Retrieve new files and upload them to GCS</li...
<python><google-cloud-platform><google-drive-api><google-cloud-storage>
2023-02-03 14:29:26
1
1,364
Prim
75,337,051
9,257,578
How to trim text from file and put it another file using python?
<p>I have a text file called file1 like</p> <pre><code> HelloWorldTestClass MyTestClass2 MyTestClass4 MyHelloWorld ApexClass * ApexTrigger Book__c CustomObject 56.0 </code></pre> <p>Now i want to output my...
<python>
2023-02-03 14:24:36
1
533
Neetesshhr
75,336,802
5,510,540
python: label position lineplot() with secondary y-axes
<p>I have a produce a plot with secondary y-axes and the labels are on top of each other: <a href="https://i.sstatic.net/h00fD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/h00fD.png" alt="enter image description here" /></a></p> <p>The code is the following:</p> <pre><code> sns.lineplot(data=incide...
<python><plot>
2023-02-03 14:04:53
1
1,642
Economist_Ayahuasca
75,336,749
1,770,902
Pyglet render into texture
<p>I'm writing a drawing program using <a href="https://pyglet.org/" rel="nofollow noreferrer">pyglet</a>, and I want to be able to have the image being created as separate from the window's buffer (for instance, the image could be larger than the window, or may want to draw to this image at a different rate than the m...
<python><opengl><pyglet><render-to-texture>
2023-02-03 14:00:35
1
463
timfoden
75,336,535
18,221,164
Downloading from Nexus Repository using Python
<p>I have a task to download some artifacts from Nexus. I am using <code>nexuscli</code> library. The nexus repository structure is very heirarchical.</p> <pre><code>https://localhostABC.de/nexus/#browse/browse </code></pre> <p>will lead to a folder structure as below:</p> <pre><code>release --de ----Updates ------oper...
<python><nexus>
2023-02-03 13:41:38
0
511
RCB
75,336,506
1,868,775
Nodejs equivalent of Python's b'string'?
<p>Give this <code>salt</code> in Python</p> <p><code>salt = b&quot;0000000000000000004d6ec16dafe9d8370958664c1dc422f452892264c59526&quot;</code></p> <p>What's the equivalent in Nodejs?</p> <p>I have this</p> <p><code>const salt = Buffer.from(&quot;0000000000000000004d6ec16dafe9d8370958664c1dc422f452892264c59526&quot;,...
<python><node.js>
2023-02-03 13:39:10
1
4,292
Filipe Aleixo
75,336,478
15,452,168
Extracting dates in a pandas dataframe column using regex
<p>I have a data frame with a column <code>Campaign</code> which consists of the campaign name (start date - end date) format. I need to create 3 new columns by extracting the start and end dates.</p> <pre class="lang-none prettyprint-override"><code>start_date, end_date, days_between_start_and_end_date. </code></pre>...
<python><pandas><regex><dataframe><datetime>
2023-02-03 13:36:40
2
570
sdave
75,336,477
19,556,055
Replace a value in a single column of a dataframe within a list of dataframes
<p>I have a long list of dataframes. For each dataframe, I want to replace all 0 values in a column with an empty string. I can use the code below to do it, but I was wondering if there is a faster way? There are about 18000 dataframes in the list, so any speed gain is a huge help.</p> <pre><code>for df_player in list_...
<python><pandas><for-loop>
2023-02-03 13:36:17
1
338
MKJ
75,336,237
1,284,499
Change json.dumps behaviour : customize serialization
<p>Imagine, I've got a dict <code>{&quot;a&quot;: &quot;hello&quot;, &quot;b&quot;: b&quot;list&quot;}</code></p> <ul> <li>'a' is a string</li> <li>'b' is a byte string</li> </ul> <p>I would like to serialize the dict into the &quot;json&quot;(*) string --&gt; '{&quot;a&quot;: &quot;hello&quot;, &quot;b&quot;: list}'</...
<python><json><string><serialization>
2023-02-03 13:13:46
1
1,131
manatlan
75,336,092
12,430,026
Seaborn clustermap showing less columns that the input dataframe has
<p>When using <code>seaborn</code> <code>clustermap</code> method, the resulting plot has less columns that the input dataframe. Does anyone know when this can happen?</p> <p>The input data is a 70x64 dataframe ofcounts, filled mostly with 0s. No row or column is ever all 0s As can be seen here: <a href="https://pasteb...
<python><seaborn><clustermap>
2023-02-03 12:59:14
0
1,577
Lamma
75,336,039
7,376,511
ClassVar for variable type defined on __init__subclass__
<pre><code>class School: def __init__(self) -&gt; None: self.number = 0 def test(self) -&gt; None: self.number = 0 class Sophism(School): def test(self) -&gt; None: self.number = 1 class Epicureanism(School): def test(self) -&gt; None: self.number = 2 PhilosophySch...
<python><mypy><python-typing><metaclass>
2023-02-03 12:54:46
2
797
Some Guy
75,336,005
8,077,270
Splinter Python ElementDoesNotExist for is_visible()
<p>In my code I have following line:</p> <pre><code>browser.find_by_css(business_role_expand).is_visible(1000) </code></pre> <p>According to the <a href="https://splinter.readthedocs.io/en/latest/api/driver-and-element-api.html?highlight=is_visible#splinter.driver.ElementAPI.is_visible" rel="nofollow noreferrer">docume...
<python><selenium><firefox><webdriver><splinter>
2023-02-03 12:51:28
2
475
eXPRESS
75,335,972
12,027,232
ONNX runtime predictions on raw CuPy arrays?
<p>I am following the ONNX inference tutorial at: <a href="https://github.com/onnx/models/blob/main/vision/classification/onnxrt_inference.ipynb" rel="nofollow noreferrer">https://github.com/onnx/models/blob/main/vision/classification/onnxrt_inference.ipynb</a>.</p> <p>Instead of doing the pre-processing in pure NumPy,...
<python><onnx><cupy><onnxruntime>
2023-02-03 12:48:57
0
410
JOKKINATOR
75,335,785
7,790,226
How to access Request object & dependencies of FastAPI in models created from Pydantic's BaseModel
<p>I am writing APIs using stack FastAPI, Pydantic &amp; SQL Alchemy and I have come across many cases where I had to query database to perform validations on payload values. Let's consider one example API, <code>/forgot-password</code>. This API will accept <code>email</code> in the payload and I need to validate the ...
<python><sqlalchemy><fastapi><pydantic>
2023-02-03 12:32:06
2
1,261
Jeet Patel
75,335,722
15,724,084
python function global and local scope confusion
<p>I have a code in which I declare a variable globally. Then inside a function, when I try to use it, it gives an error <code>Unbound variable is not declared</code> My code:</p> <pre><code>count_url =1 def foo(): ... ttk.Label(canvas1, text=f'{varSongTitle}...Done! {count_url}/{str(var_len)}').pack(pad...
<python><function><global-variables><local-variables>
2023-02-03 12:24:47
1
741
xlmaster
75,335,650
13,334,778
TypeError: MetaData.__init__() got multiple values for argument 'schema'
<p>I am trying to execute sql query to get a pandas dataframe on postgres server using sqlalchemy</p> <p>I made this class to connect to postgres server :</p> <pre><code>class Connection: def __init__(self): load_dotenv() engine = sqlalchemy.create_engine(os.getenv('CONNECTION_STRING')) tr...
<python><postgresql><sqlalchemy>
2023-02-03 12:18:39
0
341
abhinit21
75,335,466
8,406,122
dataclass_transform() got an unexpected keyword argument 'field_specifiers'
<p>I am trying to work with this <a href="https://pypi.org/project/g2p-en/" rel="nofollow noreferrer">G2P package</a>. But I am getting <code>dataclass_transform() got an unexpected keyword argument 'field_specifiers'</code> this error. I am trying to run their sample code that they have provided there after running <c...
<python>
2023-02-03 12:03:25
2
377
Turing101
75,335,461
11,155,419
How to remove a downstream or upstream task dependency in Airflow
<p>Assuming we have the two following Airflow tasks in a DAG,</p> <pre><code>from airflow.operators.dummy import DummyOperator t1 = DummyOperator(task_id='dummy_1') t2 = DummyOperator(task_id='dummy_2') </code></pre> <p>we can specify dependencies as:</p> <pre><code># Option A t1 &gt;&gt; t2 # Option B t2.set_upstrea...
<python><airflow><airflow-2.x>
2023-02-03 12:03:00
1
843
Tokyo
75,335,433
5,510,540
secondary axes 10 times smaller that the main axes using twinx()
<p>I am producing a plot and I want to make the secondary y-axes 10 times smaller than the main y-axes.</p> <pre><code>ax2 = ax.twinx() sns.lineplot(data=df[&quot;A&quot;], ax=ax) sns.lineplot(data=df[&quot;B&quot;], ax=ax2) </code></pre> <p>is it possible to do define <code>ax2 = ax.twinx()/10</code>? how can specifcy...
<python><plot><seaborn>
2023-02-03 12:00:23
1
1,642
Economist_Ayahuasca
75,335,346
7,376,511
Mypy error on __init_subclass__ example from python documentation
<p>From the <a href="https://docs.python.org/3/reference/datamodel.html#object.__init_subclass__" rel="nofollow noreferrer">official Python 3 documentation</a> for __init__subclass__:</p> <pre><code>class Philosopher: def __init_subclass__(cls, /, default_name: str, **kwargs): super().__init_subclass__(**k...
<python><mypy><metaclass>
2023-02-03 11:53:00
1
797
Some Guy
75,335,264
17,160,160
Pandas. merge/join/concat. Rows into columns
<p>Given data frames similar to the following:</p> <pre><code>df1 = pd.DataFrame({'Customer': ['Customer1', 'Customer2', 'Customer3'], 'Status': [0, 1, 1]} Customer Status 0 Customer1 0 1 Customer2 1 2 Customer3 1 df2 = pd.DataFrame({'Customer': ['Customer1', 'Customer1', 'Custom...
<python><pandas>
2023-02-03 11:45:46
3
609
r0bt
75,335,094
20,646,427
__init__() got multiple values for argument 'user'
<p>I have a form, model and view and trying to show ModelChoiceField with filters</p> <p>I wrote an init in my forms.py but when im trying to submit my form on html page i got an error:</p> <p>&quot;<code>__init__()</code> got multiple values for argument 'user' &quot;</p> <p>forms.py</p> <pre><code>class WorkLogForm(f...
<python><django>
2023-02-03 11:29:57
1
524
Zesshi
75,335,059
3,922,727
Azure function deployed but never run on blob input
<p>We are setting an Azure functions to be triggered once we have a file in an azure blob storage.</p> <p>This file will be used as an input of a python script hosted on Github.</p> <p>Here is the azure function basic script that was generated once the function was set using visual studio code:</p> <p>import logging</p...
<python><azure><azure-functions>
2023-02-03 11:27:03
1
5,012
alim1990
75,334,901
774,133
Transposed dataframe to LaTeX
<p>I am not able to change the number format in the LaTeX output of the library Pandas.</p> <p>Consider this example:</p> <pre><code>import pandas as pd values = [ { &quot;id&quot;:&quot;id1&quot;, &quot;c1&quot;:1e-10, &quot;c2&quot;:int(1000) }] df = pd.DataFrame.from_dict(values).set_index(&quot;id&quot;) print(df)...
<python><pandas><dataframe><latex><pandas-styles>
2023-02-03 11:13:43
1
3,234
Antonio Sesto
75,334,890
3,575,623
Not-quite gradient of dataframe
<p>I have a dataframe of ints:</p> <pre><code>mydf = pd.DataFrame([[0,0,0,1,0,2,2,5,2,4], [0,1,0,0,2,2,4,5,3,3], [1,1,1,1,2,2,0,4,4,4]]) </code></pre> <p>I'd like to calculate something that resembles the gradient given by <code>pd.Series.dff()</code> for each row, but with one...
<python><pandas>
2023-02-03 11:12:32
1
507
Whitehot
75,334,864
15,958,930
Use numpy to mask a row containing only zeros
<p>I have a large array of point cloud data which is generated using the azure kinect. All erroneous measurements are assigned the coordinate [0,0,0]. I want to remove all coordinates with the value [0,0,0]. Since my array is rater large (1 million points) and since U need to do this process in real-time, speed is of t...
<python><numpy><real-time>
2023-02-03 11:10:03
2
577
Thijs Ruigrok
75,334,831
2,583,765
Pylance doesn't show suggestions for not-yet-imported definitions
<p>According to the <a href="https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance" rel="nofollow noreferrer">Pylance extension page</a>, I should be able to write &quot;g&quot; in my python code, and then Pylance should suggest that I import the <code>gc</code> module (see screenshot below, or <...
<python><visual-studio-code><pylance>
2023-02-03 11:07:16
1
5,175
birgersp
75,334,744
606,576
CSV DictWriter cannot write to file open in binary mode, BigQuery Client cannot upload file read in text mode
<p>Using Python 3.10 with <code>google-cloud-bigquery==3.4.2</code>.</p> <p>I have CSV data that I need to load, transform and upload to BigQuery. I want to use a <code>SpooledTemporaryFile</code> for the intermediate data to avoid disk I/O. Simplified code:</p> <pre><code>from csv import DictReader, DictWriter from te...
<python><csv><google-bigquery>
2023-02-03 10:59:18
1
915
kthy
75,334,695
6,026,338
Rotate an image in python and fill the cropped area with image
<p>Have a look at the image and it will give you the better idea what I want to achieve. I want to rotate the image and fill the black part of image just like in required image. <a href="https://i.sstatic.net/5Ymji.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/5Ymji.png" alt="enter image description h...
<python><opencv><image-processing><deep-learning><computer-vision>
2023-02-03 10:54:48
2
1,604
Qazi Ammar
75,334,569
5,618,856
python-docx: How to get the document properties into an object
<p>I'm using python-docx and I can list the properties with <code>doc.core_properties.__dir__()</code> <a href="https://stackoverflow.com/questions/52120217/python-coreproperties-python-docx">as in this question</a>. But assigning prs.core_properties to a python variable doesn't give a usable object.</p> <p>How do I ge...
<python><python-docx><python-pptx>
2023-02-03 10:45:20
1
603
Fred
75,334,495
6,013,016
how to check if ctrl key is released (pygame)
<p>How do I check if left ctrl key is released in pygame? I saw the documentation, but following code didn't work for me:</p> <pre><code>if event.type == pygame.KEYUP: if pygame.key.get_mods() &amp; pygame.KMOD_CTRL: # this is not working! print(&quot;Left control is released&quot;) </code></pre> <p>What...
<python><pygame>
2023-02-03 10:37:39
2
5,926
Scott
75,334,441
9,703,039
How to select all Dataframe columns with the same names?
<p>I am creating a dataframe based on a csv import:</p> <pre><code>ID, attachment, attachment, comment, comment 1, lol.jpg, lmfao.png, 'Luigi', 2, cat.docx, , 'It's me', 'Mario' </code></pre> <p>Basically the number of 'attachments' and 'comment' columns corresponds to the line that has the bigger number of said attach...
<python><python-3.x><pandas><dataframe>
2023-02-03 10:32:16
3
339
Odyseus_v4
75,334,440
221,270
Meteor spectrogram from wave files
<p>I am using <a href="https://www.qsl.net/dl4yhf/spectra1.html" rel="nofollow noreferrer">SpectrumLab</a> for logging meteors with an SDR. SpectrumLab records <a href="https://www.qsl.net/dl4yhf/speclab/specdisp.htm#waterfall" rel="nofollow noreferrer">waterfall</a> screenshots and a wav file of an event. I am trying ...
<python><signal-processing><fft><librosa><rtl-sdr>
2023-02-03 10:32:16
0
2,520
honeymoon
75,334,327
9,236,505
Provide sample DataFrame from csv file
<p>when asking a python/pandas question on stackoverflow I often like to provide a sample dataframe. I usually have a local csv file I deal with for testing.</p> <p>So for a DataFrame I like to provide a code in my question like</p> <pre><code>df = pd.DataFrame() </code></pre> <p>Is there an easy way or tool to get a c...
<python><pandas>
2023-02-03 10:21:40
1
336
Paul
75,334,245
4,865,723
Second optional capturing group depending on optional delimiter in regex
<p>I'm sorry for asking this maybe duplicate question. I checked the existing questions and answers about <em>optional capturing groups</em>. I tried some things but I'm not able to translate the answer to my own example.</p> <p>This are two imput lines</p> <pre><code>id:target][label id:target </code></pre> <p>I would...
<python><regex><regex-group>
2023-02-03 10:14:09
1
12,450
buhtz
75,334,103
6,612,915
Explanation needed for a calculation
<p>I am fairly new to Python and do not understand the explanation given by the course I am doing. I cannot follow why width gets 2.</p> <p>To my understanding the <code>print(combine(1)[2])</code> appoints the value to to position one. But I thought <code>is_3D</code> is in position 0, hence height would be in positio...
<python>
2023-02-03 10:00:13
2
464
Anna
75,334,025
9,236,505
bar plot a multiheader dataframe in a desired format
<p>I have the following DataFrame:</p> <pre><code>data = {('Case1', 'A'): {'One': 0.96396415, 'Two': 0.832049574, 'Three': 0.636568627, 'Four': 0.765846157}, ('Case1', 'B'): {'One': 0.257496625, 'Two': 0.984418254, 'Three': 0.018891398, 'Four': 0.440278509}, ('Case1', 'C'): {'One': 0.512732941, 'Two': 0...
<python><pandas><dataframe><matplotlib>
2023-02-03 09:51:58
2
336
Paul
75,333,793
3,922,727
Python reading a file from blob storage on azure using argparse is returning an error of attribute not found
<p>We are trying to add a TOML file as an argument when we want to run the following:</p> <p><code>python src/main --file=something.toml</code></p> <p>Within the argument parser function, we've added this line:</p> <pre><code>def parse_args(activity_choices, country_choices): parse = argparse.ArgumentParser() ....
<python><file><argparse>
2023-02-03 09:28:50
1
5,012
alim1990
75,333,663
11,197,301
numpy array in a python function and the correct usage of if condition
<p>let's say that I have this function</p> <pre><code>def funtion(x, bb, aa): if x&gt;aa: res = aa else: xxr = x/aa res = bb*(1.5*xxr-0.5*xxr**3) return res </code></pre> <p>If I do:</p> <pre><code>xx = np.linspace(0,49,50) yy = funct(xx,74,33) </code></pre> <p>I g...
<python><arrays><if-statement><vectorization>
2023-02-03 09:17:03
0
623
diedro
75,333,654
9,490,769
Localize time zone based on column in pandas
<p>I am trying to assign a timezone to a datetime column, based on another column containing the time zone.</p> <p>Example data:</p> <pre class="lang-py prettyprint-override"><code> DATETIME VALUE TIME_ZONE 0 2021-05-01 00:00:00 1.00 Europe/Athens 1 2021-05-01 00:00:00 2.13 ...
<python><pandas><pytz><zoneinfo>
2023-02-03 09:16:08
1
3,345
oskros
75,333,571
4,388,099
Get Aerospike hyperLogLog(HLL) intersection count of multiple HLL unions
<p>I have 2 or more HLLs that are unioned, I want to get the intersection count of that unions. I have used the example from here <a href="https://github.com/aerospike-examples/hll-python/blob/master/hll.py" rel="nofollow noreferrer">hll-python example</a> Following is my code</p> <pre><code>ops = [hll_ops.hll_get_unio...
<python><aerospike><hyperloglog>
2023-02-03 09:08:07
1
301
darekarsam
75,333,570
16,220,410
generate unique id code in faker data set
<p>im trying to create a data set with a unique id code but i get a</p> <blockquote> <p><strong>'ValueError not enough values to unpack (expected 6, got 5)'</strong></p> </blockquote> <p>on line 8, basically, I am trying to:</p> <ol> <li>generate a unique 6 digit id code</li> <li>append dataset value with 'ID' ex: ID12...
<python>
2023-02-03 09:08:05
1
1,277
k1dr0ck
75,333,526
12,304,000
send POST request to Itunes API via Postman
<p>For the Itunes Reporter API, I have an <strong>access_token</strong> and <strong>vendor_number</strong>.</p> <p><a href="https://help.apple.com/itc/appsreporterguide/#/apd68da36164" rel="nofollow noreferrer">https://help.apple.com/itc/appsreporterguide/#/apd68da36164</a></p> <p>I found some old Python code that was ...
<python><post><https><postman><itunes>
2023-02-03 09:03:19
0
3,522
x89
75,333,407
8,318,946
Docker is taking wrong settings file when creating image
<p>I have Django application where my settings are placed in folder named settings. Inside this folder I have <strong>init</strong>.py, base.py, deployment.py and production.py.</p> <p>My wsgi.py looks like this:</p> <pre><code>os.environ.setdefault(&quot;DJANGO_SETTINGS_MODULE&quot;, &quot;myapp_settings.settings.prod...
<python><django>
2023-02-03 08:51:34
1
917
Adrian
75,333,342
4,451,521
How can I run a script from another script when I change folders?
<p>Originally I had two scripts <code>main.py</code> and <code>call_main.py</code> They were in the same level.</p> <p>In <code>call_main.py</code> I had</p> <pre><code>import subprocess cmd = [ &quot;python3&quot;, &quot;main.py&quot;, ] subprocess.run(cmd) </code></pre> <p>No problem there. However n...
<python><path>
2023-02-03 08:44:40
0
10,576
KansaiRobot
75,333,089
5,580,309
Raspberry Pi - Crontab task not running properly
<p>I have scheduled a task <code>arp -a</code> which runs once per hour, that scans my wi-fi network to save all the info about currently connected devices into a <code>scan.txt</code> file. After the scan, a python script reads the <code>scan.txt</code> and saves the data into a database.</p> <p>This is what my <code>...
<python><cron><raspberry-pi><arp>
2023-02-03 08:18:17
1
1,038
sirdan
75,332,748
10,689,857
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-bu
<p>I have a virtual environment with Python 3.11.0 in it. When trying to install cx-Oracle</p> <pre class="lang-none prettyprint-override"><code>pip install cx-Oracle </code></pre> <p>Is there any way to make it work with python 3.11?</p> <p>Full error:</p> <pre class="lang-none prettyprint-override"><code>(venv) PS C:...
<python><pip>
2023-02-03 07:38:49
0
854
Javi Torre
75,332,507
11,607,378
Is is possible to separate CPU resources between subprocess and main process in Python?
<p>Suppose I have Python program with a main process A, it would have a main thread a, and invoke some threads a1, a2. And I spawn a subprocess from A, let's say it B, and have the main thread b.</p> <p>Is it possible to separate the CPU resources(CPU cores) between b and (a, a1, a2), that their CPU usages would not co...
<python><cpu>
2023-02-03 07:07:20
1
673
Litchy
75,332,474
275,002
Python: MySQL Connection not available
<p>I have a routine that is accessed every second, it worked fine for the days and then gave the error:</p> <pre><code>Exception in store_price [2023-02-03 05:02:56] - Traceback (most recent call last): File “/x/db.py&quot;, line 86, in store_price with connection.cursor() as cursor: File &quot;/root/.pyenv/ver...
<python><mysql><mysql-connector>
2023-02-03 07:04:27
0
15,089
Volatil3
75,332,327
11,280,068
python f-strings with path parameters within fastapi path
<p>I'm wondering if you can use f strings within a path in fastapi. For example, I want to do the following:</p> <pre><code>common_path = '/{user}/{item_id}' @app.get(f'{common_path}/testing') </code></pre> <p>would this work?</p>
<python><python-3.x><fastapi><f-string>
2023-02-03 06:43:45
1
1,194
NFeruch - FreePalestine
75,332,264
2,161,250
compare two list of dictonary with different order in Python
<p>I have two lists of dict which I need to compare but dict in different order so I am not sure what is the correct way to do it.</p> <p>l1 = [{'a': '1'}, {'b': '2'}]</p> <p>l2 = [{'b': '2'}, {'a': '1'}]</p> <p>result should be true when I compare l1 and l2 as both have same dictionaries in their respective list.</p>
<python><list><dictionary>
2023-02-03 06:34:32
6
338
Lavish Karankar
75,332,136
305,135
Pandas groupby having condition on column
<p>I have data like this :</p> <pre><code> userID activity count 0 3 running 5 1 3 running 6 2 3 walking 0 3 3 walking 1 4 3 stopped 2 </code></pre> <p>I want to group data conditionallly, by userID and wether activity is running(1) o...
<python><sql><pandas>
2023-02-03 06:15:38
0
19,540
AVEbrahimi
75,332,124
13,538,030
Stratified sampling with multiple variables in Python
<p>I need your advice. I am performing stratified sampling in Python. There are 3 variables (A, B, and C), and each of them has 3 levels.</p> <pre><code>A: a1, a2, a3 B: b1, b2, b3 C: c1, c2, c3 </code></pre> <p>That being said, there are 3 * 3 * 3 = 27 strata, and for each stratum, I want to random sample 1000 rows. W...
<python><sampling>
2023-02-03 06:14:21
0
384
Sophia
75,332,053
10,844,937
How to merge multiple columns of a dataframe using regex?
<p>I have a <code>df</code> which as following</p> <pre><code>import pandas as pd df = pd.DataFrame( {'number_C1_E1': ['1', '2', None, None, '5', '6', '7', '8'], 'fruit_C11_E1': ['apple', 'banana', None, None, 'watermelon', 'peach', 'orange', 'lemon'], 'name_C111_E1': ['tom', 'jerry', None, None, 'paul',...
<python><pandas>
2023-02-03 06:03:33
2
783
haojie
75,331,691
11,901,732
ORA-00942: table or view does not exist when querying in Python
<p>I got this error when querying Oracle data from Python, with the query below:</p> <pre><code>CONN_INFO = { 'host': '192.xxx.xxx.xx', 'port': 4445, 'user': 'User27', 'psw': '12345678', 'service': 'xxxxxxx.xxxx.com', } CONN_STR = '{user}/{psw}@{host}:{port}/{service}'.format(**CONN_INFO) connecti...
<python><oracle-database>
2023-02-03 04:59:10
1
5,315
nilsinelabore
75,331,550
2,130,515
Unable to create chrome webdriver in an abstract class
<p>This code is working just fine:</p> <pre><code>class example: def __init__(self) -&gt; None: remote_debug_port=8956 options = webdriver.ChromeOptions() options.add_argument(f'--remote-debugging-port={remote_debug_port}') options.add_argument(&quot;--start-maximized&quot;) ...
<python><selenium><google-chrome><selenium-webdriver>
2023-02-03 04:32:19
1
1,790
LearnToGrow
75,331,489
1,039,860
how to run libreoffice python script using scriptforge
<p>I am trying to organize my python project that currently only adds a menu to a libreoffice calc menu bar:</p> <pre><code># this file is called AddMenu.py which is located in 'C:\Program Files\LibreOffice\share\Scripts\python' def create_menu(args=None): o_doc = CreateScriptService(&quot;Document&quot;) o_menu...
<python><libreoffice-calc>
2023-02-03 04:19:36
2
1,116
jordanthompson
75,331,478
754,444
Crop a box around n percentile of maximum values
<p>Given a binary image, how do I box around the majority of the white pixels? For example, consider the following image: <a href="https://i.sstatic.net/pSdty.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pSdty.png" alt="image processing to edge detection" /></a></p> <p>As canny segmentation results in...
<python><opencv><image-processing><crop><edge-detection>
2023-02-03 04:15:40
3
922
zaza
75,331,455
19,425,874
Scraping Table Data from Multiple Pages
<p>So I think this is going to be complex...hoping someone is up for a challenge.</p> <p>Basically, I'm trying to visit all HREF tags on a specific URL and then print their &quot;profile-box&quot; class into a Google Sheet.</p> <p>I have a <strong>working</strong> example with a <strong>different</strong> link below. T...
<python><pandas><beautifulsoup><python-requests>
2023-02-03 04:12:39
1
393
Anthony Madle
75,331,340
4,500,749
Send tasks to a Celery app on a remote server
<p>I have a server (Ubuntu Server) on the local network on ip address: 192.168.1.9. This server is running RabbitMQ in docker.</p> <p>I defined a basic Celery app:</p> <pre><code>from celery import Celery app = Celery( 'tasks', brocker='pyamqp://&lt;username&gt;:&lt;password&gt;@localhost//', backend='rpc:...
<python><celery><remote-server>
2023-02-03 03:52:35
2
326
Romn
75,331,308
1,496,362
What is the int needed for in map(int, icount) in Pydoop
<p>In the official <a href="https://github.com/malli3131/HadoopTutorial/blob/master/Pydoop/Tutorial" rel="nofollow noreferrer">Pydoop tutorial</a> there is a word count example.</p> <p>I understand how it works, but I am wondering about the inner workings of <code>map(int, icounts))</code>.</p> <p>Do I follow correctly...
<python><hadoop><mapreduce>
2023-02-03 03:48:42
1
5,417
dorien
75,331,240
825,920
Deserialize Protobuf datetime?
<p>I am trying to deserialize the <code>datetime?</code> data serialized using Protobuf from Redis records. (They are not epoch numbers).</p> <p>I found the following integers (left) in the Redis records (serialized <code>datetime?</code> as protobuf).</p> <pre><code> 1354218408 =&gt; &quot;2023-02-02T04:51:19.5480532Z...
<python><c#><protocol-buffers><protobuf-net><stackexchange.redis>
2023-02-03 03:36:14
0
29,537
ca9163d9
75,331,236
6,494,707
How to take only the array matrix (item) from np.array()
<p>I have a list <code>mask_arr</code> of numpy array and the element of list is numpy array like this:</p> <pre><code>mask_arr[0][:] array([[255, 255, 255, ..., 255, 255, 255], [255, 255, 255, ..., 255, 255, 255], [255, 255, 255, ..., 255, 255, 255], ..., [255, 255, 255, ..., 255, 255, 255]...
<python><arrays><list><numpy><numpy-ndarray>
2023-02-03 03:35:31
1
2,236
S.EB
75,331,127
16,971,617
One Mask subtracting another mask on numpy
<p>I am new to numpy so any help is appreciated. Say I have two 1-0 masks A and B in 2D numpy array with the same dimension. Now I would like to do logical operation to subtract B from A</p> <pre><code>A B Expected Result 1 1 0 1 0 1 0 1 0 0 0 0 </code></pre> <p>But i am not sure it works when a = 0 and b = 1 wher...
<python><numpy>
2023-02-03 03:12:53
2
539
user16971617
75,330,993
13,689,939
Python requests PUT request with json parameter fails and data parameter succeeds
<p><strong>Problem</strong></p> <p>I've looked at some of the documentation about the <code>json</code> and <code>data</code> parameters and the differences between them. I think I understand the difference, best explained <a href="https://stackoverflow.com/questions/47188244/what-is-the-difference-between-the-data-and...
<python><json><http><python-requests>
2023-02-03 02:45:14
3
986
whoopscheckmate
75,330,988
10,834,788
How to write a key function for bisect.bisect_left that compares both the index of two arrays?
<p>I want to write a key function for <code>bisect.bisect_left</code> and my objective is to compare two lists, call one list smaller than the other only if both elements of it are smaller than or equal to the other list's elements.</p> <p><code>[x1, y1]</code> should be placed before <code>[x2, y2]</code> only if <cod...
<python><binary-search><bisect>
2023-02-03 02:44:15
1
4,662
Aviral Srivastava