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,806,419 | 12,492,890 | Generating cumulative counts in NumPy using a vectorized implementation | <p>Here's a sample of the numpy array I have:</p>
<pre><code>y = np.array([
[ 0],
[ 0],
[ 2],
[ 1],
[ 0],
[ 1],
[ 3],
[-1],
])
</code></pre>
<p>I'm attempting to generate a new column containing the cumulative counts with respect to each value in the input array:</p>
<pre><code>y = np.ar... | <python><pandas><numpy><group-by><count> | 2024-01-12 12:00:35 | 1 | 15,647 | lemon |
77,806,225 | 12,390,973 | How to use binary variable in another constraint in PYOMO? | <p>I have created an RTC energy dispatch model using PYOMO. There is a demand profile and to serve this demand profile we have three main components: <strong>Solar, Wind, and Battery</strong> just so that the model won't give infeasible errors in case there is not enough energy supply from the three main sources I have... | <python><pyomo><gurobi> | 2024-01-12 11:27:37 | 1 | 845 | Vesper |
77,805,985 | 5,392,289 | Typing hinting nested dictionary with varying value types | <p>My dictionary looks as follows:</p>
<pre><code>spreadsheet_list: dict[str, dict[str, Union[str, list[str]]]] = {
'final_kpis': {
'gsheet_key': '1np6fM9d_BrBuDbBKWkWwUjhNypoCtto_84bLcx-HBdk',
'primary_key': ['KPI_Reference']
},
'maplecroft_risk_drivers': {
'gsheet_key': '1rV2oXbvv... | <python><mypy> | 2024-01-12 10:42:17 | 1 | 1,305 | Oliver Angelil |
77,805,935 | 4,844,184 | Inherit and modify methods from a parent class at run time in Python | <p>I have a parent class <strong>of which I don't know the methods a priori</strong>. Its methods can do arbitrary things such as modifying attributes of the class.</p>
<p>Say:</p>
<pre><code>class Parent():
def __init__(self):
self.a = 42
def arbitrary_name1(self, foo, bar):
self.a += 1
... | <python><class><types><decorator> | 2024-01-12 10:35:45 | 1 | 2,566 | jeandut |
77,805,825 | 14,147,996 | Efficient loading of directory sorted by modification date | <p>I am reading a directory with Python, containing <em>many</em> files, most of which are old.
However, I am only interested in the files generated in the past 24h.</p>
<p>Running something like</p>
<pre><code>for filename in os.listdir(dir_path):
if now - timedelta(hours=24) <= os.path.getmtime(filename) <=... | <python><performance><operating-system> | 2024-01-12 10:15:09 | 1 | 365 | Vivian |
77,805,804 | 896,670 | How to replace substring from df1['Column 1'] with values from df2['Column 2'] when df1['Column 1'] contains df2['Column 1']? | <p>How to replace substring from df1['Column 1'] with values from df2['Column 2'] when df1['Column 1'] contains df2['Column 1']?</p>
<p>df1:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Column1</th>
</tr>
</thead>
<tbody>
<tr>
<td>A&O Inc.</td>
</tr>
<tr>
<td>HP Canada</td>
</tr>
</t... | <python><pandas><dataframe> | 2024-01-12 10:11:41 | 2 | 2,256 | aleafonso |
77,805,469 | 2,237,916 | Pandas to Parquet with per-column compression | <p>The <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.to_parquet.html" rel="nofollow noreferrer">pandas documentation</a> marks the following:</p>
<blockquote>
<p><strong>compression</strong>: str or None, default ‘snappy’</p>
<p>Name of the compression to use. Use None for no compression. Suppo... | <python><pandas><parquet> | 2024-01-12 09:11:08 | 1 | 7,301 | silgon |
77,805,320 | 5,510,540 | Question - Asnwer with BERT: very very poor results | <p>Imagine I have the following text:</p>
<pre><code>text = "Once upon a time there was an old mother pig who had three little pigs and not enough food to feed them. So when they were old enough, she sent them out into the world to seek their fortunes. The first little pig was very lazy. He didn't want to work at ... | <python><huggingface-transformers><bert-language-model> | 2024-01-12 08:44:03 | 0 | 1,642 | Economist_Ayahuasca |
77,805,006 | 10,097,229 | ufunc 'add' did not contain loop with matching data types | <p>I have a dataframe where some columns has values and some are NaN type (basically float)</p>
<p>This is the dataframe-</p>
<p><a href="https://i.sstatic.net/0iWj0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/0iWj0.png" alt="enter image description here" /></a></p>
<p>I am looping over the <code>dec... | <python><list><numpy> | 2024-01-12 07:30:54 | 0 | 1,137 | PeakyBlinder |
77,804,589 | 10,035,190 | OSError: Couldn't deserialize thrift: No more data to read. Deserializing page header failed | <p>I am fetching data from event hub and uploading it to blob with blob_type <code>AppendBlob</code> it appending correctly but when i download and try to read that parquet file then it showing this error <code>OSError: Couldn't deserialize thrift: No more data to read. Deserializing page header failed.</code> and some... | <python><azure><azure-blob-storage><parquet> | 2024-01-12 05:51:50 | 1 | 930 | zircon |
77,804,537 | 10,518,698 | How to ignore "error while decoding" and continue live stream? | <p>I am having the RTSP FFMPEG issue while decoding in OpenCV Livestream using PyFlask. I get this particular error <code>[h264 @ 0x23a0be0] error while decoding MB 59 42, bytestream -13</code> and then the live stream stops abruptly.</p>
<p>This is my code and seems like it when ret became <code>False</code> it goes t... | <python><opencv><flask><rtsp> | 2024-01-12 05:35:48 | 0 | 513 | JSVJ |
77,804,343 | 12,425,004 | Python: load_pem_private_key is failing to recognize my private key in production | <p>Locally, I have an .env file containing a single line RSA key like so:
<code>PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\ncontentsofkey\n-----END RSA PRIVATE KEY-----\n" </code></p>
<p>Every 64 characters contains a <code>\n</code> to escape new lines.
This key format works locally and allows my Python ap... | <python><flask><cryptography><github-actions><rsa> | 2024-01-12 04:36:02 | 3 | 1,826 | yung peso |
77,804,198 | 138,830 | Replicate Pylance analysis in Pyright | <p>I've configured my VS Code project to use the Pylance extension. I know that Pylance is using Pyright internally.</p>
<p>We have a "no-warning" policy. I want to enforce this by running Pyright (in pre-commit and in the CI pipeline). Since Pyright is used internally by Pylance, I figured I should be able t... | <python><pylance><pyright> | 2024-01-12 03:36:19 | 1 | 14,239 | gawi |
77,803,998 | 16,405,935 | Error when install pandas with Anaconda Prompt | <p>I'm trying to install new pandas version to my company's PC. Because my computer cannot connect to the internet so I downloaded the file <code>tar.gz</code> and use Anaconda Prompt to install but encountered the following problem:</p>
<pre><code>(base) C:\Users\admin>pip install pandas-2.1.4.tar.gz
Processing c:\... | <python><pandas><anaconda><conda> | 2024-01-12 02:09:00 | 1 | 1,793 | hoa tran |
77,803,878 | 23,190,147 | Error installing the correct version of pywin32 to install pybrowsers in python | <p>I'm trying to install the pybrowsers module in python. I tried installing it, using my normal command in the command prompt. I got a conflict error, that apparently my current version of pywin32 was too high, it needed to be lower than 306. So I uninstalled pywin32, but when I tried to install it again to the correc... | <python><installation><browser> | 2024-01-12 01:21:18 | 1 | 450 | 5rod |
77,803,873 | 3,155,240 | Vistual Studio C++ program exiting with code -1073741819 when trying to use Python.h | <p>I asked for Poe AI to write me some basic code using the Python / C API. I followed its instructions for setup, built the project, ran the code, and it exited with -1073741819.</p>
<p>Here's the code:</p>
<pre><code>#include <iostream>
#include <Python.h>
int main() {
Py_Initialize(); // Initialize... | <python><c++><visual-studio> | 2024-01-12 01:18:44 | 1 | 2,371 | Shmack |
77,803,680 | 2,059,584 | CREATE EXTENSION silently fails in SQLAlchemy | <p>I'm trying to create a <code>pgvector</code> extension on my server programmatically though <code>sqlalchemy</code> but the execute instruction fails silently.</p>
<p>Here is the code:</p>
<pre class="lang-py prettyprint-override"><code>from sqlalchemy import create_engine, text
engine = create_engine(f"postgre... | <python><postgresql><sqlalchemy><amazon-rds> | 2024-01-12 00:04:29 | 1 | 854 | Rizhiy |
77,803,677 | 2,635,863 | extract indexes corresponding to the range of nested list elements | <pre><code>df = pd.DataFrame({'x':[0,1,2,3,4,5,6,7]})
</code></pre>
<p>I'm trying to extract the rows with indexes that correspond to the range given in a nested list:</p>
<pre><code>a = [[2,4],[6,7]]
</code></pre>
<p>Basically, I need to find a way to expand <code>a</code> to this:</p>
<pre><code>df.loc[[2,3,4, 6,7]]
... | <python><pandas> | 2024-01-12 00:04:11 | 3 | 10,765 | HappyPy |
77,803,661 | 2,352,855 | How can I iterate through a DataFrame to concatenate strings once an empty cell is reached? | <p>I've extracted some pdf tables using Camelot.<br />
The first column contains merged cells, which is often problematic.</p>
<p>Despite tweaking some of the advanced configurations, the merged cells for the first column, span across rows.</p>
<p>I'd like to iterate through the first column rows to achieve the followi... | <python><pandas><dataframe><python-camelot> | 2024-01-11 23:58:19 | 1 | 406 | NoExpert |
77,803,656 | 555,129 | Python: Mock a module that does not exist | <p>I have a large set of legacy python scripts that were developed and used on Linux.
Now the desire is to run parts of this code on Windows without too many changes.</p>
<p>But the code fails on Windows when trying to import Linux specific modules such as <code>fcntl</code>.</p>
<p>To be clear, I do not want to run th... | <python><mocking> | 2024-01-11 23:56:41 | 1 | 1,462 | Amol |
77,803,570 | 1,907,924 | Convert a single column with a list of values into one hot encoding using Power Query | <p>For now I have following table in Excel, which makes it inconvenient to use for some further processing.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>Segments</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Food</td>
</tr>
<tr>
<td>2</td>
<td>Automation</td>
</tr>
<tr>
<td... | <python><excel><powerquery> | 2024-01-11 23:21:03 | 1 | 4,338 | Dcortez |
77,803,565 | 12,935,622 | Matplotlib Error: 'LinearSegmentedColormap' object has no attribute 'resampled' | <p>I was running this in my jupyter notebook,</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib as mpl
from matplotlib.colors import LinearSegmentedColormap, ListedColormap
# Color map
top = mpl.colormaps['Oranges_r'].resampled(128)
bottom = mpl... | <python><matplotlib> | 2024-01-11 23:19:54 | 0 | 1,191 | guckmalmensch |
77,803,539 | 13,916,049 | Plot silhouette for each cluster using Plotly | <p>I want to plot the silhouette whereby the concat_omics_df.index matches the labels (i.e., subtypes). My code only produces a single silhouette value and I'm unable to plot.</p>
<pre><code>import plotly.graph_objects as go
from sklearn.metrics import silhouette_score
# Extract labels as an array
labels = subtype_lab... | <python><plotly><visualization><cluster-analysis> | 2024-01-11 23:11:58 | 0 | 1,545 | Anon |
77,803,456 | 2,663,150 | How does pytest "know" where to import code from? | <p>This thread is a follow-up to an unsuccessful attempt to resolve the issue on Reddit, which can be seen in its entirety <a href="https://www.reddit.com/r/learnpython/comments/18ugodb/confused_about_how_pytest_knows_where_to_import/" rel="nofollow noreferrer">here</a>, though I will of course replicate the essential ... | <python><pytest> | 2024-01-11 22:48:24 | 1 | 566 | readyready15728 |
77,803,436 | 1,267,363 | Python conditional replacement based on element type | <p>In Python 3.7 I am trying to remove pipe characters</p>
<pre><code>r=(('ab|cd', 1, 'ab|cd', 1), ('ab|cd', 1, 'ab|cd', 1))
[[x.replace('|', '') for x in l] for l in r]
</code></pre>
<p>Error: 'int' object has no attribute 'replace'</p>
<p>Desired outcome:
(('abcd', 1, 'abcd', 1), ('abcd', 1, 'abcd', 1))</p>
<p>How ca... | <python> | 2024-01-11 22:42:16 | 1 | 8,126 | davidjhp |
77,803,371 | 11,618,586 | Normalizing a monotonically increasing function and calculate std | <p>I have an increasing function like so:</p>
<p><a href="https://i.sstatic.net/7KKJN.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7KKJN.png" alt="image" /></a></p>
<p>I plan on breaking it up into intervals (between the red lines).
I want to rotate the segment horizontal and calculate the standard de... | <python><statistics><analytics> | 2024-01-11 22:24:38 | 1 | 1,264 | thentangler |
77,803,362 | 1,171,899 | SSH command times out the 6th time it calls after working correctly 5 times | <p>I have Python code in a script like this -</p>
<pre class="lang-py prettyprint-override"><code>def run_ssh_cmd(host, cmd):
global i
i += 1
ql(f"Running cmd {i}: {cmd}", "info", host)
cmds = ["ssh", "-t", "-p", "22", host, cmd]
process =... | <python><windows><ssh> | 2024-01-11 22:21:40 | 1 | 3,463 | Kyle H |
77,803,295 | 6,303,377 | How to handle default values in parents of python dataclasses | <p>This is a simplified version of my code:</p>
<pre class="lang-py prettyprint-override"><code>@dataclass
class _AbstractDataTableClass:
"""All dataclasses should have a _unique_fields attribute to identify the
values in that table that must be unique. This assumption simplifies type hints for
... | <python><python-3.x><python-dataclasses> | 2024-01-11 22:05:06 | 1 | 1,789 | Dominique Paul |
77,802,979 | 2,977,092 | How to draw a horizontal line at y=0 in an Altair line chart | <p>I'm creating a line chart using Altair. I have a DataFrame where my y-values move up and down around 0, and I'd like to add a phat line to mark y=0. Sounds easy enough, so I tried this:</p>
<pre><code># Add a horizontal line at y=0 to clearly distinguish between positive and negative values.
y_zero = alt.Chart().mar... | <python><altair> | 2024-01-11 20:53:12 | 2 | 739 | luukburger |
77,802,815 | 15,781,591 | How to reverse order of legend for horizontal stacked bar chart in seaborn? | <p>I have the following code that generates a horizontal stacked bar chart in python, using seaborn.</p>
<pre><code>sns.set_style('white')
ax = sns.histplot(
data=temp, y='tmp', weights='Weight', hue=field,
multiple='stack', palette='viridis', shrink=0.75
)
ax.set_xlabel('Weight')
a... | <python><matplotlib><seaborn><legend> | 2024-01-11 20:20:55 | 2 | 641 | LostinSpatialAnalysis |
77,802,806 | 12,397,582 | Decompressing large streams with Python tarfile | <p>I have a large <code>.tar.xz</code> file that I am downloading with python requests that needs to be decompressed before writing to the disk (Due to limited disk space). I have a solution which works for smaller files, but larger files hang indefinitely.</p>
<pre><code>import io
import requests
import tarfile
sessio... | <python><python-3.x><python-requests><tarfile> | 2024-01-11 20:19:13 | 2 | 683 | Spiff |
77,802,755 | 200,304 | Python: recursively import all files in a directory | <p>I want to do something like this:</p>
<pre><code>myprog --tests-dir /my/dir
</code></pre>
<p>which will recursively traverse <code>/my/dir</code>, find all Python files, and import them. An extra challenge is that there may be dependencies between them.</p>
<p>Example. If the files are like this:</p>
<pre><code>/my/... | <python> | 2024-01-11 20:07:22 | 1 | 3,245 | Johannes Ernst |
77,802,458 | 44,330 | Functional equivalent in pandas to assigning one or more elements in a series | <p>I am wondering if there is a functional but efficient equivalent to the following mutative code:</p>
<pre><code>import pandas as pd
s = pd.Series(...)
s[k] = v # I don't want to mutate s
</code></pre>
<p>so that the operation returns a new series <code>s2</code> with the mutation. I can use <code>copy()</code> an... | <python><pandas> | 2024-01-11 19:05:45 | 1 | 190,447 | Jason S |
77,802,033 | 15,671,866 | C program and subprocess | <p>I wrote this simple C program to explain a more hard problem with the same characteristics.</p>
<pre><code>#include <stdio.h>
int main(int argc, char *argv[])
{
int n;
while (1){
scanf("%d", &n);
printf("%d\n", n);
}
return 0;
}
</code></pre>
<p>and it w... | <python><c><subprocess> | 2024-01-11 17:38:08 | 2 | 585 | ma4stro |
77,801,604 | 12,771,298 | Jupyer Notebook not hiding cells even with the hide-input tag | <p>I realize there are plenty of questions about hiding Jupyter Notebook cells, but even following all the instructions I can find, Jupyter still refuses to hide the cell.</p>
<p>I've added the 'hide-input' tag to my cell, and this is what the metadata looks like:</p>
<pre><code>{
"trusted": true,
"t... | <python><jupyter-notebook><jupyter> | 2024-01-11 16:26:56 | 1 | 375 | Petra |
77,801,556 | 10,200,497 | How can I create a list of range of numbers as a column of dataframe? | <p>My DataFrame is:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
{
'a': [20, 100],
'b': [2, 3],
'dir': ['long', 'short']
}
)
</code></pre>
<p>Expected output: Creating column <code>x</code>:</p>
<pre><code> a b dir x
0 20 2 long [22, 24, 26]... | <python><pandas><dataframe> | 2024-01-11 16:20:15 | 4 | 2,679 | AmirX |
77,801,481 | 534,238 | How to use both `with_outputs` and `with_output_types` in Apache Beam (Python SDK)? | <p>An Apache Beam <code>PTransform</code> can have <code>with_outputs</code> and <code>with_output_types</code> appended to it. Eg,</p>
<pre class="lang-py prettyprint-override"><code>pcoll | beam.CombinePerKey(sum).with_output_types(typing.Tuple[unicode, int])
</code></pre>
<p>and</p>
<pre class="lang-py prettyprint-... | <python><apache-beam> | 2024-01-11 16:08:34 | 1 | 3,558 | Mike Williamson |
77,801,321 | 2,437,514 | Undo operation in Xlwings | <p>Does Xlwings have an undo operation?</p>
<p>I have searched the documentation and cannot find anything.</p>
<pre class="lang-py prettyprint-override"><code>import xlwings as xw
wb_name = "my_wb.xlsx"
app = xw.App(visible=True)
wb: xw.Book = app.books.open(wb_name )
sh: xw.Sheet = wb.sheets[0]
sh.range(&qu... | <python><xlwings> | 2024-01-11 15:44:13 | 1 | 45,611 | Rick |
77,801,279 | 5,072,692 | pandas set_table_styles not working for table tag | <p>I am using the following code to set a border to table and and some formatting to the header column. The styling for the header column works fine but the code doesn't render the border for the table.</p>
<pre><code>styled_df = df.style.applymap(colorize).set_table_styles([
{'selector': 'table',
'pro... | <python><pandas><dataframe><css-selectors> | 2024-01-11 15:38:32 | 2 | 955 | Adarsh Ravi |
77,801,188 | 3,433,875 | Get metadata from ttf font files in windows with python and fontTools library | <p>To be able to quickly find the font I want (windows only for now) I want to create a list I can query to find the font name, family and styles available for the font.</p>
<p>Using fontTools and ttlib , I am able to create the list but, when the font styles are not a part of the file name, I am not able to get them.<... | <python><python-3.x><ttx-fonttools> | 2024-01-11 15:24:25 | 1 | 363 | ruthpozuelo |
77,801,162 | 11,807,683 | Applying islice to ijson, getting list of lists when applied? | <p>I'm trying to apply <code>islice</code> over a huge JSON file which contains around ~180k documents.</p>
<p>The file is, as an example:</p>
<pre><code>[
{"propertyA": "abc"},
{"propertyB": "bcd"},
...
]
</code></pre>
<p>As of now I'm doing <code>islice(ijson.items(file, ... | <python><json> | 2024-01-11 15:22:02 | 1 | 591 | czr_RR |
77,800,955 | 3,702,377 | How to use Depends or similar thing as dependency injection outside of FastAPI request methods? | <p>Can anybody tell me how to use dependency injection for my <code>get_db()</code> outside of the FastAPI routers methods? Apparently, <code>Depends()</code> only covers DI in request functions.</p>
<p>Here's the <code>get_db()</code> async generator:</p>
<pre class="lang-py prettyprint-override"><code>async def get_d... | <python><dependency-injection><python-asyncio><fastapi><depends> | 2024-01-11 14:53:56 | 2 | 35,654 | Benyamin Jafari |
77,800,759 | 9,212,313 | Calling psutil.Process() fails when used inside of Docker container on Jenkins | <p>When running <code>psutil.Process()</code> in Docker, while using Jenkins runner, I get <code>psutil.NoSuchProcess: process PID not found</code> error, the whole error trace is below.</p>
<p>The interesting thing is that this works in Docker/Podman outside of Jenkins runner (tested with various versions of both Dock... | <python><linux><docker><jenkins> | 2024-01-11 14:22:24 | 0 | 315 | robocat314 |
77,800,583 | 4,133,188 | Converting XGBoost Shapely values to SHAP's Explanation object | <p>I am trying to convert XGBoost shapely values into an SHAP explainer object. Using the example [here][1] with the built in SHAP library takes days to run (even on a subsampled dataset) while the XGBoost library takes a few minutes. However. I would like to output a beeswarm graph that's similar to what's displayed i... | <python><machine-learning><xgboost><shap> | 2024-01-11 13:55:27 | 1 | 771 | BeginnersMindTruly |
77,800,291 | 9,974,205 | How can I get sequences of actions from a Pandas dataframe | <p>I have a Pandas dataframe in Python in which is registered when Ramirez enters and leaves a building. I also have a list in which all events in the building are registrered, from turning on the lights to flushing a toilet or calling an elevator. I have ordered them chronollogically as:</p>
<pre><code>Visit 1: C2, C4... | <python><pandas><statistics><pattern-matching><combinations> | 2024-01-11 13:05:44 | 1 | 503 | slow_learner |
77,800,210 | 832,490 | Pytest not raising an exception | <p>I have the following code</p>
<pre><code>@blueprint.post("/bulk")
@validate()
def bulk(body: BulkRequestBody) -> tuple[BulkResponseBody, int]:
try:
bulk_insert(body.items) # Should raise the exception here.
return BulkResponseBody(ok=True), 200
except: # noqa
pass
r... | <python><pytest> | 2024-01-11 12:54:51 | 1 | 1,009 | Rodrigo |
77,800,061 | 7,341,904 | different output between command execution and subprocess.run | <p>I am getting two different output for same command when i am trying to execute command from command line manual and from python.</p>
<p>I am trying to run one command <strong>python --version</strong> from linux to window over ssh from command line and python. but observed two different output.
following code i am u... | <python><ssh><subprocess> | 2024-01-11 12:33:39 | 1 | 1,823 | True Vision _ Zunna Berry |
77,800,048 | 8,315,634 | Refresh button using streamlit. Had to click on refresh twice to make it work | <p>How to make it work on single click.</p>
<pre><code>import streamlit as st
import pandas as pd
import numpy as np
# Function to read DataFrame from CSV
def read_dataframe():
return pd.read_excel(r"E:\projects\smartscan2_1\patients_info.xlsx")
def main():
st.title("Refresh DataFrame Example&... | <python><streamlit> | 2024-01-11 12:31:03 | 1 | 1,379 | Soumya Boral |
77,799,921 | 12,319,746 | Autogen's human input reloads server | <p>So, basically I am using <a href="https://nicegui.io/" rel="nofollow noreferrer">NiceGui</a> to create a UI over <code>AutoGen</code>. I have set the <code>human_input_mode</code> to <code>ALWAYS</code>. Whenever <code>Autogen</code> asks for the human input, the server reloads and the conversation is lost. <code>re... | <python><artificial-intelligence><ms-autogen> | 2024-01-11 12:09:38 | 0 | 2,247 | Abhishek Rai |
77,799,809 | 1,473,517 | Why do I get different random numbers with the same seed? | <p>I am using the numpy random number generator with the following MWE:</p>
<pre><code>import numpy as np
np.random.seed(40)
print(np.random.randint(-3, 4))
rng = np.random.default_rng(seed=40)
print(rng.integers(-3, 4))
</code></pre>
<p>This outputs:</p>
<pre><code>3
0
</code></pre>
<p>Why are the outputs different?</... | <python><numpy><random-seed> | 2024-01-11 11:50:05 | 2 | 21,513 | Simd |
77,799,804 | 4,377,632 | Python - Add nested dictionary items from a list of keys | <p>I'm trying to find a quick and easy way to add nested items to an existing Python dictionary. This is my most recent dictionary:</p>
<pre class="lang-py prettyprint-override"><code>myDict = {
"a1": {
"a2": "Hello"
}
}
</code></pre>
<p>I want to use a function similar to this one... | <python><dictionary> | 2024-01-11 11:49:14 | 0 | 323 | bkbilly |
77,799,796 | 7,319,413 | Trouble Extracting Recording URLs from website | <p>I am new to python and I have a requirement to parse all the recording URL from a website. I tried the below program but it's not able to find the recording links but It's printing other links in the web page. I am not aware of the website design, I tried with AI tools and Stackoverflow but I can find same solution ... | <python><web-scraping><beautifulsoup> | 2024-01-11 11:47:52 | 1 | 545 | goodman |
77,799,764 | 1,056,179 | Undetstanding the Torch Cosine Similarity along Different Dimensions | <p>I have two tensors:</p>
<pre><code>a = tensor([[1., 2., 3., 5.],
[1., 9., 9., 5.]])
b = tensor([[ 7., 8., 9., 5.],
[10., -1., 3., 5.]])
</code></pre>
<p>I can not understand why calculating the cosine similarity along <em>dim = 0</em> results in a tensor with 4 distances:</p>
<pre><code>tensor(... | <python><pytorch> | 2024-01-11 11:41:50 | 0 | 2,059 | Amir Jalilifard |
77,799,470 | 4,340,985 | How to turn dataframe rows into multiindex levels? | <p>I have a csv file that looks something like this:</p>
<pre><code>ID ; name; location; level; DATE19970901; DATE19970902; ...;DATE20201031;survey;person
001; foo; east; 500; 123.1; 342.5; ...; 234.5; A; John
002; bar; west; 50; 67.8; 98.3; ...; 76.6; ... | <python><pandas><dataframe><multi-index> | 2024-01-11 10:52:25 | 1 | 2,668 | JC_CL |
77,799,262 | 3,810,748 | Why doesn't BERT give me back my original sentence? | <p>I've started playing with <code>BERT</code> encoder through the <code>huggingface</code> module.
<a href="https://i.sstatic.net/N6J8m.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/N6J8m.png" alt="enter image description here" /></a></p>
<p>I passed it a normal unmasked sentence and got the following... | <python><huggingface-transformers><bert-language-model><huggingface> | 2024-01-11 10:19:52 | 1 | 6,155 | AlanSTACK |
77,799,221 | 7,112,039 | SqlAlchemy add hybrid property that is a sum of a datetime and a numeric field | <p>I am trying to calculate a field combining two existing fields in a SQLAlchemy Model, and use it in the query parameters.</p>
<p>I have a model like this:</p>
<pre class="lang-py prettyprint-override"><code> class Booking(BaseORMModel):
start: Mapped[datetime] = mapped_column(TIMESTAMP(timezone=True))
... | <python><sqlalchemy> | 2024-01-11 10:13:01 | 1 | 303 | ow-me |
77,799,177 | 18,782,190 | Apache2 not working with mod_wsgi: "ModuleNotFoundError: No module named 'encodings'" | <p>I run Apache2 in a Docker container and want to host my Django site using <code>mod_wsgi</code>. Anyway WSGI process fails to start and I get the error below. I tried using Python paths of the container and of a separate virtual environment, but I get the same error. What am I doing wrong?</p>
<pre><code>[Thu Jan 11... | <python><docker><apache><mod-wsgi><wsgi> | 2024-01-11 10:05:37 | 1 | 593 | Karolis |
77,798,960 | 755,371 | How to specify python paths in pyproject.toml for poetry? | <p>I want to build a poetry python environment by setting the pyproject.toml file so when I activate it and running in python interpreter <code>import sys; print(sys.path)</code> will show the paths added in pyproject.toml</p>
<p>How to proceed ?</p>
| <python><python-poetry> | 2024-01-11 09:29:36 | 1 | 5,139 | Eric |
77,798,875 | 13,568,193 | Cumulatative Subtraction in pyspark | <p>I want to achieve cumulative Subtraction in pyspark.
I have dataset like this</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>councs</th>
<th>coitm</th>
</tr>
</thead>
<tbody>
<tr>
<td>1000</td>
<td>1110</td>
</tr>
<tr>
<td>100</td>
<td>1110</td>
</tr>
<tr>
<td>50</td>
<td>1110</td>
</tr... | <python><pyspark><azure-databricks> | 2024-01-11 09:14:17 | 1 | 383 | Arpan Ghimire |
77,798,692 | 4,872,294 | Pyspark error in EMR writting parquet files to S3 | <p>I have a process that reads data from S3, processes it and then saves it again to s3 in other location in parquet format. Sometimes I get this error when it is writting:</p>
<pre><code> y4j.protocol.Py4JJavaError: An error occurred while calling o426.parquet.
: org.apache.spark.SparkException: Job aborted due to ... | <python><apache-spark><amazon-s3><pyspark><amazon-emr> | 2024-01-11 08:40:45 | 2 | 1,472 | Shadowtrooper |
77,798,604 | 2,234,246 | Unable to parse dates with an optional day part in Pyspark | <p>I have a Pyspark data frame with string dates that may be either yyyyMM (e.g. 200802) or yyyyMMdd (e.g. 20080917). I am trying to parse these into dates. The function I am currently considering is <a href="https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.to_date.html" r... | <python><datetime><pyspark><apache-spark-sql> | 2024-01-11 08:22:22 | 0 | 323 | Tim Keighley |
77,798,563 | 18,876,759 | Add support for new data type (quantiphy.Quantity) | <p>I'm having a Pydantic model which includes a custom data tpye (specifically <code>quantiphy.Quantity</code>):</p>
<pre class="lang-py prettyprint-override"><code>from pydantic import BaseModel
class SpecLimit(BaseModel):
label: str
minimum: Quantity | None = None
maximum: Quantity | None = None
typi... | <python><pydantic> | 2024-01-11 08:14:53 | 2 | 468 | slarag |
77,798,015 | 2,178,942 | Putting space between every two bars in seaborn's factorplot | <p>I have a drawn a plot using seaborn and the following command:</p>
<pre><code>ax = sns.factorplot(x="feat", y="acc", col="roi", hue="alpha", data=df_d_pt, kind="bar", dodge=True)
</code></pre>
<p>Results look like this:</p>
<p><a href="https://i.sstatic.net/rc2Zk.png... | <python><matplotlib><seaborn><figure> | 2024-01-11 06:17:25 | 0 | 1,581 | Kadaj13 |
77,797,969 | 3,810,748 | Why does Python's Decimal class generate additional digits that weren't there before? | <p>Take a look at the following outputs</p>
<pre><code>>>> from decimal import Decimal
>>> print(2.4)
2.4
>>> print(Decimal(2.4))
2.399999999999999911182158029987476766109466552734375
</code></pre>
<p>Why exactly is this happening? If the explanation is that 2.4 couldn't be represented prec... | <python><python-3.x><floating-point><decimal> | 2024-01-11 06:02:42 | 0 | 6,155 | AlanSTACK |
77,797,689 | 2,987,552 | langchain.document_loaders.ConfluenceLoader.load giving AttributeError: 'str' object has no attribute 'get' while reading all documents from space | <p>When I try sample code given <a href="https://python.langchain.com/docs/integrations/document_loaders/confluence" rel="nofollow noreferrer">here</a>:</p>
<pre><code>from langchain.document_loaders import ConfluenceLoader
loader = ConfluenceLoader(
url="<my confluence link>", username="<m... | <python><langchain><confluence><document-loader> | 2024-01-11 04:31:15 | 1 | 598 | Sameer Mahajan |
77,797,420 | 5,269,749 | How to increase the resolution of axis when plotting via hist2d | <p>Using the following code I create a 2d histogram.</p>
<pre><code>import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
np.random.seed(19680801)
x, y = np.random.rand(2, 1000) * 10
hist, xedges, yedges, im = plt.hist2d(x, y, bins=10, range=[[0, 10], [0, 10]])
for i in range(l... | <python><matplotlib> | 2024-01-11 02:54:20 | 0 | 1,264 | Alex |
77,797,208 | 13,916,049 | Iteratively identify columns with binary values in a nested dictionary | <p>I want to identify columns with binary or label-encoded values as the <code>y_label_encoded_columns variable</code>. My code returns an empty dictionary.</p>
<p>Code:</p>
<pre><code># Identify label-encoded columns from all dataframes in the nested dictionary
y_label_encoded_columns = {}
for outer_key, inner_dict in... | <python><pandas><numpy> | 2024-01-11 01:26:14 | 1 | 1,545 | Anon |
77,797,152 | 3,380,902 | ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+ | <p>I am seeing this error when attempting to launch a jupyter notebook from the terminal.</p>
<pre><code>Error loading server extension jupyterlab
Traceback (most recent call last):
File "/Users/kevalshah/myvenv/lib/python3.7/site-packages/notebook/notebookapp.py", line 2047, in init_server_extensio... | <python><python-requests><openssl><importerror><urllib3> | 2024-01-11 01:03:04 | 1 | 2,022 | kms |
77,797,041 | 12,393,400 | Can't Access SQLite3 Database With pypyodbc | <p>I am switching a python program over from my Windows laptop which had Microsoft SQL Studio 18 on it to a raspberry pi so I can keep it running 24/7. On the laptop, it worked just fine using pyodbc to connect to the local Microsoft SQL Server, but on the raspberry pi, it isn't working. I first had to switch out pyodb... | <python><sqlite><odbc><pyodbc><pypyodbc> | 2024-01-11 00:16:04 | 1 | 616 | Frasher Gray |
77,796,979 | 2,142,728 | VSCode not suggesting imports for symbols in Poetry-managed path dependency | <p>I have two Python projects managed by Poetry, ProjectA and ProjectB, where ProjectA depends on ProjectB (using <a href="https://python-poetry.org/docs/dependency-specification/#path-dependencies" rel="nofollow noreferrer">path dependency</a>). When using symbols (such as classes or variables) from external libraries... | <python><visual-studio-code><intellisense><python-poetry> | 2024-01-10 23:51:23 | 1 | 3,774 | caeus |
77,796,696 | 1,144,854 | Type hinting a dataclass for instance variable that accepts multiple types as an argument and stores single type | <p>I want my class constructor to accept variable inputs, then normalize them for storage and access. For example:</p>
<pre class="lang-py prettyprint-override"><code>class Ticket:
def __init__(self, number: int | str):
self.number: int = int(number)
# so that it's flexible in creation:
t = Ticket(6)
t = T... | <python><python-typing><python-dataclasses> | 2024-01-10 22:20:06 | 1 | 763 | Jacktose |
77,796,659 | 20,122,390 | How can I get the index ranges of a pandas series that are NaN? | <p>I have a dataframe in Pandas where the indices are dates and the columns are codes, like this:
<a href="https://i.sstatic.net/ahA0E.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ahA0E.png" alt="enter image description here" /></a></p>
<p>I need to identify the columns that have NaN values, I impleme... | <python><pandas><dataframe> | 2024-01-10 22:12:42 | 1 | 988 | Diego L |
77,796,630 | 8,328,007 | creating dynamic frame using glue context catalog from Athena view | <p>I have a view created in Athena and I am trying to execute the following inside Glue job:</p>
<pre><code>from awsglue.context import GlueContext
dataframe = glueContext.create_dynamic_frame.from_catalog(
database=db_name,
table_name=view_name,
push_down_predicate=f&qu... | <python><aws-glue><amazon-athena> | 2024-01-10 22:04:48 | 1 | 346 | python_enthusiast |
77,796,550 | 9,290,374 | pd.to_datetime() DateParseError when run in Airflow | <p><strong>Goal</strong></p>
<p>Date field [YYYY-MM-DD] comes into a dataframe via <code>pd.read_sql()</code>. Because of destination system constraints, the field needs to be created as a datetime string. Then it is reformatted as a datetime so it can be uploaded to BigQuery. The entirety of the script is being run vi... | <python><pandas><datetime><airflow> | 2024-01-10 21:44:55 | 0 | 490 | hSin |
77,796,418 | 1,783,593 | Overriding a route dependency in FastAPI | <p>I am using FastAPI</p>
<p>I have a route:</p>
<pre><code>@router.post("/product", tags=["product"])
async def create_product(request: Request,
id_generator: IdGenerator = Depends(get_id_generator)):
</code></pre>
<p>I have a dependencies file.</p>
<pre><code>def get_id_ge... | <python><testing><dependencies><overriding><fastapi> | 2024-01-10 21:16:56 | 1 | 993 | stevemarvell |
77,796,345 | 5,269,749 | How to print the value for each bin on the plot when plotting via seaborn histplot | <p>Lets say I am plotting a histogram with following code,
is there a way to print the value of each bin (basically the height of each bar) on the plot?</p>
<pre><code>import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
# Fixing random state for reproducibility
np.random.seed(19680801)
x, y = np.... | <python><seaborn> | 2024-01-10 21:02:11 | 1 | 1,264 | Alex |
77,796,003 | 251,589 | How to redirect tensorflow import errors from `stderr` to `stdout` | <h3>Question</h3>
<p>When you import tensorflow, it prints to <code>stderr</code> - <a href="https://github.com/tensorflow/tensorflow/issues/62770#issue-2073291734" rel="nofollow noreferrer">bug report</a>.</p>
<p>Currently this is confusing my monitoring system and logging these informative messages as errors.</p>
<p>... | <python><tensorflow><logging><stderr> | 2024-01-10 19:41:51 | 1 | 27,385 | sixtyfootersdude |
77,795,931 | 11,637,422 | Vectorising or Using Multiprocessing on a Large Dataframe | <p>I have a weird dataframe where there are amounts for theoretical deposits up to Day30, so 30 triplets of columns. I want to gather all the data into one single column, where I have all the dates and deposits, regardless of if they happened on Day1,Day2 or DayX for that player. I have tried the following code, which ... | <python><pandas><multiprocessing><vectorization> | 2024-01-10 19:27:28 | 1 | 341 | bbbb |
77,795,874 | 15,781,591 | Unable to set custom color palette in pandas pie chart, colors keep getting set based on value | <p>I have a for loop in python that generates many pie charts for different calculations from a dataframe. I want the color labelling between each pie chart for each for loop iteration to be the same, and so I try to set them to the same color palette dictionary.</p>
<pre><code>color_mapping = dict(zip(df_pc_region.ind... | <python><pandas><matplotlib> | 2024-01-10 19:15:46 | 0 | 641 | LostinSpatialAnalysis |
77,795,735 | 5,429,320 | Failed to connect to database: ('HYT00', '[HYT00] [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired (0) (SQLDriverConnect)') | <p>I have an Azure Function app, which has a couple endpoints, written in Python and it is running in a docker container in Docker Desktop. The Function App seems to run correctly but when I try to call the endpoint I get the following error:</p>
<pre><code>{
"error": "Database connection failed: Faile... | <python><sql-server><azure><docker><odbc> | 2024-01-10 18:47:15 | 1 | 2,467 | Ross |
77,795,681 | 9,642 | How to specify OpenAI Organization ID in Microsoft AutoGen? | <p>In order to create a "config_list" for OpenAI in <a href="https://github.com/microsoft/autogen" rel="nofollow noreferrer">Microsoft AutoGen</a> I do the following:</p>
<pre class="lang-py prettyprint-override"><code>import os
config_list = [{
'model': 'gpt-3.5-turbo-1106',
'api_key': os.getenv("OP... | <python><openai-api><ms-autogen> | 2024-01-10 18:36:01 | 1 | 20,614 | Neil C. Obremski |
77,795,612 | 3,929,525 | How to run TensorFlow GPU version on Google Colab with Python 2.7? | <p>I have a code written using the <strong>TensorFlow version 1.15</strong> for an image to image translation task and I want to run it on Google Colab environment which currently has Python 3.10.12 installed by default.</p>
<p>Due to my source code's dependencies, I have to use TensorFlow version 1.15 and that's why I... | <python><python-2.7><tensorflow><google-colaboratory><tensorflow1.15> | 2024-01-10 18:24:19 | 1 | 1,312 | Naser.Sadeghi |
77,795,529 | 18,476,381 | SQLAlchemy Async Join not bringing in columns | <p>I am trying to join two tables using sqlalchemy, the query I am trying to acheive is:</p>
<pre><code>SELECT *
FROM service_order
JOIN vendor ON service_order.vendor_id = vendor.vendor_id
WHERE service_order.service_order_id = 898;
</code></pre>
<p>My current sqlalchemy statement below just generates an object <db... | <python><sql><sqlalchemy><orm> | 2024-01-10 18:09:14 | 1 | 609 | Masterstack8080 |
77,795,452 | 1,473,517 | How fast can a max sum rectangle be found? | <p>I need to find a rectangle in a large matrix of integers that has the maximum sum. There is an O(n^3) time algorithm as described <a href="https://www.interviewbit.com/blog/maximum-sum-rectangle/" rel="nofollow noreferrer">here</a> and <a href="https://stackoverflow.com/questions/69368984/maximum-sum-rectangle-in-a-... | <python><numpy><optimization><numba><pythran> | 2024-01-10 17:55:19 | 1 | 21,513 | Simd |
77,795,419 | 7,287,543 | Python globbing to match find's "-print -quit" behavior | <p>I have a few arbitrarily deep directories, each of which contains a single file with a consistent name. In the command line I can use <code>find <dir> -name <filename> -print -quit</code> for optimized searching: once it finds the file, it stops looking through the directory. I can do that because it's f... | <python><find><glob><subdirectory> | 2024-01-10 17:50:54 | 1 | 1,893 | Yehuda |
77,795,406 | 1,593,077 | Can I get argparse not to repeat the argument indication after the two option names? | <p>When I specify a parameter for argparse with both a short and long name, e.g.:</p>
<pre><code>parser.add_argument("-m", "--min", dest="min_value", type=float, help="Minimum value")
</code></pre>
<p>and ask for <code>--help</code>, I get:</p>
<pre><code> -m MIN_VALUE, --min MI... | <python><command-line-arguments><argparse> | 2024-01-10 17:47:31 | 1 | 137,004 | einpoklum |
77,795,398 | 3,446,051 | Regular Expresssion does not catch the last digit | <p>I have the following cases I want to capture:</p>
<pre><code>| Task| Text | Capture |
|:---- |:------| :-----|
| Capture| 1.304 /XXX 0.0000 XX 15/Oct/2000 | 1.304 and 0.000 |
| Capture | XXX 1.304% - XXXX 15.10.2044 XXX | 1.304 but not part of the date 15.10.2044|
| Capture| XXX 11,8275% XXX1 AAA | 11,8275|
|... | <python><regex> | 2024-01-10 17:46:40 | 2 | 5,459 | Code Pope |
77,795,362 | 6,160,119 | How to migrate from typing.TypeAlias to type statements | <p>I have created a type alias for defining member variables in a <a href="https://docs.python.org/3/library/dataclasses.html#dataclasses.dataclass" rel="nofollow noreferrer"><code>dataclass</code></a> through type annotations:</p>
<pre><code>>>> from typing import TypeAlias
>>> Number: TypeAlias = in... | <python><python-typing> | 2024-01-10 17:39:50 | 1 | 13,793 | Tonechas |
77,795,233 | 4,704,065 | Combine two panda series of the same data frame with different lengths | <p>I have a Data frame which consist of multiple Pandas series . I want to combine three series with different lengths .</p>
<p>My data frame looks like this:</p>
<pre><code>X message Main table:
_tunneled _iTOW _messageIndex version numSv
0 0.0 518431.0 1387.0 2.0 8.0 ... | <python><pandas> | 2024-01-10 17:18:25 | 1 | 321 | Kapil |
77,795,176 | 3,707,564 | multiple with statement in one line for python | <p>Can I write multiple <code>with</code> statement in one line in python? For</p>
<pre><code>with suppress(Exception): del a;
with suppress(Exception): del b;
</code></pre>
<p>is there something like?</p>
<pre><code>with suppress(Exception): del a;|| with suppress(Exception): del b;
</code></pre>
| <python><with-statement> | 2024-01-10 17:09:27 | 1 | 1,930 | user40780 |
77,795,150 | 577,805 | Cannot import name 'Actor' from 'pygame.sprite' | <p>I have the following python / pygame code:</p>
<pre><code>import pygame
import time
pygame.init()
WIDTH = 800
HEIGHT = 600
from pygame.sprite import Actor
alien = Actor('alien')
def draw():
alien.draw()
pygame.quit()
</code></pre>
<p>When I run it I get the error:</p>
<pre><code>ImportError: cannot import ... | <python><pygame><pgzero> | 2024-01-10 17:06:04 | 1 | 40,016 | Miguel Moura |
77,795,119 | 10,425,150 | How to import locally installed library? | <p>I've installed my library using the following command:</p>
<pre><code>pip install .
</code></pre>
<p><strong>Here is the directory structure:</strong></p>
<pre><code>└───module1
├───__init__.py
└───mod_1.py
└───module2
├───__init__.py
└───mod_2.py
__init__.py
setup.py
</code></pre>
<p><strong>inside ... | <python><python-3.x><pip><python-import><setuptools> | 2024-01-10 17:00:27 | 1 | 1,051 | Gооd_Mаn |
77,795,013 | 2,386,113 | How to stack arrays and compute inverse using Numba? | <p>I need to compute some vectors, stack them vertically in an array and finally calculate the inverse of the stacked vectors. I am able to do that using numpy but for better performance (and to assign it to a separate thread), I want to the calculations using Numba.</p>
<p>The code below works without the <code>@njit<... | <python><numba> | 2024-01-10 16:44:42 | 2 | 5,777 | skm |
77,794,842 | 4,564,080 | Spinner doesn't show and then everything updates once the task in the spinner completes | <p>I am creating a chat app using Streamlit that will be connected to an LLM to respond to the user.</p>
<p>While the LLM is generating a response, I would like a spinner to show until the response can be printed.</p>
<p>Currently, I am mocking the LLM's response generation with a simple <code>time.sleep(5)</code>. How... | <python><streamlit> | 2024-01-10 16:19:02 | 1 | 4,635 | KOB |
77,794,807 | 7,236,077 | Using pulumi python sdk to retrieve resource's attributes | <p>I feel stupid. I've been trying to figure this out for a few hours - totally clueless.</p>
<p>I've set up several services through pulumi on aws in a successful manner.</p>
<p>Each of these services has an id (s3 buckets), or an endpoint (rds database) that other applications will require.</p>
<p>While I can manuall... | <python><amazon-web-services><pulumi> | 2024-01-10 16:14:54 | 1 | 2,498 | epattaro |
77,794,794 | 5,734,793 | pycharm TypeError: Additional arguments should be named <dialectname>_<argument>, got 'autoload' | <p>I am new to python and my program had been working and now I am getting this error -</p>
<pre><code>File "C:\Repos\caers-api-to-cedars\venv\Lib\site-packages\sqlalchemy\sql\base.py", line 599, in _validate_dialect_kwargs
raise TypeError(
TypeError: Additional arguments should be named <dialectname>_&... | <python><sqlalchemy> | 2024-01-10 16:12:52 | 2 | 975 | Ethel Patrick |
77,794,741 | 2,382,483 | Control how uncaught exceptions are logged on exit in Python? | <p>I've got the following python program:</p>
<pre class="lang-py prettyprint-override"><code>import logging
if __name__ == "__main__":
# configure logger to write logs in json format, and put exception traceback on "exception" field
logger = logging.getLogger(__name__)
logger.info(&q... | <python> | 2024-01-10 16:03:43 | 0 | 3,557 | Rob Allsopp |
77,794,637 | 8,521,346 | LlamaIndex Not Checking All Documents When Queried | <p>I'm loading a large amount of documents into LlamaIndex and I am able to ask questions about each of these documents individually, but when it comes to asking questions about the documents overall, there are gaps in its knowledge.</p>
<p>An example of the document in context of real estate would be.</p>
<pre><code>D... | <python> | 2024-01-10 15:49:31 | 1 | 2,198 | Bigbob556677 |
77,794,386 | 1,473,517 | Compute the max sum circular area | <p>I have an n by n matrix of integers and I want to find the circular area, with origin at the top left corner, with maximum sum. Consider the following grid with a circle imposed on it.</p>
<p><a href="https://i.sstatic.net/Gp0WV.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Gp0WV.png" alt="enter im... | <python><algorithm><numpy><performance><optimization> | 2024-01-10 15:10:14 | 4 | 21,513 | Simd |
77,793,991 | 2,386,113 | Numba Exception: Cannot determine Numba type of <class 'type'> | <p>I want to convert a function to Numba for performance reasons. My <strong>MWE</strong> example is below. If I remove the <code>@njit</code> decorator then, the code works but with <code>@njit</code>, I am getting a runtime exception. The exception is most likely coming because of the <code>dtype=object</code> to de... | <python><numba> | 2024-01-10 14:09:28 | 1 | 5,777 | skm |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.