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,929,930 | 14,256,643 | Django rest how to show hierarchical data in api response | <p>I am getting the category id for GET request but I want to show text in hierarchical structure like child1 -> child -> child3</p>
<p>my expected response will be look like this</p>
<pre><code>{
'category': 'child1 -> child -> child3'
}
</code></pre>
<p>now getting response like this</p>
<pre><code>{
'cat... | <python><python-3.x><django><django-models><django-rest-framework> | 2024-02-02 21:28:38 | 1 | 1,647 | boyenec |
77,929,691 | 4,134,881 | Why doesn't this simple while loop work with sympy? | <p>Consider the following commands</p>
<pre class="lang-py prettyprint-override"><code>from sympy import init_session()
init_session
def test(v, th):
va = v
val = 5*ln((2*(10**4))/(2*(10**4)+va-10))
while (va-val > th):
va=va-0.01
val = 5*ln((2*10**4)/(2*10**4+va-10))
return val
</co... | <python><while-loop><sympy> | 2024-02-02 20:27:27 | 1 | 3,514 | xoux |
77,929,667 | 386,861 | Trying to understand Bayes theory with direct application | <p>I'm trying to apply Bayes theorem to a problem of my own so I can understand the methodology and how to set up the numbers.</p>
<p>Essentially, I've got some data on four artists and the number of objects that they make every month over 80 periods.</p>
<p>I'm interested in 'h' and believe there are three possibiliti... | <python><pandas><bayesian> | 2024-02-02 20:22:50 | 0 | 7,882 | elksie5000 |
77,929,620 | 1,058,090 | Could not switch to new window and verify content using Selenium python | <p>I am automating a saas application using Selenium Python, and in that i need to verify a new window content, after clicking on the button. Below is the screenshot of the window.</p>
<p><a href="https://i.sstatic.net/qu5Zt.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/qu5Zt.png" alt="enter image desc... | <python><selenium-webdriver> | 2024-02-02 20:09:55 | 1 | 534 | Vincent |
77,929,607 | 816,566 | How can I reduce the namespace qualifiers When using inner Enums? | <p>I'm using Python 3.10.12.
When I use an inner <code>Enum</code>, my code has many redundant namespace qualifiers, and they require a lot of horizontal space. How can I reduce them? For example:</p>
<pre><code>class Outer:
class InnerEnum(Enum):
INNER_VALUE_ONE = 1
INNER_VALUE_TWO = 2
def ou... | <python><enums> | 2024-02-02 20:06:13 | 1 | 1,641 | Charlweed |
77,929,603 | 7,259,176 | Element-wise comparison of SymPy Matrices | <p>Is there a convenient way to compare two equal sized SymPy matrices element-wise?</p>
<p>Here's what I'm attempting:</p>
<pre class="lang-py prettyprint-override"><code>from sympy import Matrix
def element_wise_matrix_comparison(matrix1, matrix2):
result_matrix = Matrix([[matrix1[i, j] == matrix2[i, j] for j in... | <python><sympy> | 2024-02-02 20:04:46 | 3 | 2,182 | upe |
77,929,560 | 590,552 | Python Loading JSON config file on __init__ | <p>I am new to Python and I am trying to create a class that handles loading my config values.
So far this is what I have :</p>
<pre><code>import os, json
class ConfigHandler:
CONFIG_FILE = "/config.json"
def __init__(self):
print("init config")
if os.path.exists(self.CONFI... | <python><json><python-3.x> | 2024-02-02 19:54:39 | 2 | 312 | evolmonster |
77,929,554 | 1,316,702 | databricks - how to debug parameters when calling function | <p>In databricks, I have 2 notebooks. One notebooks holds a function. The other notebook calls the function in the first notebook.</p>
<p>this is how I am calling the function</p>
<pre><code>from pyspark.sql.functions import col
df_adatposUpload = joined_df.select(
,'PATBKG'
,varMyBloombergFun... | <python><tags><databricks> | 2024-02-02 19:53:37 | 1 | 1,277 | solarissf |
77,929,475 | 50,385 | Is it possible to check if an asyncio.Task is blocked vs ready? | <p>I'm working on a make-like system written in Python and I want to be able to throttle how many cores are in use for parallel building, similar to the <a href="https://www.gnu.org/software/make/manual/html_node/Parallel.html" rel="nofollow noreferrer"><code>-j</code>/<code>--jobs</code> option supported by GNU make</... | <python><async-await><python-asyncio><event-loop> | 2024-02-02 19:37:35 | 1 | 22,294 | Joseph Garvin |
77,929,347 | 1,029,902 | Insert row from CSV file2 in file1 if row is unique in file1 (according to a common key) | <p>I have two csv files that have the same structure. <code>tops.csv</code> and <code>yesterday.csv</code>. I am first sorting yesterday by a specific column than I want to take the row with the highest value in that column. For this row, I want to check 3 of its columns, (the 3rd fourth and fifth columns) and see if t... | <python><pandas><dataframe><csv> | 2024-02-02 19:11:08 | 2 | 557 | Tendekai Muchenje |
77,929,264 | 2,812,625 | Python Dictionary from pd.DataFrame | <p>How come this method results in an embedded dictionary which then I can not use to rename columns.</p>
<pre><code># Rename columns
cen_columns = cen_columns[['VARIABLE','LABEL_CLEAN']].set_index("VARIABLE").to_dict()
census_age.columns = census_age.columns.to_series().map(cen_columns['LABEL_CLEAN'])
</code... | <python><pandas><dictionary> | 2024-02-02 18:54:42 | 1 | 446 | Tinkinc |
77,929,243 | 14,735,451 | Find unique answers from list of strings | <p>I have 2 lists:</p>
<pre><code>texts = ["this is string 1", "this is string 2", "this is string 3"]
answers = ["this", "string 1", "string 3"]
</code></pre>
<p>I need to create a function that returns as many possible answers from <code>answers</code> (and ... | <python><string><list> | 2024-02-02 18:49:45 | 1 | 2,641 | Penguin |
77,929,212 | 823,859 | Uninstall package located in /Library/Python/3.9/bin | <p>I would like to install a package (streamlit) only in a <code>conda</code> environment, not system-wide. However, when I go to <code>pip install</code> it in the environment, it says that the requirements were already satisfied in <code>/Users/adamg/Library/Python/3.9/bin</code>. How do I remove this instance, so th... | <python><pip><anaconda><streamlit> | 2024-02-02 18:41:38 | 1 | 7,979 | Adam_G |
77,929,174 | 1,313,890 | Pyspark adding an extra row with `.select` | <p>I have a pyspark dataframe that I am building out to get the unique values of a column in a table. I have run scripts on this table to update any NULL values in the column in question and have confirmed that there are no NULL values in the table. Here's where things get a weird.</p>
<p>I use <code>.groupBy</code> to... | <python><pyspark><databricks><delta-live-tables> | 2024-02-02 18:33:07 | 0 | 547 | Shane McGarry |
77,929,077 | 1,663,382 | How to maintain Polars DataFrame metadata through processing, serialization and deserialization in Apache Arrow IPC format in Python? | <p>I would like to be able to track metadata related to a <a href="https://docs.pola.rs/user-guide/concepts/data-structures/#dataframe" rel="nofollow noreferrer">polars DataFrame</a> through processing, serialization, and deserialization using the Apache Arrow IPC format in python-polars. How can this be accomplished?<... | <python><python-3.x><dataframe><metadata><python-polars> | 2024-02-02 18:12:32 | 1 | 718 | Liquidgenius |
77,929,049 | 2,038,912 | Convert a DataFrame of 2 columns into a dict ColA -> ColB | <p>If I had a DataFrame of 2 columns(a and b)
How do I convert this into a dictionary mapping a->b?
(None of the DataFrame.to_dict() options is doing what I want</p>
<pre><code>pd.DataFrame(data={ 'a':[1,3], 'b':[2,4]})
a b
0 1 2
1 3 4
</code></pre>
<p>and I want a resulting dictionary like</p>
<pre><code>{ ... | <python><pandas><dictionary> | 2024-02-02 18:04:40 | 2 | 593 | 9mjb |
77,928,941 | 10,437,727 | How to run a FileSensor inside of an Airflow task? | <p>Airflow version: 2.8</p>
<p>I'm struggling to run a <code>FileSensor</code> inside a DAG in Airflow. I built a generic <code>FileSensor</code> <em>generator</em>:</p>
<pre class="lang-py prettyprint-override"><code>def generic_human_feedback_sensor(step_name: str) -> FileSensor:
prefix = ""
run_... | <python><airflow> | 2024-02-02 17:43:01 | 0 | 1,760 | Fares |
77,928,740 | 1,576,208 | Python sockets in a multithreaded program with classes/objects interfere with each other | <p>As an aid to my work, I am developing a communication simulator between devices, based on TCP sockets, in Python 3.12 (with an object oriented approach).
Basically, the difference between a SERVER type communication channel rather than a CLIENT type is merely based on the way by which the sockets are instantiated: r... | <python><java><multithreading><sockets><tcp> | 2024-02-02 17:06:31 | 1 | 5,467 | SagittariusA |
77,928,449 | 3,170,559 | How to get data from REST API over self-hosted integration runtime on Synapse Analytics? | <p>In my company I got access to a data source via a REST API which can only be accessed from within the company network. When I run my code for testing on my pc, it works as expected. However, I want to run the code on Synapse Analytics which is not internal because it is in Azure. So the code won't work. We got a sel... | <python><azure><rest><azure-data-factory><azure-synapse> | 2024-02-02 16:20:47 | 1 | 717 | stats_guy |
77,928,407 | 3,160,284 | NumPy C-API: Undefined reference error trying to support numpy.float16 | <p>I am trying to build one of the <code>ufunc</code> examples from NumPy's documentation (see <a href="https://numpy.org/doc/stable/user/c-info.ufunc-tutorial.html#example-numpy-ufunc-with-multiple-dtypes" rel="nofollow noreferrer">here</a>), but I am unable to get the support for half-precision floating point numbers... | <python><c><numpy><linker-errors><meson-build> | 2024-02-02 16:14:17 | 0 | 335 | Roland Seubert |
77,928,345 | 715,348 | Delete possible despite Foreign Key | <p>I'm facing a behavior that I don't technically understand.</p>
<p>Let's assume I have a data model that looks like the following.</p>
<pre><code>class MastoList(db.Model):
__tablename__ = 'mastolist'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255), nullable=False)
list_id... | <python><sqlite><sqlalchemy> | 2024-02-02 16:04:28 | 1 | 318 | André |
77,928,256 | 9,983,652 | how to union multiple index? | <p>I'd like to find union of index of multiple dataframes, in pandas union can only be used for 2 indexes at a time, so I have to do it multiple times like below. I am wondering if I can do it using only one line? Thanks</p>
<pre><code>NewIdx = pd.Index(Idx1.union(Idx2),
name = 'depth')
NewIdx=pd.Ind... | <python><pandas> | 2024-02-02 15:49:13 | 2 | 4,338 | roudan |
77,928,197 | 2,812,625 | A more Pythonic Way to clean up strings | <p>I am looking to clean up some strings to make them column names and the easiest method i found is a series of replace statements: is there a cleaner way to achieve this outcome?</p>
<p>Sample String for clarity:</p>
<pre><code>0 Estimate!!Total:
1 Estimate!!To... | <python><string><replace> | 2024-02-02 15:38:18 | 3 | 446 | Tinkinc |
77,928,132 | 1,911,722 | How to install .conda file downloaded from anaconda package site? | <p>For example, I want to install fish shell using conda. But the server has no internet connection.</p>
<p>On <a href="https://anaconda.org/conda-forge/fish/files" rel="nofollow noreferrer">https://anaconda.org/conda-forge/fish/files</a> , many versions are provided. But almost the latest few versions are always in .c... | <python><anaconda><conda> | 2024-02-02 15:28:45 | 1 | 2,657 | user15964 |
77,927,935 | 2,986,153 | multiple hue in same kdeplot | <pre><code>import polars as pl
import numpy as np
import seaborn as sb
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick
TRIALS = int(10e3)
RATE_A = 0.65
RATE_B = 0.66
SIMS = int(4e3)
np.random.seed(42)
df_sim = pl.DataFrame(
{
"A": np.random.binomial(TRIALS, RATE_A, SIMS) / TRI... | <python><seaborn> | 2024-02-02 15:00:31 | 1 | 3,836 | Joe |
77,927,837 | 11,908,438 | import function from folder in python | <p>Im trying to import a function located in another folder into my python file which is located in another folder.</p>
<p>Folder structure looks like this</p>
<pre><code>Project:
-dbNameFolder
+ __init__.py
+ dbNames.py
-FolderIwantToImportTo
+ file.py
</code></pre>
<p>for example, i tried this wit... | <python><import><module> | 2024-02-02 14:45:36 | 1 | 545 | Zayne komichi |
77,927,819 | 11,039,749 | PulseAudio Create Virtual Mic and use it in Python | <p>I am working on creating a virtual mic that mirrors speakers, a loopback to the mic pretty much.
I was able to successfully create this mic, and when I look at pavucontrol and it shows the mic is copying the sound waves as the speakers. BUT when I connect it to a python script I tried all available inputs it doesnt ... | <python><pulseaudio> | 2024-02-02 14:42:33 | 1 | 529 | Bigbear |
77,927,706 | 7,972,989 | Dash datatable ignores zeros at beginning of string in filter input | <p>I have a dash datatable and I activated the filter option.</p>
<p>I want to filter on "col2", which is a columns of character values. Not numeric.</p>
<p>However, when I filter put "00500" in the filter input on top of the table, the table has 2 rows : the one containing "00500" and &qu... | <python><plotly-dash> | 2024-02-02 14:25:36 | 0 | 2,505 | gdevaux |
77,927,700 | 7,956,959 | Python. SeleniumWebDriver. How to operate with {Webelement} as iterable unit? | <p>got a problem with my trying to use clear selenium.webdriver.
I want to operate with element {WebElement} which was taken from list of WebElements.
Is it possible at all?</p>
<pre><code>...
for button in web_driver.find_elements(By.XPATH, path):
try:
wait = WebDriverWait(self.web_driver, 10)
wai... | <python><selenium-webdriver> | 2024-02-02 14:25:21 | 1 | 518 | Kaonashi |
77,927,600 | 616,460 | ProxyFix does not seem to be working (Flask behind nginx) | <p>I have a server running nginx. I'm trying to set up a Flask application at a specific sub-URL (e.g. <code>http://server/app/</code> maps to Flask application's <code>/</code>). If it matters, ultimately I intend for multiple Flask applications to run at various other sub-URLs on this same server.</p>
<p>I'm new to a... | <python><nginx><flask> | 2024-02-02 14:10:36 | 1 | 40,602 | Jason C |
77,927,589 | 7,529,256 | The IF - OR condition does not work with Float(nan) in python. How to write this in a single line? | <p>There are 4 conditions mainly :</p>
<ol>
<li>str(row["Vch Type*"]) == "Payment"</li>
<li>str(row["Vch Type*"]) == "Contra" and row["Withdrawal*"] is not null</li>
<li>str(row["Vch Type*"]) == "Receipt"</li>
<li>str(row["Vch Type*"]) == &... | <python><pandas> | 2024-02-02 14:09:16 | 0 | 1,584 | Viv |
77,927,531 | 9,608,860 | set_permission_overrides not assigning permission with dpytest | <p>I am trying to configure a testing bot with dpytest. I want to create a bot which has permission to manage channels
Here is my code base:</p>
<pre><code>@pytest_asyncio.fixture(params=BOT_FIXTURE)
async def bot(request) -> AsyncGenerator[Tuple[commands.Bot, str], None]:
b = commands.Bot(
command_prefi... | <python><discord.py><pytest> | 2024-02-02 14:00:01 | 0 | 405 | Aarti Joshi |
77,927,401 | 3,071,626 | How to integrate pydantic with pymongo? | <p>I get a simple Json from my mongodb with pymongo which I want to validate using pydantic:</p>
<pre><code>from pydantic import TypeAdapter, BaseModel, Json
# contents is the mongodb collection and returns this
# content = [{"content": {}}]
content = list(contents.find(projection={'_id': 0}))
class Content... | <python><json><pymongo><pydantic> | 2024-02-02 13:37:58 | 0 | 575 | Tom |
77,927,370 | 4,948,719 | Typing a class member that gets overriden by a property in subclass | <p>Here is an example code of what I have:</p>
<pre class="lang-py prettyprint-override"><code>class A:
value: int
def __init__(self, value):
self.value = value
class B(A):
@property
def value(self) -> int:
return 3
</code></pre>
<p>Dynamically this works perfectly, but pyright complains that ... | <python><python-3.x><inheritance><python-typing> | 2024-02-02 13:33:38 | 1 | 1,834 | tbrugere |
77,927,215 | 8,771,082 | Understanding scikit learn import variants | <p>Scikit learn import statements in their tutorials are on the form</p>
<pre><code>from sklearn.decomposition import PCA
</code></pre>
<p>Another versions that works is</p>
<pre><code>import sklearn.decomposition
pca = sklearn.decomposition.PCA(n_components = 2)
</code></pre>
<p>However</p>
<pre><code>import sklearn
p... | <python><scikit-learn><python-import> | 2024-02-02 13:06:29 | 1 | 449 | Anton |
77,926,884 | 101,022 | AWS S3 generate_presigned_post loses content-type after formData POST | <p>Using Python's boto3 library, I create a presigned URL and return it to the front end:</p>
<pre class="lang-py prettyprint-override"><code>s3_client = boto3.client('s3')
response = s3_client.generate_presigned_post(
"bucket",
"logo",
Fields={
"Content-Type": "im... | <javascript><python><amazon-web-services><amazon-s3> | 2024-02-02 12:12:40 | 0 | 1,480 | timborden |
77,926,865 | 9,074,767 | Is it a good practice to define datatypes in `__init__.py`? | <p>I have a folder structure like this:</p>
<pre><code>nlp
├── generation
│ ├── io_operations
│ ├── __init__.py
│ ├── generator.py
│ ├── processing.py
│ └── prompting.py
│ ├── prompts (folder)
│ ├── ressources (folder)
│ ├── __init__.py
│ ├── classifier.py
│ ├── clustering.py
│ ├── dsos.py... | <python><architecture><design-principles> | 2024-02-02 12:10:15 | 0 | 1,183 | Marcel Braasch |
77,926,829 | 7,959,614 | How to write "probability that result of objective function is lower than y" in LinearConstraint using scipy.optimize | <p>I have the following working optimization problem:</p>
<pre><code>import random
import numpy as np
from scipy.optimize import minimize, LinearConstraint
random.seed(123)
# assumptions
d = np.array([1.3, 10])
p = np.array([random.randint(700, 950) / 1000 for _ in range(100)])
scenarios = np.array([[1],
... | <python><scipy><scipy-optimize> | 2024-02-02 12:02:42 | 1 | 406 | HJA24 |
77,926,630 | 2,123,706 | compare row equality by linking values between columns in pandas | <p>I have a df:</p>
<pre><code>rdata = {'id': {0: 'a01', 1: 'a02', 2: 'a03', 3: 'a04', 4: 'a05', 5: 'a06', 6: 'a07', 7: 'a08', 8: 'a09', 9: 'a10', 10: 'a11'}, 'col1': {0: 123456, 1: 1234567, 2: 123456, 3: 123456, 4: 1234, 5: 123456, 6: 123456, 7: 1234, 8: 1234, 9: 12345, 10: 12345}, 'col2': {0: 'a', 1: 'c', 2: 'a', 3: ... | <python><pandas> | 2024-02-02 11:21:22 | 1 | 3,810 | frank |
77,926,591 | 1,216,183 | Pillow raise OSError when fail to read image (not real OSError), how to workaround this? | <p>Some images pass the <code>image.verify()</code> method but still fail to be read and the following errors can be raised :</p>
<pre><code>OSError
broken data stream when reading image file
</code></pre>
<pre><code>OSError
image file is truncated (XXX bytes not processed)
</code></pre>
<p>I've read many issues on git... | <python><python-imaging-library> | 2024-02-02 11:15:59 | 0 | 2,213 | fabien-michel |
77,926,337 | 6,546,694 | Why is it that setting a value on a dataframe that is (I think) a copy changing the original dataframe? | <p>I create a dataframe and (I think) I create a copy out of it. I think I create a copy out of it since <code>._is_view</code> property is <code>False</code></p>
<pre><code>import pandas as pd
df = pd.DataFrame({'a':[1,2,3],'b':['x','y','z']})
df.loc[[True, True, False],'a']._is_view
output: False
</code></pre>
<p>S... | <python><pandas><dataframe> | 2024-02-02 10:39:14 | 2 | 5,871 | figs_and_nuts |
77,926,327 | 355,401 | How to see current exception in VS Code Python Debugger in except clause | <p>I am using VS Code to debug Python application.<br />
If I have the following code</p>
<pre class="lang-py prettyprint-override"><code>try:
do_something()
catch Exception:
handle_exception() # <--- program is here
</code></pre>
<p>Is there a way in VS Code to watch the exception catch even though I didn't as... | <python><vscode-debugger> | 2024-02-02 10:37:42 | 1 | 11,544 | Ido Ran |
77,926,266 | 9,443,693 | Google OR-Tools: Different cost for same node base on position in route | <p>I have a list of costs for each node based on the position of a node in a route. The depot is positioned at 0.</p>
<pre><code>costs = [
{"part": 0, "final": 0},
{"part": 2, "final": 3},
{"part": 4, "final": 2},
{"part": 1, "fi... | <python><python-3.x><or-tools> | 2024-02-02 10:26:26 | 3 | 863 | Nguyen Hoang Vu |
77,926,226 | 10,815,899 | In AND condition which side evaluate first in python? | <p>I have an AND statement, the right side condition of the statement, can be checked only, if the first one returns true.</p>
<pre><code>if foo is not None and foo.passes_the_test():
# do something
</code></pre>
<p>Does the python skip the right side condition check if the left side returns false, thus preventing th... | <python> | 2024-02-02 10:19:22 | 1 | 831 | Viljami |
77,926,208 | 1,059,549 | What's the difference StreamingResponse or EventSourceResponse? | <p>I'm looking to stream back server side events generated by LLM.
I noticed that LiteLLM and LangChain use the built in StreamingResponse.
I also came across <a href="https://github.com/sysid/sse-starlette" rel="nofollow noreferrer">https://github.com/sysid/sse-starlette</a> ServerSideEvent</p>
<p>Has anyone experimen... | <python><streaming><fastapi><starlette> | 2024-02-02 10:16:16 | 0 | 10,767 | Dory Zidon |
77,925,955 | 10,750,537 | Unexpected behavior of numpy invert | <p>I am wondering why the following Python code</p>
<pre><code>import numpy as np
a = np.array([0], dtype=np.int8)
print(np.invert(a))
</code></pre>
<p>prints</p>
<pre><code>[-1]
</code></pre>
<p>instead of [0]. According to the <a href="https://numpy.org/devdocs/reference/generated/numpy.invert.html" rel="nofollow nor... | <python><numpy> | 2024-02-02 09:35:47 | 1 | 381 | JtTest |
77,925,889 | 15,227,516 | How can I align text by width using python-docx library | <p>I make some report document using <code>python-docx>=1.1.0</code> and I need to align text by width.
I don't understand which constant from <code>WD_PARAGRAPH_ALIGNMENT</code> I should use.</p>
<p>I tried to user <code>WD_PARAGRAPH_ALIGNMENT.DISTRIBUTE</code> and all constants with prefix <code>JUSTIFY_</code> , ... | <python> | 2024-02-02 09:27:32 | 0 | 369 | Andrei Gurko |
77,925,761 | 4,742,357 | How to make Python Azure Function (v2) Block Requests without functionkey/code | <p>I have created my first Python Azure Function (v2) and detected that the function accepts all requests regardless if they have the "code"(FunctionKey) param used in .Net Azure functions.</p>
<p>How can I make the function block all requests that don't have a valid key attached?</p>
| <python><azure-functions> | 2024-02-02 09:00:20 | 1 | 1,207 | Nelssen |
77,925,755 | 2,971,409 | Jump ahead n random generations on the specific seed | <p>I got this function which returns a set of random choices from a collection where I want the generation to be similar when called close in time (not actual time, just when the input variable time is close to what it was last time).
I have the implementation here in Python which works as expected, but Im not so satis... | <python><random> | 2024-02-02 08:58:48 | 0 | 464 | Dwadelfri |
77,925,670 | 5,168,463 | Pyspark to_timestamp date format parsing error | <p>In my pyspark dataframe, there is a column <code>CallDate</code> with datatype as <code>string</code> containing the values shown below:</p>
<pre><code>2008-04-01T00:00:00
2008-04-01T00:00:00
2008-04-01T00:00:00
2008-04-01T00:00:00
2008-04-01T00:00:00
2008-04-01T00:00:00
</code></pre>
<p>I am trying to convert this ... | <python><apache-spark><pyspark><to-timestamp> | 2024-02-02 08:43:55 | 2 | 515 | DumbCoder |
77,925,333 | 5,790,653 | my python code show last day of previous month instead of current month | <p>This is my python code:</p>
<pre><code>import datetime
import jdatetime
jcurrent_year = jdatetime.datetime.now().year
jcurrent_month = jdatetime.datetime.now().month
jcurrent_day = jdatetime.datetime.now().day
jnow = jdatetime.datetime.now()
jlast_day_of_current_month = jdatetime.date(jnow.year, 1 if jnow.month==12... | <python> | 2024-02-02 07:32:18 | 1 | 4,175 | Saeed |
77,925,274 | 3,727,079 | How can I append one text file to another in Python, if there might be overlap between the two? | <p>Say I have two .txt files. The first one is:</p>
<pre><code>2024-01-26 09:00:00, Alice, 4, Win
2024-01-27 09:00:00, Bob, 6, Loss
2024-01-28 09:00:00, Charlie, 2, Loss
2024-01-29 09:00:00, Denise, 3, Loss
</code></pre>
<p>The second one is:</p>
<pre><code>2024-01-29 09:00:00, Denise, 3, Loss
2024-01-30 09:00:00, Eve,... | <python><datetime><merge> | 2024-02-02 07:20:22 | 1 | 399 | Allure |
77,925,185 | 19,123,103 | ValueError: Expected EmbeddingFunction.__call__ to have the following signature | <p>When I try to pass a Chroma Client to Langchain that uses <code>OpenAIEmbeddings</code>, I get a ValueError:</p>
<pre class="lang-none prettyprint-override"><code>ValueError: Expected EmbeddingFunction.__call__ to have the following signature: odict_keys(['self', 'input']), got odict_keys(['self', 'args', 'kwargs'])... | <python><valueerror><langchain><chromadb><openaiembeddings> | 2024-02-02 06:59:32 | 2 | 25,331 | cottontail |
77,925,087 | 9,394,465 | combine 2 dataframes with a duplicate common identifier in both | <p>I have two dataframes both having the exact same column names and I am trying to combine them both where both and preferring the second df for conflicting data</p>
<p>df1:</p>
<pre><code>A,B,C,D
123,xyz,S1,1111
123,xyz,S1,1111
234,mno,S3,2222
999,abc,S9,9999
999,abc,S9,9999
</code></pre>
<p>df2:</p>
<pre><code>A,B,C... | <python><pandas> | 2024-02-02 06:36:48 | 2 | 513 | SpaceyBot |
77,925,004 | 1,176,504 | SMS not sending even if the phone number is verified - 400 Error Code | <p>I signed up with Twilio Yesterday for educational purposes and just trying to send myself a SMS. But it keep giving me 400 - Bad Request Error.</p>
<p>I am from a high-risk country but Twilio has automatically updated my Geo Permissions. I am using Python and there is no errors in my code.</p>
<p>Python Error:</p>
<... | <python><twilio><http-status-code-400> | 2024-02-02 06:17:17 | 0 | 1,627 | guitarlass |
77,924,487 | 1,982,032 | How can simpify and clear the expression to get the cell value? | <p>My target dataframe is something as below:</p>
<pre><code>df
SimFinId Currency Fiscal Year ... Net Extraordinary Gains (Losses) Net Income Net Income (Common)
Ticker Report Date ...
A 2018-10... | <python><pandas><dataframe> | 2024-02-02 03:14:36 | 2 | 355 | showkey |
77,924,456 | 584,239 | using python pycups cups how to set margin for custom page size | <p>Below is script using pycups I am able to print with custom page size but I need to set the margin also how do it do that.</p>
<pre><code>import cups
def print_to_printer(printer_name, file_path, custom_width=720, custom_length=432):
conn = cups.Connection()
# Get the printer information
printer_info =... | <python><python-3.x><cups> | 2024-02-02 03:02:37 | 2 | 9,691 | kumar |
77,924,248 | 1,396,516 | How to write to a BigQuery table using ApacheBeam ran locally without running the Google Cloud CLI executable? | <p>I can use the external Python engine to read data from a BigQuery table, but I cannot authenticate when I use Apache Beam + Python run locally.</p>
<p><a href="https://cloud.google.com/dataflow/docs/concepts/security-and-permissions" rel="nofollow noreferrer">Documentation</a> only gives the CLI option "When yo... | <python><authentication><google-bigquery><apache-beam> | 2024-02-02 01:33:38 | 1 | 3,567 | Yulia V |
77,924,142 | 7,662,164 | JAX `vjp` does not recognize cotangent argument with `custom_vjp` | <p>I have a JAX function <code>cart_deriv()</code> which takes another function <code>f</code> and returns the Cartesian derivative of <code>f</code>, implemented as follows:</p>
<pre><code>@partial(custom_vjp, nondiff_argnums=0)
def cart_deriv(f: Callable[..., float],
l: int,
R: Array
... | <python><function><jax><automatic-differentiation> | 2024-02-02 00:51:44 | 1 | 335 | Jingyang Wang |
77,924,082 | 1,429,402 | Apply the Savitzky-Golay filter with locked endpoints | <p>I have a stream of values I would like to smooth with <code>locked end-points</code>, meaning that the first and last data elements of the array are taken into account in the filtering algorithm but remain untouched.</p>
<p>For the smoothing algorithm I chose <code>scipy.signal.savgol_filter</code>, which gives me g... | <python><numpy><scipy> | 2024-02-02 00:29:56 | 1 | 5,983 | Fnord |
77,923,904 | 10,705,248 | How to run multiple python based slurm jobs together in HPC | <p>I need to submit 100 slurm jobs they all perform the same computing but with a slight change (the only difference is the year; all files have different years). Is there a way to submit them together without writing slurm file and running separately?</p>
<p>For example, I have 100 python files with the name: <code>pr... | <python><parallel-processing><slurm><hpc><multiple-processes> | 2024-02-01 23:19:36 | 1 | 854 | lsr729 |
77,923,835 | 7,106,508 | How to save a stream object in Azure text to speech without speaking the text using Python | <p>I want to convert a book to audio, and save the file, so naturally I don't want my computer to be speaking the book out loud while the conversion happens, but looking at the Azure documentation, I frankly don't see a way to get a stream object without speaking the text first. I've already got the code set up so tha... | <python><azure-cognitive-services> | 2024-02-01 22:58:14 | 1 | 304 | bobsmith76 |
77,923,733 | 1,375,292 | Recursive version of python unittest assertDictContainsSubset | <p><a href="https://stackoverflow.com/questions/20050913/python-unittests-assertdictcontainssubset-recommended-alternative">Python unittest's assertDictContainsSubset recommended alternative</a> discusses how to check if a <code>dict</code> contains another <code>dict</code> using <code>d1 | d2</code>. However, th... | <python><unit-testing> | 2024-02-01 22:30:00 | 1 | 3,658 | Troy Daniels |
77,923,632 | 127,251 | How do I set the focus on entering an axes in matplotlib? | <p>I bind key_press events in Matplotlib. They are not triggered unless I click on the figure first. I want to force the keyboard focus to be on the axes when the mouse enters it.</p>
<p>I attempted to follow the guidance in this answer:</p>
<p><a href="https://stackoverflow.com/questions/31656345/matplotlib-key-press-... | <python><matplotlib><setfocus> | 2024-02-01 22:02:44 | 1 | 5,593 | Paul Chernoch |
77,923,604 | 920,599 | How to examine and invoke the functions in Python's __main__ module from a different module | <p>In Python, is it possible for a function in a module to examine the list of functions in <code>__main__</code> then execute functions that match a pattern?</p>
<p>For example, can I write a module that contains the function <code>run_all_auto</code> that will examine the list of functions in <code>__main__</code> th... | <python><reflection> | 2024-02-01 21:55:14 | 1 | 6,694 | Zack |
77,923,461 | 263,061 | How to type __eq__ in generic Python class? | <p>When I define a type with generic type parameters (e.g. <code>K</code>/<code>V</code> for key and value of a mapping), I seemingly cannot write a suitable <code>isinstance</code> check for implementing <code>__eq__</code>:</p>
<pre class="lang-py prettyprint-override"><code>from collections import OrderedDict
from c... | <python><python-typing><pyright> | 2024-02-01 21:24:11 | 2 | 25,947 | nh2 |
77,923,449 | 438,223 | Generating non-zero mean AR(2) samples in python | <p>I am trying to generate non-zero mean AR(2) samples using statsmodels package. But it seems , by default we can't generate non-zero mean samples.</p>
<p>Is there any workaround, in python. I want to generate only positive samples.</p>
<p>My current code is</p>
<pre><code>import numpy as np
from statsmodels.tsa.arim... | <python><statsmodels><autoregressive-models> | 2024-02-01 21:21:46 | 1 | 1,596 | Shew |
77,923,380 | 2,205,799 | python input() not printing to screen when piping to another command | <p>I have a simple python program that is using input to get a username and password, ie:</p>
<pre><code>
from getpass import getpass
username = input("Username: ")
password = getpass()
</code></pre>
<p>When i run the program and pipe to wc, the username prompt does not print. It takes input, and then the ge... | <python><shell><io-redirection><getpass> | 2024-02-01 21:07:37 | 0 | 309 | feeble |
77,923,330 | 437,260 | Google Colab 'Credentials' object has no attribute 'universe_domain' | <p>When trying to use google colab with google speech to text (from google sample notebook :</p>
<p>I get :</p>
<pre><code>if credentials:
--> 505 credentials_universe = credentials.universe_domain
506 if client_universe != credentials_universe:
507 default_universe = ... | <python><google-cloud-platform><google-colaboratory> | 2024-02-01 20:57:16 | 1 | 950 | Antonin |
77,923,160 | 2,011,779 | SwaggerHub introducing duplicate keys by lower casing when downloading SDK | <p>I'm trying to use the BinanceSpotAPI on <a href="https://app.swaggerhub.com/apis/binance_api/BinanceSpotAPI/1.0" rel="nofollow noreferrer">https://app.swaggerhub.com/apis/binance_api/BinanceSpotAPI/1.0</a>
When I look at the raw code that is there, the /api/v3/aggTrades has a bunch of parameters,
one of which is</p>... | <python><swagger><swagger-codegen> | 2024-02-01 20:26:05 | 0 | 2,384 | hedgedandlevered |
77,922,861 | 1,142,970 | Why does sympy.solve produce empty array for certain inequalities | <p>sympy's solve seems to generally work for inequalities. For example:</p>
<pre><code>from sympy import symbols, solve;
x = symbols('x');
print(solve('x^2 > 4', x)); # ((-oo < x) & (x < -2)) | ((2 < x) & (x < oo))
</code></pre>
<p>In some cases where all values of x or no values of x are valid... | <python><python-3.x><sympy><inequality> | 2024-02-01 19:25:46 | 1 | 21,993 | ChaseMedallion |
77,922,825 | 4,030,166 | How to mock argparse with pytest in bigger Python cli application | <p>I'm working on the following application: <a href="https://github.com/TobiWo/eth-duties" rel="nofollow noreferrer">https://github.com/TobiWo/eth-duties</a></p>
<p>I didn't include unit-tests from the beginning which is bad, I know but I wanted to concentrate on the functionality. Anyway, I want to add unit-tests now... | <python><pytest><argparse><python-poetry> | 2024-02-01 19:19:54 | 0 | 574 | Tobias |
77,922,823 | 2,375,040 | GDExtension cannot find a tool chain to build for the web, in spite of compatibility | <p>To clarify my title, "web" is an available export platform for GDExtension as of Godot 4.2, which, while no doubt limited, is great news for those of us building web applications. This is mentioned <a href="https://godotengine.org/article/dev-snapshot-godot-4-2-dev-6/" rel="nofollow noreferrer">here</a>. W... | <python><c++><build><webassembly><godot> | 2024-02-01 19:19:17 | 1 | 1,801 | Michael Macha |
77,922,817 | 13,086,128 | ImportError: cannot import name 'Iterator' from 'typing_extensions' | <p>When I try to install <code>openai</code> on my Google Colab, I get this error:</p>
<pre><code>from openai import OpenAI
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-5ee9a4e68b89> in &l... | <python><python-3.x><pip><openai-api> | 2024-02-01 19:18:15 | 1 | 30,560 | Talha Tayyab |
77,922,776 | 5,327,068 | How do I mock a function called by an instance of a class | <p>I am writing a unit test, and in my <code>test_model.py</code> file, I have a class <code>TestPlayerAnomalyDetectionModel</code> that creates an instance of <code>PlayerAnomalyDetectionModel</code>, and then calls the <code>.fit</code> method using a fixture that returns sample data. The <code>.fit</code> method cal... | <python><unit-testing><mocking><pytest><decorator> | 2024-02-01 19:10:31 | 1 | 20,200 | Derek O |
77,922,733 | 2,575,970 | Bearer token expires after 3599, refresh data steps | <p>The bearer token expires after 3599. I still need to refresh it and keep using it. How is that possible? I am looking for a simple code example to do that. I am using Python</p>
<pre><code> # Create an MSAL instance providing the client_id, authority and client_credential parameters
client = msal.ConfidentialClien... | <python><azure-active-directory><bearer-token> | 2024-02-01 19:00:02 | 1 | 416 | WhoamI |
77,922,683 | 7,844,237 | python resample incorrectly | <p>I have a <code>pandas</code> dataframe like this:</p>
<pre><code> ticker_name price
timestamp_column
2024-02-01 18:34:58 NIFTY_08-FEB-2024_CE_21000 85.0
2024-02-01 18:34:55 NIFTY_08-FEB-2024_CE_21000 84.0
2024-02-01 18:34:52 NIFTY_08-FEB-2024_CE_21000 83.0
2024-02-01 18:3... | <python><pandas><ohlc><resample> | 2024-02-01 18:51:49 | 2 | 393 | keerthan kumar |
77,922,478 | 11,092,636 | sets are unordered but python seems to "set a seed" | <p>I know that Python sets are unordered. For example, executing this code 10 times will yield around 5 times [DR1, DR12] and five times [DR12, DR1].</p>
<pre><code>list_of_list = [[] for _ in range(3)]
list_of_list[0].append("DR1")
list_of_list[0].append("DR1")
list_of_list[0].append("DR1"... | <python> | 2024-02-01 18:14:33 | 0 | 720 | FluidMechanics Potential Flows |
77,922,451 | 11,770,390 | How to ensure python is installed for C++ code generation with cmake & conan | <p>I have a library that uses a python code generator to read in some yaml files and spit out a *.hpp file. Now I want to ship it on conancenter and have it build effortlessly on the consumer machines.</p>
<p>There's one problem though: I use the pyyaml package for the code generator to read the yaml file, which is not... | <python><cmake><code-generation><conan> | 2024-02-01 18:09:11 | 1 | 5,344 | glades |
77,922,414 | 8,874,388 | Python Lists: Why is the Pythonic list comprehension 8-20% slower? | <p><strong>(Update: The issue has been found. <a href="https://stackoverflow.com/a/77922551/8874388">See my answer</a>. This turned out to be a performance issue in Python 3.11, and only affects small lists. For Python 3.9, 3.10 and 3.12, list comprehension is ALWAYS faster, regardless of list size.)</strong></p>
<p>I'... | <python><python-3.x><list><optimization> | 2024-02-01 17:59:36 | 1 | 4,749 | Mitch McMabers |
77,922,373 | 11,515,528 | Convert column of dates to count of days from start day | <p>Simple question but I am struggling to find the answer. I am after a simple count of days from the start date. Thanks in advance.</p>
<pre><code>df = pd.DataFrame({'year': [2015, 2015, 2015],
'month': [2, 2, 2],
'day': [4, 5, 10]})
pd.to_datetime(df)
output
0 2015-02-04
1 ... | <python><pandas> | 2024-02-01 17:53:13 | 3 | 1,865 | Cam |
77,922,238 | 5,728,714 | Errors "overflow encountered in matmul" and "Optimization failed to converge" while trying to use statsmodels' Exponential smoothing | <p>I have the following series:</p>
<pre><code>month,demand
2022-02-01,6059
2022-03-01,11990
2022-04-01,6586
2022-05-01,7363
2022-06-01,10837
2022-07-01,2268
2022-08-01,2615
2022-09-01,1590
2022-10-01,3797
2022-11-01,2195
2022-12-01,4480
2023-01-01,4030
2023-02-01,3242
2023-03-01,3111
2023-04-01,6724
2023-05-01,8781
20... | <python><statsmodels> | 2024-02-01 17:30:00 | 0 | 1,877 | Mathias Hillmann |
77,922,041 | 1,506,763 | Performance of numpy sum and bottleneck nansum | <p>I've got a piece of code that is quiet heavily dependent on the use of <code>numpy</code> <code>sum</code>, about 60% of my time is spent on the calculation of just a few results and an replication of the offending code is shown below. This section of code (not including the array generation as this is passed in fro... | <python><arrays><numpy><performance><bottleneck-package> | 2024-02-01 16:59:50 | 1 | 676 | jpmorr |
77,922,007 | 275,088 | Is creating a constant dictionary inside a function efficient in Python? | <p>Say, I have a function that creates a dictionary just to look up a value, e.g.:</p>
<pre><code>def check_map(val):
value_map = {"val1": "newval1", "val2": "newval2", "val3": "newval3"}
val = value_map.get(val, val)
# other stuff
return val
</cod... | <python><dictionary> | 2024-02-01 16:55:40 | 1 | 16,548 | planetp |
77,921,942 | 7,844,237 | sma calcualted in talib in reverse order | <p>i have a panda</p>
<pre><code>timestamp_column
2024-01-31 14:23:10 794.65
2024-01-31 14:23:00 794.65
2024-01-31 14:22:50 794.65
2024-01-31 14:22:40 794.65
2024-01-31 14:22:30 794.65
2024-01-31 14:22:20 794.65
Freq: -10S, Name: close, dtype: float64
</code></pre>
<p>im using the below code -</p>
<pr... | <python><pandas><ta-lib> | 2024-02-01 16:42:52 | 0 | 393 | keerthan kumar |
77,921,898 | 1,478,905 | Not getting source documents from chain in langchain and openAI embeddings | <p>I'm loading pdfs using langchain.document_loaders:</p>
<p><code>loader = DirectoryLoader( './files/', glob='*.pdf', loader_cls=PyPDFLoader)</code></p>
<p>then splitted the docs, created the embeddings, stored and loaded them :</p>
<pre><code>docsearch = Chroma.from_documents(texts, embeddings, persist_directory=pers... | <python><openai-api><langchain><openaiembeddings> | 2024-02-01 16:35:23 | 3 | 997 | Diego Quirós |
77,921,888 | 2,675,981 | Allow python script to be executed by Apache, but not read in a browser | <p>I have a website that uses a python script to get information from a separate entity. The python script is required due to the libraries in use and the structure of the other entity. The retrieved information will be used in various ways on the site.</p>
<p>The website itself is PHP running on Apache and there is a ... | <python><php><apache> | 2024-02-01 16:34:40 | 1 | 885 | Apolymoxic |
77,921,360 | 151,939 | How to specific augmentation data types in mediapipe_model_maker? | <p>I'm trying to use the image_classifier from mediapipe_model_maker to train a custom tflite image classification model. All I see for data augmentation is a boolean that can be passed in the options called "do_data_augmentation" that does random augmentation (cropping, flipping, etc.).</p>
<pre><code>spec =... | <python><tensorflow><machine-learning><mediapipe><image-classification> | 2024-02-01 15:20:08 | 1 | 8,618 | Michael Eilers Smith |
77,921,326 | 2,575,970 | Azure bearer token lifetime | <p>I have a python code to call a graph API and browse directory on sharepoint. The directory has 120GB of files and needs hours to scan. However, what I have observed is the script just shows as running on Visual Studio code and no further execution happens. I am printing the files names in the loop and it stops to pu... | <python><azure><microsoft-graph-api><onedrive><bearer-token> | 2024-02-01 15:14:52 | 2 | 416 | WhoamI |
77,921,195 | 10,054,520 | Running Python on Windows, how can I run multiple scripts that write to the same file? | <p>I'm running one instance of a Python 3.10 script on Windows 10. I would like to run another instance of the same script; however, at the end of the script it will write to a txt file so I don't want the scripts competing/overwriting what the other has done.</p>
<p>The flow goes like this</p>
<pre><code>for i in new... | <python> | 2024-02-01 14:58:23 | 2 | 337 | MyNameHere |
77,920,996 | 1,929,820 | Remove all jobs from plone.app.async queue | <p>I have a lot of jobs in the queue and I just want to empty it, instead of waiting for them. So I managed to access pdb and this is what I tried:</p>
<pre><code>from zope.component import queryUtility
from plone.app.async.interfaces import IAsyncService
service = queryUtility(IAsyncService)
(Pdb) service
<plone.a... | <python><queue><plone> | 2024-02-01 14:29:45 | 1 | 3,437 | GhitaB |
77,920,917 | 1,987,599 | Unable to validate XML with schema but works by reading the written file from it | <p>I am currently using <code>lxml</code> and want to validate a XML content.</p>
<p>I wrote it completely in Python from <code>tei = etree.Element("TEI", nsmap={None: 'http://www.tei-c.org/ns/1.0'}</code> with many subelements.</p>
<p>At a moment, I want to check if the structure is ok using a specific <code... | <python><xml><xsd><lxml> | 2024-02-01 14:19:37 | 1 | 609 | Guuk |
77,920,700 | 13,518,907 | Langserve Streaming with Llamacpp | <p>I have built a RAG app with Llamacpp and Langserve and it generally works. However I can't find a way to stream my responses, which would be very important for the application. Here is my code:</p>
<pre><code>from langchain_community.vectorstores.pgvector import PGVector
from langchain_core.prompts import ChatPrompt... | <python><langchain><large-language-model><llama-cpp-python> | 2024-02-01 13:49:59 | 0 | 565 | Maxl Gemeinderat |
77,920,479 | 1,467,533 | How to specify bounds and variable length in python union types? | <p>I have a type that has subclasses. E.g., <code>Event</code>, with classes <code>Event1(Event)</code>, <code>Event2(Event)</code>, etc. I want to specify a type annotation for the argument to a function that accepts any union of subclasses of <code>Event</code>. Concretely, I want all of the following to type chec... | <python><python-typing> | 2024-02-01 13:15:05 | 1 | 1,855 | mattg |
77,920,475 | 2,410,605 | selenium python how do i convert a string into time.strftime() date? | <p>I'm reading a string from an html table that represents a date: Feb 1, 2024 87:05:23 AM. How do I convert this to a true date variable so that I can compare it to the current time? Below is the code I'm using, it doesn't produce any errors but also is not working because when it gets to the compare it doesn't fall ... | <python><selenium-webdriver> | 2024-02-01 13:14:46 | 1 | 657 | JimmyG |
77,920,297 | 19,838,445 | How to properly annotate pydantic fields if it's another class | <p>I have a model with the fields which are other Pydantic models (but not instances of them), so I'm able to use it later as a builder.</p>
<pre class="lang-py prettyprint-override"><code>class ItemModel(BaseModel):
id: int
class UserModel(BaseModel):
name: str
class MatchModels(BaseModel):
name: str
... | <python><python-3.x><pydantic><pydantic-v2> | 2024-02-01 12:45:26 | 1 | 720 | GopherM |
77,920,228 | 6,042,172 | jupyter notebook export with embedded CSV files | <p>I need to share a jupyter notebook, a really simple interactive app using pandas, plotly and dash with some colleagues who have not installed Python.</p>
<p>If my notebook uses no csv files, it seems to work well.</p>
<p>But, is there any way to export in html format with somewhat embedded data in csv files?</p>
<p>... | <python><csv><jupyter-notebook> | 2024-02-01 12:34:11 | 0 | 908 | glezo |
77,920,171 | 1,473,517 | How can I return the subarrays in my max k-subarray sum code? | <p>Consider an array A of integers of length n. The k-max subarray sum asks us to find up to k (contiguous) non overlapping subarrays of A with maximum sum. If A is all negative then this sum will be 0. If A = [-1, 2, -1, 2, -1, 2, 2] for example, then the two subarrays could be [2, -1, 2] and [2, 2] with total sum 7... | <python><algorithm> | 2024-02-01 12:26:26 | 1 | 21,513 | Simd |
77,920,123 | 13,000,695 | Using starlette TestClient causes an AttributeError : '_UnixSelectorEventLoop' object has no attribute '_compute_internal_coro' | <p>Using FastAPI : <code>0.101.1</code></p>
<p>I run this <code>test_read_aynsc</code> and it pass.</p>
<pre class="lang-py prettyprint-override"><code># app.py
from fastapi import FastAPI
app = FastAPI()
app.get("/")
def read_root():
return {"Hello": "World"}
# conftest.py
import... | <python><pycharm><python-asyncio><fastapi><starlette> | 2024-02-01 12:18:03 | 1 | 4,032 | jossefaz |
77,920,104 | 1,473,517 | How to speed up the code for k-max subarray sum | <p>Consider an array A of integers of length n. The k-max subarray sum asks us to find up to k (contiguous) non-overlapping subarrays of A with maximum sum. If A is all negative then this sum will be 0. If A = [-1, 2, -1, 2, -1, 2, 2] for example, then the two subarrays could be [2, -1, 2] and [2, 2] with total sum 7... | <python><algorithm><performance><optimization> | 2024-02-01 12:15:08 | 0 | 21,513 | Simd |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.