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,993,854 | 5,057,022 | Using PyPDF2 in a with Loop - Getting ValueError | <p>I've got some code that loops over a list of pdfs, reads in each pdf in a PdfReader object and appends all but the last page to a single PdfWriter object.</p>
<p>Here is my code:</p>
<pre><code>def remove_last_page():
sorted_filenames = sorted(glob.glob('Reading*.pdf'), key = sort_key)
writer = PyP... | <python> | 2024-02-14 11:12:27 | 0 | 383 | jolene |
77,993,834 | 2,595,216 | Incompatible types in assignment for function return union of types | <p>What is best way to fix mypy for such function?</p>
<pre class="lang-py prettyprint-override"><code>from typing import Union
def a(b: int) -> Union[int, str]:
if b:
return b
else:
return '2'
c: int = a(1)
d: str = a(0)
</code></pre>
<p>mypy result:</p>
<pre><code>error: Incompatible typ... | <python><mypy><python-typing> | 2024-02-14 11:09:12 | 1 | 553 | emcek |
77,993,730 | 2,876,079 | How to use indexed data frames with altair? | <p>Lets say I have an indexed pandas DataFrame <code>indexed_df</code>:</p>
<pre><code>df = pd.DataFrame(
[
{'id_foo': 1, 'energy_carrier': 'oil', '2000': 5, '2020': 10},
{'id_foo': 2, 'energy_carrier': 'electricity', '2000': 10, '2020': 20},
]
)
indexed_df = df.pivot_table(
columns='energy... | <python><pandas><altair> | 2024-02-14 10:51:16 | 1 | 12,756 | Stefan |
77,993,663 | 2,876,079 | How to create stacked bar chart from different data format with altair in python? | <p>What y-expression should I specify in the following example to create a stacked bar chart? Is there some expression like</p>
<pre><code>y="$all-other-columns"
</code></pre>
<p>or</p>
<pre><code>y="$group-of-columns"
</code></pre>
<p>Or would I need to reshape the data to <a href="https://altair-v... | <python><pandas><altair> | 2024-02-14 10:40:09 | 1 | 12,756 | Stefan |
77,993,595 | 10,053,485 | anaconda-navigator fails to launch, ImportError. Install was previously fine | <p>After functioning fine for nearly a year my Anaconda Navigator has stopped functioning after my Windows11 device updated itself overnight (unprompted, thank you Microsoft.)
Update: <em>2024-02 Cumulative Update for Windows 11 Version 23H2 for x64-based Systems (KB5034765)</em></p>
<p>It's unclear whether this is the... | <python><anaconda> | 2024-02-14 10:30:16 | 0 | 408 | Floriancitt |
77,993,273 | 160,206 | Protocol for arithmetic operation implemented on another class | <p>In Python, arithmetic operations between operands of different types can be implemented on either of the operand types either using for example <code>__add__</code> for the left-hand operand, or <code>__radd__</code> for the right-hand operand. I'm trying to write a protocol that expresses that a type supports addit... | <python><python-typing> | 2024-02-14 09:33:47 | 0 | 77,084 | Björn Pollex |
77,993,223 | 3,433,875 | Polar bar chart with rounded corners in Matplotlib? | <p>I am trying to recreate this radial bar chart in matplotlib:
<a href="https://i.sstatic.net/X2VJp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/X2VJp.png" alt="enter image description here" /></a></p>
<p>I can do it without problems using:</p>
<pre><code> import matplotlib.pyplot as plt
impor... | <python><matplotlib> | 2024-02-14 09:25:37 | 1 | 363 | ruthpozuelo |
77,993,198 | 21,920,909 | .venv indicator may not be present in the terminal prompt | <p>After updating, I encountered an error with Visual Studio Code that was working fine before.</p>
<pre class="lang-none prettyprint-override"><code>Python virtual environment was successfully activated, even though
"(.venv)" indicator may not be present in the terminal prompt.
</code></pre>
<p>When I instal... | <python><python-3.x><visual-studio-code> | 2024-02-14 09:22:04 | 3 | 383 | SSujitXX |
77,993,188 | 7,026,806 | How do I define a pandas coercion for a custom dtype? | <p>I have a special implementation of a <code>date</code> dtype. For various reasons it isn't a <code>date</code> since that has its own set of issues.</p>
<p>For Pandas I would like to just have it treated exactly as if it was a builtin <code>datetime</code>.</p>
<p>So far I haven't been able to get around <code>TypeE... | <python><pandas><dataframe> | 2024-02-14 09:19:33 | 0 | 2,020 | komodovaran_ |
77,993,073 | 2,828,099 | python jira client and rate limit | <p>I am currently working on a script to do some bulk operations on our company jira instance, that saves plenty of time compared to doing it via the UI.</p>
<p>Unfortunately there is a very strict rate limiting in place. To not run into the limit accidentially, I have to wait 3 minutes after every 3 requests.</p>
<p>I... | <python><jira><jira-rest-api><python-jira> | 2024-02-14 09:02:04 | 1 | 1,653 | peez80 |
77,993,017 | 11,013,499 | finding the intersection of several curves in python | <p>I have 4 sets of data that try to fit curves on these data. for each of the sets of data, I used a code like below to fit a curve.</p>
<pre><code>center_540=np.sort(center_540,axis=0)
y=center_540[itr,:]
x=[0.2 ,0.4, 0.6, 0.8, 1, 2, 3, 4, 5,6]
popt, pcov,info,msg, ier= curve_fit(objective, x, y,full_output=True)
# s... | <python><python-3.x><curve-fitting> | 2024-02-14 08:51:51 | 1 | 1,295 | david |
77,992,980 | 1,753,640 | regex to extract citation | <p>Given the following example text, I want to be able to extract the sentences associated to <strong>Citation:</strong>. So for the following text:</p>
<pre><code>1. **Fact:** The Tenant is obligated to obtain all consents required by law and provide copies to the Landlord upon request.
**Citation:** "to obtai... | <python><regex> | 2024-02-14 08:44:33 | 2 | 385 | user1753640 |
77,992,967 | 22,437,609 | How can i add white border after background color in Kivy via Pure Python? | <p>Below code works and i can clearly see the blue Color(0, 0.525, 0.953, 1) background of takim_isimleri_box BoxLayout
Base code:</p>
<pre><code>from kivy.graphics import Color, RoundedRectangle, Line
from kivy.uix.boxlayout import BoxLayout
takim_isimleri_box = BoxLayout()
with takim_isimleri_box.canvas.before:
... | <python><python-3.x><kivy><kivymd> | 2024-02-14 08:42:38 | 1 | 313 | MECRA YAVCIN |
77,992,857 | 5,761,601 | How to handle events from Azure Eventhub on multiple partitions one by one by an Azure function app locally | <p>While debugging a Python azure function app locally, that processes events from an Azure Eventhub with 32 paritions I would like to know whether it is possible to handle the events one by one.
It seems that whatever setting I set to limit the number of events that arrive are always equal to the number of partitions,... | <python><azure><azure-functions><azure-eventhub> | 2024-02-14 08:17:44 | 1 | 557 | warreee |
77,992,562 | 5,810,717 | How to group by and find new or disappearing items | <p>I am trying to assess in a sales database whether the # of advertisements has changed.
The example dataframe I am using is as such:</p>
<pre><code>df = pd.DataFrame({"offer-id": [1,1,2,2,3,4,5], "date": ["2024-02-10","2024-02-11","2024-02-10","2024-02-11",&... | <python><pandas><group-by><comparison> | 2024-02-14 07:09:24 | 1 | 363 | fußballball |
77,992,364 | 9,394,465 | Processing a large csv files with pandas in a faster way | <p>I have a task of reading two large csv files (~5 millions of records, ~2Gig) every day and to process the intersecting and non-intersecting columns in different ways (which is irrelevant to the question). The problem I am facing is that the files are taking more time to load, but once they are loaded (via read_csv(.... | <python><pandas> | 2024-02-14 06:10:00 | 1 | 513 | SpaceyBot |
77,992,176 | 4,399,016 | Pandas idxmax - top n values | <p>I have this code:</p>
<pre><code>import pandas as pd
df = pd.DataFrame({'consumption': [10.51, 103.11, 55.48], 'co2_emissions': [37.2, 19.66, 1712]}, index=['Pork', 'Wheat Products', 'Beef'])
df['Max'] = df.idxmax(axis=1, skipna=True, numeric_only=True)
df
</code></pre>
<p>I need to find the n largest values. <a hre... | <python><pandas><data-wrangling> | 2024-02-14 05:05:01 | 2 | 680 | prashanth manohar |
77,992,160 | 4,277,485 | TypeError: __init__() got an unexpected keyword argument 'aws_access_key_id' | <p>I want to read parquet files in S3 using polars, evidently the following code is working in python 3.9 but not in python 3.7:</p>
<pre><code>import polars as pl
storage_options = {
"aws_access_key_id": access_key,
"aws_secret_access_key": secret_key,
"aws_session_token": tok... | <python><amazon-s3><parquet><python-polars> | 2024-02-14 04:59:42 | 0 | 438 | Kavya shree |
77,992,101 | 10,292,638 | How to get all elements as rows for each href in HTML and add it to a pandas dataframe? | <p>I am trying to fetch as rows the different values inside each href element from the following website: <a href="https://www.bmv.com.mx/es/mercados/capitales" rel="nofollow noreferrer">https://www.bmv.com.mx/es/mercados/capitales</a></p>
<p>There should be 1 row that matches each field on the provided headers for eac... | <python><pandas><dataframe><web-scraping><python-requests> | 2024-02-14 04:39:17 | 5 | 1,055 | AlSub |
77,992,011 | 964,267 | How to resolve conflicts with conda packages | <p>I have this Dockerfile and I want to install all the Python dependencies which include opencv-python 4.7.0.68 in the requirements.txt file</p>
<pre><code># PyTorch image
...
RUN pip install -r requirements.txt
</code></pre>
<p>However, I am getting this error and I can't seem to resolve the issue except not instal... | <python><docker><pytorch> | 2024-02-14 03:59:29 | 1 | 750 | ln9187 |
77,991,993 | 3,731,622 | How to configure VSCode with pylance so that I can change conda environments? | <p>When I use VSCode with pylance, if I change conda environments I get the</p>
<blockquote>
<p>overriding the stdlib module ... Pylance (reportShadowedImports)</p>
</blockquote>
<p>warning.</p>
<p>There are lots of posts about this (e.g. <a href="https://github.com/microsoft/pylance-release/issues/5191" rel="nofollow ... | <python><visual-studio-code><conda><pylance> | 2024-02-14 03:47:51 | 1 | 5,161 | user3731622 |
77,991,777 | 1,477,064 | NiceGui: Hide table header | <p>Following the <a href="https://nicegui.io/documentation/table" rel="nofollow noreferrer">documentation example</a>.</p>
<p>I wasn't able to figure out how to remove the table headers <code><th></code>, in this case the "Name" and "Age" row.</p>
<pre><code>columns = [
{'name': 'name', 'l... | <python><nicegui> | 2024-02-14 02:06:08 | 1 | 4,849 | xvan |
77,991,709 | 10,576,557 | Exception Handling for subprocess.run | <p>I am using the following code to test for error capture when sending a command to the shell:</p>
<pre class="lang-python prettyprint-override"><code>#!/usr/bin/python3
'''Trying to get a better error capture for subprocess.run'''
import subprocess
import argparse
cmd = 'ixconfig'
useShell = False
if useShell:
... | <python><python-3.x><exception> | 2024-02-14 01:31:24 | 1 | 569 | shepster |
77,991,701 | 558,639 | How to install pipenv in "externally managed environment" | <p>I want to use pipenv for managing my virtual Python environments. In a freshly built Debian (on RPi4B):</p>
<pre><code> % pip install pipenv
</code></pre>
<p>fails with</p>
<pre><code>error: externally-managed-environment
× This environment is externally managed
</code></pre>
<p>and it goes on to suggest that I ... | <python><pip><debian><raspberry-pi4><pipenv> | 2024-02-14 01:29:06 | 2 | 35,607 | fearless_fool |
77,991,554 | 10,637,953 | How is ContiguousSelection mode set in QListWiget using Python? | <p>How can we set the 'ContiguousSelection' mode for a QListWidget in Python?</p>
<p>My problem seems to be in accessing the QAbstractView modes, as given in the
QAbstractItemView docs.</p>
<p>See: <a href="https://doc.qt.io/qt-6/qabstractitemview.html#setSelectionModel" rel="nofollow noreferrer">https://doc.qt.io/qt-6... | <python><qt><selection><qlistwidget> | 2024-02-14 00:24:50 | 0 | 353 | user10637953 |
77,991,512 | 15,982,771 | How do I send a modal after a deferred button call in Pycord? | <p>I'm trying to defer a button call and then send a modal afterward in Pycord. Here's a portion of my code:</p>
<pre class="lang-py prettyprint-override"><code>class AddItemButton(Button): # Button class from discord.ui.Button
def __init__(self, title):
super().__init__(style=discord.ButtonStyle.blurple, ... | <python><pycord> | 2024-02-14 00:11:07 | 1 | 1,128 | Blue Robin |
77,991,214 | 4,408,275 | hashlib.sha256 returns different results on Linux | <p>I am hashing a file including its name from the path component with the code shown below<sup>1</sup>.
I am getting these strange results (hash value simplified for readability):</p>
<div class="s-table-container"><table class="s-table">
<thead>
<tr>
<th>Machine</th>
<th>Hash</th>
</tr>
</thead>
<tbody>
<tr>
<td>Wind... | <python><hash><hashlib> | 2024-02-13 22:32:08 | 0 | 1,419 | user69453 |
77,991,137 | 1,351,691 | python SSL error c:1000 using boto3 to connect to AWS | <p>Having an issue with python script (3.12) that previously worked that used boto3 to connect to AWS Glue and return table information.</p>
<p>The error message is:</p>
<p>"botocore.exceptions.SSLError: SSL validation failed for <a href="https://glue.us-west-2.amazonaws.com/" rel="nofollow noreferrer">https://glu... | <python><boto3><aws-glue> | 2024-02-13 22:11:00 | 1 | 589 | Jeff A |
77,991,125 | 1,597,106 | How can I stretch a list to be filled with its existing values distributed proportionally? | <p>I have a list like this:</p>
<pre><code>original_list = [10, 10, 2, 11, 11]
</code></pre>
<p>The values happen to be numbers, but they represent states. I need to "stretch" this list to a given length, and fill-in the missing values. If I were to stretch it to a length of 10 (i.e. double its length), it sh... | <python> | 2024-02-13 22:08:38 | 0 | 2,357 | antun |
77,991,106 | 8,491,510 | Fill DataFrame column value with value from parent row | <p>Let's say that I have DataFrame like this:</p>
<pre><code>+-------+----------+---------+
| Key | Parent | Value |
|-------+----------+---------|
| Key1 | Key10 | 246 |
| Key2 | Key1 | None |
| Key3 | Key14 | 434 |
+-------+----------+---------+
</code></pre>
<p>Now I need to replace dat... | <python><pandas><dataframe> | 2024-02-13 22:02:13 | 2 | 335 | Karol Oleksy |
77,991,049 | 9,915,864 | Is there a way to print a formatted dictionary to a Python log file? | <p>I've got a logging handler setup that prints to stream and file. I'm working with a few dictionaries and modifying dictionaries. Is there a way to format a dictionary for the log file so that it shows up as one block rather than a line?</p>
<p>I've gone through a bunch of simpler formatting attempts and read through... | <python><python-logging> | 2024-02-13 21:48:23 | 2 | 341 | Meghan M. |
77,990,969 | 3,837,778 | Array value must start with "{" or dimension information when excute_values to jsonb column | <p>My codes</p>
<pre><code>from psycopg2.extras import Json
from psycopg2.extensions import register_adapter
register_adapter(dict, Json)
data = [{
'end_of_epoch_data': ['GasCoin', [{'Input': 5}, {'Input': 6}, {'Input': 7}]],
}]
def get_upsert_sql(schema: str, table: str, columns: str, primary_keys: list | tuple... | <python><postgresql><psycopg2> | 2024-02-13 21:30:22 | 1 | 9,056 | BAE |
77,990,956 | 5,837,992 | Finding First and Last Values of a "Run" in Pandas | <p>I am trying to figure out the best way to get information on a "run" in pandas</p>
<p>The sample code below returns the following results:</p>
<p><a href="https://i.sstatic.net/8Lteh.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8Lteh.png" alt="enter image description here" /></a></p>
<pre... | <python><pandas><series> | 2024-02-13 21:26:48 | 2 | 1,980 | Stumbling Through Data Science |
77,990,939 | 2,658,228 | Unable to install packages in virtual environment VS Code | <p>I'm trying to install packages in a newly created virtual environment in VS Code. The environment is created and selected (highlighted in red in the below image) but <code>pip</code> is installing packages in the global environment instead:</p>
<p><a href="https://i.sstatic.net/74TQT.png" rel="nofollow noreferrer"><... | <python><visual-studio-code><virtualenv> | 2024-02-13 21:23:46 | 2 | 2,763 | Gautam |
77,990,870 | 3,448,136 | Pylint in VSCode is not reading the configuration in settings.json | <p>I installed Pylint v2023.11.13481007 (pre-release) in VSCode 1.86.1 and it works in vanilla install, i.e., no config settings. I run VSCode on a Windows machine with a remote SSH connection to a Mac laptop, so the Pylint extension is enabled on the remote SSH host. The remote host is running Python 3.10.9 and Pylint... | <python><visual-studio-code><pylint> | 2024-02-13 21:06:49 | 1 | 2,490 | Lee Jenkins |
77,990,860 | 6,943,622 | Async Programming vs Multi-threading for multiple reads to postgres | <p>So I have a python script that is going to read a million or so rows from a csv file. With the data from each row, I am going to make at most two and at least one sql query to a table in postgres. I would like to introduce some parallelism to speed up the process. I'm not yet an expert in that regard so I would like... | <python><postgresql><parallel-processing><python-asyncio> | 2024-02-13 21:04:38 | 1 | 339 | Duck Dodgers |
77,990,552 | 1,904,995 | Cannot install/run pip install -U sentence-transformers | <p>I've tried to uninstall and reinstall the packages and several other dependencies.</p>
<p>Here's my error:</p>
<pre><code> Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [31 lines of outp... | <python><pip><sentence-transformers> | 2024-02-13 19:50:25 | 1 | 568 | Head |
77,990,420 | 1,912,104 | How to create average value by group and assign loop ID to generate a polygon in a data frame? | <p>My data looks like this:</p>
<pre class="lang-py prettyprint-override"><code>mydict = {'year' : [2010, 2010, 2011, 2011, 2010, 2010, 2011, 2011],
'region' : [1,1,1,1,2,2,2,2],
'group' : ['lower', 'upper', 'lower', 'upper', 'lower', 'upper', 'lower', 'upper'],
'var' : [10,20,30,40,50,60,... | <python><pandas> | 2024-02-13 19:24:39 | 1 | 851 | NonSleeper |
77,990,385 | 19,816 | Complex C++ lifetime issue in python bindings between C++ and numpy | <p>I'm looking for advice on how to handle a complex lifetime issue between C++ and numpy / Python. Sorry for the wall of text, but I wanted to provide as much context as possible.</p>
<p>I developed <a href="https://github.com/pthom/cvnp" rel="nofollow noreferrer">cvnp</a>, a library that offers casts between bindings... | <python><c++><numpy><opencv><pybind11> | 2024-02-13 19:15:36 | 2 | 4,111 | Pascal T. |
77,990,365 | 5,031,446 | VSCode Test Debugger not stopping at breakpoints when using coverage | <p>I've started to use <code>pytest-cov</code> for coverage reporting. Using VSCode.</p>
<p>This is how I set up my <code>pytest.ini</code> file so that every time I run tests from the VSCode test explorer, the coverage report gets updated:</p>
<pre><code>[pytest]
addopts = "--cov=src/ --cov-report=lcov:lcov.info ... | <python><visual-studio-code><pytest><pytest-cov> | 2024-02-13 19:12:16 | 3 | 393 | Xoel |
77,990,353 | 1,485,926 | PyLong_Check() wrongly detecting PyBool type? | <p>I'm using <a href="https://docs.python.org/3/c-api/index.html" rel="nofollow noreferrer">Python C API</a> in my C++ program. I have a function like this one (simplified) that returns the a string with the type of a given PyObject passed as argument:</p>
<pre><code>#include <Python.h>
static std::string getPyO... | <python><python-c-api> | 2024-02-13 19:10:37 | 1 | 12,442 | fgalan |
77,990,093 | 7,700,802 | Creating a pandas dataframe from a dictionary with unique structure | <p>I have this dictionary:</p>
<pre><code>{'CC OTH 00009438 2023 TR.2a1e3e6f-58c4-4166-93ea-96073626dccb.pdf_Rebate-Count': 'Two rebate types',
'CC OTH 00009438 2023 TR.2a1e3e6f-58c4-4166-93ea-96073626dccb.pdf_Rebate-Spec-CashCredit': 'Credit Note',
'CC OTH 00009438 2023 TR.2a1e3e6f-58c4-4166-93ea-96073626dccb.pdf_Re... | <python><pandas> | 2024-02-13 18:18:26 | 5 | 480 | Wolfy |
77,989,853 | 3,828,463 | ctypes.ArgumentError Don't know how to convert parameter 1 | <p>I am getting this error (applying to x in the call to f in the definition of fun(x)):</p>
<pre><code>ctypes.ArgumentError: argument 1: <class 'TypeError'>: Don't know how to convert parameter 1
</code></pre>
<p>when running this code:</p>
<pre><code>import ctypes as ct
lib = ct.CDLL('x64\\Debug\\main2.dll')
f ... | <python><fortran> | 2024-02-13 17:34:48 | 1 | 335 | Adrian |
77,989,852 | 824,954 | Run custom function to generate choices in cookiecutter.json | <p>I need to generate choices for a cookiecutter at runtime that reflect the programs available on a system. The code to do so is ≈30 lines, and thus too complicated to be placed in <code>cookiecutter.json</code>. Where should it be placed and how should it be invoked?</p>
<p>e.g. <code>cookiecutter.json</code></p>
<pr... | <python><jinja2><cookiecutter> | 2024-02-13 17:34:37 | 1 | 2,484 | Jonathon Vandezande |
77,989,783 | 2,587,422 | Custom sqlalchemy visitor not registered | <p>I have a Postgres DB maintained via SQLAlchemy/Alembic, to which I want to add a new column of type array. I'm trying to follow this page of the SQLAlchemy documentation: <a href="https://docs.sqlalchemy.org/en/20/core/compiler.html" rel="nofollow noreferrer">https://docs.sqlalchemy.org/en/20/core/compiler.html</a><... | <python><postgresql><sqlalchemy><alembic> | 2024-02-13 17:22:23 | 1 | 315 | Luigi D. |
77,989,646 | 9,403,186 | Connecting to an On-prem Database from within Snowflake | <p>Can a connection to an on-prem database (e.g. Sybase) be made directly from Snowflake, or does it need to be made external to Snowflake? E.g., I know I can make a connection to my DB in some AWS compute (EMR, Lambda, EC2) and then load that data into Snowflake by opening a connection to Snwoflake, but I'm not sure I... | <python><snowflake-cloud-data-platform><cloud><etl> | 2024-02-13 16:58:35 | 1 | 633 | Python Developer |
77,989,616 | 3,502,079 | pyqtgraph: how to make simple plot in vs code? | <p>I am new to pyqtgraph but I cannot get it to work. I run the following code in VS code as a jupyter cell:</p>
<pre><code># %%
import pyqtgraph as pg
import numpy as np
x = np.linspace(0,10)
y = np.linspace(0,10)
X, Y = np.meshgrid(x, y)
img = np.sin(X)*np.sin(Y)
pg.image(img)
</code></pre>
<p>Then I get a frozen cel... | <python><visual-studio-code><plot><pyqtgraph> | 2024-02-13 16:53:44 | 1 | 392 | AccidentalTaylorExpansion |
77,989,391 | 541,729 | How do I extract data from a document using the OpenAI API? | <p>I want to extract key terms from rental agreements.</p>
<p>To do this, I want to send the PDF of the contract to an AI service that must return some key terms in JSON format.</p>
<p>What are some of the different libraries and companies that can do this? So far, I've explored the OpenAI API, but it isn't as straight... | <python><artificial-intelligence><openai-api><openai-assistants-api> | 2024-02-13 16:13:32 | 1 | 7,341 | Kritz |
77,989,376 | 10,224,533 | Using user defined functions in pandas eval | <p>I'm trying to use my custom function within pandas eval. It works properly for limited use:</p>
<pre class="lang-python prettyprint-override"><code>basic_df = DataFrame({"A":[1,2,3,4,5],"B":[20,40,60,100,90],
"C":["C1","C2","C3&quo... | <python><pandas><parsing><eval> | 2024-02-13 16:11:07 | 1 | 303 | Konstanty Maciej Lachowicz |
77,989,371 | 893,254 | Should Python properties use underscores as a name prefix? | <p>Take a look at <a href="https://realpython.com/python-getter-setter/" rel="nofollow noreferrer">this article</a>, which explains Python Properties.</p>
<p>(You can access it via archive.ph to get around the paywall.)</p>
<p>In the article the following code is presented:</p>
<pre><code># employee.py
from datetime i... | <python><properties> | 2024-02-13 16:10:10 | 2 | 18,579 | user2138149 |
77,989,271 | 306,381 | Unable to run Connexion 3 /w Flask - Middleware loads swagger twice | <p>I have created a openapi.yml file and initiated a connexion app and started the app without any errors.</p>
<p>My directory structure is as follows:</p>
<pre><code>/my_app
/app
__init__.py
/api
__init__.py
api.py # My API endpoint implementations
/models
... | <python><flask><swagger><openapi><connexion> | 2024-02-13 15:54:02 | 0 | 473 | Qedrix |
77,989,265 | 4,699,441 | Pydantic/JSON: do not serialize fields with default value | <p>I have a class with a member that has a default value.</p>
<p>I do not wish the default value to be part of the serialization.</p>
<p>Example:</p>
<pre><code>import json
from typing import List
from pydantic import BaseModel
from pydantic.json import pydantic_encoder
class Animal(BaseModel):
name: str
legs: i... | <python><json><pydantic><pydantic-v2> | 2024-02-13 15:53:13 | 1 | 1,078 | user66554 |
77,989,093 | 5,722,359 | "isinstance() and not" vs "==" for checking x=() | <p>I want an if-statement to check if <code>x</code> is an empty tuple.</p>
<p>Is there any significant advantage of writing the if-statement as</p>
<pre class="lang-py prettyprint-override"><code>if isinstance(x, tuple) and not x:
</code></pre>
<p>vs</p>
<pre class="lang-py prettyprint-override"><code>if x == ():
</co... | <python> | 2024-02-13 15:25:46 | 2 | 8,499 | Sun Bear |
77,988,462 | 2,558,463 | Azzure AD JWT validation: signature verification failed | <p>i stumbled in a problem, i have this JWT verification code:</p>
<pre><code>def validate_access_token(self, access_token):
jwks_url = f"{self.authority}/discovery/v2.0/keys"
# Fetch keys from the JWKS endpoint
response = requests.get(jwks_url)
jwks_data = response.json()
... | <python><azure-active-directory><jwt><fastapi> | 2024-02-13 13:54:57 | 1 | 511 | galih |
77,988,452 | 2,882,125 | Assigning Pydantic Settings Fields not by alias even when environment variable is defined | <p>I’d like to be able to create a Pydantic Settings object where the environment variable can be overriden if desired. In the example below the constructor call for <code>user_3</code> fails:</p>
<pre class="lang-py prettyprint-override"><code>from pydantic import Field
from pydantic_settings import BaseSettings, Sett... | <python><pydantic><pydantic-settings> | 2024-02-13 13:52:54 | 1 | 390 | RonenKi |
77,988,426 | 8,284,452 | Why did mamba keep older version of package's files in /pkgs directory upon update to newer version? | <p>I updated a python package using mamba to a newer version, but I found it kept the files of the older version in the <code>mamabforge/pkgs</code> directory. Why would it do this and what is the proper way to update packages so it completely removes the older version?</p>
<p>I was updating the <code>libcurl</code> pa... | <python><conda><mamba><mini-forge><mambaforge> | 2024-02-13 13:49:17 | 1 | 686 | MKF |
77,988,380 | 22,221,987 | Convert local coordinate system to global system and vice versa | <p>I'm trying to convert local coordinate system to global coordinate system and vise versa.<br />
I have 3 position coordinates and 3 rotating angles, so my input is <code>(X, Y, Z, RX, RY, RZ)</code>.</p>
<p>I'm trying to understand the theory of this process, but I don't have enough experience in math science to ext... | <python><math><matrix><linear-algebra><coordinate-systems> | 2024-02-13 13:44:11 | 1 | 309 | Mika |
77,988,374 | 1,014,217 | torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 112.00 MiB | <p>I have a big compute, 448gb of ram and 4 GPUS and I am executing this code:</p>
<pre><code>import torch
import pandas as pd
from pyspark.sql.functions import pandas_udf
from pyspark.sql.types import StringType
from pyspark.sql import SparkSession
from transformers import pipeline
# Initialize the SparkSession
spark... | <python><pandas><apache-spark><pyspark><pytorch> | 2024-02-13 13:42:51 | 0 | 34,314 | Luis Valencia |
77,988,116 | 8,848,025 | Using regular expressions in Python to find specific word | <p>I have following lines (the order of lines can be different, there can be other similar lines as well). And I would like to replace <code>"sid"</code> with <code>"tempvalue"</code> taking into an account that <code>"sid"</code> can be surrounded by any symbol except for letters and digi... | <python><python-re> | 2024-02-13 13:01:32 | 1 | 720 | Prokhozhii |
77,988,008 | 14,636,729 | How to read scalar, vector and matrix information in string format resembling Python syntax in R? | <p>I have strings that contain scalars, vectors, and matrices, e.g.</p>
<p>"[0,1],[[1,2],[3,4]],42"</p>
<p>And following the same example, that input in R should give me this:</p>
<pre><code>[[1]]
[1] 0 1
[[2]]
[,1] [,2]
[1,] 1 3
[2,] 2 4
[[3]]
[1] 42
</code></pre>
<p>So the notation is sim... | <python><r><parsing><matrix> | 2024-02-13 12:45:35 | 1 | 653 | Aku-Ville Lehtimäki |
77,987,920 | 5,820,814 | Pandas: Explode a list of nested dictionaries column and append as new rows | <p>Please consider the below dict for example:</p>
<pre><code>d2 = [{'event_id': 't1',
'display_name': 't1',
'form_count': 0,
'repetition_id': None,
'children': [{'event_id': 't_01',
'display_name': 't(1)',
'form_count': 1,
'repetition_id': 't1',
'children': [],
'forms': [{'form_id': 'f1',
... | <python><pandas><nested> | 2024-02-13 12:29:40 | 1 | 34,176 | Mayank Porwal |
77,987,566 | 3,077,037 | How can I load excel in visio using python? | <p>I have an excel file containing columns:
Process step ID, Process step description, Next step ID, Connector label, Shape type, Function, Phase.</p>
<p>It has everything required. I want to load it in visio and map the columns to corresponding types and then generate flow. I can do it manually using opening visio->... | <python><visio> | 2024-02-13 11:30:40 | 1 | 940 | Nazmul Hasan |
77,987,511 | 7,454,177 | Why is this type annotation not showing up in FastAPI? | <p>This is one of the endpoints in my FastAPI application:</p>
<pre><code>@router.get("/", response_model=Page[DeviceConfigSchemaOUT])
async def get_device_configs(
search: str | None = None,
page: int = 1,
size: int = 50,
) -> Any:
...
</code></pre>
<p>Which shows up like this in Swagger:<... | <python><fastapi><python-typing> | 2024-02-13 11:22:25 | 1 | 2,126 | creyD |
77,987,451 | 18,030,965 | Django - How to use AJAX within a form | <p>I'm trying to use AJAX for the first time as we have a Django project but a required feature is for one form to behave more like a react app or SPA so I'm trying to use AJAX to add that functionality. I have the following template for the page. It has a form to let the user select from a dropdown what their highest ... | <javascript><python><django><ajax><django-rest-framework> | 2024-02-13 11:11:04 | 0 | 351 | Jack Duffy |
77,987,420 | 1,922,302 | Get real count of solutions of MIP Gurobi model | <p>I have a MIP model that was already solved to some extent with a time limit, and now I want to get exactly one more solution.</p>
<p>One way to produce one additional solution is to keep doing this from the beginning by incrementing <code>model.Params.SolutionLimit</code> one by one.</p>
<p>But in my situation I don... | <python><optimization><gurobi><mixed-integer-programming> | 2024-02-13 11:04:35 | 0 | 953 | johk95 |
77,987,278 | 4,575,197 | Feature selection using backward feature selection in scikit-learn and PCA | <p>i have calculated the scores of all the columns in my DF,which has 312 columns and 650 rows, using PCA with following code:</p>
<pre><code>all_pca=PCA(random_state=4)
all_pca.fit(tt)
all_pca2=all_pca.transform(tt)
plt.plot(np.cumsum(all_pca.explained_variance_ratio_) * 100)
plt.xlabel('Number of components')
plt.g... | <python><pca><feature-selection> | 2024-02-13 10:42:34 | 1 | 10,490 | Mostafa Bouzari |
77,987,277 | 6,649,591 | How can I build an embedding encoder with FastAPI | <p>I just want to use a pre-trained open source embedding model from SentenceTransformer for encoding plain text.</p>
<p>The goal is to use swagger as GUI - put in a sentence and get out embeddings.</p>
<pre><code>from fastapi import Depends, FastAPI
from pydantic import BaseModel
from sentence_transformers import Sent... | <python><fastapi><word-embedding> | 2024-02-13 10:42:23 | 1 | 487 | Christian |
77,987,186 | 350,685 | Unable to get flask_mysqldb to work with python 3.x | <p>I have a <code>flask</code> application that uses <code>flask_mysqldb</code> to connect with database. I had imported <code>MySQLdb</code> and <code>flask_mysqldb</code> packages to use. Some update today morning screwed this. I had to replace <code>MySQLdb</code> with <code>pymysql</code> because it is not compatib... | <python><mysql-python><flask-mysql> | 2024-02-13 10:28:18 | 0 | 10,638 | Sriram |
77,987,163 | 5,346,843 | Change logging level dynamically in Python | <p>I am logging messages from various modules and want to change the log level dynamically. The code snippet is</p>
<pre><code>import logging
logging.basicConfig(filename='my_log.log', filemode='w', encoding='utf-8', level=logging.WARNING, force=True)
# Code here that works so only worry about WARNINGs
# ....
# Code... | <python><logging> | 2024-02-13 10:25:24 | 0 | 545 | PetGriffin |
77,986,991 | 1,189,330 | Errno 111 Connection refused from web.archive.org | <p>Does web.archive.org have any limits?</p>
<p>I'm trying to pump pages out of webarchive with pause using python. But after less than a minute I get an error:</p>
<pre><code>ConnectionRefusedError: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
NewConnectionError... | <python> | 2024-02-13 09:54:37 | 1 | 1,304 | IvanS |
77,986,897 | 16,798,185 | Dynamically derive dataframe names for assignment | <p>I have array of columns. For each of the column in the array, I need to perform same operation and create in a separate dataframe. So that later these dataframes can be merged/joined into one.</p>
<p>with below, getting error : cannot assign to expression here. Maybe you meant '==' instead of '='?</p>
<p>I get that ... | <python><apache-spark><pyspark> | 2024-02-13 09:39:46 | 2 | 377 | user16798185 |
77,986,845 | 10,695,613 | I am training an autoencoder for anomaly detection. How can I incorporate anomalous data in training using a custom loss function? | <p><a href="https://arxiv.org/pdf/1903.10709.pdf" rel="nofollow noreferrer">This</a> paper suggests the following algorithm that incorporates anomalous data points into the training process:</p>
<p>Algorithm 1 Autoencoding Binary Classifiers</p>
<pre><code>while not converged do:
Sample minibatch {(x1, y1), · · · , (... | <python><tensorflow><keras> | 2024-02-13 09:33:15 | 1 | 405 | BovineScatologist |
77,986,837 | 19,318,120 | Celery Redis how to prevent task acknowledge if raised an exception | <p>I want to prevent celery from acknowledging task if it raised an exception</p>
<p>setting acks_late didn't make any difference</p>
<pre><code>@app.task(acks_late=True)
def send_mail(data):
raise Exception
</code></pre>
<p>I tried doing the following</p>
<pre><code>class CeleryTask(celery.Task):
def on_failu... | <python><redis><celery> | 2024-02-13 09:31:42 | 0 | 484 | mohamed naser |
77,986,775 | 10,053,485 | Pydantic / FastAPI, how to set up a case-insensitive model with suggested values | <p>Using FastAPI I have set up a POST endpoint that takes a command, I want this command to be case insensitive, while still having suggested values (i.e. within the SwaggerUI docs)</p>
<p>For this, I have set up an endpoint with a <code>Command</code> class as a schema for the POST body parameters:</p>
<pre class="lan... | <python><fastapi><pydantic> | 2024-02-13 09:22:47 | 3 | 408 | Floriancitt |
77,986,643 | 1,980,208 | how to execute multiple functions in pandas groupby processing | <p>I am calculating <code>pct_change</code> in pandas groupby but from the first element of each group. Hence i am using <code>cumprod()</code>. I already have a working code but it is little ugly. How can i use <code>pct_change()</code> and <code>cumprod()</code> in one liner.</p>
<p><strong>My code:</strong></p>
<pre... | <python><pandas> | 2024-02-13 08:59:21 | 1 | 439 | prem |
77,986,459 | 6,839,853 | how to decompress and write to disk lz4 compressed OS image | <p>I am trying to fetch an OS image with pycurl and write the decompressed data to disk. With gzip it is straight forward, only with lz4 formats I face issues, it seems the write_lz4(buf) decompresses and writes to disk, only when I try to resize the partition, I get an error:</p>
<blockquote>
<p>entries is 0 bytes, bu... | <python><zlib><pycurl><lz4> | 2024-02-13 08:24:58 | 1 | 625 | Max |
77,986,253 | 10,570,372 | List is invariant because it violates LSP? | <p>Python's type system says that list is invariant, and that <code>List[int]</code> is not a subtype of <code>List[float]</code>.</p>
<p>Here's the Python code snippet:</p>
<pre class="lang-py prettyprint-override"><code>def append_pi(lst: List[float]) -> None:
lst += [3.14]
my_list = [1, 3, 5] # type: List[i... | <python><python-typing><liskov-substitution-principle><invariance> | 2024-02-13 07:44:22 | 0 | 1,043 | ilovewt |
77,986,231 | 3,828,463 | Linking Python to a complex Fortran model which needs to return to the caller | <p>I have a complex model written in Fortran which is a self contained entity which reads an input file, allocates memory for all the data structures, initializes the model, provides guesses to the solution, uses a derivative-based solver to solve the nonlinear equations, and populates the output structures, deallocate... | <python><fortran> | 2024-02-13 07:40:09 | 0 | 335 | Adrian |
77,986,158 | 2,711,059 | Getting Empty Result while trying to read S3 bucket file using boto3 | <p>I am trying to access a CSV file from S3 bucket by using the following code in python</p>
<pre><code>s3=boto3.client('s3')
_data=s3.get_object(Bucket='ml-titanic-dataset',Key='test_data/test.csv')
_data['Body'].read().decode('utf-8')
</code></pre>
<p>I am getting the result as empty but i have data inside the mapped... | <python><amazon-s3><boto3> | 2024-02-13 07:25:57 | 0 | 5,268 | Lijin Durairaj |
77,985,988 | 10,795,596 | how to avoid string with certain words before # | <p>I have to find strings doesn't have either of words(as word boundaries) abc, def or ghi anywhere before # using regex in python</p>
<p><strong>he is abc but # not xyz</strong> - no match</p>
<p><strong>he is good # but small</strong> - match</p>
<p><strong>he might ghi but # not abc will</strong> - no match</p>
<p>... | <python><regex> | 2024-02-13 06:51:35 | 1 | 332 | Cassius Clay |
77,985,422 | 9,776,466 | Is regex in python different with regex in other system like PostgreSQL? | <p>I have this code to parsing street and house number in Python</p>
<pre><code>import re
def parse_street(address):
pattern = r'^(.*?)(?i)\b no\b'
match = re.match(pattern, address)
if match:
return match.group(1).strip()
else:
return None
def parse_housenumber(address):
pattern... | <python><regex><postgresql> | 2024-02-13 03:24:58 | 1 | 561 | Hermawan Wiwid |
77,985,337 | 4,898,202 | How can I calculate the difference between two named columns in a huge CSV file, then save the results to a second CSV file? | <p>I have a CSV file containing almost 200 million rows (gigabytes of data). It has only 5 columns. I want to iterate over the data and do simple calculations, first between columns, but then between rows.</p>
<p>Sample data:</p>
<pre><code>DateTime,Width,Length,Count,Age
01.01.2010 00:00:00,0.55,0.25,1,4
07.02.2010 00... | <python><pandas><dataframe><statistics><bigdata> | 2024-02-13 02:47:00 | 1 | 1,784 | skeetastax |
77,985,260 | 1,887,281 | Concurrency issue with writing batches via AIOFile - output file data getting corrupted | <p>I'm having trouble concurrently writing to a couple of files. I tried adding locks to prevent a race condition on the writes, and I verified that the data is valid when it enters the <code>write_batches</code> method, but when I check the data in either of the output files, it's all messed up. It appears that each w... | <python><python-asyncio> | 2024-02-13 02:17:28 | 1 | 5,144 | devinbost |
77,985,182 | 7,587,176 | Reshaping DataFrame; Melt/Pivot | <p>Body:</p>
<p>Problem:</p>
<p>I have a wide DataFram that I'm struggling to reshape and aggregate using pandas.</p>
<p>Sample Data:</p>
<div class="s-table-container"><table class="s-table">
<thead>
<tr>
<th>Unnamed: 1</th>
<th>Unnamed: 2</th>
<th>Unnamed: 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bezeichnung (Bezirksre... | <python><pandas><transformation><data-modeling> | 2024-02-13 01:43:25 | 1 | 1,260 | 0004 |
77,985,008 | 816,566 | How to migrate from python 2.7 urllib2.Request to python 3.10 urllib.requests.Request, and encode data in a compatible way? | <p>I'm trying to port some code from python 2.7 which uses <code>urllib2.Request</code>, to python 3.10, and use the newer <code>json.dumps()</code> function and the <code>urllib.requests.Request</code> class. My problem is that the server accepts Posts from the original code, but fails with an in internal 500 error wh... | <python><json><request><urllib> | 2024-02-13 00:29:54 | 1 | 1,641 | Charlweed |
77,984,922 | 395,857 | How can I get the embedding of a document in langchain? | <p>I use the langchain Python lib to create a vector store and retrieve relevant documents given a user query. How can I get the embedding of a document in the vector store?</p>
<p>E.g., in this code:</p>
<pre><code>import pprint
from langchain_community.vectorstores import FAISS
from langchain_community.embeddings imp... | <python><nlp><langchain><word-embedding> | 2024-02-12 23:59:51 | 1 | 84,585 | Franck Dernoncourt |
77,984,857 | 23,393,520 | Paho MQTT "Unsupported callback API version" error | <p>I am trying to implement Paho Python MQTT and connect to an online broker but the code seems to through an error.</p>
<blockquote>
<p>ValueError: Unsupported callback API version: version 2.0 added a callback_api_version, see migrations.md for details</p>
</blockquote>
<p>I was trying to implement a simple paho clie... | <python><mqtt><mosquitto><paho><hivemq> | 2024-02-12 23:35:44 | 5 | 349 | user330720 |
77,984,737 | 1,730,405 | Python socket servers don't see abrupt disconnect when using docker network | <p>When running a socket server and client in python, an abrupt disconnect by the client is handled differently by the server when running both locally versus running both in docker containers and through a docker network. If it matters, all of these tests are done on a Linux machine.</p>
<p>Here is a simple socket ser... | <python><docker><sockets><docker-compose> | 2024-02-12 22:58:22 | 2 | 391 | Elias Benevedes |
77,984,729 | 21,313,539 | ImportError: cannot import name 'VectorStoreIndex' from 'llama_index' (unknown location) | <p>I ran into this problem when I was trying to import the following libraries and it is giving the error "ImportError: cannot import name 'VectorStoreIndex' from 'llama_index' (unknown location)"</p>
<p>I ran this exact same code in the morning and it worked perfectly.</p>
<p>I did <code>!pip install llama_i... | <python><jupyter-notebook><amazon-sagemaker><huggingface><llama-index> | 2024-02-12 22:56:20 | 7 | 471 | lat |
77,984,545 | 6,843,153 | How to fulfill ABC class definition of abstract properties in child class in Python | <p>I have the following abc class:</p>
<pre><code>class Logger(ABC):
@abstractproperty
def filename_prefix(self):
pass
@abstractproperty
def trace_id_length(self):
pass
@abstractproperty
def run_id_length(self):
pass
def __init__(self):
self._load_history()... | <python><abstract-class> | 2024-02-12 22:01:47 | 0 | 5,505 | HuLu ViCa |
77,984,347 | 1,018,447 | Pydantic 2: JSON serialize a set to a sorted list | <h3>Context</h3>
<p>In Pydantic 2, fields of type <code>set</code> are already JSON-serialized to lists. However, these lists are unordered. Or, more specifically, their items are ordered according to internal ordering of the original set.</p>
<p>Unfortunately, even when two sets contain the same items, their internal ... | <python><serialization><pydantic> | 2024-02-12 21:11:24 | 1 | 957 | Peter Bašista |
77,984,323 | 356,630 | cross compiled numpy with clang depends on libgcc_s.so.1 | <p>I am trying to cross compile numpy for an different platform using a clang-based cross compiler toolchain. I have built a custom version of python that runs on the target platform, and trying to use crossenv make a wheel of numpy. Even though the underlying compiler that I am using is clang (both host-python and bui... | <python><numpy><clang><cross-env> | 2024-02-12 21:06:06 | 1 | 1,618 | Lawrence Kok |
77,984,267 | 11,248,638 | Expanding Rows in Pandas DataFrame based on Time Intervals, Accounting for Optional Breaks | <p>I have a Pandas DataFrame representing timesheets with start and end times, as well as optional rest and meal break intervals. My goal is to expand a single row into multiple rows with correct intervals. It's worth noting that:</p>
<ul>
<li>A timesheet might not have any breaks.</li>
<li>A timesheet might have only ... | <python><pandas><dataframe><datetime> | 2024-02-12 20:52:13 | 1 | 401 | Yara1994 |
77,984,234 | 3,007,075 | pandas rolling window apply function to dataframe slice? | <p>Without indexing and for/while loops, I'd like to apply a function to a rolling window on my dataframe, that returns a row, for what will become a new dataframe (or extra columns on my previous one). The best method I've found so far is the one below:</p>
<pre class="lang-py prettyprint-override"><code>import numpy ... | <python><pandas><dataframe> | 2024-02-12 20:43:34 | 1 | 1,166 | Mefitico |
77,983,855 | 7,587,176 | CKAN Data Extraction via API | <p><strong>Goal:</strong> Extract Berlin Crime Data via CKAN.</p>
<p>Can you anyone help me write a basic api request to validate that you can return the data documented here via CKAN? I am having trouble understanding how to adjust the url when it is not demo data. The goal is to extract berlin crime data : <a href="h... | <python><ckan><opendata> | 2024-02-12 19:28:00 | 0 | 1,260 | 0004 |
77,983,736 | 15,176,150 | Can MLFlow be used without the `with mlflow.start_run()` block? | <p>I want to track an entire notebook and log the parameters of cleaning steps that occur before training a model. I'd like to use <a href="https://mlflow.org/docs/latest/index.html" rel="nofollow noreferrer"><code>mlflow</code></a> to do it, but on all the docs it looks like you have to track models using this format:... | <python><machine-learning><mlflow><mlops> | 2024-02-12 19:05:13 | 1 | 1,146 | Connor |
77,983,609 | 1,711,271 | merge some columns in a Polars dataframe and duplicate the others | <p>I have a similar problem to <a href="https://stackoverflow.com/q/77982046/1711271">how to select all columns from a list in a polars dataframe</a>, but slightly different:</p>
<pre><code>import polars as pl
import numpy as np
import string
rng = np.random.default_rng(42)
nr = 3
letters = list(string.ascii_letters)
... | <python><concatenation><python-polars> | 2024-02-12 18:36:51 | 2 | 5,726 | DeltaIV |
77,983,552 | 2,384,982 | How to slice 2D array from 3D array using a 2D array that represents the indices for the first dimension? | <p>Create a sample 3D array with shape (10, 33, 66)</p>
<p><code>data_3d = np.random.random((10, 33, 66))</code></p>
<p>Create a 2D index array with shape (33, 66) representing indices for the first dimension</p>
<p><code>index_2d = np.random.randint(0, 10, size=(33, 66))</code></p>
<p>How to slice a 2D array with shap... | <python><arrays><numpy> | 2024-02-12 18:25:25 | 1 | 371 | Yu Guo |
77,983,466 | 6,498,753 | scipy lognorm does not converge to params | <p>I have manually fitted a lognormal distribution to my data:</p>
<pre><code>from scipy.stats import lognorm
sigma = 0.15
mu = 2
x_fit = np.linspace(x.min(), x.max(), 100)
y_fit = lognorm.pdf(x_fit, sigma, scale=np.exp(mu))
fig, ax = plt.subplots()
plt.plot(x_fit, y_fit, color='red')
</code></pre>
<p><a href="https:/... | <python><scipy><curve-fitting><distribution><scipy-optimize> | 2024-02-12 18:10:17 | 1 | 461 | Roland |
77,983,362 | 9,582,542 | Unable to use scrapy to login into Instagram | <p>I am trying to use scrapy to log into Instagram to scan and read comments but I cant seem to be able to login looks likr the request gets blocked by a bot. Is there a better way to attempt the scrapy login?</p>
<pre><code>url = 'https://www.instagram.com/accounts/login'
request = scrapy.Request(url,method='GET')
fet... | <python><scrapy> | 2024-02-12 17:47:37 | 0 | 690 | Leo Torres |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.