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,749,531
18,313,588
Remove comma only at the end of pandas column values
<p>I only want to remove the comma at the end of the pandas column value, how can I accomplish this?</p> <pre><code>value apple, orange, banana,pineapple, grapes,tomato, </code></pre> <p>How can I accomplish this?</p> <p>Expected outcome</p> <pre><code>value apple orange banana,pineapple grapes,tomato </code></pre...
<python><python-3.x><pandas><dataframe>
2023-03-15 20:00:13
1
493
nerd
75,749,521
4,114,325
Ho to set hadoop configuration values from pyspark after 2019?
<p>The accepted answer to <a href="https://stackoverflow.com/questions/28844631/how-to-set-hadoop-configuration-values-from-pyspark">this</a> question:</p> <pre><code>sc._jsc.hadoopConfiguration().set('my.mapreduce.setting', 'someVal') </code></pre> <p>stopped working due to removal of <code>_jsc</code> attribute as po...
<python><apache-spark><pyspark><jupyter-notebook>
2023-03-15 19:59:20
1
1,023
Kagaratsch
75,749,443
3,535,152
How to return a QuerySet of 2 models via reverse ForeignKey lookup in Django?
<p>I have &quot;Parameter&quot; and &quot;ParameterChoice&quot; models where I define multiple choices for each parameter. The end goal is to have some sort of assessment where I have a list of parameters where each parameter has a specific fixed set of choices available for selection from a dropdown list within the HT...
<python><django><django-models><django-queryset>
2023-03-15 19:51:14
1
479
Trm
75,749,349
1,615,890
Multiple span tag under one parent DIV id always returns first record
<p>I have multiple span tag with same class name under one parent div id. But, the BeautifulSoup item loop always returns first attribute only, rest of the attributes are not printing.</p> <p>Note : All of my span class names are same as mentioned below. Any suggestions?</p> <pre><code>&lt;div class=&quot;product_const...
<python><html><beautifulsoup>
2023-03-15 19:40:05
1
451
Kumanan
75,749,348
4,980,705
get email and website from two different <div> with same name with beautifulsoup
<p>I've managed to use <code>find_all</code> to get the two classes <code>&quot;IdiaP Me sNsFa&quot;</code> , but now I'm struggling to get the website and the email address.</p> <pre><code>contacts_container = s_restaurant.find_all(class_=&quot;IdiaP Me sNsFa&quot;) for contact in contacts_container: print(contac...
<python><beautifulsoup>
2023-03-15 19:40:03
1
717
peetman
75,749,138
12,139,954
Pandas plot line chart of two columns based on grouping in third column
<p>I am sure this is simple but I struggle with plotting charts for this dataframe.<br /> I have a pandas dataframe with multiple columns of which three columns are Gender, Age, Balance<br /> I want to plot two lines with x-axis = Age, y-axis = Balance and two line in a single charts one for Male and Female based on Ba...
<python><pandas><matplotlib>
2023-03-15 19:15:02
0
381
Ani
75,749,036
11,002,498
No module named 'transformers.models.ernie_m.configuration_ernie_m'
<p>So I am trying to use Haystack to run a model in Google Colab. I am using <a href="https://haystack.deepset.ai/tutorials/01_basic_qa_pipeline" rel="nofollow noreferrer">this</a> tutorial and I am adapting it to my project.</p> <p>My problem is in the initialization of the reader:</p> <pre><code>from haystack.nodes i...
<python><google-colaboratory><huggingface-transformers><haystack>
2023-03-15 19:02:22
0
464
Skapis9999
75,748,962
9,386,819
What is n in the for loop that begins: "for n in sequence:"
<p>I'm wondering what the technical description is of the variable <code>n</code> in a <code>for</code> loop that begins <code>for n in sequence</code>. I suppose my question is about nomenclature. Would it be accurate to say that it's a temporary named variable that gets discarded upon conclusion of the loop? I suspec...
<python><for-loop>
2023-03-15 18:52:47
2
414
NaiveBae
75,748,952
4,502,950
Join data frames after applying fuzzywuzzy library
<p>I have two data frames</p> <pre><code>df1 = pd.DataFrame({'Key':['Apple Souce', 'Banana', 'Orange', 'Strawberry', 'John tabel']}) df2 = pd.DataFrame({'Key2':['Aple suce','apple','app','orange', 'Mango', 'Orag','Jon table', 'Straw', 'Bannanna', 'Berry'],'Key23':['1', '2', '2','3', '3','4','4', '5', '6', '7']}) </code...
<python><pandas><fuzzywuzzy><fuzzy>
2023-03-15 18:51:04
0
693
hyeri
75,748,912
3,804,098
All rows in one dataframe substracts another row
<p>I have a dataframe like this:</p> <pre><code>ID, A, B, C, D 111 0, 1, 2, 3 222 2, 3, 4, 5 333 3, 4, 5, 6 </code></pre> <p>and a row</p> <pre><code>A, B, C, D 0, 1, 0, 1 </code></pre> <p>I want every row in the first dataframe minus the row in the above, and do not affect the ID column. The expect result is</...
<python><pandas><dataframe>
2023-03-15 18:46:51
1
6,246
lserlohn
75,748,777
1,290,055
Does polars preserve row order in a left join?
<p>Consider the following polars dataframes:</p> <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; left = pl.DataFrame(pl.Series('a', [1,5,3,2])) &gt;&gt;&gt; left shape: (4, 1) ┌─────┐ │ a │ │ --- │ │ i64 │ ╞═════╡ │ 1 │ │ 5 │ │ 3 │ │ 2 │ └─────┘ &gt;&gt;&gt; right = pl.DataFrame([pl.Series('a', [...
<python><dataframe><join><python-polars>
2023-03-15 18:31:10
2
1,823
Martin Wiebusch
75,748,683
472,610
Create conda environment with platform-specific python version
<p>I sifted through many similar questions but couldn't find an answer to my question. I am trying to create a conda environment not only with a specific Python version, but a specific platform too. The following command (and variations thereof) fails:</p> <pre><code>conda create -n test python=3.9.11-macos11 </code><...
<python><python-3.x><macos><conda><apple-m1>
2023-03-15 18:21:16
1
8,002
Jonathan H
75,748,638
5,942,100
Perform calculation based on filter within dataframe using Pandas
<p>I have a dataframe where I would like to only perform a specific calculation based on if a column value is true. (Else perform a calculation if column is not true)</p> <p><strong>Data</strong></p> <pre><code>ID USED AVAIL TOTAL stat Ready Box1 5 5 10 yes TRUE Box1 40 10 50 ...
<python><pandas><numpy>
2023-03-15 18:15:58
1
4,428
Lynn
75,748,582
19,600,130
Django, how i can add item corectly in my cart?
<p>I have a online shop project, in my product detail view i can add to cart items and also this is a cart page which can increase or decrease item there too. the problem is that when i add one myb item in cart page it work like fibonacci sequence and it's add the new number if I have 3 item and use plus one it's gonna...
<python><django><django-views>
2023-03-15 18:10:44
1
983
HesamHashemi
75,748,544
1,471,980
How to get performance metrics from Aruba AirWave?
<p>I need to be able to log in to the Aruba AirWave appliance and retrieve metric data such as CPU usage, number of connections, and memory usage for certain devices.</p> <p>I already have code that gets the <code>ap_list</code>, but I'm looking for ideas on how to modify it to obtain the desired metrics. Any suggestio...
<python><metrics><aruba>
2023-03-15 18:06:12
0
10,714
user1471980
75,748,439
17,194,313
How to read only some columns of a parquet file from Azure blob storage?
<p>I have some large parquet files in Azure blob storage and I am processing them using python polars.</p> <p>Is there any way to read only some columns/rows of the file?</p> <p>Currently I'm downloading the file into a io.BytesIO and doing pl.read_parquet(...) over it.</p>
<python><dataframe><azure-blob-storage><python-polars>
2023-03-15 17:54:20
1
3,075
MYK
75,748,302
4,659,442
SQLAlchemy: select ... into having no effect
<p>Is <code>select ... into</code> not something we're able to do in SQLAlchemy?</p> <p>The following is a minimal example of something I'm trying to do - and it isn't adding a table to my d/b as expected.</p> <pre><code>driver = '{ODBC Driver 17 for SQL Server}' server = xxxxxxxxxxxxxxxxxxxxxxxxx database = xxxxxxxxxx...
<python><sql-server><sqlalchemy>
2023-03-15 17:40:43
1
727
philipnye
75,748,260
4,212,870
How to get the most frequent value over partitions in Polars?
<p>I'm trying to use Polars to get the most frequent value in a column of a DataFrame, for each category, and this category is given by multiple other columns (i.e., using a composite primary key).</p> <p>For example, I have a DataFrame that looks something like this:</p> <p><strong>Input</strong></p> <pre class="lang-...
<python><dataframe><vectorization><python-polars>
2023-03-15 17:36:43
1
1,298
Vinícius Queiroz
75,748,240
3,408,158
Deleting and creating a Azure VPN-Gateway with python Azure SDK
<p>I have some Azure Python functions which I would use to build and destroy a VPN Gateway every day. In a first step I tried to delete an existing Gateway with that code:</p> <pre><code>import azure.functions as func from azure.identity import ClientSecretCredential from azure.mgmt.network import NetworkManagementClie...
<python><azure><azure-functions><azure-sdk-python>
2023-03-15 17:35:26
1
624
Joe Platano
75,748,174
1,671,319
What is the correct type hint for dynamo db resource in boto3?
<p>I have added <code>ruff</code> to an existing project and one of my rules are flake8-annotations. I am struggling a bit with the type hint for a function that does this:</p> <pre><code>def _dynamodb_resource(): return boto3.resource('dynamodb', region_name=REGION) </code></pre> <p>In the docs, it says <code>boto...
<python><python-3.x><boto3>
2023-03-15 17:27:33
1
3,074
reikje
75,748,113
1,473,517
why is numba dict lookup so much slower than cpython?
<p>I ran the following simple experiment:</p> <pre><code>import numba import numpy as np @njit def foo(): d = dict() d[(1.0, 2)] = np.random.rand(500) return d e = dict() e[(1.0, 2)] = np.random.rand(500) d = foo() </code></pre> <p>e and d are both dictionaries with one key each.</p> <pre><c...
<python><numba>
2023-03-15 17:22:00
1
21,513
Simd
75,748,037
1,008,636
How do I distinguish a variable passed as input to a function that's hardcoded, vs a locally defined variable?
<p>If I have:</p> <pre><code>def my_func(x: str) -&gt; void: // def my_caller_func()-&gt; void local_var = &quot;xyz&quot; local_var_2 = &quot;zzz&quot; my_func(x=local_var) </code></pre> <p>I am trying to write a libcst visitor that will detect that the input value passed into my_func's x input is &quot;xyz...
<python><libcst>
2023-03-15 17:14:15
1
3,245
user1008636
75,747,941
11,922,765
Python Dataframe index isocaldenar() code giving different answers in a span of 2 days
<p>I am in a perfect state of confusion and dilemma. I don't know what is going on. I had raised a question couple of days ago with some sample data and code. I already had a working solution but was looking for short one. This is fine.</p> <p>I am running the code again today, but this time, I am getting a different a...
<python><pandas><dataframe><datetime><python-datetime>
2023-03-15 17:05:59
0
4,702
Mainland
75,747,906
468,334
Virtual environment wrappers for globally installed Python scripts
<p>I have a (rather specialist) software package with numerous programs which needs to be installed globally (i.e., into <code>/usr/local/bin</code>) and called by numerous users on the target machine <em>including system users</em>. A few of these programs are Python, and I've managed dependencies so-far by a hard r...
<python><python-venv>
2023-03-15 17:03:35
0
1,120
jjg
75,747,888
6,064,135
uWSGI Segmentation Fault With Flask/Python App Behind Nginx After Running for ~24 hours
<h1>Problem</h1> <p>I have a <a href="https://github.com/Justintime50/harvey" rel="nofollow noreferrer">Python/Flask app</a> running in prod with uWSGI behind Nginx that deploys my personal projects via Docker. It works great for about <code>12-24 hours</code> when it suddenly starts <code>segfaulting</code>. The app a...
<python><docker><nginx><segmentation-fault><uwsgi>
2023-03-15 17:00:52
1
729
Justin Hammond
75,747,822
18,108,367
Calculate the number of rows filled by a string in a multi_cell of the library PyFPDF
<p>I'm using the method <a href="https://pyfpdf.readthedocs.io/en/latest/reference/multi_cell/index.html" rel="nofollow noreferrer">multicell()</a> of the class <code>FPDF</code> (library <a href="https://pyfpdf.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer">PyFPDF</a>) and, to manage it in my real appl...
<python><algorithm><pdf><pyfpdf>
2023-03-15 16:54:43
1
2,658
User051209
75,747,504
4,882,126
Showing value inside bubble of folium
<p>I am trying to show the values battery storage capacity of some countries in Maps: I want to show it through bubble maps on folium charts according to the size</p> <p>My code is as following.</p> <pre><code>import folium # Make an empty map m = folium.Map(location=[20,0], tiles=&quot;OpenStreetMap&quot;, zoom_start...
<python><folium>
2023-03-15 16:29:09
1
512
Zeryab Hassan Kiani
75,747,252
10,693,596
Using `sqlalchemy.orm` with composite primary keys
<p>Using <code>sqlalchemy.orm</code> I am trying to link two tables on a composite key, but keep getting an error. Unfortunately, the official docs provide an example that uses a single primary key (not composite), so I tried to come up with a basic example that reproduces the issue:</p> <pre class="lang-py prettyprint...
<python><sqlalchemy><orm>
2023-03-15 16:06:01
1
16,692
SultanOrazbayev
75,747,212
7,366,596
How to scale ticks on an axis in proportion
<p>The numbers I have on y-axis might be distributed in a broad range. What I want is simply having the axis with these ticks [5,10,15,20,50,100,500,1000,1500,2000,2500], but proportionally distributed.</p> <pre><code>import matplotlib.pyplot as plt from datetime import datetime x_axis = [datetime.strptime(date, &quot;...
<python><matplotlib>
2023-03-15 16:02:19
1
402
bbasaran
75,747,174
3,087,409
Return only certain rows when reading a DataFrame from SQL
<p>I'm trying to read part of an SQL table into a pandas dataframe using SQLAlchemy, but I can't seem to find how to run the equivalent of a pandas filter at the time the table is read. I don't want to have to read the whole table and then filter, that seems like a waste of memory.</p> <p>Just using pandas I would do:<...
<python><pandas><sqlalchemy>
2023-03-15 15:59:14
1
2,811
thosphor
75,747,156
3,398,554
"Invalid JSON given in the body of the request - expected a map" when using reset_job method
<p>I am trying to change an existing job settings using the cli but when I invoke the <code>reset_job</code> method I am getting this error:</p> <pre><code>Traceback (most recent call last): File &quot;/home/vsts/work/1/s/S1.DataPlatform.DR/main.py&quot;, line 78, in &lt;module&gt; dr.experiment(host,token) Fil...
<python><json><databricks><databricks-cli><databricks-rest-api>
2023-03-15 15:57:50
1
11,991
Georgi Koemdzhiev
75,747,121
1,784,153
How to programmatically create doctrees in Sphinx?
<p>I'm creating a Sphinx extension that generates a pretty huge number of RST files.</p> <p>Since I formally know the content of them, I'd like to gain time and space by directly writing the docutils, skipping the RST generation and parsing of them.</p> <p>Is there a way to directly write doctree files and integrate th...
<python><python-sphinx><restructuredtext><docutils>
2023-03-15 15:54:51
1
1,134
Oragon Efreet
75,747,100
7,776,781
Python typing a function that converts all values in a container recursively
<p>I am dealing with an object that comes from a database that is a subclass of <code>dict</code>, but it is not defined in a way where it can take any type arguments. In my below sample I have named this type <code>SpecialDict</code>, for the purposes of what I am doing I just want to convert it to a standard <code>di...
<python><python-3.x><mypy><typing>
2023-03-15 15:53:04
1
619
Fredrik Nilsson
75,746,952
348,576
alembic_utils create_entity if not exists
<p>Similar to <a href="https://stackoverflow.com/questions/31299709/alembic-create-table-check-if-table-exists">alembic create_table, check if table exists</a> However this question is for creating entities like extensions. The solution for tables using reflection does not appear like it would work for extensions as I ...
<python><postgresql><sqlalchemy><alembic>
2023-03-15 15:39:18
1
4,045
Khorkrak
75,746,950
11,703,015
Reorganizing DataFrame (interchanging row information as columns)
<p>I have the next DataFrame.</p> <pre><code>data={ 'date':['2023-01', '2023-01', '2023-01', '2023-01', '2023-02', '2023-02', '2023-02', '2023-02', '2023-02'], 'concept':['FOOD', 'CAR', 'EDUCATION', 'ELECTRICITY', 'FOOD', 'CAR', 'TRAVEL', 'WATER', 'ELECTRICITY'], 'amount':[455.54, 237.41, 3.91, 213.2, 28.72, 422.72, 2...
<python><pandas><dataframe><group-by>
2023-03-15 15:39:10
1
516
nekovolta
75,746,623
8,543,025
Pandas: Split DataFrame between Values of a Column
<p>I have a (large) DataFrame, where one of the columns contains repeating values (see column <code>'A'</code> in the example below).<br /> I want to split the DataFrame to multiple frames, containing all rows between some value (e.g. <code>df['A'] == 0</code>) and another value (e.g. <code>df['A'] == 3</code>), but I ...
<python><pandas><dataframe>
2023-03-15 15:10:24
2
593
Jon Nir
75,746,612
15,152,059
Python: Why is Pandarallel's first worker incredibly slow?
<p>I am using pandarallel to apply a function to my pandas dataframe. Everything works as expected, but the first (out of eight) worker is extremely slow:</p> <pre><code>INFO: Pandarallel will run on 8 workers. INFO: Pandarallel will use standard multiprocessing data transfer (pipe) to transfer data between the main pr...
<python><pandas><pandarallel>
2023-03-15 15:09:22
0
345
diggi2395
75,746,506
4,618,743
Polars - Get specific columns groupby column names based on expression
<p>I have a df as:</p> <pre><code>position 1164_1164.0 1164_1164.1 yes_001.0 yes_001.1 10316.0 10316.1 10349.0 10349.1 10418.0 10418.1 4414 0 1 0 0 1 0 0 0 1 1 5295 0 1 0 0 1 0 0 0 1 1 5738 0 1 0 0 1 0 0 0 1 1 5785 0 1 0 0 1 0 0 0 ...
<python><python-polars>
2023-03-15 15:00:56
0
679
guidebortoli
75,746,426
15,959,591
Creating a dataset from 2d matrices
<p>I have a series of 2d matrices like these two:</p> <pre><code>matrix_1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) matrix_2 = np.array([[10, 11, 12], [13, 14, 15], [16, 17, 18]]) </code></pre> <p>And Each matrix has a label like:</p> <pre><code>labels = np.array([0, 1]) </code></pre> <p>I want to make a dataset fr...
<python><pandas><numpy><dataset><training-data>
2023-03-15 14:54:39
2
554
Totoro
75,746,373
5,765,649
Convert UploadFile after receiving request to pillow image
<p>I have the following code where trying to convert and UploadFile from a REST call to pillow image. The request is sent via POSTMAN with form-data in body section and a simple png image as input.</p> <pre><code>from fastapi import File, APIRouter from PIL import Image from io import BytesIO @api.post(&quot;/myEndPoi...
<python><arrays><rest><byte><fastapi>
2023-03-15 14:50:00
0
827
singa1994
75,746,367
1,655,878
Monitor continual output with no newlines from one python script by another script with subprocess module
<p>When I tried to monitor the output of one python script from another none of the standard methods I could find were working. The things complicating this case is the first script need to continue running in parrallel and I need to monitor its output live. Also, the script does not have newlines - it just updates the...
<python><subprocess><buffer>
2023-03-15 14:49:41
1
5,408
argentum2f
75,746,308
397,354
python: packaging throws InvalidVersion error for 3.9.16+
<p>When I try to install packages in my virtualenv from Pipfile.lock, I get the following InvalidVersion error message (see below) that is blocking the installation. How can I fix this to get the packages from Pipfile.lock installed?</p> <p>Note that I'm not sure where the version number 3.9.16+ is coming from. I'm usi...
<python><python-3.x><virtualenv><python-packaging>
2023-03-15 14:44:34
1
2,122
monotasker
75,746,291
827,927
Using system-installed Python libraries from docker containers
<p>I have several projects that use very large Python packages. I would like to put each project in a different docker container. To save disk space, I would like to install the large Python packages on the underlying server, so that each docker container can use them without having to install them in each container se...
<python><docker><pip>
2023-03-15 14:43:10
1
37,410
Erel Segal-Halevi
75,746,289
19,556,055
How to use a custom font in a Python visual in PowerBI
<p>I have written a Python script for a visual that I want to run as part of a PowerBI dashboard. The visual itself works, but I want to use my company's font (Euclid Flex). This font is not a standard font in matplotlib, so I would need to add it through the path to the ttf files on my computer. However, the font does...
<python><fonts><powerbi>
2023-03-15 14:43:02
1
338
MKJ
75,746,185
11,883,920
Python argparse - optional argument 'overriding' required one
<p>I'm looking for a way to have the following behavior with argparse.</p> <p>Imagine as an example that I want a program that pretty print a file given as input. And I also want an optional argument to display the list of file types that the program handles. What I'd like is the following behavior.</p> <pre class="lan...
<python><argparse>
2023-03-15 14:34:35
1
508
SPH
75,746,033
14,688,879
Python conditionally include class from command line
<p>I'm making a python script which needs to compare the stdout of two programs, it uses <code>subprocess</code> to run two binaries and collects their stdout. However, depending on the programs I am comparing the stdout format will be different. I would like to be able to define a &quot;<code>output_collector</code>&q...
<python><class><command-line-interface><stdout>
2023-03-15 14:22:11
1
342
confusedandsad
75,745,991
7,318,488
Running sampling in scikit-learn with imblearn in parallel
<p>I just noticed that the over-/undersampler methods from the imbalanced-learn (<code>imblearn</code>) package now give a future deprecation warning for running in parallel / <code>n_jobs=x</code> argument</p> <blockquote> <p>FutureWarning: The parameter <code>n_jobs</code> has been deprecated in 0.10 and will be remo...
<python><performance><imblearn>
2023-03-15 14:18:52
0
1,840
Björn
75,745,959
7,848,173
How can I set the x axis label values without it affecting my graph?
<p>Let's say I have a pandas dataframe that's a few thousand rows long and I want to plot them with Matplotlib.</p> <pre class="lang-py prettyprint-override"><code>temps = df['temperature'] plt.plot(temps) </code></pre> <p>I want the values along the x-axis to start at 0 and end with 25. Something like this:</p> <pre><...
<python><matplotlib>
2023-03-15 14:16:36
1
386
breakthatbass
75,745,746
1,050,187
Using GPU for training DQN agents with TensorFlow in Kaggle notebook: it doesn't work - but GPU quota is decreasing anyway
<p>I am training an <strong>RL model</strong> based on TensorFlow DQN agent having two NNs both with one hidden layer made of 100 neurons; all in a <strong>Kaggle notebook</strong>. Since it is used NNs and everything is under TensorFlow I take for granted that once the GPU accelerator has been activated in the noteboo...
<python><tensorflow><gpu><kaggle>
2023-03-15 13:59:17
0
623
fede72bari
75,745,738
9,385,568
How to condition lambda calculation
<p>I want to perform row=based operation only over columns matching certain column name pattern (specifically, having 'vv' at the end of the strings).</p> <p>My data sample:</p> <pre><code>df.head() per1-vh per1-vv per2-vh per2-vv per3-vh ... per19-vv per20-vh per20-vv per23-vh per23-vv 0 0.038960 0.15...
<python><pandas><numpy>
2023-03-15 13:58:48
1
873
Stanislav Jirak
75,745,646
10,802,163
Using a reflected attribute in a column_property in sqlAlchemy ORM
<p>I have a question that may have a straightforward answer, regarding SQLAlchemy ORM (using 2.0).</p> <p>I have an existing model in a PostgreSQL database, holding:</p> <ul> <li>message headers in a table named <code>single_recipient_message_header</code> (holding a primary key column named <code>id</code>). This tabl...
<python><sqlalchemy><orm>
2023-03-15 13:52:18
1
852
Pierre Massé
75,745,496
13,518,907
Twitter API / Tweepy: Retrieve tweets by author id and date/timestamp
<p>I scraped millions of tweets with the Twitter API V2 and in order to publish the data I wanted to replace all data with the tweet id, so that future users can reproduce my dataset. However I just realized that I did not save the &quot;tweet_id&quot; and I am now looking for ways to retrieve a tweet with different in...
<python><tweepy><tweets><twitterapi-python>
2023-03-15 13:38:37
1
565
Maxl Gemeinderat
75,745,411
5,932,454
Text widget expands wide without being asked to do that (other elements don't expand)
<p>Building a GUI app, and I'm using Tkinter with ttkbootstrap.</p> <p>Despite all problems and weird/inconsistent experience with Tkinter, I managed to build a functional GUI app, but I can't style it properly, because Tkinter behaves in unstable manner. The app runs ok, but my configurations and parameters for differ...
<python><python-3.x><tkinter><tkinter-text>
2023-03-15 13:31:35
1
1,575
Ilya
75,745,385
4,942,661
Incompatible types in assignment for mypy
<p>I'm adding 60 minutes in a <code>datetime</code> object. For this I'm using <code>timedelta</code>, the add works well but mypy throws me the following error:</p> <pre class="lang-none prettyprint-override"><code>error: Incompatible types in assignment (expression has type &quot;datetime&quot;, variable has type &qu...
<python><python-typing><mypy>
2023-03-15 13:29:21
2
1,022
Italo Lemos
75,745,320
5,114,342
Force update on bokeh server start
<p>I have an application running on a Bokeh Server which renders data.<br /> The computation of the data is somewhat costly, and I want to show a loading screen while it is done.<br /> When the server has opened and I am changing parameters, this works out fine so far using <code>curdoc().add_next_tick_callback()</code...
<python><bokeh>
2023-03-15 13:23:40
1
3,912
Aziuth
75,745,302
12,106,577
Default monospace font with text.usetex in matplotlib
<p>I need to use <code>rc('text', usetex=True)</code> in one of my plots, and I noticed that it changes the fonts that are used in the figure.</p> <p>Before:</p> <pre><code>from matplotlib import rc import matplotlib.pyplot as plt rc('font', **{'family': 'monospace', 'monospace': 'Deja Vu Sans Mono', 'size': 25}) rc('...
<python><matplotlib><fonts><latex>
2023-03-15 13:22:07
1
399
John Karkas
75,745,290
12,466,687
I am getting this error- "exceptions.ArrowErrorException: This app has encountered an error." on streamlit web app when deployed on cloud
<p>I am new to <strong>Streamlit</strong> and this my first app that I have uploaded on the <strong>streamlit cloud</strong>.</p> <p><strong>App</strong>: <a href="https://india-bse-stocks.streamlit.app/One_stock_analysis" rel="nofollow noreferrer">https://india-bse-stocks.streamlit.app/One_stock_analysis</a></p> <p><s...
<python><parquet><streamlit><python-polars>
2023-03-15 13:21:12
0
2,357
ViSa
75,745,242
2,523,581
Interpolate sql in SQLDataset in catalog.yml
<p>Is there a way to interpolate a SQLDataset query in <code>catalog.yml</code> passing some argument\parameter. Example:</p> <pre class="lang-yaml prettyprint-override"><code>person: type: pandas.SQLQueryDataSet sql: &quot;SELECT * FROM public.people WHERE id = ${id};&quot; credentials: db_credentials </code></p...
<python><kedro>
2023-03-15 13:15:38
1
630
Nikola
75,745,186
21,343,992
Boto3 how to attach public IP addresses to network interface
<p>I'm creating instances using Boto3's <code>create_instances()</code> function.</p> <p>According to the AWS Instances page, some network interfaces support up to fifty IPv4 addresses.</p> <p>I would like to have multiple network interfaces, each with multiple public IP addresses.</p> <ol> <li>Do I need to attach the ...
<python><amazon-web-services><amazon-ec2><boto3>
2023-03-15 13:09:40
1
491
rare77
75,745,128
11,829,999
Django Design Pattern with NoSQL DynamoDB
<p>This is a general design question as to how to best implement <strong>DynamoDB</strong> (or NoSQL/Key-Value in general) with the <strong>Django ORM</strong> for a rather large project with many django apps in it. I am planning on using this <strong>in conjunction with a regular SQL</strong> DB as well for the more &...
<python><django><design-patterns><amazon-dynamodb><pynamodb>
2023-03-15 13:04:51
0
508
sebieire
75,744,991
17,194,313
Is there any PEP regarding a pipe operator in Python?
<p>It is often common to write this type of python code:</p> <pre class="lang-py prettyprint-override"><code>def load_data(): df_ans = get_data() df_checked = check_data(df_ans) # returns df_ans or raises an error return_dict = format_data(df_ans) return return_dict </code></pre> <p>One could write the abo...
<python><pep>
2023-03-15 12:53:15
2
3,075
MYK
75,744,939
207,119
How do I assert that observe takes a queue that I can add As to, without necessarily caring what else the queue could hold?
<p>I have an asyncio.Queue with items of either A or B type. I therefore typed my class like this:</p> <pre><code>class Observer: def __init__(self): self.queue: Queue[A|B] = asyncio.Queue() </code></pre> <p>There is another method that takes the queue and calls queue.put with an A item. I'd like to type hint...
<python><types>
2023-03-15 12:48:55
1
3,680
Capi Etheriel
75,744,892
10,847,096
pandas - filter rows with same value in many columns
<p>I have a pandas DataFrame with many columns (around 100+ columns but the exact amount doesn't matter).</p> <p>Most rows have the same value in all columns, some rows have more than one unique value. <br> For example, in the following table, rows <code>1</code> and <code>2</code> have the same value in all columns an...
<python><pandas><dataframe>
2023-03-15 12:44:56
1
993
Ofek Glick
75,744,687
12,990,915
How to create a block diagonal weight tensor without torch.block_diag? (PyTorch)
<p>The following code does what I am looking for in 2D, but doesn't generalize to higher dimensions:</p> <pre><code>M = torch.block_diag(M1, M2, M3, M4) </code></pre> <p>Here <code>M1, M2, M3, M4</code> are <code>m x m</code> weight tensors.</p> <p>So I tried to create the same block diagonal weight tensor without usin...
<python><pytorch>
2023-03-15 12:27:48
1
383
user572780
75,744,669
227,755
How to speed up resample idxmax and idxmin column calculations in pandas?
<p>I have 1 minute ohlcv data in a pandas dataframe. I want to resample it with 5 minute intervals and see if the high of the 5 minutes was hit first, or the low, all the while keeping the ohlcv values.</p> <p>Input is like</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>datetime</th> <th>o...
<python><pandas><pandas-resample>
2023-03-15 12:26:11
1
11,821
nurettin
75,744,633
3,134,181
pyzmq: high water mark does not seem to block for push
<p>Thanks for reviewing, There are several thread on this topic but non was able to lead me to solution, I dont think it's duplicate, as this was not answered on many of the other threads on the subject</p> <p>I've decided to write another more up to date question we working example.</p> <p><strong>issue</strong>: sett...
<python><zeromq><pyzmq>
2023-03-15 12:21:53
1
2,156
LordTitiKaka
75,744,477
17,724,172
Pandas DataFrame Created from Dictionary vs Created from List
<p>Is there a line or two of code that would make the DataFrame created from lists behave like the one created from a dictionary?</p> <pre><code>#DataFrame created from dictionary, this works: import pandas as pd data= {'Salary': [30000, 40000, 50000, 85000, 75000], 'Exp': [1, 3, 5, 10, 25], ...
<python><pandas><dataframe><list><dictionary>
2023-03-15 12:07:32
2
418
gerald
75,744,275
3,338,917
How to wrap __getitem__ method correctly to keep square brackets functionality
<p>I have a class B that wraps the the <code>__getitem__</code> method of class A:</p> <pre><code>def my_decorator(method): def wrapper(*args, **kwargs): print('Decorator') method(*args, **kwargs) return wrapper class A: def __getitem__(self, idx): print(idx) class B: def __ini...
<python>
2023-03-15 11:47:14
1
497
danst_18
75,744,247
13,023,647
How can I save the website response in JSON format
<p>Could you tell me please, is it possible to somehow save the information in a <code>JSON</code> file with the response information from the site using the <code>selenium library</code>? <a href="https://i.sstatic.net/Ce5NR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Ce5NR.png" alt="enter image des...
<python><json><python-3.x><selenium-webdriver>
2023-03-15 11:44:15
0
374
Alex Rebell
75,744,031
14,014,925
Why do we need to write a function to "Compute Metrics" with Huggingface Question Answering Trainer when evaluating SQuAD?
<p>Currently, I'm trying to build a Extractive QA pipeline, following the <a href="https://huggingface.co/course/chapter7/7?fw=pt#question-answering" rel="nofollow noreferrer">Huggingface Course on the matter</a>. There, they show how to create a compute_metrics() function to evaluate the model after training. However,...
<python><machine-learning><nlp><huggingface-transformers><squad>
2023-03-15 11:22:10
1
345
ignacioct
75,743,961
10,750,541
Error when calling a class that uses a folder within the same directory as the class, but is applied within a file that runs in another directory
<p>I am having some trouble using a class I have created which includes a function that calls a folder of geojson files. The folder lives in the same directory as the .py file with the class and it is very important that I do not provide the full path for this folder.</p> <p>If I do provide the full path, the function ...
<python><class><directory>
2023-03-15 11:15:21
0
532
Newbielp
75,743,842
743,188
pydantic: BaseSettings with parametrized default values
<p>It appears one cannot create an <code>__init__</code> function on pydantic BaseSettings superclasses.</p> <p>I am trying to achieve this (note; for demonstration, this code is not supported in pydantic):</p> <pre><code>class MySettings(BaseSettings): def __init__(self, foo: str): self.p1 = ...
<python><pydantic>
2023-03-15 11:02:36
1
13,802
Tommy
75,743,702
6,203,350
Open3D WARNING Read PLY failed: unable to read file
<p>I'm facing an issue regarding reading <code>.ply</code> files. I double-checked that the file's path is correct. The code raises a warning and continues running. However, the results of the processing made on the <code>cloud</code> variable empty.</p> <pre><code>import open3d as o3d cloud = o3d.io.read_point_cloud(&...
<python><point-clouds><open3d>
2023-03-15 10:52:09
3
1,114
asendjasni
75,743,666
5,430,729
Customer Analysis - How to handle unbalanced data?
<p>I'm taking a data analysis course and decided to work on a customer analysis project. In the data, I have three countries:</p> <p>USA (539 unique users) BRA(385 unique users) TUR (129 unique users)</p> <p>I'm trying to analyze the country that brings in the most income, so I've decided to look at the mean revenue fo...
<python><statistics><analytics>
2023-03-15 10:49:19
0
1,565
noor h
75,743,580
5,025,650
integer to bytes - conversion problems - Python
<p>I want to send data via a serial bus to a device. Need to convert integer values to 4 bytes. So far so good.</p> <p>For most values it works, while for e.g. <code>100</code> I get results which I do not understand:</p> <pre><code>(5000).to_bytes(4, byteorder='big') -&gt; b'\x00\x00\x13\x88' </code></pre> <p>that's w...
<python><python-3.x><byte>
2023-03-15 10:41:03
1
321
Nikolaij
75,743,490
11,452,928
Adding a new layer to a stax.serial object
<p>I'd like to &quot;convert&quot; the following tensorflow code in jax:</p> <pre><code>def mlp(L, n_list, activation, Cb, Cw): model = tf.keras.Sequential() kernel_initializers_list = [] kernel_initializers_list.append(tf.keras.initializers.RandomNormal(0, math.sqrt(Cw/n_list[0]))) for l in range(1, L...
<python><tensorflow><deep-learning><neural-network><jax>
2023-03-15 10:32:33
1
753
fabianod
75,743,443
991,710
Using multiple sets of credentials in to_parquet when transfering to s3 using pandas
<p>I have a pipeline that does some data processing and then transfers parquet files to s3.</p> <p>I wanted to push this data directly to s3 without saving it locally, so I thought the best way for that would just be to use an <code>s3</code> URI in the <code>to_parquet</code> call, as follows:</p> <pre class="lang-py ...
<python><pandas><amazon-s3><boto3>
2023-03-15 10:28:35
1
3,744
filpa
75,743,370
5,019,002
How to disable SSL verification using Qt and Python?
<p>I use <code>Python</code> and <code>Qt</code> to request <code>https://some-site.com</code> like this:</p> <pre><code>def init_request(self): req = QtNetwork.QNetworkRequest(QtCore.QUrl('https://some-site.com')) self.nam = QtNetwork.QNetworkAccessManager() self.nam.finished.connect(self.handle_resp...
<python><ssl><pyqt>
2023-03-15 10:20:46
1
449
MapUser
75,743,289
15,222,211
In python flasgger, how to expand schema in web interface by default?
<p>I have started to use Swagger for API documentation. Please help me configure it. How to expand the schema in Swagger UI by default?</p> <pre class="lang-py prettyprint-override"><code>from flasgger import Swagger, swag_from from flask import Flask app = Flask(__name__) swagger = Swagger(app) @swag_from(&quot;exa...
<python><swagger-ui><flasgger>
2023-03-15 10:13:32
0
814
pyjedy
75,743,166
20,612,566
More than one ForeignKey from same Model
<p>I have a model Analytics</p> <pre><code>class StoreAnatytics(models.Model): store = models.ForeignKey(Store, on_delete=models.CASCADE, null=True) tax_sum = models.DecimalField( max_digits=10, decimal_places=2, default=0, verbose_name=&quot;tax sum&quot; ) </code></pre> <p>which has a ForeignKey t...
<python><django-models><django-rest-framework><django-filters>
2023-03-15 10:03:21
2
391
Iren E
75,743,127
1,033,591
How to sort a queryset based on objects' foreign key by sorted method?
<p>I'm happy with the instruction to do sorting:</p> <pre><code>sorted(qs, key=lambda obj: obj.name.lower(), reverse=True) </code></pre> <p>But as I need to sort the queryset by obj's foreign key's field. It looks invalid with: (Sort won't work! The order didn't change.)</p> <pre><code>sorted(qs, key=lambda obj: obj.fk...
<python><django><sorting><django-models><django-queryset>
2023-03-15 10:00:41
1
2,147
Alston
75,743,120
4,530,173
OSError: Cannot load native module 'Crypto.Hash._SHA256'
<p>I am building an app with a vue.js front end with a FastAPI back end. I was having some backend issues with Python 3.11 (uvicorn getting Internal Server Errors) so have just rolled back to 3.10 following some advice I got. However, I'm now getting crypto errors on start.</p> <p>The errors I'm getting are as follows:...
<python><fastapi><apple-m1><python-venv><pycryptodome>
2023-03-15 09:59:38
0
534
Sean
75,742,962
8,541,953
Use pip flags in a conda yml file
<p>I am creating a conda env using a <code>.yml</code> file that contains some dependencies that should be installed with pip.</p> <pre><code>name: test channels: - conda-forge dependencies: - geojson - pip - pip: - mypackage --pre </code></pre> <p>It seems that the --pre flag is not been considered as the ...
<python><pip><conda><requirements.txt>
2023-03-15 09:46:21
0
1,103
GCGM
75,742,915
4,190,657
Spark - time difference within each group
<p>Given a streaming data, how to calculate the time difference between first and last message in the same group?</p> <p>Input: message on kafka topic, 1 message per topic</p> <pre><code>MESSAGE | TIME ---------------------------- MESSAGE1 | 2019-01-01 14:00:00 # group for MESSAGE1 MESSAGE1 | 2019-01-01 14:05:0...
<python><apache-spark><pyspark><apache-kafka><apache-spark-sql>
2023-03-15 09:42:35
1
305
steve
75,742,851
1,661,465
Why Python is too slow compared to FFI
<p>To illustrate the performance difference, I compare the execution time of some function in pure Python and a function that executes the same algorithm implemented in C. First, let's measure the execution time in pure Python:</p> <pre><code>def fibonacci(n: int): if n &lt; 2: return 1 return fibo...
<python><ctypes><ffi>
2023-03-15 09:35:46
1
3,421
serghei
75,742,650
9,138,148
Django Rest Framework Model Viewsets 'POST' method not appeared in ALLOW methods after explicitly allowing it
<p>Fairly new to it but have after trying out many different solutions, I still get the following problem where the POST html form would not appear (and POST method not allowed) as seen below, all while using a root <strong>superuser</strong></p> <p><a href="https://i.sstatic.net/VuzhC.jpg" rel="nofollow noreferrer"><i...
<python><django><django-rest-framework><backend><django-guardian>
2023-03-15 09:16:14
1
463
momo668
75,742,626
4,947,216
value of selectbox is always zero - selenium python
<p>The following html code is from the website I want to automate data using selenium. There is a selectbox and selenium select the required option but the value passed in the server is always zero. Why is that?</p> <p>html:</p> <pre><code>&lt;select2 id=&quot;selectBranch&quot; name=&quot;selectBranch&quot;&gt; &lt...
<python><selenium-webdriver>
2023-03-15 09:14:35
2
3,397
Amrita Stha
75,742,615
8,461,786
Make set keep order of a tuple
<p>In the code below, how can I use keep using <code>set</code> to have unique values, but also make <code>set</code> keep the order of how the filters are typed in?</p> <pre><code>&gt;&gt;&gt; filters = ('f1', 'f2') &gt;&gt;&gt; set((*filters, 'f3')) {'f1', 'f3', 'f2'} # expected: {'f1', 'f2', 'f3'} </code></pre>
<python><data-structures><set><tuples>
2023-03-15 09:13:49
2
3,843
barciewicz
75,742,612
5,527,679
How to show raw queries(CQL) in Scylla/Cassandra
<p>I am using Scylla(Cassandra's drop in replacement) db in docker container. I am using Python driver to connect with Scylla db for querying. I need to know the exact CQL query is applying on the database engine.</p> <p>So, if there any way to print the query on the console(docker logs) or somewhere I can see and copy...
<python><cassandra><cql><scylla>
2023-03-15 09:13:20
1
1,922
Ashraful
75,742,294
10,962,766
Python joining strings fails
<p>I have an odd problem with my code and cannot find the mistake.</p> <p>I am trying the reverse names in &quot;SURNAME, First Names, Religious Title&quot; format to &quot;First Names Surname&quot; and have written the following lines of code:</p> <pre><code> try: for x in range(0, df_length): print...
<python><string><join>
2023-03-15 08:42:05
1
498
OnceUponATime
75,742,265
4,056,181
NumPy savetxt/loadtxt encoding unnecessary?
<p>I use NumPy's <a href="https://numpy.org/doc/stable/reference/generated/numpy.savetxt.html" rel="nofollow noreferrer"><code>savetxt()</code></a> and <a href="https://numpy.org/doc/stable/reference/generated/numpy.loadtxt.html" rel="nofollow noreferrer"><code>loadtxt()</code></a> to write and read data to and from di...
<python><python-3.x><numpy><encoding><utf-8>
2023-03-15 08:38:29
0
13,201
jmd_dk
75,742,147
8,721,742
export pptx by Preserving all the Master Layouts using win32com
<p>I export a slide using win32com</p> <pre><code>for master in presentation.Designs: master.Preserved = True presentation.Slides[1].Export(save_pptx_name, &quot;PPTX&quot;) </code></pre> <p>But this option doesn't export the slide with all master layouts.<br> If I have 3 master layouts, it exports the slide with ...
<python><powerpoint><pywin32><win32com><python-pptx>
2023-03-15 08:27:58
0
502
Naren Babu R
75,742,134
1,516,331
Is there a Python library that shows execution time per line?
<p>I have found this library called <code>heartrate</code> which shows how many times each line has been hit. I'm wondering if there is a similar library that can show the execution time of each line? Sometimes a single line can be a bottleneck of a program.</p> <p><a href="https://i.sstatic.net/koEhQ.gif" rel="nofollo...
<python><performance><profiling><stack-trace><execution-time>
2023-03-15 08:27:00
2
3,190
CyberPlayerOne
75,742,003
1,610,626
Streamlit Altair Bar chart Y axismax min
<p>According to this <a href="https://stackoverflow.com/questions/62281179/how-to-adjust-scale-ranges-in-altair">answer</a>, I'm suppose to use <code>scale = alt.Scae(domain=[0,1.4])</code> to scale the axis to my preference. But when I do it, the entire bar chart moves lower, hiding the entire x-axis. Why is that?</p>...
<python><streamlit><altair>
2023-03-15 08:12:03
1
23,747
user1234440
75,741,984
13,023,647
Correctly save list to CSV file
<p>Using the <code>Selenium</code> library, I get some information (a table from the site) and try to save this table to a <code>CSV file</code>.</p> <pre><code>elements_xpach_url = browser.find_element(By.XPATH, '/html/body/div[2]/span[2]/table/tbody[2]') values = re.split('\n', elements_xpach_url.text) df = pd.DataFr...
<python><python-3.x><pandas>
2023-03-15 08:09:42
1
374
Alex Rebell
75,741,820
13,742,058
How to change some settings on LabeledProgressbar in tkinter?
<p>The source code is ..</p> <pre><code>from tkinter import * import time from tkinter.ttk import Progressbar, Style def prog(): for i in range(0, 11): time.sleep(0.1) p1.step(100 / 10) txt = str(i) + '/' + str(10) s1.configure(&quot;LabeledProgressbar&quot;, text=txt) fn.u...
<python><user-interface><tkinter><label><progress-bar>
2023-03-15 07:50:34
1
308
fardV
75,741,385
4,692,826
Unable to import numbered Streamlit pages as modules
<p>I've a multi-page Streamlit application in the following structure:</p> <pre><code>src\project | Home.py | pages\ | 1_abc.py | 2_def.py | 3_ghi.py tests | test_app.py </code></pre> <p>Streamlit is able to launch and load these pages correctly. However, I'm having issues trying to import these...
<python><python-import><streamlit>
2023-03-15 06:57:41
2
3,068
thegreatjedi
75,741,221
9,798,210
Extract the words between a number and alphabets
<p>I have a string that has both numbers and words where I need to extract the specific word from the string</p> <p>below is the string</p> <p><strong>2014). Research in fields like human–computer interactio n1Andrew Burton-Jones was the accepting senior editor for this paper</strong></p> <p>I need to extract the wor...
<python><python-3.x><regex>
2023-03-15 06:37:19
1
1,835
merkle
75,741,136
139,150
Find and compare all methods recursively
<p>This python code is working correctly and it returns the similarity score of 91%</p> <pre><code>import textdistance string_a = 'Hello World!' string_b = 'Hello Word!' algs = textdistance.algorithms algs.levenshtein.normalized_similarity(string_a, string_b) </code></pre> <p>But Jaro inkler score is a lot higher at ...
<python><nlp><similarity>
2023-03-15 06:21:21
1
32,554
shantanuo
75,740,943
4,420,797
python script: Arrange text file one word in one line
<p>I have a <code>.txt</code> file that is not arranged properly and contains 11273 characters in one line I would like to arrange one character in one line and I am unable to do so because there is no space between characters. <code>가</code> is one character and I want to arrange the <code>.txt</code> file like the o...
<python><python-3.x><bash>
2023-03-15 05:47:35
1
2,984
Khawar Islam