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,548,703 | 11,462,274 | Collect selected value text from a dropdown box that doesn't change anything on the element upon click | <p>I open <a href="https://int.soccerway.com/teams/brazil/ituano-futebol-clube/340/statistics/" rel="nofollow noreferrer">this page</a> with selenium webdrive Firefox.</p>
<p>Here there is a dropdown box:</p>
<p><a href="https://i.sstatic.net/MMOg3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MMOg3.pn... | <python><selenium-webdriver><web-scraping><beautifulsoup> | 2023-02-23 18:07:42 | 1 | 2,222 | Digital Farmer |
75,548,633 | 1,870,969 | Find all disjoint subsets of a binray matrix in Pyhton | <p>I have a binary matrix, and I want to find all disjoint subsets that exist in this matrix. To clarify the problem, the matrix is a collection of image masks, masks of irregular shapes, and each disjoint subset of 1s representing a separate mask. In other words, if I have a collection of <code>N</code> disjoint subse... | <python><image-processing><matrix><disjoint-sets> | 2023-02-23 18:02:17 | 1 | 997 | Vahid S. Bokharaie |
75,548,459 | 14,269,252 | Streamlit app - if the check box is clicked, concat all the relevant Data Frames that each check box is indicating | <p>I am building an streamlit app. I put check box which indicates to each Data Frame.
Then if the check box is clicked, concat all the relevant Data Frames.</p>
<p>for instance if option 1 and 2 are clicked, I want to concat only dataframe 1 and 2.</p>
<p>I wrote some piece of code which I can not get the final result... | <python><pandas><streamlit> | 2023-02-23 17:44:23 | 2 | 450 | user14269252 |
75,548,444 | 8,895,744 | Polars dataframe drop nans | <p>I need to drop rows that have a nan value in any column. As for null values with <code>drop_nulls()</code></p>
<pre><code>df.drop_nulls()
</code></pre>
<p>but for nans. I have found that the method <code>drop_nans</code> exist for Series but not for DataFrames</p>
<pre><code>df['A'].drop_nans()
</code></pre>
<p>Pand... | <python><dataframe><python-polars> | 2023-02-23 17:43:13 | 4 | 563 | EnesZ |
75,548,255 | 2,478,485 | How to find file location using the regular expression ("*" in the path)? | <p>Following <code>cp</code> linux command is working fine to find a file <code>"/home/temp/test-1.34.56/sample"</code> to current location</p>
<p><strong>Shell command:</strong> Working fine</p>
<pre><code>cp "/home/temp/test-*/sample" "./"
</code></pre>
<p><strong>Python code:</strong>
I... | <python><python-os> | 2023-02-23 17:24:33 | 1 | 3,355 | Lava Sangeetham |
75,548,138 | 10,095,440 | Python returns changes the return dimensions if called with extra return | <p>I have this function that perform pooling on an image
'''</p>
<pre><code>def pool_forward(A_prev, hparameters, mode = "max"):
(m, n_H_prev, n_W_prev, n_C_prev) = A_prev.shape
f = hparameters["f"]
s = hparameters["stride"]
n_H = int(1 + (n_H_prev - f) / s)
n_W = int(1 + (n_W_prev - f... | <python><function><return> | 2023-02-23 17:12:11 | 0 | 317 | Ibrahim zawra |
75,548,059 | 264,136 | post value of selected item in drop down | <p>app.py:</p>
<pre><code>from flask import Flask, flash, redirect, render_template, request, url_for
app = Flask(__name__)
import requests
import json
@app.route("/", methods=['GET'])
def fill_devices():
devices = requests.request("GET", "http://10.64.127.94:5000/api/get_platforms", ... | <python><flask> | 2023-02-23 17:04:47 | 1 | 5,538 | Akshay J |
75,548,009 | 2,218,321 | Python doesn't know the class attributes, while Jupyter does | <p>I have this code from StatQuest channel. This code works in Jupyter, however when I run this in a <code>.py</code> file, it reports the error</p>
<blockquote>
<p>AttributeError: 'BasicNNTrain' object has no attribute 'w00'</p>
</blockquote>
<p>This is the code:</p>
<pre><code>import torch
import torch.nn as nn
impor... | <python><python-3.x><machine-learning><jupyter> | 2023-02-23 17:01:43 | 1 | 2,189 | M a m a D |
75,547,914 | 6,320,794 | ModuleNotFoundError: No module named 'openvino' | <p>I'd like to run some official OpenVINO samples, but I always get the following error:</p>
<pre><code>from openvino.inference_engine import IECore
ModuleNotFoundError: No module named 'openvino'
</code></pre>
<p>I created a simple script to test this behavior:</p>
<p>IECore_test.py</p>
<pre><code>import sys
from open... | <python><raspberry-pi3><pythonpath><openvino><raspbian-buster> | 2023-02-23 16:53:26 | 1 | 581 | IanHacker |
75,547,787 | 11,740,625 | AWS ECR describe_image_scan_findings does not return findings | <p>strange issue i think. I am trying to automate gathering findings from AWS ECR image scans using Python Boto3 ECR client describe_image_scan_findings. I am able to get "findingSeverityCounts" in the response but the actual detailed "findings" are not returned with the response even though the doc... | <python><amazon-web-services><boto3><amazon-ecr> | 2023-02-23 16:43:02 | 1 | 513 | Trevor Griffiths |
75,547,772 | 9,720,696 | Recovering input IDs from input embeddings using GPT-2 | <p>Suppose I have the following text</p>
<pre><code>aim = 'Hello world! you are a wonderful place to be in.'
</code></pre>
<p>I want to use GPT2 to produce the input_ids and then produce the embedding and from embeddings recover the input_ids, to do this I do:</p>
<pre><code>from transformers import GPT2Tokenizer, GPT2... | <python><pytorch><huggingface-transformers><gpt-2> | 2023-02-23 16:41:17 | 1 | 1,098 | Wiliam |
75,547,631 | 16,706,763 | Overwrite single file in a Google Cloud Storage bucket, via Python code | <p>I have a <code>logs.txt</code> file at certain location, in a <a href="https://cloud.google.com/compute/docs/instances#:%7E:text=An%20instance%20is%20a%20virtual,or%20the%20Compute%20Engine%20API." rel="noreferrer">Compute Engine VM Instance</a>. I want to periodically backup (i.e. <strong>overwrite</strong>) <code>... | <python><google-cloud-platform><google-cloud-storage><google-compute-engine> | 2023-02-23 16:28:27 | 1 | 879 | David Espinosa |
75,547,526 | 8,262,535 | How to refactoring different actions on files inside subfolders | <p>I am trying to functionalize and clean up file organization scripts. Each one is something like this:</p>
<pre><code>for dir_level in dirs:
dates = glob.glob(dir_level)
for date in dates:
files = glob.glob(date)
for file in files:
# do_stuff
</code></pre>
<p>What is a clean way... | <python><file><directory><higher-order-functions> | 2023-02-23 16:20:49 | 1 | 385 | illan |
75,547,519 | 2,601,293 | export an environment variable from python | <p>How can I export an environment variable from Python?</p>
<pre><code># I want to export a variable in python the same way you would in bash
export my_var="foo"
</code></pre>
<pre><code># The variable can be set in Python but it won't stay outside of the python session since it's not exported.
os.environ['... | <python><export> | 2023-02-23 16:20:07 | 0 | 3,876 | J'e |
75,547,505 | 9,202,041 | Function similar to xlookup in Python | <p>So I am looking for some Python code/function similar to Xlookup in excel.</p>
<p>Basically I am trying to include one new column in a dataframe (df). The values within this new column will depend on two columns of df which are time and day of week. The df looks like:
<a href="https://i.sstatic.net/7cPSP.png" rel="n... | <python><pandas><merge><xlookup> | 2023-02-23 16:19:15 | 0 | 305 | Jawairia |
75,547,503 | 1,200,914 | How do you use ANY using psycopg2? | <p>Using psycopg2, I want to do an update statement using a list of elements:</p>
<pre><code>cursor.execute("UPDATE mytable SET mycol=2 WHERE name=ANY(%s) RETURNING id",
tuple(keywords))
</code></pre>
<p>where keywords is a list of strings, since <code>name</code> is a var... | <python><sql><postgresql><psycopg2> | 2023-02-23 16:19:09 | 1 | 3,052 | Learning from masters |
75,547,485 | 12,932,447 | How to check if any async function has never been awaited? | <p>I'm testing my Python software using Pytest.
I have to call many <code>async</code> function and sometimes my tests pass even when I forgot to write the <code>await</code> keyword.</p>
<p>I would like my test to automatically fail if I call an <code>async</code> function without <code>await</code>.</p>
<p>I was thin... | <python><async-await><python-decorators> | 2023-02-23 16:18:21 | 1 | 875 | ychiucco |
75,547,449 | 11,391,711 | how to convert a string containing characters into date time using strptime in Python | <p>I'm trying to convert a string where there exists a characters between date information into a datetime. I was wondering if this is possible without using <code>replace</code> function. Suppose my string is defined as <code>'20220117A1745'</code> implying Jan. 17th, 2022 at 5:45pm.</p>
<p>If I use <code>strptime</co... | <python><regex><datetime><strptime> | 2023-02-23 16:15:33 | 2 | 488 | whitepanda |
75,547,380 | 2,109,064 | How can I configure the "Run" button next to the editor tabs in VS Code for Python files? | <p>I have the following configuration in my <code>launch.json</code>:</p>
<pre class="lang-json prettyprint-override"><code>{
"configurations":
[
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
... | <python><visual-studio-code> | 2023-02-23 16:08:24 | 2 | 7,879 | Michael |
75,547,323 | 5,568,409 | In PyMC, the "thin" argument seems no more in use. What can be put instead? | <p>Trying to understand PyMC through examples, I made a small model referring to a set of birds weight (data observed: <code>y20</code>), supposedly coming from a normal population <code>N(mu, sigma)</code>.</p>
<pre><code>import pymc as pm
import arviz as az
with pm.Model() as model:
# Priors for unknown mod... | <python><pymc> | 2023-02-23 16:02:26 | 1 | 1,216 | Andrew |
75,547,286 | 1,866,775 | What does "errorStatus code 9" mean coming from the Looker SDK for Python and how to fix it? | <p>I have</p>
<ul>
<li>some Looker Studio dashboards, accessible via: <a href="https://lookerstudio.google.com" rel="nofollow noreferrer">https://lookerstudio.google.com</a></li>
<li>enabled the Looker Studio API</li>
<li>created an OAuth client</li>
</ul>
<p>I'd like to manage the dashboards using <a href="https://pyp... | <python><looker-studio> | 2023-02-23 15:59:14 | 0 | 11,227 | Tobias Hermann |
75,547,257 | 1,196,358 | Extract frequency of sin wav from clean and noisy numpy arrays | <p>Here is a graph that shows a "control" (blue) and "recorded" (orange) signals.</p>
<p><a href="https://i.sstatic.net/s25ta.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/s25ta.png" alt="enter image description here" /></a></p>
<p>Both are numpy arrays with 10,756 items, acquired f... | <python><numpy><scipy><modulation> | 2023-02-23 15:56:22 | 1 | 1,272 | ghukill |
75,547,158 | 11,192,771 | Legend outside of plot is cut off when saving figure | <p>I made a scatterplot where I put the legend just outside (beneath) the plot. When saving my plot, the legend is cut off halfway.</p>
<p>What is the best method to fix this?</p>
<pre><code>scalebar = ScaleBar(1, location='lower right')
plt.style.use('seaborn')
plt.scatter(x['xcoord'], x['ycoord'], c='lightgrey', s=... | <python><matplotlib> | 2023-02-23 15:47:35 | 1 | 425 | TvCasteren |
75,546,893 | 10,337,789 | Get all parent topics in recursive query in flask with m2m relationship | <p>I have two tables with many to many relationship.</p>
<p>The Topic table is:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>parent</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Mathematics</td>
<td>0</td>
</tr>
<tr>
<td>2</td>
<td>Algebra</td>
<td>1</td>
</tr... | <python><sqlalchemy> | 2023-02-23 15:27:20 | 0 | 622 | Владимир Кузовкин |
75,546,638 | 5,095,986 | Why is pip on version 3 and python -V on python 2.7 | <pre><code>~$ export PATH="$PATH:/usr/bin/python"
:~$ pip --version
pip 21.3.1 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
~$ python -V
Python 2.7.17
</code></pre>
<p>Why is pip on python3? I want pip to be on python2.</p>
<p>I have tried adding path of python2 to the PATH variable but it di... | <python><pip> | 2023-02-23 15:07:33 | 0 | 1,171 | Shivangi Singh |
75,546,632 | 12,304,000 | You're trying to access a column, but multiple columns have that name | <p>I am trying to join 2 dataframes such that both have the following named columns. What's the best way to do a LEFT OUTER join?</p>
<pre><code>df = df.join(df_forecast, ["D_ACCOUNTS_ID", "D_APPS_ID", "D_CONTENT_PAGE_ID"], 'left')
</code></pre>
<p>Currently, I get an error that:</p>
<pre>... | <python><pyspark><left-join><outer-join><foundry-code-repositories> | 2023-02-23 15:06:59 | 1 | 3,522 | x89 |
75,546,587 | 4,391,249 | Subprocess Popen stdout is empty if the subprocess is a Python script | <p>Here is some code that should print numbers 0 through 4 to the terminal: (adapted from <a href="https://stackoverflow.com/a/59291466/4391249">https://stackoverflow.com/a/59291466/4391249</a>)</p>
<pre class="lang-py prettyprint-override"><code>import os
import time
import subprocess
cmd = 'python', '-c', 'import ti... | <python><subprocess> | 2023-02-23 15:02:41 | 1 | 3,347 | Alexander Soare |
75,546,550 | 4,954,037 | python function or operation that returns float("nan") | <p>the <a href="https://en.wikipedia.org/wiki/IEEE_754" rel="nofollow noreferrer">IEEE Standard for Floating-Point Arithmetic (IEEE 754)</a> requires the existence of a <code>float</code> (or two...) that is called <code>nan</code> (not a number).</p>
<p>there are two ways to get <code>nan</code> (that i know of)</p>
<... | <python><python-3.x><floating-point> | 2023-02-23 14:59:27 | 2 | 47,321 | hiro protagonist |
75,546,543 | 8,412,665 | How to average based on data range in a difference table in Pandas | <p>With two tables, <code>Values</code> and <code>dates</code>, I would like to get the average value between the date ranges.
<code>Values</code> looks like:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Date</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>2023-01-01 10:00</td>
<td>1... | <python><pandas><group-by> | 2023-02-23 14:59:02 | 2 | 518 | Beavis |
75,546,385 | 10,792,871 | Normalizing a Nested JSON in Python and Converting it to a Pandas Dataframe | <p>I have created a simpler version of some JSON data I've been working with here:</p>
<pre><code>[
{
"id": 1,
"city": "Philadelphia",
"Retaillocations": { "subLocation": [
{
"address": "1235 Passyunk Ave&qu... | <python><json><python-3.x><pandas><json-normalize> | 2023-02-23 14:46:13 | 1 | 724 | 324 |
75,546,371 | 8,318,946 | Django taggit returns empty list of tags in search view | <p><strong>Explanation</strong></p>
<p>I would like to add to <code>SearchView</code> a filter that checks tags in my models and if <code>raw_query</code> contains tag then it displays the list of relevant objects.</p>
<p>Each model contains title and tags fields. I am using django taggit with autosugest extension to h... | <python><django><django-taggit> | 2023-02-23 14:45:08 | 0 | 917 | Adrian |
75,546,338 | 12,435,792 | Use list comprehension to extract value from another dataframe based on a key from another dataframe | <p>I have a dataframe test which has a column <code>company</code>.
I have another dataframe bsr which has 2 columns, <code>market</code> and <code>region</code>, both contain the same data type.</p>
<p>I want to extract the region of each company.</p>
<p>For that I wrote the following code:</p>
<pre class="lang-py pre... | <python><pandas> | 2023-02-23 14:41:45 | 1 | 331 | Soumya Pandey |
75,546,202 | 2,005,415 | How to create a limited size cache shared by multiple processes in Python | <p>I'm trying to use a cache shared by multiple processes, using <code>multiprocessing.Manager</code>'s <code>dict</code>. The following demo gives some context (adopted from <a href="https://stackoverflow.com/a/8533626/2005415">this answer</a>):</p>
<pre><code>import multiprocessing as mp
import time
def foo_pool(x, ... | <python><caching><multiprocessing> | 2023-02-23 14:30:03 | 1 | 3,356 | Jason |
75,546,121 | 13,647,125 | Fitz draw_rect coordination | <p>I am struggling with right coordination of square to overlap the name field in pdf file.
This is my pdf file</p>
<pre><code>https://docdro.id/wiAwsH8
</code></pre>
<p>I would like to get this</p>
<p><a href="https://i.sstatic.net/phZg7.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/phZg7.jpg" alt="en... | <python><pdf> | 2023-02-23 14:24:24 | 1 | 755 | onhalu |
75,546,062 | 19,079,397 | How to append list of values into a desired string format? | <p>I have two lists like below. I want to convert the list of values into a desired string format like <code>'123,1345;2345,890;'</code>. I tried to use loop and tried to append as list but how do I convert that into a string format.</p>
<pre><code>l1 = [123,4567,80,3456,879]
l2=[98,789,5674,678,9087]
out=[]
for i,j i... | <python><string><list><append> | 2023-02-23 14:19:31 | 2 | 615 | data en |
75,545,992 | 8,115,653 | Custom calendar in Pandas make iterable | <p>trying to make the class iterable for the below NYSE custom calendar using <code>pandas</code>, say to run this check:</p>
<pre><code>nyse_cal = NYSECalendar()
for date in nyse_cal:
print(date)
</code></pre>
<p>but the statement <code>last_holiday = self.rules[-1]</code> produces <code>TypeError: 'method' is not... | <python><pandas> | 2023-02-23 14:13:58 | 1 | 1,117 | gregV |
75,545,957 | 3,294,378 | AWS S3 Pre Signed Post with custom domain | <p>I am looking for a way to use a custom domain with the S3 pre signed post functionality. Right now the URL returned is the default S3 bucket URL e.g. <code>https://mybucket.s3.amazonaws.com/</code>. Using python I generate the pre-signed post data as such:</p>
<pre class="lang-py prettyprint-override"><code>content_... | <python><amazon-web-services><amazon-s3><boto3> | 2023-02-23 14:11:29 | 1 | 1,060 | Jelle |
75,545,944 | 12,439,683 | Efficient algorithm for online Variance update over batched data / color channels | <p>I have a large amount of multi-demensional data (images) and want to calculate the variance of an axis (color channel) across all of them. Memory wise I cannot create a large array to calculate the variance in one step. I therefore need to load the data in batches and update the current variance somehow in an online... | <python><math><statistics><variance><online-algorithm> | 2023-02-23 14:10:26 | 1 | 5,101 | Daraan |
75,545,793 | 352,319 | Getting help on matching modules in Zeppelin/Python | <p>We're setting up a new Zeppelin 0.10.0 environment running Python 3.7. I'm new to Zeppelin and fairly new to Python and I want to see what modules are already loaded. I start off asking for help:</p>
<pre><code>%livy.pyspark
help()
</code></pre>
<p>I get a response:</p>
<blockquote>
<p>... less relevant text omitt... | <python><python-3.x><apache-zeppelin> | 2023-02-23 13:58:54 | 0 | 5,249 | kc2001 |
75,545,718 | 10,159,065 | Convert string to dictionary in a dataframe | <p>I have a dataframe that looks like this</p>
<pre><code>df = pd.DataFrame({'col_1': ['1', '2', '3', '4'],
'col_2': ['a:b,c:d', ':v', 'w:,x:y', 'f:g,h:i,j:']
})
</code></pre>
<p>Datatype of col_2 is currently string. I want to extract the first key and first value from col_2 as co... | <python><pandas><string><dataframe><numpy> | 2023-02-23 13:51:29 | 2 | 448 | Aayush Gupta |
75,545,599 | 532,054 | Django get duration between now and DateTimeField | <p>I have a Django model with the following field:</p>
<pre><code>date = models.DateTimeField('start date')
</code></pre>
<p>I want to create a duration function that returns the duration between now and the date in the format "hours:minutes"</p>
<p>How can we achieve this?</p>
| <python><django><date> | 2023-02-23 13:39:01 | 1 | 1,771 | lorenzo |
75,545,443 | 10,428,677 | Extract all entries from a pandas df where the values are the same across all years | <p>I have a dataframe that looks like this (with many more other countries, this is a sample):</p>
<pre><code>df_dict = {'country': ['Japan','Japan','Japan','Japan','Japan','Japan','Japan', 'Greece','Greece','Greece','Greece','Greece','Greece','Greece'],
'year': [2016, 2017,2018,2019,2020,2021,2022,2016, 201... | <python><pandas> | 2023-02-23 13:23:05 | 1 | 590 | A.N. |
75,545,413 | 1,697,288 | sqlalchemy MSSQL Cannot insert/update datetime2 | <p>I need to bulk insert & update data in MSSQL using sqlalchemy 2.0, it's working but is always ignoring my two datetime fields without error, I end up with NULL in those fields</p>
<pre><code>import datetime
from sqlalchemy import DateTime, ForeignKey, String, insert, update
from sqlalchemy.orm import Declarative... | <python><sql-server><sqlalchemy> | 2023-02-23 13:20:37 | 1 | 463 | trevrobwhite |
75,545,410 | 7,380,417 | OpenSSL.crypto.Error when trying to load certificate from Azure Key Vault | <p>I need to implement certificate-based authentication for web API hosted in app service on Azure. To do this I firstly generated <code>.crt</code> certificate file and private key <code>.key</code> file like this:</p>
<pre class="lang-bash prettyprint-override"><code>openssl req -x509 -newkey rsa:4096 -sha256 -days ... | <python><azure><openssl><azure-keyvault><pkcs> | 2023-02-23 13:20:32 | 1 | 2,201 | devaerial |
75,545,379 | 9,403,950 | What is the fastest way to shallow copy a (`__slots__`) object in python? | <p>‘Fastest’ as in we’re trying to squeeze out every nanosecond. If the number of attributes is relevant, then let’s say it has one attribute.</p>
<p>Assume we want to shallow copy <code>c</code>:</p>
<pre class="lang-py prettyprint-override"><code>class C:
__slots__ = (‘foo’,)
def __init__(self, foo):
... | <python><python-3.x> | 2023-02-23 13:17:45 | 0 | 317 | Liam |
75,545,370 | 1,729,210 | How to configure the entrypoint/cmd for docker-based python3 lambda functions? | <p>I switched from a zip-based deployment to a docker-based deployment of two lambda functions (which are used in an API Gateway). Both functions where in the same zip file and I want to have both functions in the same docker-based container (meaning I can't use the <code>cmd</code> setting in my Dockerfile (or to be p... | <python><amazon-web-services><docker><aws-lambda><aws-cloudformation> | 2023-02-23 13:17:09 | 1 | 659 | user1729210 |
75,545,320 | 8,895,744 | Modify some rows of one column based on conditions from another column using Polars | <p>Given the data frame below, I would need to modify column 'A' using conditions of 'B'. Pandas expression for that is presented with <code>.loc</code></p>
<pre><code>df = pl.DataFrame(
{
"A": [1, 1, 1, 1, 1],
'B': [1, 2, 2, 3, 3]
}
)
df.loc[df['B'] == 2, 'A'] = 100
</code></pre>
<p>I have a... | <python><python-polars> | 2023-02-23 13:12:20 | 1 | 563 | EnesZ |
75,545,314 | 822,896 | Python Pandas DataFrame Merge on Columns with Overwrite | <p>Is there a way to merge two Pandas DataFrames, by matching on (and retaining) supplied columns, but overwriting all the rest?</p>
<p>For example:</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
df1 = pd.DataFrame(columns=["Name", "Gender", "Age", "LastLogin... | <python><pandas><dataframe> | 2023-02-23 13:11:38 | 1 | 1,229 | Jak |
75,545,272 | 11,951,910 | How can I use a custom sort order for dict keys with the standard library json module? | <p>I am trying to output a dictionary as JSON, using python 2.7 (this can not be upgraded)
The keys in the <code>data</code> are strings that contain numbers, like <code>'item_10'</code>, and have an arbitrary order. For example, this code generates some test data:</p>
<pre><code>import random
data = {}
numbers = list... | <python><json><dictionary> | 2023-02-23 13:08:27 | 2 | 718 | newdeveloper |
75,544,918 | 9,121,235 | Python Fuzzywuzzy does not give a similarity of 100 for identical terms | <p>Why is Fuzzywuzzy library not giving me back proper results for terms which are identical?
I would assume a similarity of 100, or at least 95 if 100 is not working. Am I missing something?
Maybe there's a better fuzzy matching algorithm?</p>
<p>My code:</p>
<pre><code>from fuzzywuzzy import process
import pandas as ... | <python><fuzzy-search><fuzzywuzzy> | 2023-02-23 12:35:02 | 0 | 455 | smartini |
75,544,869 | 4,451,315 | Propagate error in function which returns tuple of int | <p>Here's a file <code>t.pyx</code> I've written:</p>
<pre class="lang-py prettyprint-override"><code># cython: language_level=3
cdef int foo(val: int) except? -1:
if val != 42:
raise ValueError("foo")
return 0
cpdef (int, int) bar(val: int):
res = foo(val)
return res, res+1
</code>... | <python><cython> | 2023-02-23 12:31:09 | 2 | 11,062 | ignoring_gravity |
75,544,826 | 3,045,351 | Itertools Group list of dicts of variable length by key/value pairs | <p>I have this input object:</p>
<pre><code>vv = [{'values': ['AirportEnclosed', 'Bus', 'MotorwayServiceStation']},{'values': ['All']}]
</code></pre>
<p>...there can be variable numbers of dicts present, but all dicts will always have the key 'values' and values populated for this.</p>
<p>The type of value assigned to ... | <python><python-3.x><python-itertools> | 2023-02-23 12:27:00 | 1 | 4,190 | gdogg371 |
75,544,822 | 14,594,208 | How to access custom dataframe accessor's namespace? | <p>According to Pandas <a href="https://pandas.pydata.org/docs/development/extending.html" rel="nofollow noreferrer">docs</a> it is possible to register custom accessors like below:</p>
<pre class="lang-py prettyprint-override"><code>@pd.api.extensions.register_dataframe_accessor("geo")
class GeoAccessor:
... | <python><pandas><dataframe> | 2023-02-23 12:26:25 | 1 | 1,066 | theodosis |
75,544,795 | 9,403,950 | Is there a way to cache a global as a local const in cpython? | <p>Is there a way to define a const object from a pre-existing global variable inside a function (in cpython) such that it gets loaded with the <code>LOAD_CONST</code> instruction (short of modifying and recompiling the interpreter yourself)?</p>
<p>Assuming the value of the global doesn’t change and we only care about... | <python><python-3.x> | 2023-02-23 12:24:12 | 1 | 317 | Liam |
75,544,762 | 5,269,959 | How to encrypt pandas Dataframe with pyarrow and parquet | <p>I would like to encrypt pandas dataframe as parquet file using the modular encryption. I tought the best way to do that, is to transform the dataframe to the pyarrow format and then save it to parquet with a ModularEncryption option. Something like this:</p>
<pre><code>import pandas as pd
d = {'col1': [1, 2], 'col2'... | <python><pandas><encryption><parquet><pyarrow> | 2023-02-23 12:21:30 | 3 | 538 | seb2704 |
75,544,728 | 1,424,395 | multivariate Kernel Density Estimator with independent bandwidth for each dimension | <p>I found several types of KDEs implementations on python, but still I cannot find one version that is flexible regarding the kernel used and that can use different bandwidth per dimension. This actually is available in MATLAB's <code>mvksdensity()</code>.</p>
<pre><code>scipy.stats.multivariate_normal
scipy.stats.kde... | <python><scikit-learn><statsmodels><scipy-optimize><kernel-density> | 2023-02-23 12:17:54 | 0 | 1,827 | myradio |
75,544,652 | 7,211,014 | bash print multiline variable, but also use it as a command for python? | <p>I want to create a variable that is human readable with bash, but then also be able to run the variable as a python script.</p>
<pre><code>run_cmd(){
echo "[+] Creating stuff"
run_command="$script 10.10.10.10 \\
--config $settings \\
--cid $cid \\
-v"
e... | <python><bash><arguments><echo><newline> | 2023-02-23 12:10:39 | 1 | 1,338 | Dave |
75,544,534 | 1,773,702 | ModuleNotFoundError: No module named 'google.ads.googleads.v10' | <p>We use a python script to connect to Google Ads API and consume its REST operations.</p>
<p>All of a sudden the working script has started giving error with below message:</p>
<pre><code>from google.ads.googleads.v10.enums.types import offline_user_data_job_status
ModuleNotFoundError: No module named 'google.ads.goo... | <python><google-ads-api> | 2023-02-23 12:00:00 | 0 | 949 | azaveri7 |
75,544,224 | 2,612,592 | Minimize class method with class attributes as parameters | <p>How do I make that a class like this:</p>
<pre><code>class Conic:
def __init__(self, x: float, y: float):
self.x = x
self.y = y
def get_value(self) -> float:
return (self.x - 2) ** 2 + (self.y + 3) ** 2
def calibrate(self):
pass
</code></pre>
<p>Calibrates its att... | <python><class><oop><optimization><calibration> | 2023-02-23 11:30:58 | 1 | 587 | Oliver Mohr Bonometti |
75,543,920 | 59,300 | LDAP3 search when Active Directory accounts expire | <p>I want to specify an <a href="https://ldap3.readthedocs.io/en/latest/" rel="nofollow noreferrer">LDAP3</a> search against an Active Directory server which returns when the PW of an account expires.</p>
<pre><code>server = Server(server_name, port=636, use_ssl=True, get_info=ALL)
conn = Connection(server, user='{}\\{... | <python><active-directory><ldap> | 2023-02-23 11:03:39 | 1 | 7,437 | wishi |
75,543,832 | 7,760,910 | Python unittest gives file not found exception | <p>I have a core class which is as below:</p>
<pre><code>class GenerateDag(object):
def __int__(self):
pass
def generate_dag(self, manifest: dict):
"""
:return: bytes of the file passed
"""
with open('../../resources/dag.py', 'rb') as f:
... | <python><python-3.x><python-unittest> | 2023-02-23 10:55:30 | 1 | 2,177 | whatsinthename |
75,543,822 | 12,304,000 | grouping expressions sequence is empty | <p>This pyspark code with <strong>df.select</strong> works fine.</p>
<pre><code>def dev_prev_month(cleaned):
df = cleaned
df = df.select(
F.coalesce(
_sum(
F.when(
(F.col("ORDERS_VIA_ARTICLE") > 0) &
(
(F.col("... | <python><pyspark><group-by><aggregate-functions><foundry-code-repositories> | 2023-02-23 10:54:25 | 1 | 3,522 | x89 |
75,543,492 | 10,232,932 | Open a website in AWS SageMaker Notebooks | <p>I am using Amazon SageMaker and running a notebook instance in it. In my notebook instance I created a conda_python3 file and try to running the following command (which is running on my local machine):</p>
<pre><code>import os
for i in range(1):
os.system("start \"\" https://google.com")
os... | <python><amazon-web-services><amazon-sagemaker> | 2023-02-23 10:25:33 | 1 | 6,338 | PV8 |
75,543,424 | 15,991,297 | Counting Groups with Same Datetime and Comparing Count with Other Groups in Dataframe | <p>Below is an extract from a dataframe. For each MarketName there should be two Date/Times as in "Ascot - 12:35 Ascot 22nd Jan 1m7f Hrd" in the extract below. Sometimes data is missing from either the earliest or latest Date/Time (as in "Ascot - 13:10 Ascot 22nd Jan 3m Hcap Chs") so I want to coun... | <python><pandas> | 2023-02-23 10:18:54 | 2 | 500 | James |
75,543,387 | 1,438,934 | Need to write custom User model in DJango and return pre stored json file in response | <p>Just started learning Python/Django 5 days back. Need to write an API where it gets 'username', 'password', 'password2' in request and it should store username in some User object. And if the username already exists in User, then just return simple error message: "username is duplicate".</p>
<p>I am using... | <python><django> | 2023-02-23 10:15:46 | 1 | 1,182 | Anish Mittal |
75,543,376 | 8,794,133 | Generating a 3D mesh from a string in Python | <p>I am Looking for a way to turn a text string into a 3D mesh, that could then be further manipulated using relevant python libraries, such as pyMesh or open3D. I thought this should be a common feature but this proves more difficult than imagined.</p>
| <python><3d><mesh><open3d><pymesh> | 2023-02-23 10:14:27 | 1 | 594 | IamTheWalrus |
75,543,343 | 14,269,252 | Streamlit multiselect, if I don't select anything, doesn't show data frame | <p>I am building a Streamlit app. Part of my code includes <code>multiselect</code> as follows, when I dont select anything in <code>multiselect</code>, I want to show whole data frame without any filtration, but it doesn't show any data, how should I modify the code?</p>
<pre class="lang-py prettyprint-override"><code... | <python><dataframe><streamlit> | 2023-02-23 10:11:46 | 1 | 450 | user14269252 |
75,543,332 | 6,803,114 | Databricks notebook ipywidgets not working as expected | <p>I am working on Azure databricks(IDE). I wanted to create a button which takes a text value as input and on the click of a button a function needed to be run which prints the value entered.
For that I created this code:</p>
<pre><code>import ipywidgets as widgets
def my_function(param):
print(f"The paramet... | <python><databricks><azure-databricks> | 2023-02-23 10:11:07 | 1 | 7,676 | Shubham R |
75,542,778 | 14,752,392 | DRF - list of optionals field in serializer meta class | <p>I have a model with about 45 fields that takes information about a company</p>
<pre><code>class Company(models.Model):
company_name = models.Charfield(max_length=255)
.
.
.
last_information = models.Charfield(max_lenght=255)
</code></pre>
<p>I also have a serializer that looks like so,</p>
<pre><... | <python><django><django-models><django-rest-framework><django-serializer> | 2023-02-23 09:20:27 | 4 | 918 | se7en |
75,542,704 | 11,644,523 | Extract year, month, day from a string with forward slashes | <p>Given a string like
<code>s3://bucket/year=2023/month=02/day=22/test.csv</code>,
I would like to return the <code>year</code>, <code>month</code>, <code>day</code> as separate variables.</p>
<p>Is there some regex that can search for this? Assuming the pattern is always the same. I tried with <code>datetime</code> m... | <python> | 2023-02-23 09:13:37 | 1 | 735 | Dametime |
75,542,637 | 486,181 | prettier throws error `Failed to resolve a parser` | <p>Prettier throws error "failed to resolve a parser". Prettier is selected in Workspace, User and Python > Workspace, so I'm out of ideas why the error is thrown...</p>
<pre><code>["INFO" - 08:57:18] File Info:
{
"ignored": false,
"inferredParser": null
}
["WARN"... | <python><visual-studio-code><vscode-extensions><prettier> | 2023-02-23 09:08:01 | 1 | 1,512 | Ajax |
75,542,507 | 9,640,238 | NLP: Calculate text time to read | <p>I need to calculate estimated reading time for a few hundred Word documents. I couldn't identify a method to do so in common NLP libraries such as <code>spaCy</code> and <code>nltk</code>.</p>
<p>Any hint?</p>
| <python><nlp> | 2023-02-23 08:55:59 | 0 | 2,690 | mrgou |
75,542,501 | 14,667,788 | How to turn pandas df into 2D form | <p>I have a following dataset:</p>
<pre class="lang-py prettyprint-override"><code>
import pandas as pd
input = {"Product" : ["Car", "", "", "House", "", "", ""], "Name" : ["Wheel", "Glass", "Seat",... | <python><pandas> | 2023-02-23 08:55:31 | 1 | 1,265 | vojtam |
75,542,366 | 4,872,985 | Pytorch - What module should I use to multiply the output of a layer using Sequential? | <p>While defining a neural network using <em>nn.Module</em>, in the forward function I can multiply the output of the final layer using:</p>
<pre><code>def forward(self, x):
...
x = torch.mul(x, self.max_action)
return x
</code></pre>
<p>I am trying to do the same but instead using <em>nn.Sequential</em> me... | <python><pytorch> | 2023-02-23 08:40:34 | 1 | 616 | Fabio Olivetto |
75,542,224 | 13,612,961 | RuntimeError: Failed to add edge detection - On Raspberrypi | <p>I'm working on a button example on a Raspberry Pi. I found <a href="https://raspberrypihq.com/use-a-push-button-with-raspberry-pi-gpio/" rel="noreferrer">this</a> tutorial on the internet, and I was trying to complete it 1 by 1. The code is exactly the same, and I'm sure I used the correct pins.</p>
<p>This is what ... | <python><raspberry-pi><gpio><edge-detection> | 2023-02-23 08:24:43 | 3 | 569 | Lumberjack |
75,542,143 | 9,850,681 | Sphinx errors with Pydantic settings, does not generate documentation | <p>I am trying to generate documentation with Sphinx (apidoc) but all the files that call the settings file, are not documented.</p>
<p>When I run the <code>make html</code> command I get these error messages</p>
<pre><code>#...
File "pydantic/env_settings.py", line 39, in pydantic.env_settings.BaseSettings.... | <python><python-sphinx><pydantic> | 2023-02-23 08:15:57 | 0 | 460 | Plaoo |
75,542,120 | 14,269,252 | Insert image on the top of side bar in stream lit app | <p>Is there a way to insert image on the top of side bar in Streamlit app? I used the code as follows but it shows the image below the menu in sidebar.</p>
<pre class="lang-py prettyprint-override"><code>st.sidebar.image("st.png", width=70)
</code></pre>
| <python><streamlit> | 2023-02-23 08:13:56 | 1 | 450 | user14269252 |
75,541,891 | 7,215,853 | What is an efficient way to transfer an relation defining id between two types of (JSON)entities in Python3? | <p>I have to types of entities contacts and clubs.
Both are represented as a json object. Contacts have unique id's and clubs also have unique id's. Contacts and Clubs are stored in individual lists.</p>
<p>The relation between those two is, that each club can have one or more contacts.
This relation is currently store... | <python><json> | 2023-02-23 07:46:22 | 1 | 320 | MrTony |
75,541,888 | 1,852,526 | Python subprocess open command prompt in new window as administrator and execute command | <p>I have the following code, where I am trying to open command prompt in a separate window as administrator and want to execute a command. I am trying to follow the <a href="https://www.xingyulei.com/post/py-admin/index.html" rel="nofollow noreferrer">tutorial</a> here, but it says:</p>
<blockquote>
<p>FileNotFoundErr... | <python><subprocess><command-prompt> | 2023-02-23 07:46:05 | 0 | 1,774 | nikhil |
75,541,730 | 2,998,077 | Month column in dataframe, plus number of months, to compare with current calendar month | <p>A column in dataframe looks like month, I want to use it to plus a month, as a 'future' month, then to compare this 'future' month with current (calendar) month.</p>
<pre><code>import pandas as pd
from io import StringIO
import numpy as np
from datetime import datetime
csvfile = StringIO(
"""Name Yea... | <python><pandas><dataframe><numpy><datetime> | 2023-02-23 07:27:07 | 4 | 9,496 | Mark K |
75,541,631 | 14,673,832 | Printing binary tree after initialising gives None value | <p>I have a simple binary tree. I have intialized it using TreeNode class, but while printing out the values from the tree, it gives me None value as well. How to mitigate this?</p>
<p>The code snippet is as follows:</p>
<pre><code>class TreeNode:
def __init__(self, root=None, left = None, right= None):
sel... | <python><graph><binary-tree><nodes> | 2023-02-23 07:15:17 | 2 | 1,074 | Reactoo |
75,541,607 | 17,973,259 | Pygame animation now showing on screen | <p>In my game there is an animation of "exploding" when the ship hits something and loses 1 hp. This is the code that triggers <code>self.first_player_ship.explode()</code>:</p>
<pre><code> def _first_player_ship_hit(self):
"""Respond to the first player ship being hit by an alien."&qu... | <python> | 2023-02-23 07:12:39 | 1 | 878 | Alex |
75,541,586 | 4,907,187 | How to access Oracle DB Link in Django models? | <p>Im trying to access table from different databases using database Link. Im getting error <code>database link not found</code></p>
<p>My model looks like this:</p>
<pre><code>from django.db import models
# Create your models here.
class Customer(models.Model):
cust_num = models.CharField(max_length=20)
custo... | <python><django> | 2023-02-23 07:09:58 | 1 | 429 | arisalsaila |
75,541,272 | 10,962,766 | Copying values from dataframe cell to other cell in the same row | <p>I have a problem with chain-indexing in a Pandas dataframe, which I know has to be avoided.</p>
<p>I am checking a dataframe for identical start and end dates in two different columns. If they are identical, I want to read the same value to a third column in the same row, which is the exact date column.</p>
<p>The d... | <python><pandas><indexing> | 2023-02-23 06:25:23 | 1 | 498 | OnceUponATime |
75,541,013 | 9,861,647 | Jupyter Notebook Print unnecessary Index and results | <p>I have this code in Geopandas in a jupyter notebook</p>
<pre><code>import geopandas as gpd
gdf = gpd.read_file("adm4.shp")
gdf['coordinates'] = gdf.geometry.apply(lambda x: (x.centroid.y, x.centroid.x))
df['coordinates'] = list(zip(df.latitude_geopy, df.longitude_geopy))
joined = gpd.sjoin(gdf, df, how=... | <python><pandas><jupyter-notebook><geopandas> | 2023-02-23 05:47:39 | 0 | 1,065 | Simon GIS |
75,540,802 | 14,109,040 | Convert dictionary values to floats based on key | <p>I have the following dictionary:</p>
<pre><code>{'Month': 'July', '# short': 8, '# cancelled': 6, '% TT delivered': '0.9978408389882788', '% ontime': '0.85284108487160981', '% cancelled': '0.0018507094386181369', '% short': '0.0024676125848241827', '# scheduled': 3242, '# scheduled': 9697, '# ontime': 8270, 'Route':... | <python><dictionary> | 2023-02-23 05:14:22 | 1 | 712 | z star |
75,540,692 | 8,884,612 | Run kmeans text clustering with pytorch in gpu to create more than 1000 clusters | <p>I am trying to implement kmeans clustering using kmeans-pytorch but I am getting memory error when I am try to create more than 10 clusters</p>
<p>My dataset is having 7000 text records</p>
<p>Here is my code snippet</p>
<pre><code>import torch
from sklearn.feature_extraction.text import TfidfVectorizer
from kmean... | <python><pytorch><gpu><k-means> | 2023-02-23 04:54:59 | 1 | 579 | Tanmay Shrivastava |
75,540,685 | 2,458,922 | Tensor, How to Gather Values of a List of Index? | <pre><code>t2 = tf.constant([[0, 11, 2, 3, 4],
[5, 61, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19]])
valid_mask = t2 <= 10
validIndex = tf.where(valid_mask)
print('validIndex',validIndex) # Expectation = Reality
print()
print('Final Output',tf.gather... | <python><tensorflow><tensor> | 2023-02-23 04:53:40 | 1 | 1,731 | user2458922 |
75,540,444 | 412,234 | Python efficently convert string to numpy integer array, character by character | <p>NumPy can work with <a href="https://numpy.org/doc/stable/reference/generated/numpy.fromstring.html" rel="nofollow noreferrer">comma separated lists</a> but that is a different task.
I want to convert each <em>character</em> of a string into an entry of a np array:</p>
<pre><code>x = np.frombuffer('fooλ'.encode(), d... | <python><numpy><performance><encoding><utf-8> | 2023-02-23 03:59:46 | 1 | 3,589 | Kevin Kostlan |
75,540,423 | 14,109,040 | Replacing the keys in a dictionary based on the values of another | <p>I have two dictionaries (Dic1 and Dict2)</p>
<pre><code>Dict1 = {'M0': 399, 'M1': 71, 'M2': '0.979827269', 'M3': '0.84576281', 'M4': '0.011849132', 'M5': '0.066588785'}
Dict2 = {'M0': 'KPI1', 'M1': 'KPI2', 'M2': 'KPI3', 'M3': 'KPI4', 'M4': 'KPI5', 'M5': 'KPI6'}
</code></pre>
<p>I want to update the keys of Dict1 bas... | <python><dictionary> | 2023-02-23 03:54:15 | 1 | 712 | z star |
75,540,286 | 19,316,811 | Indexing all items excluding an index from the back | <p>I want to slice a numpy array such that an index, -7 for example, is excluded. What is the best way to do this?</p>
| <python><numpy> | 2023-02-23 03:25:07 | 1 | 457 | PeriodicParticle |
75,540,267 | 18,148,705 | Generate epoch time | <p>I want to convert my time_stamp string into epoch time but I am not good with datetime and related modules, so getting a little confused. I saw many solutions but none of them had date_time format like mine.</p>
<p>my date_time is in the below format
date_time = "2023-01-1T17:35:19.818"</p>
<p>How can I ... | <python><datetime><unix-timestamp> | 2023-02-23 03:19:44 | 1 | 335 | user18148705 |
75,540,264 | 1,424,739 | Finding high points in a zigzag plot with only one segment on the right | <p>For a zigzag line graph like the following (nearby points are guaranteed to be either lower or higher, depending the center points are high or low), I want to find out all the high points where there is only one segment of the zigzag line on their right.</p>
<p>In this example, those points are indicated by the left... | <python><r><algorithm><data-structures><geometry> | 2023-02-23 03:19:33 | 2 | 14,083 | user1424739 |
75,540,110 | 1,610,626 | Pandas asof_locs Example | <p>I've tried searching the entire internet for an example of how to use <code>pandas.index.asof_locs</code> but couldn't. I don't quite understand what to pass in to the second <code>mask</code> variable.</p>
<p>I have a list of datetime variables <code>dt</code> and a target dataframe with dates and price data <code>... | <python><pandas> | 2023-02-23 02:42:15 | 1 | 23,747 | user1234440 |
75,540,092 | 9,338,509 | Missing 1 required positional argument in python tests | <pre><code>@patch("aioboto3.client")
@patch(“my_handler.send_batch", new_callable=truthy_async_mock)
@patch("my_handler.ConfigLoader.get_config")
@patch.dict(os.environ, {"STAGE": "Prod”})
@pytest.mark.parametrize("expected_value", ["123", "456"])
de... | <python><testing><parameters><mocking> | 2023-02-23 02:39:05 | 0 | 553 | lakshmiravali rimmalapudi |
75,539,894 | 10,500,424 | Randomly sample numpy columns using Cython | <p>I would like to sample columns from a large Numpy matrix a million times. I am achieving satisfactory speed using Python; however, I aim to repeat this process tens of thousands of time. At this scale, speed becomes an issue, and I am looking for ways to improve performance. I am leaning towards Cython, but I am a n... | <python><numpy><random><cython><cpython> | 2023-02-23 01:54:46 | 0 | 1,856 | irahorecka |
75,539,859 | 1,857,373 | Linear Regression ValueError X shape Y shape with .values() numpy.array. OK, ValueError Expected 2D array, got 1D array | <p><strong>PROBLEM</strong></p>
<p>Preparing data for LinearRegression with pre-encoded dataset, e.g., null, NAN, imputed missing values handles. Problem with ValueError on numpy.array even after trying .reshape(). This attempt is trying to fix this code which ran 5 years ago.</p>
<p>Assigning Y response SalePrice colu... | <python><arrays><pandas><numpy><linear-regression> | 2023-02-23 01:47:43 | 1 | 449 | Data Science Analytics Manager |
75,539,817 | 8,481,155 | Apache Beam Map, DoFn and Composite Transform | <p>I want to understand the difference is use cases between a Map function, a DoFn called from Pardo and a Composite transform.</p>
<p>I could achieve the same results with the below code for a list of transformations that I need to do for my pipeline. I made a sample of what I mean by multiple stages.</p>
<pre><code>i... | <python><python-3.x><google-cloud-dataflow><apache-beam> | 2023-02-23 01:40:01 | 1 | 701 | Ashok KS |
75,539,785 | 2,571,607 | Why sklearn's KFold can only be enumerated once (also on using it in xgboost.cv)? | <p>Trying to create a <code>KFold</code> object for my <code>xgboost.cv</code>, and I have</p>
<pre><code>import pandas as pd
from sklearn.model_selection import KFold
df = pd.DataFrame([[1,2,3,4,5],[6,7,8,9,10]])
KF = KFold(n_splits=2)
kf = KF.split(df)
</code></pre>
<p>But it seems I can only enumerate once:</p>
<p... | <python><scikit-learn><xgboost><cross-validation><k-fold> | 2023-02-23 01:32:45 | 1 | 593 | Yue Y |
75,539,748 | 3,099,733 | reference undefined fields in dataclass will still pass static check (pylint, pylance) | <p>Given the following sample code:</p>
<pre class="lang-py prettyprint-override"><code>from dataclasses import dataclass
@dataclass
class Demo:
a: int = 1
d = Demo()
d.b # b: Any
</code></pre>
<p>I don't know why static check won't report missing attribute but treating it as Any type instead. Is there any way to m... | <python><pylint><python-typing><python-dataclasses><pylance> | 2023-02-23 01:25:09 | 0 | 1,959 | link89 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.