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 ⌀ |
|---|---|---|---|---|---|---|---|---|
77,793,939 | 12,436,050 | Join pandas dataframes with column having pipe delimited values | <p>I have a dataframe df2 with one of the column with comma separated values. I would like to join df2 with another dataframe df1 using label first and if match not found then use synonym column. The synonym column can also have more than 2 values.</p>
<pre><code>df1
label
Werner syndrome
Ageing
df2
id label ... | <python><pandas><dataframe> | 2024-01-10 14:00:52 | 0 | 1,495 | rshar |
77,793,935 | 5,594,712 | Y-labels on secondary axis on top of each other | <p>I'm trying to plot the following and I notice that the labels on the y-axis is all on top of each other.</p>
<p><a href="https://i.sstatic.net/d78HD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/d78HD.png" alt="enter image description here" /></a></p>
<p>How can I avoid this?</p>
<p>I am using the c... | <python><matplotlib> | 2024-01-10 14:00:31 | 1 | 1,244 | Adam Merckx |
77,793,897 | 4,859,499 | Numpy: Accessing sub ndarrays with multiple index lists | <p>I am trying to access (more precisely: add to) a subset of a numpy array using multiple index lists.
However, what is working perfectly with slices, does not work as expected using arbitrary index lists:</p>
<pre><code>import numpy as np
# this one works:
A_4th_order = np.zeros( (4,2,4,2) )
sub_a = np.ones( (3,1,... | <python><numpy><indexing> | 2024-01-10 13:55:54 | 1 | 457 | mneuner |
77,793,887 | 12,692,466 | Quickfix python: memory leak on UtcTimeStamp | <p>I started using the library <a href="https://github.com/quickfix/quickfix" rel="nofollow noreferrer">quickfix</a> and I faced an issue using the python version:</p>
<pre><code>swig/python detected a memory leak of type 'UtcTimeStamp *', no destructor found
</code></pre>
<p>And when I go to the source code in C++ of ... | <python><swig><quickfix> | 2024-01-10 13:54:11 | 1 | 572 | DipStax |
77,793,527 | 4,638,207 | How to interpret values returned by numpy.ndarray.item() when downcasting floats | <p>I work with spatial data and often have coordinates that require, at most, precision to only a few decimal places, e.g. <code>89.995</code>.</p>
<p>A simple example:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
arr = np.array([89.995])
</code></pre>
<p>Inspect the dtypes:</p>
<pre class="... | <python><numpy><casting><floating-point> | 2024-01-10 12:53:24 | 2 | 572 | lusk |
77,793,505 | 3,457,761 | Code scan issue: URLValidator does not prohibit newlines and tabs | <p>I am getting vulnerability while prisma scan.</p>
<pre><code>- CVM : CVE-2021-32052
- PACKAGE : Python
- VERSION: 3.9.18
- STATUS: fixed in 3.2.2, 3.1.10, 2.2.22
- DESCRIPTION: In Django 2.2 before 2.2.22, 3.1 before 3.1.10, and 3.2 before 3.2.2 (with Python 3.9.5+), URLValidator does not prohibit newlines and tabs... | <python><security><security-code-scan> | 2024-01-10 12:49:57 | 0 | 7,288 | Harsha Biyani |
77,793,435 | 8,040,369 | Convert a list of floats in a df column into percentage and round off to 1 decimal digit | <p>Is there a way to get percentage & roundoff the list of values in a df column.
I have a df as</p>
<pre><code>id name value
============================================
1 AA [0.0012, 0.0022, 0.365]
2 BB [0.0412, 0.822, 0.3]
3 CC [0.692, 0.0002, 0.56]
<... | <python><pandas><dataframe> | 2024-01-10 12:40:02 | 2 | 787 | SM079 |
77,793,386 | 3,732,793 | Pandas smarter conditional merge for two dataframes | <p>Here I tried to find the shortest possible example code for a conditional merge of two dataframes. There I try to merge exact rows based on a condition. Currently I have to iterate over both dataframes for that.</p>
<pre><code>import pandas as pd
df1 = pd.DataFrame([
['a', 'Test1', 2995],
['b', 'Test2', 399... | <python><pandas> | 2024-01-10 12:30:51 | 1 | 1,990 | user3732793 |
77,793,292 | 7,713,770 | How to resolve error: collectstatic - Could not find backend 'storages.custom_azure.AzureStaticStorage' | <p>I have a django app and I have installed the module: <code>django-storages[azure]</code> with the command: <code>pipenv install django-storages[azure]</code></p>
<p>And now I try to run the collectstatic command. But if I enter the command: <code>python manage.py collectstatic</code></p>
<p>I get this error:</p>
<pr... | <python><django><azure><azure-blob-storage> | 2024-01-10 12:16:59 | 1 | 3,991 | mightycode Newton |
77,792,905 | 5,663,844 | PySide2: Load SVG from Variable rather than from file | <p>I want to display an <code>svg</code> file using PySide. But I would prefer not having to create a <code>file.svg</code> and then load it using <code>QSvgWidget</code></p>
<p>Rather I just have the file contents of the <code>file.svg</code> contents already stored in a variable as a string.</p>
<p>How would I go abo... | <python><pyside2> | 2024-01-10 11:08:21 | 2 | 480 | Janosch |
77,792,821 | 5,429,320 | Azure Function App in Docker Desktop does not have access to local sql server database on host | <p>I have my mssql server on my local windows desktop, which hold the development database for my application. I have a Azure function app that is written in python which has a couple endpoints that query the database.</p>
<p>If I run this function app in VSCode is connects to the database file. It uses the following e... | <python><sql-server><azure><docker><azure-functions> | 2024-01-10 10:54:41 | 1 | 2,467 | Ross |
77,792,819 | 1,619,432 | Linear fit through point (using weights in NumPy Polynomial.fit()) | <p>How can a linear fit be forced to exactly pass through a point (specifically, the origin) with <a href="https://numpy.org/doc/stable/reference/generated/numpy.polynomial.polynomial.Polynomial.fit.html" rel="nofollow noreferrer">NumPy's Polynomial.fit()</a> function?
I've tried some weights, but I'm unclear on how th... | <python><numpy><linear-regression> | 2024-01-10 10:54:15 | 2 | 6,500 | handle |
77,792,759 | 7,295,599 | How to rotate+scale PDF pages around the center with pypdf? | <p>I would like to rotate PDF pages around the center (other than just multiples of 90°) in a PDF document and optionally scale them to fit into the original page.</p>
<p>Here on StackOverflow, I found a few similar questions, however, mostly about the outdated PyPDF2.
And in the <a href="https://pypdf.readthedocs.io/e... | <python><pdf><rotation><pypdf> | 2024-01-10 10:46:20 | 2 | 27,030 | theozh |
77,792,697 | 6,630,397 | How to properly aggregate Decimal values in a django app: 'decimal.Decimal' object has no attribute 'aggregate' | <p>I'm in a <a href="https://django-tables2.readthedocs.io/en/latest/" rel="nofollow noreferrer">django-tables2</a> <code>Table</code>, trying to compute the sum of a column (based on a <code>MoneyField</code> (<a href="https://django-money.readthedocs.io/en/latest/" rel="nofollow noreferrer"><code>django-money</code><... | <python><django><decimal><django-tables2><django-money> | 2024-01-10 10:37:52 | 1 | 8,371 | swiss_knight |
77,792,636 | 8,532,748 | OpenTelemetry not logging messages with exception details to Application Insights from python code | <p>I am in process of migrating a python 3.10 project from OpenCensus to OpenTelemetry as the former is being <a href="https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-python-opencensus-migrate?tabs=python" rel="nofollow noreferrer">sunsetted this year</a>.</p>
<p>The logs are working correctly f... | <python><azure><logging><azure-application-insights><open-telemetry> | 2024-01-10 10:29:45 | 1 | 4,260 | SBFrancies |
77,792,415 | 2,784,493 | How can I run a python github project to my nodejs project? | <p>So I want to use this python project <a href="https://github.com/m-bain/whisperX" rel="nofollow noreferrer">https://github.com/m-bain/whisperX</a> and access it in my nodejs project.</p>
<p>I am thinking of using <a href="https://www.npmjs.com/package/python-shell" rel="nofollow noreferrer">python-shell</a> but I am... | <javascript><python><node.js><interop><openai-whisper> | 2024-01-10 09:56:18 | 1 | 4,680 | I am L |
77,792,414 | 2,735,286 | Handling psycopg_pool.PoolTimeout connection errors | <p>How do you deal with pooled connection errors when using the Python library <code>psycopg = {extras = ["binary", "pool"], version = "^3.1.16"}</code>?</p>
<p>For context: I have implemented a Python web app which runs on aiohttp and uses a connection pool to access Postgres.</p>
<p>The ... | <python><psycopg3> | 2024-01-10 09:56:14 | 1 | 14,809 | gil.fernandes |
77,791,698 | 13,132,728 | How to find the most common pairings of size n in a set of values out of all rows pandas | <h2>MY DATA</h2>
<p>Let's say I have the following dataframe where each row consists of a unqiue shopping cart:</p>
<pre><code>pd.DataFrame({'0':['banana','apple','orange','milk'],'1':['apple','milk','bread','cheese'],'2':['bread','cheese','banana','eggs']})
0 1 2
0 banana apple bread
1 apple ... | <python><pandas> | 2024-01-10 07:56:41 | 1 | 1,645 | bismo |
77,791,623 | 2,149,718 | Recording script based on gstreamer doesn’t work with Dahua camera | <p>I have the following python script that records video from an rtsp camera:</p>
<pre><code># initialize GStreamer
Gst.init(None)
# calculate pipeline string
pipeline_str = ...
pipeline_str += f"! filesink location={full_path}.mkv"
# build the pipeline
pipeline = Gst.parse_launch(pipeline_str) ... | <python><gstreamer><rtsp><ip-camera> | 2024-01-10 07:41:36 | 1 | 72,345 | Giorgos Betsos |
77,791,600 | 13,999,613 | Odoo14 Action Server Error - Unable to Call Python Method Correctly | <p>I am facing an issue while trying to define an action server in Odoo14. The objective is to call a Python method that returns a window action because I need to access fields in the current model and pass them to the context. Unfortunately, directly using a window action with a context that calls fields doesn't seem ... | <python><xml><odoo><odoo-14> | 2024-01-10 07:35:58 | 1 | 311 | Ka_ |
77,791,525 | 13,132,728 | How to get the value counts of each unique value in a row for all rows in a pandas dataframe | <h2>MY DATA</h2>
<p>Let's say I have a dataframe where each row represents one shopping cart, like so:</p>
<pre><code>pd.DataFrame({'0':['banana','apple','orange'],'1':['apple','milk','bread'],'2':['bread','cheese','banana']})
0 1 2
0 banana apple bread
1 apple milk cheese
2 orange bread... | <python><pandas> | 2024-01-10 07:20:38 | 1 | 1,645 | bismo |
77,791,392 | 6,822,178 | Proportion of each unique value of a chosen column for each unique combination of the other in a DataFrame | <p>I have a DataFrame with a variable number of columns. I need to calculate the proportion of each unique value of a chosen column for each unique combination of the other. For example:</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
import pandas as pd
a="A";b="B"
df = pd.D... | <python><pandas><dataframe><count><unique> | 2024-01-10 06:51:23 | 1 | 2,289 | Max Pierini |
77,791,241 | 126,362 | Consistent order of tracks in mediainfo library (pymediainfo) | <p>I would like to get a consistent ordering of tracks from mediainfo - in other words, for a given media file, the order should be the same every time the code is run, on any machine.</p>
<p>(Assuming for now the same library version is used, but if there is a way to get an ordering that won't change with future libra... | <python><metadata><mediainfo> | 2024-01-10 06:11:32 | 0 | 835 | ejm |
77,791,091 | 10,200,497 | Finding the maximum value between two columns where one of them is shifted and change the value of last row | <p>My DataFrame is:</p>
<pre><code>df = pd.DataFrame(
{
'a': [20, 9, 31, 40],
'b': [1, 10, 17, 30],
}
)
</code></pre>
<p>Expected output: Creating column <code>c</code> and <code>name</code></p>
<pre><code> a b c name
0 20 1 20 NaN
1 9 10 20 NaN
2 31 17 17 NaN
3 40 ... | <python><pandas><dataframe> | 2024-01-10 05:25:51 | 1 | 2,679 | AmirX |
77,790,973 | 11,049,287 | Lengths of overlapping time ranges listed by rows | <p>I am using pandas version 1.0.5</p>
<p>The example dataframe below lists time intervals, recorded over three days, and I seek where some time intervals overlap <strong>every</strong> day.</p>
<p><a href="https://i.sstatic.net/1fICR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/1fICR.png" alt="Interi... | <python><pandas><dataframe><numpy><python-datetime> | 2024-01-10 04:45:37 | 1 | 838 | usr_lal123 |
77,790,846 | 10,200,497 | Finding the maximum value between two columns where one of them is shifted | <p>My DataFrame is:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
{
'a': [20, 9, 31, 40],
'b': [1, 10, 17, 30],
}
)
</code></pre>
<p>Expected output: Creating column <code>c</code></p>
<pre><code> a b c
0 20 1 20
1 9 10 20
2 31 17 17
3 40 30 31
</code></pre>
<p>Steps:<... | <python><pandas><dataframe><max> | 2024-01-10 03:56:10 | 3 | 2,679 | AmirX |
77,790,767 | 2,924,334 | Runtime.ImportModuleError: Unable to import module 'main': cannot import name 'is_arabic' from | <p>When I do:
<code>sam local invoke MyFunction --event events/my_event.json</code></p>
<p>I get this error:
<code>[ERROR] Runtime.ImportModuleError: Unable to import module 'main': cannot import name 'is_arabic' from 'charset_normalizer.utils' (/var/task/charset_normalizer/utils.py)</code></p>
<p>Sorry, I am not too f... | <python><aws-sam><aws-sam-cli> | 2024-01-10 03:18:42 | 1 | 587 | tikka |
77,790,704 | 270,043 | Matching a nested column in pandas dataframe | <p>I have a pandas dataframe with 5 columns, and one of the columns is a list. If I print out the list only, I get something like this:</p>
<pre><code>Row(a='abc',b='def',c=['qwe','rty'])
Row(a='123',b='456',c=['789','089'])
...
</code></pre>
<p>I'm trying to match on the field <code>a</code> and also on the list <code... | <python><pandas><dataframe> | 2024-01-10 02:59:02 | 2 | 15,187 | Rayne |
77,790,649 | 5,082,463 | Qt Creator Python debugger | <p>After using QtCreator on C++ projects for years, and seeing it being advertised for python development I tried and it works.</p>
<p>But, no debugger?</p>
<p>Even SublimeText has a python debugger <a href="https://github.com/daveleroy/SublimeDebugger" rel="nofollow noreferrer">https://github.com/daveleroy/SublimeDebu... | <python><debugging><qt-creator><debuggervisualizer> | 2024-01-10 02:30:30 | 1 | 6,367 | KcFnMi |
77,790,633 | 6,943,690 | Why can not get body field in response of Microsoft Graph API for listing messages? | <p>I want to read certain email messages and filter them. I am using Microsoft Graph API to query the office 365 mail box as below. I also added API permission "Mail.ReadBasic.All" for getting mails from application.</p>
<pre><code>graph_api_endpoint = 'https://graph.microsoft.com/v1.0/users/xyz@outlook.com/m... | <python><email><microsoft-graph-api><office365api><outlook-restapi> | 2024-01-10 02:23:52 | 1 | 2,740 | avantdev |
77,790,619 | 7,802,751 | What is the default datatype for the emotions dataset (one of huggingface's site dataset)? | <p>I'm working with the emotions dataset from HuggingFace library.</p>
<p>I know I can switch its presentation format to pandas by doing:</p>
<pre><code>emotions.set_format(type='pandas')
</code></pre>
<p>And I can switch it back to its default presentation format by doing:</p>
<pre><code>emotions.reset_format()
</code... | <python><formatting><format><huggingface><huggingface-datasets> | 2024-01-10 02:17:58 | 0 | 997 | Gustavo Mirapalheta |
77,790,459 | 4,126,652 | python concurrent futures executing even on unhandled exceptions | <p>Consider the following code snippet:</p>
<pre class="lang-py prettyprint-override"><code>import concurrent.futures
import time
def throw_func(a):
print(a)
time.sleep(10)
raise ValueError(a)
params = list(range(5000))
with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
... | <python><multithreading> | 2024-01-10 01:12:28 | 3 | 3,263 | Vikash Balasubramanian |
77,790,274 | 2,386,605 | Multi-stage build in Docker shows unknown PATH | <p>I want to build a Docker image with a multi-stage build. The image is based on FastAPI and Uvicorn.</p>
<p>If I use the following <code>Dockerfile</code> for a multi-stage build</p>
<pre><code># Stage 1: Build stage
FROM pytorch/pytorch:2.1.2-cuda12.1-cudnn8-runtime as builder
# set working directory
WORKDIR /usr/s... | <python><docker><docker-compose><fastapi><uvicorn> | 2024-01-09 23:47:00 | 1 | 879 | tobias |
77,790,158 | 10,749,925 | How do i put a .env file in GitHub? | <p>In most instances .env files for Python are in the .gitignore directory. However it's crucial for me to have my .env file in my private repository. I need to be able to git pull it to my local machines or my code does not run. Doing something simple such as:</p>
<pre><code>import streamlit as st
import os
from dote... | <python><github><version-control> | 2024-01-09 23:02:26 | 1 | 463 | chai86 |
77,789,700 | 18,476,381 | Docker not properly setting environment variables via GitHub actions | <p>In my python application I am trying to access/print out an environment variable but it is printing out None.</p>
<pre><code>logger.info(f"OIDC SECRET: {os.getenv('OIDC_CLIENT_SECRET')}")
</code></pre>
<p>This is my step/job in github actions</p>
<pre><code>name: Build and push image to harbor
run: |
... | <python><docker><github-actions> | 2024-01-09 20:56:39 | 1 | 609 | Masterstack8080 |
77,789,573 | 1,839,674 | VSCode Pytest Discovers but won't run | <p>In VScode, pytests are discovered. Using a conda env and it is the selected Python:Interpreter.</p>
<p>However, when I try to run one or all the tests, it just says "Finished running tests!". Can't get into debug. Doesn't give green checkmark or red x's.</p>
<p>If I run <code>pytest</code> in the terminal,... | <python><visual-studio-code><pytest> | 2024-01-09 20:28:00 | 2 | 620 | lr100 |
77,789,489 | 2,386,113 | Efficiently find neighbors in python | <p>I have a three-dimensional grid. For each point on the grid, I want to find its nearest neighbours. Since my grid is uniformly sampled, I just want to gather the immediate neighbors.</p>
<p><strong>Sample grid:</strong></p>
<p><a href="https://i.sstatic.net/BWTu9.png" rel="nofollow noreferrer"><img src="https://i.ss... | <python><performance><parallel-processing><cpython><nearest-neighbor> | 2024-01-09 20:10:59 | 1 | 5,777 | skm |
77,789,467 | 11,551,386 | ipython - docstring not showing for functions that are wrapped | <p>With the code below entered in ipython, entering subsequent <code>func_with_wrap?</code> shows <code><no docstring></code> while <code>func_no_wrap?</code> shows the docstring as expected. How can I get <code>func_with_wrap?</code> to properly show the docstring of <code>func_with_wrap</code>?</p>
<pre class="... | <python><ipython> | 2024-01-09 20:06:16 | 1 | 344 | likethevegetable |
77,789,428 | 8,447,743 | Does the requests module truncate headers? | <p>I'm trying to make a POST request to my API using a fairly long (1017 chars) Bearer token for authorization.</p>
<p>No matter what I try, as I fire up the request I get an error saying that <code>\u2026</code> (horizontal ellipsis) in position 512 can't be encoded with the 'latin-1' encoding. Since I can't find any ... | <python><python-requests> | 2024-01-09 19:59:02 | 2 | 916 | NoBullsh1t |
77,789,207 | 441,709 | Searching Gmail from Python | <p>I am trying to write a script to search my gmail. I have followed the <a href="https://developers.google.com/gmail/api/quickstart/python" rel="nofollow noreferrer">quickstart</a> guide and got that working and played with altering that with other API calls. When I follow the <a href="https://developers.google.com/gm... | <python><gmail> | 2024-01-09 19:14:46 | 0 | 675 | Tommy |
77,789,103 | 2,893,712 | Python Requests Login Automation | <p>I am trying to use Python Requests to login to my UPS MyChoice account. Each page request has it's own <code>CSRFToken</code> value. I am trying to simulate this with Python Requests but I keep getting 403 Forbidden Error.</p>
<p>UPS does their login in a two-stage setup.. You enter username, make request, and then ... | <python><cookies><automation><python-requests> | 2024-01-09 18:52:13 | 0 | 8,806 | Bijan |
77,789,028 | 6,467,512 | I keep getting bad verification code when requesting github access token | <p>I am using auth0-vue for user authentication. I have added the github login connection in my auth0 console, selected the permission to view the user repo. I have also created the github auth0 application in my developer settings and the login/permession process in my frontend work as expected. Then when the code and... | <python><vue.js><authentication><github><github-api> | 2024-01-09 18:36:44 | 0 | 323 | AynonT |
77,789,024 | 2,159,372 | Poetry Install Subprocess PoetryException | <p>I am facing the below issue with poetry install in Cloud composer.
Failing at installation of URLObject.
Looking for suggestions on resolving the same as my online search didnt get any results.</p>
<p>The shell script portion is</p>
<pre><code>cat ${SPARK_HOME}/conf/spark-defaults.conf
export POETRY_HOME=/etc/poetry... | <python><setuptools><sha256><google-cloud-composer><python-poetry> | 2024-01-09 18:36:01 | 1 | 1,538 | mehere |
77,788,942 | 2,835,427 | Altair - plot on background image | <p>I would like to display an image and plot markers on it. However, the image does not appear to align with the axis well, resulting in the markers in wrong places. Here is my code:</p>
<pre class="lang-py prettyprint-override"><code>import altair as alt
import pandas as pd
from PIL import Image
import numpy as np
fro... | <python><altair><vega-lite><python-interactive> | 2024-01-09 18:19:41 | 1 | 1,692 | Tu Bui |
77,788,836 | 2,731,076 | How to set new index for Pandas dataframe from existing column that has duplicates? | <p>I am grabbing data from a MongoDB database and converting it into a Pandas dataframe for additional operations to be done later. The MongoDB database contains a bunch of time-based entries and due to how they are stored, each sample for each channel is its own document. Some of these channels always sample at the sa... | <python><pandas><mongodb> | 2024-01-09 18:00:10 | 1 | 813 | user2731076 |
77,788,494 | 14,649,310 | Partial validation with marshmallow to ingore unknown field | <p>I have searched this as much as I could, read the docs, looked in various posts but i start to believe it is not possible. So I want to have a partial validation schema, for a Flask app, with marshmallow like this</p>
<pre><code>from marshmallow import Schema, fields, validate
class MySchema(Schema):
product_t... | <python><validation><flask><marshmallow> | 2024-01-09 17:01:26 | 1 | 4,999 | KZiovas |
77,788,492 | 11,277,108 | Reduce size between table subplots | <p>I'm trying to add two tables to a report but am having issues with the space between the tables. By way of an MRE:</p>
<pre><code>import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
from plotly.subplots import make_subplots
def main():
fig = make_subplots(
rows=2,
... | <python><plotly> | 2024-01-09 17:01:08 | 1 | 1,121 | Jossy |
77,788,481 | 3,813,064 | Correct type annotation for a 2D transpose function in python | <p>In our code we do a lot of 2D transposes like <code>zip(*something)</code> where <code>something</code> is a list of tuples.</p>
<p>For example take:</p>
<pre class="lang-py prettyprint-override"><code>>>> a = [('a', 1), ('b', 2), ('c', 3)]
>>> result = tuple(*zip(*a))
>>> result # type ch... | <python><python-typing> | 2024-01-09 16:59:12 | 1 | 2,711 | Kound |
77,788,233 | 8,223,367 | use pyalsaaudio to connect an input and output device | <p>I'm facing an issue with my Python audio streaming code. Currently, when running the code, I can only hear a "tuuuut" sound on the Bluetooth audio speaker. I expected the audio from the input sound device to be properly streamed to the speaker.</p>
<p>The magic happens in the function _process_audio and I ... | <python><pyalsaaudio> | 2024-01-09 16:18:50 | 1 | 327 | theother |
77,788,150 | 1,008,588 | Pandas data frame use interpolate() partitioning with specific columns | <p>I have the following Pandas data frame (called <code>df</code>).</p>
<pre><code>+--------+--------+------+--------+
| Person | Animal | Year | Number |
+--------+--------+------+--------+
| John | Dogs | 2000 | 2 |
| John | Dogs | 2001 | 2 |
| John | Dogs | 2002 | 2 |
| John | Dogs | 2... | <python><pandas><dataframe><interpolation><fillna> | 2024-01-09 16:06:17 | 2 | 2,764 | Nicolaesse |
77,787,937 | 601,493 | Use network namespace per thread with sytem DNS resolution | <p>I would like to have single Python application to work with different network namespaces. This to my understanding can be achieved on per-thread basis via <code>pthread.setns(...)</code> as explained for example in <a href="https://stackoverflow.com/questions/28846059/can-i-open-sockets-in-multiple-network-namespace... | <python><linux-kernel><namespaces> | 2024-01-09 15:32:33 | 0 | 17,968 | Jan Zyka |
77,787,715 | 22,538,132 | How to approximate contour into four points | <p>I have binary masks obtained from segmentation model, and I want to get four corners only of its contour that include majority of the points with minimal area as you can see in this image:
<a href="https://i.sstatic.net/qN7gQ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qN7gQ.png" alt="enter image ... | <python><opencv><image-processing><computer-vision> | 2024-01-09 15:02:56 | 1 | 304 | bhomaidan90 |
77,787,408 | 16,383,578 | How to tell if a bunch of shapes are all mirror images using OpenCV? | <p>I had taken an online visual IQ test, in it a lot of questions are like the following:</p>
<p><img src="https://www.idrlabs.com/static/i/eysenck-iq/en/3.png" alt="" /></p>
<p><img src="https://www.idrlabs.com/static/i/eysenck-iq/en/5.png" alt="" /></p>
<p><img src="https://www.idrlabs.com/static/i/eysenck-iq/en/7.pn... | <python><opencv><image-processing><computer-vision><heuristics> | 2024-01-09 14:15:42 | 1 | 3,930 | Ξένη Γήινος |
77,787,361 | 775,155 | How do I concatenate two data frames/arrays where each row must have the same key in Python? | <p>I have two CSV files:</p>
<pre><code>index,X,Y
1,1.0,2.0
3,1.3,2.3
</code></pre>
<p>and</p>
<pre><code>index,Z
1,3.0
</code></pre>
<p>that I want to read and concatenate into a m x 4 numpy array in Python
with the rule that only rows with indices that are present in both files should be used.</p>
<p>The result of th... | <python><pandas><numpy> | 2024-01-09 14:08:04 | 1 | 4,009 | Andy |
77,787,231 | 1,422,096 | Function parameter parsing if the type can vary | <p>I have a function that can be called with either a boolean <code>onoff</code> or a dictionary <code>request</code>. If <code>onoff</code> comes <em>directly</em> as a parameter, it can be <code>True</code>, <code>False</code> or <code>None</code>. If it comes from <code>request</code> dictionary, then <code>request[... | <python> | 2024-01-09 13:47:07 | 2 | 47,388 | Basj |
77,787,226 | 3,941,671 | define type of queue items in python | <p>I have a function with a <code>queue.Queue</code> as an argument. This queue contains elements of my self defined class <code>PlantCommand</code> and should be processed by another thread.
Therefor, I defined the thread target function in the following way:</p>
<pre><code>def run(command_queue: queue.Queue, status: ... | <python> | 2024-01-09 13:46:20 | 1 | 471 | paul_schaefer |
77,787,084 | 5,230,928 | Python: Iterate and modify a complex dict including lists | <p>I need to iterate through a complex dictionary and modify it according to several conditions.</p>
<p>This is a very basic example of the dict</p>
<pre><code>a = {
'x' : ["x1", "x2", 'x3'],
'y' : [
{'y1' : 1},
{'y2' : 2.0},
{'y3' : True},
{'y4' : 99},
],
'z'... | <python><dictionary><parsing> | 2024-01-09 13:21:08 | 2 | 475 | JustMe |
77,787,027 | 13,364,448 | How to apply filters on MongoDBAtlasVectorSearch similarity_search_with_score” of langchain? | <p>I am using <a href="https://python.langchain.com/docs/integrations/vectorstores/mongodb_atlas" rel="nofollow noreferrer">MongoDBAtlasVectorSearch</a> and ì want to search for the most similar documents so I use the function <a href="https://python.langchain.com/docs/integrations/vectorstores/mongodb_atlas#pre-filter... | <python><mongodb><langchain><vector-search> | 2024-01-09 13:13:06 | 1 | 877 | colla |
77,786,930 | 1,830,758 | Correct virtual environment setup to allow VS Code to format Python Files (using autopep8, Black Formatter or Ruff) | <p>In Visual Studio Code, all formatter extensions for Python are failing to format my .py files. Message is <strong>"Skipping standard library file"</strong>.</p>
<p>I understand that formatters built into Python are no longer supported and I have installed separate <a href="https://stackoverflow.com/questio... | <python><visual-studio-code><format> | 2024-01-09 12:52:29 | 3 | 617 | Alex Cooper |
77,786,853 | 1,860,805 | How to print timedelta consistently (i.e. formatted) | <p>I have this code that prints the time difference in milliseconds.</p>
<pre><code>#!/usr/bin/python
import datetime
import sys
date1= datetime.datetime.strptime('20231107-08:52:53.539', '%Y%m%d-%H:%M:%S.%f')
date2= datetime.datetime.strptime('20231107-08:52:53.537', '%Y%m%d-%H:%M:%S.%f')
diff = date1-date2
sys.stdou... | <python><datetime><printing><timedelta> | 2024-01-09 12:43:08 | 2 | 523 | Ramanan T |
77,786,816 | 8,877,753 | Radar Vegation Index scaling issues [0, 1] for Sentinel-1 data | <p>I am trying to understand some data issues I am having with using Sentinel-1 VV and VH data to create RVI statistics.</p>
<p>I am familiar with the fact that you need true quad polarisation to calculate the RVI. The best approximate RVI equation for S1 has been discussed at length at the ESA forum <a href="https://f... | <python><image-processing><statistics><sentinel1> | 2024-01-09 12:36:51 | 0 | 351 | Mars |
77,786,729 | 4,133,464 | Pandas concat converts dtype to object instead of numeric | <p>I have a dataset separated into 10 different .csv files. After importing each separately, I use concat to merge them into one. This converts each column to dtype "object". As a result, when I use Keras model .fit to run the model, I get the error: ValueError: Failed to convert a NumPy array to a Tensor (Un... | <python><pandas><numpy><tensorflow><keras> | 2024-01-09 12:23:19 | 1 | 819 | deadpixels |
77,786,578 | 11,159,734 | How to get proper context from AI-Search documents when calling OpenAI completion endpoint | <p>I found <a href="https://github.com/openai/openai-cookbook/blob/main/examples/azure/chat_with_your_own_data.ipynb" rel="nofollow noreferrer">this documentation</a> about chatting with your own data using AI-Search & OpenAI.</p>
<p>It works fine for my data however I don't get any additional context aside from th... | <python><azure-cognitive-services><openai-api><azure-openai> | 2024-01-09 11:54:41 | 1 | 1,025 | Daniel |
77,786,441 | 7,441,757 | Using pd.cut with duplicate bins and labels | <p>I'm using <code>pd.cut</code> with the keyword argument <code>duplicates='drop'</code>. However, this gives errors when you combine it with the keyword argument <code>labels</code>.</p>
<p>The question is similar to <a href="https://stackoverflow.com/questions/70986532/how-to-fix-pd-cut-with-duplicate-edges">this</a... | <python><pandas> | 2024-01-09 11:29:30 | 1 | 5,199 | Roelant |
77,786,410 | 8,113,126 | QuickFIX Python Session File Corruption Issue | <p>I am encountering a recurring problem in my production environment using QuickFIX Python. The issue revolves around the corruption of session files (FIX.4.4-A-B.session) in the Sessions folder. The session file is expected to contain a valid date-time format (e.g., <code>20240108-11:42:01</code>), but at random time... | <python><quickfix><fix-protocol><quickfixj><quickfixn> | 2024-01-09 11:24:46 | 0 | 340 | Jai Simha Ramanujapura |
77,786,242 | 16,525,263 | How to call the functions that are inside a python class | <p>I have a python class where I have nested functions. Im not able to call the functions that are nested.</p>
<pre><code>class Data:
__instance__ = None
def writeCleanData(df,path,d_path,row,days,lk):
Data.write(Data.unify(df,row),path,"append")
d_path[path] = os.path.split(d_path[pa... | <python> | 2024-01-09 10:59:54 | 1 | 434 | user175025 |
77,786,212 | 5,091,467 | How to choose pandas Sparse dtype and what are the memory implications? | <p>I am trying to understand how to set up a sparse pandas matrix to minimize memory usage and retain precision of all values. I did not find the answers in the pandas Sparse <a href="https://pandas.pydata.org/docs/user_guide/sparse.html" rel="nofollow noreferrer">documentation</a>. Below is an example which illustrate... | <python><pandas><precision><sparse-matrix><dtype> | 2024-01-09 10:54:45 | 1 | 714 | Dudelstein |
77,785,950 | 3,932,463 | Plotting rows of a df based on their label (colour coded) | <p>I am trying to plot a dataset where rows have the information. I want to plot the rows as a line plot (so there will be 6 lines), in the colour that their labels are encoded (for ex. <code>label 0 is blue, label 1 is red</code>)
The example df is:</p>
<pre><code>Label,col1,col2,col3
0,43.55,98.86,2.34
1,21.42,51.42,... | <python><pandas><line-plot><color-codes> | 2024-01-09 10:16:27 | 2 | 909 | bapors |
77,785,410 | 7,622,324 | Pylance: use Mypy for autocomplete | <p>I have python code that uses <code>__getattr__</code> to relay non existing member accesses to another object.</p>
<p>I have written a Mypy plugin which makes the type hints work.</p>
<pre class="lang-py prettyprint-override"><code>class StrProxy(Proxy[str])
s: str
def __init__(self, s: str):
self.s... | <python><mypy><pylance> | 2024-01-09 08:47:33 | 0 | 669 | Omer Lubin |
77,785,396 | 1,826,066 | Run group_by_dynamic in polars but only on timestamp | <p>I have some dummy data like such:</p>
<pre><code>datetime,duration_in_traffic_s
2023-12-20T10:50:43.063641000,221.0
2023-12-20T10:59:09.884939000,219.0
2023-12-20T11:09:56.003331000,206.0
...
more rows with different dates
...
</code></pre>
<p>Assume this data is stored in a file <code>mwe.csv</code>.
Using <code>po... | <python><python-polars> | 2024-01-09 08:45:04 | 1 | 1,351 | Thomas |
77,785,263 | 3,510,201 | Deprecating a function that is being replaced with a property | <p>I am refactoring parts of an API and wish to add deprecation warnings to parts that will eventually be removed. However I have stumbled into an issue where I would like to replace a function call with a property sharing a name.</p>
<p>Is there a hack where I can support both calling the <code>.length</code> as a pro... | <python> | 2024-01-09 08:24:04 | 1 | 539 | Jerakin |
77,785,036 | 7,583,919 | Iteratively convert an arbitrary depth list to a dict | <p>The input has a pattern, every element in the list is a dict and has a fixed keys</p>
<pre class="lang-py prettyprint-override"><code>[{'key': 'a', 'children': [{'key': 'a1', 'children': [{'key': 'a11', 'children': []}]}]}, {'key': 'b', 'children': [{'key': 'b1', 'children': [{'key': 'b11', 'children': []}]}]},]
</c... | <python><algorithm><iteration> | 2024-01-09 07:41:04 | 2 | 4,211 | ComplicatedPhenomenon |
77,784,846 | 709,439 | How to find similar sounding words? | <p>I'm writing a specialized (in food realm) multi-lingual search engine.<br />
I use python and nltk libraries.
I have quite a big database of recipes for all cultures I want to support.</p>
<p>I'm asking if and how it is possible to be able to find in my indexed words corpus a <em>wrong spelled</em> word...<br />
For... | <python><nlp><nltk> | 2024-01-09 06:57:38 | 2 | 17,761 | MarcoS |
77,784,646 | 15,361,826 | Issues while using related names | <p>This is the Course and LearnerCourse model:</p>
<pre><code>class Course(BaseModel, Timestamps, SoftDelete):
name = models.TextField(_("Course Name"), max_length=100,
blank=True, null=True, unique=False)
description = models.TextField(
_("Course Description&q... | <python><django><django-models><django-rest-framework> | 2024-01-09 06:04:51 | 2 | 331 | user15361826 |
77,784,599 | 12,458,212 | Adding value to 2d numpy array based on condition | <p>Having trouble manipulating a 2D numpy array (below). I'm using np.where to add a value if the given condition is met, but doesn't seem to be working. Is this simply not possible or am I making a simple mistake?</p>
<pre><code>a = ['circle','square']
b=['north','south']
c=['red','blue']
d=['long','short']
x = []
for... | <python><numpy> | 2024-01-09 05:50:30 | 2 | 695 | chicagobeast12 |
77,784,528 | 11,053,801 | how to reinitialise global variable in flask app python | <p>Here is the Flask app.py</p>
<pre><code>from flask import Flask, redirect, url_for, request
import trainer
app = Flask(__name__)
@app.route('/success/<name>')
def success(name):
gValue = trainer.myFunction()
name = name + gValue
return 'welcome %s' % name
@app.route('/login', methods=['POST'... | <python><flask> | 2024-01-09 05:28:35 | 2 | 1,616 | hanzgs |
77,784,445 | 11,637,422 | How to carry out a function in parallel for a large df? | <p>I am trying to carry out a function that searches through my dataframe and substitutes newer entries for older ones. My dataframe is dependant on players and their tickets, which means I have had to split the dataframe by players instead of by even sized chunks. The function works fine for smaller dataframes, but fo... | <python><multiprocessing> | 2024-01-09 05:00:10 | 0 | 341 | bbbb |
77,784,413 | 16,405,935 | Fill N/A with previous day data | <p>I have a dataframe and it just has data for weekday. Below is sample dataframe:</p>
<pre><code>import pandas as pd
import numpy as np
df = pd.DataFrame({'BAS_DT': ['2023-01-02', '2023-01-03', '2023-01-04', '2023-01-05', '2023-01-05', '2023-01-05', '2023-01-06', '2023-01-07'],
'CUS_NO': [np.nan, n... | <python><pandas> | 2024-01-09 04:46:14 | 4 | 1,793 | hoa tran |
77,784,396 | 2,272,824 | How to quickly (vectorized?) extract varying length slices from one numpy 1D array an insert into a 2d array | <p>I'm trying to extract multiple, non-overlapping, slices from a single 1D numpy array into consecutive rows of a 2D array.</p>
<p>Let's say the source array is,</p>
<pre><code>s=array([0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12])
</code></pre>
<p>and the target array is a 2D array of zeroes such as,</p>
<pre><code>t = arr... | <python><numpy><slice> | 2024-01-09 04:39:21 | 1 | 391 | scotsman60 |
77,784,395 | 338,479 | How can I read a file with varying encoding? | <p>Writing code that will read a file in Berkeley mbox format. This is a file containing multiple email messages, each of which may have its own encoding. Code is currently crashing because it encounters a non-utf8 character in the file.</p>
<pre><code> # test; read and print just the headers from an email message
... | <python><email><character-encoding> | 2024-01-09 04:38:19 | 1 | 10,195 | Edward Falk |
77,784,148 | 13,528,142 | Pandas groupby.head(-n) drops some groups | <p>I have a df such as below:</p>
<p><a href="https://i.sstatic.net/iXZVW.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/iXZVW.png" alt="dataframe" /></a></p>
<p>For each reviewerID I want to select 2 last instances (sorted by reviewTime) as test data and the rest (up to 2 last instances) as train datas... | <python><pandas><dataframe><group-by> | 2024-01-09 03:03:47 | 2 | 391 | Zeinab Sobhani |
77,784,048 | 1,492,229 | What does the value of LIME mean? | <p>I'm exploring the workings of <strong>LIME</strong> in <strong>NLP</strong> models to understand how it elucidates positive and negative words.</p>
<p>I possess a trove of documents resembling this excerpt:</p>
<blockquote>
<p>The UN children’s agency says the 'world cannot stand by and watch' the suffering in Gaza.... | <python><nlp><lime> | 2024-01-09 02:19:24 | 1 | 8,150 | asmgx |
77,783,847 | 2,986,153 | ModuleNotFoundError: No module named 'yaml' despite having installed yaml and pyyaml | <p>I have installed Quarto in VSCode on my M1 Mac.</p>
<p>When I try to render a qmd file into an html file ...</p>
<pre><code>quarto render quarto_vscode.qmd
</code></pre>
<p>...I get a strange error message</p>
<pre><code>Starting python3 kernel...Traceback (most recent call last):
File "/Applications/quarto/s... | <python><visual-studio-code><quarto> | 2024-01-09 00:50:18 | 1 | 3,836 | Joe |
77,783,488 | 5,638,335 | Airflow same dag runs notebook code at different times | <p>New to airflow:
I need to run a notebook code from my application dag that's currently scheduled to run at 5AM PST for US region. But I want to expand to a few more countries and that notebook code needs to run at 5AM Local time for that given country.</p>
<p>E.g.</p>
<p>For UK, run the notebook at 5 AM UTC - while ... | <python><jupyter-notebook><airflow> | 2024-01-08 22:32:42 | 1 | 680 | priya khokher |
77,783,264 | 15,781,591 | How to grab color mapping from matplotlib pie chart in python? | <p>From pandas documentation on creating pie charts from data frames:</p>
<p>I have the following code:</p>
<pre><code>df = pd.DataFrame({'mass': [0.330, 4.87 , 5.97],
'radius': [2439.7, 6051.8, 6378.1]},
index=['Mercury', 'Venus', 'Earth'])
plot = df.plot.pie(y='mass', figsize=(5, ... | <python><pandas><matplotlib> | 2024-01-08 21:32:57 | 2 | 641 | LostinSpatialAnalysis |
77,783,172 | 9,983,652 | Permutation feature importance with multi-class classification problem | <p>I am wondering if we can do Permutation feature importance for multi-class classification problem?</p>
<pre><code>from sklearn.inspection import permutation_importance
metrics = ['balanced_accuracy', 'recall']
pfi_scores = {}
for metric in metrics:
print('Computing permutation importance with {0}...'.format(metr... | <python><scikit-learn> | 2024-01-08 21:07:38 | 1 | 4,338 | roudan |
77,783,148 | 2,801,669 | how to deal with compression when using pydantic for deserialization and serialization | <p>Consider the following simple example of a class called <code>TableConfigs</code>:</p>
<pre><code>import pydantic
from enum import Enum
class TimeUnit(str, Enum):
days = "days"
hours = "hours"
minutes = "minutes"
seconds = "seconds"
class TableNames(str, En... | <python><pydantic> | 2024-01-08 21:02:03 | 1 | 1,080 | newandlost |
77,783,143 | 9,357,484 | The requirments.txt file on Github repo unable to install the python packages | <p>I downloaded a repository from the Github and save it to the computer's download(not clone) folder. In the description section of the repository it is written that their project's dependency is defined in the requirments.txt file and one can install the packages using <strong>"pip3 install -r requirments.txt&qu... | <python><github><pip> | 2024-01-08 21:01:04 | 2 | 3,446 | Encipher |
77,783,062 | 3,182,496 | MacOS - how to choose audio device from terminal | <p>I've been working on a Python program to create audio and also play back existing sound files. I can spawn multiple processes and have them all play to the laptop speakers, but I was wondering if it was possible to send each signal to a separate sound device. This is so I can apply effects to some processes but not ... | <python><macos><audio><ffmpeg> | 2024-01-08 20:39:38 | 2 | 1,278 | jon_two |
77,782,973 | 7,802,751 | How do I return to the default output (cell output) in Google Colab? Reassign sys.stdout to sys.__stdout__ doesn't seem to be working | <p>I'm trying to save results from printing the help of a function in a file, instead of presenting them on the cell output in Google Colab.</p>
<p>My code is below:</p>
<pre><code>import sys
import io
def capture_help_to_buffer(obj):
output_buffer = io.StringIO()
sys.stdout = output_buffer
try:
h... | <python><io><printf><google-colaboratory><stdout> | 2024-01-08 20:14:49 | 1 | 997 | Gustavo Mirapalheta |
77,782,906 | 7,462,275 | How to add a column in a panda series that contains the exponential of another column in multiprecision? | <p>Considering this panda data frame :</p>
<pre><code>df = pd.DataFrame({'x': list(range(-10000, 10001, 1000))})
</code></pre>
<p>I would like to insert a column (named <code>exp_x</code>) that contains the exponential of these numbers.
Multi precision is needed because some numbers are too large or too low. The gmpy2 ... | <python><pandas><multiprecision><gmpy> | 2024-01-08 19:56:03 | 0 | 2,515 | Stef1611 |
77,782,603 | 23,179,206 | Is there a way to read the values property of a PySimpleGUI combobox? | <p>I have created a PySimpleGUI combo box with code which simplifies down to:</p>
<pre><code>combo_list = ['Choice 1', 'Choice 2']
layout = [[sg.Combo(combo_list, default_value=combo_list[0], key='-COMBO-', enable_events=True)]]
</code></pre>
<p>The user is able to add items to the drop-down list, and when he quits... | <python><pysimplegui> | 2024-01-08 18:44:34 | 1 | 910 | Lee-xp |
77,782,599 | 9,443,671 | How can I extract all the frames from a particular time interval in a video? | <p>I'm trying to extract all the frames from a particular time frame in Python. For example, I want to take the frames of a video from <code>start_time = 3.25</code> to <code>end_time = 5.5</code>. Let's assume the fps of the video is 60. How would I do that?</p>
<p>Very loose code of what I'm thinking of doing:</p>
<p... | <python><opencv><video-processing> | 2024-01-08 18:43:27 | 1 | 687 | skidjoe |
77,782,460 | 1,830,639 | How to configure VsCode to debug python uvicorn + open telemetry | <p>This <a href="https://stackoverflow.com/a/61000306/1830639">answer</a> works for debugging FastAPI applications in VsCode.</p>
<p>But now I would like to debug FastAPI while using OpenTelemetry automatic instrumentation for python.</p>
<p>To run your python code with open telemetry, you need to run through the CLI l... | <python><open-telemetry><uvicorn><otel> | 2024-01-08 18:16:09 | 1 | 1,033 | JobaDiniz |
77,782,437 | 5,924,264 | How to check that all non-nan values in dataframe column are > 0? | <p>I have a dataframe column that may have NaN, which are acceptable, however non-positive values are not acceptable.</p>
<p>I tried to do</p>
<pre><code>assert (df[col] > 0).all()
</code></pre>
<p>But this asserts if there is a nan column.</p>
<p>I also tried</p>
<pre><code>assert (df[col] > 0 | df[col] == np.na... | <python><pandas><dataframe><nan> | 2024-01-08 18:11:06 | 4 | 2,502 | roulette01 |
77,782,213 | 5,133,005 | Django Foreign Key To Any Subclass of Abstract Model | <p>I have an abstract Django model with two concrete implementations. E.g.</p>
<pre class="lang-py prettyprint-override"><code>class Animal(models.Model):
name = models.CharField("name", max_length=100)
class Meta:
abstract = True
class Dog(Animal):
...
class Cat(Animal):
...
</cod... | <python><django><generic-foreign-key> | 2024-01-08 17:26:25 | 1 | 589 | Gree Tree Python |
77,782,132 | 7,243,493 | Getting lastrowid with sqlite in flask app | <p>I am having a Flask app with a factory pattern that just uses Sqlite.</p>
<p>When trying to do "last_row = db.lastrowid" id i get the error:</p>
<p>AttributeError: 'sqlite3.Connection' object has no attribute 'lastrowid'</p>
<p>When i am using this sqlite function "last_inserted_rowid"
<a href="h... | <python><sqlite><flask> | 2024-01-08 17:11:05 | 1 | 568 | Soma Juice |
77,782,115 | 3,757,672 | WGET working in WSL shell but not in pythons subprocess | <p><strong>Context</strong></p>
<p>In a Python (3.11) script in Windows WSL (version 1) I wanted to download a file using the <code>requests</code>-module. It didn't work so I did it manually in the shell using <code>wget</code>:</p>
<p><code>wget https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoke... | <python><python-requests><subprocess><windows-subsystem-for-linux> | 2024-01-08 17:07:23 | 0 | 2,497 | Markus |
77,782,091 | 4,399,016 | Removing rows that have outliers in pandas data frame using Z - Score method | <p>I am using <a href="https://stackoverflow.com/a/23202269/4399016">this code</a> to remove outliers.</p>
<pre><code>import pandas as pd
import numpy as np
from scipy import stats
df = pd.DataFrame(np.random.randn(100, 3))
df[np.abs(stats.zscore(df[0])) < 1.5]
</code></pre>
<p>This works. We can see that the numbe... | <python><pandas><outliers><z-score> | 2024-01-08 17:03:21 | 1 | 680 | prashanth manohar |
77,781,998 | 4,451,315 | Vectorized numpy functions to get elements of array between bounds defined by other array | <p>If I have</p>
<pre><code>data = np.array([97, 98, 99, 100])
offsets = np.array([0, 1, 2, 2, 3, 3, 4])
</code></pre>
<p>then I'd like to do</p>
<pre class="lang-py prettyprint-override"><code>result = []
for i in range(len(offsets)-1):
result.append(data[offsets[i]: offsets[i+1]])
</code></pre>
<p>and get</p>
<pr... | <python><numpy> | 2024-01-08 16:47:50 | 1 | 11,062 | ignoring_gravity |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.