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 β |
|---|---|---|---|---|---|---|---|---|
76,285,683 | 21,107,707 | Rotating cube through constant degree intervals is speeding up | <p>I am coding a rotating cube using rotation matrices and generating plots of the cube at equally spaced intervals along its rotation. However, I notice that the cube likes to speed up sometimes during the gif. Here is the code to generate the cube:</p>
<pre class="lang-py prettyprint-override"><code>import matplotlib... | <python><python-3.x> | 2023-05-19 02:42:48 | 0 | 801 | vs07 |
76,285,582 | 5,336,013 | Pandas: Drop rows at beginning of groups if a column equals certain string value ('Sell' or 'Buy') | <p>To clarify, the 'group' in the title is not a result of pd.groupby. Instead, I meant it as rows that share the same values of certain columns. In my case it would be <strong>account</strong> and <strong>symbol</strong>.</p>
<p>I am trying to calculate profits&loss by account and position from trade data on a Fir... | <python><pandas><finance><fifo> | 2023-05-19 02:11:26 | 1 | 1,127 | Bowen Liu |
76,285,542 | 11,162,983 | How to calculate sum and average bars for every histogram bin | <p>I would like to plot stacked bar charts. The first 3 bars are red, black and blue as shown below.</p>
<p>I want to add a fourth bar that is the 'sum' of the values of red, black and blue bars.</p>
<p>(In another case I want to add a fourth bar that is the 'average' of red, black and blue bars.)</p>
<p>For example, t... | <python><numpy><matplotlib><histogram><grouped-bar-chart> | 2023-05-19 02:00:55 | 1 | 987 | Redhwan |
76,285,436 | 16,589,029 | How to filter out each entry in a column, if each entry is a list, PANDAS | <p>i have this column called "content", every entry in this column is a list, i want to filter and modify "every list" in the column so that every element in a list is filtered out if it does not contain the word <code>car</code>, how can i do that with pandas?</p>
<p>I tried this, however it does a... | <python><pandas><dataframe> | 2023-05-19 01:21:48 | 2 | 766 | Ghazi |
76,285,293 | 9,352,077 | scatterplot skips major ticks with log scale even with manual spacing | <p>I'm plotting points on a log-log scatterplot with <code>matplotlib</code>. The <code>x</code> coordinate of these points rises twice as fast (exponentially speaking) than the <code>y</code> coordinate, which means that the <code>x</code> axis is twice as densely packed when plotted on a square plot.</p>
<p>Here's th... | <python><matplotlib><plot><logarithm><xticks> | 2023-05-19 00:26:41 | 1 | 415 | Mew |
76,285,142 | 3,821,009 | Compare polars list to python list | <p><strong>Update:</strong> Support for direct list comparison was added to Polars.</p>
<pre class="lang-py prettyprint-override"><code>df.filter(pl.concat_list(pl.all()) == [2, 5, 8])
</code></pre>
<hr />
<p>Say I have this:</p>
<pre><code>df = polars.DataFrame(dict(
j=[1,2,3],
k=[4,5,6],
l=[7,8,9],
))
shape:... | <python><python-polars> | 2023-05-18 23:43:22 | 3 | 4,641 | levant pied |
76,285,127 | 13,891,832 | How to format the timeseries axis of a matplotlib plot like a pandas plot | <p>I've created following graph with <code>pd.Series([1]*month_limits.size, month_limits).plot(ax=ax)</code><br />
How do I recreate same x ticks labels with just matplotlib? I mean years and month not overriding each other
<a href="https://i.sstatic.net/KvgGt.png" rel="nofollow noreferrer"><img src="https://i.sstatic.... | <python><matplotlib><time-series><axis><xticks> | 2023-05-18 23:39:35 | 1 | 917 | bottledmind |
76,285,106 | 1,860,222 | How to get the underlying data of a row from a PyQt Table? | <p>I'm working on a python application that uses a QTableView to display some information. When the user double-clicks a row of the table, I want to extract the model data for that row and do something with it. The problem is, the data method for QAbstractTableModel returns the display string, not the data that was use... | <python><model-view-controller><pyqt><qtableview> | 2023-05-18 23:34:14 | 0 | 1,797 | pbuchheit |
76,285,079 | 1,530,967 | How to type dynamically created classes so mypy can lint them properly | <p>I'm looking to refactor the function task decorator of a dataflow engine I contribute to called <a href="https://pydra.readthedocs.io" rel="nofollow noreferrer">Pydra</a> so that the argument types can be linted with mypy. The code captures the arguments to be passed to the function at workflow construction time and... | <python><python-typing><mypy><python-attrs> | 2023-05-18 23:26:15 | 2 | 594 | Tom Close |
76,285,036 | 18,150,609 | Python, Selenium: Take a Full-Page Screenshot as .pdf Without Page Breaks, Regardless of Page Dimensions | <p>Currently, I see it is possible to create screenshots with Selenium. However, they are always <code>.png</code> files. How can I take the same style screenshot but as <code>.pdf</code>?</p>
<p>Required style: No margins; Same dimensions as current page (like a full page screenshot)<br />
Printing the page doesn't ac... | <python><selenium-webdriver><geckodriver> | 2023-05-18 23:10:56 | 2 | 364 | MrChadMWood |
76,285,010 | 219,355 | lxml xpath on new element yields empty list | <p>Say I am composing a xml based on a incomplete xml that lives on a file. I go over each element trying to find it or else creating it.</p>
<pre><code> if len(list(root.xpath(COMSTACK_XPATH, namespaces=NS))) == 0:
create_com_stack_subelement(root.xpath(CDDROOT_XPATH, namespaces=NS).pop())
</code></pre>
<p>If the... | <python><lxml> | 2023-05-18 23:03:29 | 1 | 695 | debuti |
76,284,971 | 19,369,393 | Can python list sort key function take index instead of an element? | <p>Take a look at this code:</p>
<pre><code>points = [...]
properties = [compute_point_property(point) for point in points]
points.sort(?)
</code></pre>
<p>Here I have a list of points, and I compute a property of each point. Then I need to sort the points by their corresponding property value.
The problem is that the ... | <python><list><sorting> | 2023-05-18 22:53:34 | 1 | 365 | g00dds |
76,284,950 | 461,048 | Reshape a numpy array so the columns wrap below the original rows | <p>Consider the following scenario:</p>
<pre><code>a = np.array([[1,1,1,3,3,3], [2,2,2,4,4,4]])
np.reshape(a, (4, 3))
</code></pre>
<p>Output:</p>
<pre><code>array([[1, 1, 1],
[3, 3, 3],
[2, 2, 2],
[4, 4, 4]])
</code></pre>
<p>Desired output:</p>
<pre><code>array([[1, 1, 1],
[2, 2, 2],
... | <python><numpy><reshape> | 2023-05-18 22:48:26 | 2 | 3,838 | imbrizi |
76,284,869 | 1,282,160 | Pytest: how to do snapshot tests for Pandas DataFrame while failed | <p>I have two data frames:</p>
<ul>
<li><code>df1</code>: it originated from a csv file, and has been cleaned by drop unwanted data.</li>
<li><code>df2</code>: it was a validated data frame from the previous success results. We save it into a file and load it back when testing.</li>
</ul>
<p>Now we write a test:</p>
<p... | <python><pandas><pytest><snapshot> | 2023-05-18 22:29:53 | 1 | 3,407 | Xaree Lee |
76,284,748 | 19,410,411 | In which format should I send the date data? | <p>So I have a <strong>Django</strong> <strong>Flutter</strong> setup where I run an app that gets data from the a rest api server on my pc.</p>
<p>I created a serilizer for creating users in <strong>Django</strong>, here is the code:</p>
<pre class="lang-py prettyprint-override"><code>class CreateUserSerializer(serial... | <python><django><flutter><dart> | 2023-05-18 22:01:07 | 1 | 525 | Mikelenjilo |
76,284,724 | 1,864,162 | Iterating over Dataframes - revisited? | <p>I have a dataframe of about 500.000 rows. Contains long, lat,, altitude, datetime (and a LOT more data) of aircraft radar data.</p>
<p>To calculate 'propensity' (a dimensionsless number based on closest point of approach [cpa] theory) I do the following:</p>
<ol>
<li>take a chunk of rows within a certain time window... | <python><pandas><combinations><nested-loops> | 2023-05-18 21:56:22 | 1 | 303 | Job BrΓΌggen |
76,284,578 | 19,369,393 | Is there a standard way to create a "view" of a list in python with an element excluded? | <p>Let's say I have a huge list and a function that expects a list as an argument. This function does not modify the list in any way.
I want to pass this list to the function, but with an element excluded.
Removing the element would require me to copy the entire list without the element I want to exclude, which is obvi... | <python><list> | 2023-05-18 21:22:18 | 0 | 365 | g00dds |
76,284,496 | 13,877,993 | Enabling API Key Auth in FastAPI for all endpoints except / and a healthcheck endpoint? | <p>I want to implement basic api key auth for all endpoints of my FastAPI app except for <code>/</code> and <code>/health</code>.</p>
<p>I was going to do it using middleware, e.g.</p>
<pre><code>@app.middleware("http")
async def validate_api_key(request, call_next):
if is_production():
api_key = ... | <python><authentication><fastapi> | 2023-05-18 21:07:18 | 1 | 1,610 | fooiey |
76,284,412 | 15,295,149 | How can I stream a response from LangChain's OpenAI using Flask API? | <p>I am using Python Flask app for chat over data. In the console I am getting streamable response directly from the OpenAI since I can enable streming with a flag <code>streaming=True</code>.</p>
<p>The problem is, that I can't "forward" the stream or "show" the strem than in my API call.</p>
<p>Co... | <python><flask><openai-api><langchain> | 2023-05-18 20:53:03 | 2 | 746 | devZ |
76,284,376 | 7,437,143 | How to format dash datatable cell using HTML code in cell string? | <h2>MWE</h2>
<p>Suppose one has:</p>
<pre class="lang-py prettyprint-override"><code>from dash import Dash, dash_table
import pandas as pd
from collections import OrderedDict
data = OrderedDict(
[
("Name", ["a", "b", "c"]),
("Region", [ "Toront... | <python><html><plotly-dash> | 2023-05-18 20:46:50 | 1 | 2,887 | a.t. |
76,284,294 | 3,853,504 | Why is seaborn objects breaking on basic data? | <p>I am a native R user but need to use Python in a new job. Seaborn objects seems to match up with <code>ggplot</code> much more closely (I know about <code>plotnine</code>; let's ignore it for now).</p>
<p>Unfortunately, it is not working and I cannot find help on the error. The code below is as basic as it gets, and... | <python><seaborn><seaborn-objects> | 2023-05-18 20:33:24 | 0 | 935 | jpm_phd |
76,284,275 | 4,422,095 | Vanishing data in PySpark: How to get it to stop vanishing? | <p>I'm having a problem with my PySpark script. My task is basically</p>
<ol>
<li>Import data into PySpark from mySQL database.</li>
<li>Do some transformations</li>
<li>Write the transformed data back to the MySQL database</li>
</ol>
<p>I can't show you the full code but I can show you an outline of what it looks like... | <python><mysql><apache-spark><pyspark> | 2023-05-18 20:29:59 | 1 | 2,244 | Stan Shunpike |
76,284,273 | 3,858,193 | Sagemaker Sklearn Transformation Jobs not able to process parquet file | <p>I have a trained model built using sklearn container (<code>framework_version="0.23-1"</code>).
While running batchg transform job using parquet file I am getting below error:</p>
<pre><code> File "transform_job.py", line 47, in <module>
content_type='application/x-parquet')
return ... | <python><machine-learning><amazon-sagemaker> | 2023-05-18 20:29:42 | 1 | 1,558 | user3858193 |
76,284,095 | 6,912,830 | SIGUSR1 signal mysteriously fails with `tar`, kills process instead of reporting progress | <p>I'm executing a <code>tar</code> process with the <code>subprocess</code> module and I discovered the ability to use signals to <a href="https://www.gnu.org/software/tar/manual/html_section/verbose.html" rel="nofollow noreferrer">get progress information out of it</a> (send to stderr).</p>
<pre class="lang-bash pret... | <python><subprocess><signals><tar> | 2023-05-18 20:01:11 | 1 | 759 | Xevion |
76,284,094 | 979,242 | How to parse a string to access a python dict | <p>This is my python dict:</p>
<pre><code>my_dict={
"key":{
"outbound_email_detail":{
"from":"value"
}
}
}
</code></pre>
<p>Here is my input String :</p>
<pre><code>input="key#outbound_email_detail#from"
</code></pre>
<p>How could I parse my ... | <python> | 2023-05-18 20:01:05 | 2 | 505 | PiaklA |
76,284,080 | 4,709,300 | Is it possible to create a Substate type in Python that removes the first section of a Literal type? | <p>I have a Python <code>Literal</code> type that includes various period separated strings. I would like to also have a <code>Literal</code> type that includes the same strings but without the first period-delimited section. I could manually do this, but I don't want to do that every time I need to remove a section.</... | <python><types><mypy><pylance> | 2023-05-18 19:59:04 | 0 | 5,105 | andria_girl |
76,284,035 | 14,244,437 | Two backends, one DB - what's the best way to integrate data with Django? | <p>Currently I'm working in a project that will add a functionality to a legacy application.</p>
<p>For a number of reasons that are completely out of my control, this functionality will resides in a different backend.</p>
<p>Not only that, each backend is actually in a different programming language (legacy is ruby, u... | <python><ruby-on-rails><django><ruby><integration> | 2023-05-18 19:51:23 | 1 | 481 | andrepz |
76,284,030 | 8,942,319 | format function name as string and then call it? fn_call = f"static_{dynamic}" then fn_call() | <p>I have a series of functions that do some data cleaning.</p>
<pre><code>def clean_field_1(field_1):
return field_1
</code></pre>
<p>for example.</p>
<p>When looping through a dict of fields, field_1 may not be there. But if it is I'd like to call <code>clean_field_1()</code>.</p>
<pre><code>for field in dict_ob... | <python><python-3.x><string><function> | 2023-05-18 19:50:26 | 0 | 913 | sam |
76,283,978 | 9,386,819 | Why doesn't seaborn barplot retain the order of a groupby index? | <p>I'm trying to create a seaborn barplot of a groupby object. Here is an example:</p>
<pre><code>data = {'ID':[1, 2, 3, 1, 2, 3],
'value':[10, 20, 30, 100, 200, 300],
'other': ['a', 'b', 'c', 'd', 'e','f']
}
data = pd.DataFrame(data)
</code></pre>
<p>I want to use <code>groupby()</code> to gr... | <python><pandas><group-by><seaborn><bar-chart> | 2023-05-18 19:41:52 | 2 | 414 | NaiveBae |
76,283,974 | 4,268,602 | Using scpi commands on python with mac Ventura - is this possible? | <p>I am trying to use easy_scpi.</p>
<p>However, this says that it requires a backend. I am not able to find a backend compatible with Ventura 13.3.1.</p>
<p>Is it not possible to use this library on Ventura 13.3.1 for this reason? Is there a workaround or an alternative backend to NI-VISA?</p>
| <python><pyvisa> | 2023-05-18 19:40:42 | 1 | 4,156 | Daniel Paczuski Bak |
76,283,963 | 5,446,972 | How Can I Make Kate Properly Indent Snippets with Multiple Lines | <p>I enjoy using Kate snippets for quick Python scripts, but I'm having a hard time getting them to properly inherit or detect indentation levels after the first line. Consider the following snippet:</p>
<pre class="lang-py prettyprint-override"><code>print("line1")
print("line2")
</code></pre>
<p>... | <python><indentation><code-snippets><auto-indent><kate> | 2023-05-18 19:39:01 | 0 | 490 | WesH |
76,283,962 | 13,630,719 | How to make multiple APIs in parallel using Python Django? | <p>Currently, I have 2 API enpoints. The first API enpoint takes in a file as input and performs some calculations that take up to 30 minutes. The second API endpoint is a healthcheck that returns the status of the first API. Possible healthchecks are 15% complete, 25% complete, 50% complete, 75% complete, 90% complete... | <python><django><multithreading><asynchronous> | 2023-05-18 19:38:56 | 1 | 1,342 | ENV |
76,283,892 | 2,301,970 | How to add an information display button to the interactive plot toolbar | <p>The matplotlib plot toolbar has some support for <a href="https://matplotlib.org/stable/gallery/user_interfaces/toolmanager_sgskip.html" rel="nofollow noreferrer">customization</a>. This example is provided on the official documentation:</p>
<pre><code>import matplotlib.pyplot as plt
from matplotlib.backend_tools im... | <python><matplotlib><user-interface><toolbar> | 2023-05-18 19:29:57 | 1 | 693 | Delosari |
76,283,757 | 6,828,329 | Manipulating image/gif files and their .bin or .dat representations, and then converting them back to image/gif representation | <p>I'm trying to play around with Python and image/gif files and their .bin or .dat representations. For instance, I want to take a PNG file, convert it to its .bin or .dat file (its binary version), and then do something to manipulate the image, such as turning it from greyscale to black-and-white, or taking a black-a... | <python><image><png><gif><bin> | 2023-05-18 19:05:14 | 1 | 2,406 | The Pointer |
76,283,754 | 8,365,573 | I need help to split parquet file up to a maximum of 1000 lines with boto3 | <p>I have a function to upload a parquet file in s3 using boto3. I need to split the files with a maximum of 1000 lines and upload them.</p>
<pre><code>for i, file_data in enumerate(data):
file_path = f'{path}{i:06}.{file_format.name}'
save_to_s3(bucket, file_path, file_data, content_type=file_format.value, **k... | <python><amazon-web-services><amazon-s3><boto3> | 2023-05-18 19:04:47 | 1 | 522 | Leticia Fatima |
76,283,682 | 228,177 | PYTHONPATH from launch.json not visible in Python script (VS Code) | <p>I would like to import methods from a directory one level above my current working directory. One way to do this is to manually append the directory to <code>sys.path</code>. I found a better solution for VSCode <a href="https://k0nze.dev/posts/python-relative-imports-vscode/" rel="nofollow noreferrer">on this post<... | <python><visual-studio-code><import><environment-variables><pythonpath> | 2023-05-18 18:52:05 | 3 | 1,320 | vpk |
76,283,397 | 3,324,136 | How can I use the 'afade' parameter in ffmpeg-python without getting an 'option not found' error? | <p>I am using the ffmpeg library with python to add subtitles and a video as an overlay to a background still image. This code is working fine, but I want to use the <code>afade</code> parameter. The code without the <code>afade</code> parameter works fine. However, when I add the <code>afade</code> code in, I am ge... | <python><ffmpeg-python> | 2023-05-18 18:05:22 | 0 | 417 | user3324136 |
76,283,363 | 8,869,570 | How to make groupby get rid of the column you're groupbying | <p>Is there an innate way to drop the column you're grouping by when using the <code>groupby</code> operation?</p>
<p>By that, I mean, suppose you have a dataframe <code>df</code> with columns <code>dt</code> and <code>values</code>, and you run <code>groups = df.groupby("dt")</code>.</p>
<p>When iterating ov... | <python><pandas> | 2023-05-18 17:59:15 | 1 | 2,328 | 24n8 |
76,283,296 | 851,699 | Tkinter - memory leak arising from "Frame.pack" | <p>I have a TKinter application (running on MacOS, M1 laptop) that allows you to select a video or livestream, and play it in an adjacent frame.</p>
<p>When it's a livestream, there is no need for "video progress" slider, so I hide it.</p>
<p>Here is the critical code:</p>
<pre><code>class DetectionVideoPlaye... | <python><tkinter><memory-leaks> | 2023-05-18 17:50:57 | 1 | 13,753 | Peter |
76,283,254 | 8,869,570 | Inheriting from an abstract class and defining an abstract method to be an existing child class's method | <p>Suppose you have an ABC <code>base</code> with a method <code>compute</code>, and 2 child classes <code>child1, child2</code> with <code>compute</code> defined. <code>child1, child2</code> only inherit from <code>base</code>.</p>
<p>Then suppose you another another class <code>related</code> that inherits from <code... | <python><inheritance> | 2023-05-18 17:44:52 | 2 | 2,328 | 24n8 |
76,283,207 | 8,079,611 | Altair - Plot Number of Stars/Rating (starting from bar or point graph) | <p>I am plotting a bar graph using Altair. However, instead of having the bar, I was hoping to have the number of stars (i.e. the symbol). In my case, this data is the rating (from 1 start up to 5 stars) of, for example, a movie. Checking their documentation, I see a similar idea being used <a href="https://altair-viz.... | <python><bar-chart><altair> | 2023-05-18 17:39:21 | 1 | 592 | FFLS |
76,283,041 | 9,265,735 | gspread_formatting not changing cell type to percentage in google doc | <p>I'm able to run <code>format_cell_range()</code> successfully to change a cell from normal to bold and back again, but I'm unable to change it to percent.</p>
<pre class="lang-py prettyprint-override"><code>from gspread_formatting import format_cell_range, CellFormat, NumberFormat
worksheet = <worksheet success... | <python><google-sheets><google-api-python-client><gspread> | 2023-05-18 17:13:30 | 1 | 612 | glitchwizard |
76,282,918 | 504,773 | mkdocstrings not finding module | <p>I've hit a bit of a wall with the mkdocstring plugin as it does not seem to load modules as I would have expected.</p>
<p>My folder structure is as such:</p>
<pre><code>docs/
api.md
src/
module/
somemodule.py
</code></pre>
<p>The api.md file looks like this:</p>
<pre><code># API Documentation
::: module.som... | <python><mkdocs><mkdocstrings> | 2023-05-18 16:57:54 | 4 | 1,655 | renderbox |
76,282,914 | 5,817,109 | Dynamically Create the Expression of a List Comprehension | <p>I have a bunch of AWS Lambda functions in Python that retrieve data from an API and write it to CSV. After I retrieve the data, I extract the relevant fields I want using list comprehensions, something like:</p>
<pre><code>records = requests.get(url,headers,params)
values = [(x['id'],x['name'],x['address']) for x in... | <python> | 2023-05-18 16:56:53 | 3 | 305 | Moneer81 |
76,282,611 | 10,866,873 | Tkinter: complex reassignment of variables from Event | <p>This is a complicated question based on the solution of cloning widgets from <a href="https://stackoverflow.com/questions/46505982/is-there-a-way-to-clone-a-tkinter-widget/69538200#69538200">this answer</a>.</p>
<p>Basis:</p>
<p>When cloning widgets using this method any functions that are reliant on the references ... | <python><tkinter> | 2023-05-18 16:14:12 | 0 | 426 | Scott Paterson |
76,282,553 | 3,878,377 | Panda says my Dataframe column type is object however analysis shows that it is float | <p>I have a Panda dataframe such as this:</p>
<pre><code>col value
0 1.28
1 4
2 9.34
3 13
4 15
5 23
6 35
</code></pre>
<p>When I do <code>df.info()</code> I get that value is <code>object</code> however when I test this as follows:</p>
<pre><code>... | <python><pandas><dataframe><types> | 2023-05-18 16:05:33 | 0 | 1,013 | user59419 |
76,282,520 | 1,441,592 | KeyError when filter pandas dataframe by column with particular key:value pair | <p>My df looks like the following</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>col1</th>
<th>col_x</th>
</tr>
</thead>
<tbody>
<tr>
<td>...</td>
<td>{"key_x":"value1"}</td>
</tr>
<tr>
<td>...</td>
<td>None</td>
</tr>
<tr>
<td>...</td>
<td>{"key_x":"valu... | <python><pandas><dataframe><dictionary><pandas-loc> | 2023-05-18 16:01:17 | 2 | 3,341 | Paul Serikov |
76,282,454 | 253,924 | Pandas DataFrame groupby and aggregate counting on condition | <p>I have started playing with Data Analysis and all the related tools: Pandas, Numpy, Jupyter etc...</p>
<p>The task I am working on is simple, and I could do easily with regular python. However I am more interested in exploring Pandas, and I am looking therefore for a Pandas solution.</p>
<p>I have this simple Pandas... | <python><pandas><dataframe> | 2023-05-18 15:52:53 | 1 | 9,857 | Leonardo |
76,282,434 | 1,011,253 | writing tasks/operators without using them in DAG | <p>We are running Airflow in production and we have existing DAG that looks like:</p>
<pre class="lang-py prettyprint-override"><code>import os
from datetime import datetime
from airflow import DAG
from airflow.operators.empty import EmptyOperator
with DAG(
"partial",
description="A simple par... | <python><airflow> | 2023-05-18 15:50:00 | 1 | 11,527 | ItayB |
76,282,382 | 5,306,861 | Equivalent of Python scipy.signal.correlate in C# or C++ | <p>I have code in Python that searches for matching a small audio file within a large audio file. For this purpose it uses the <code>scipy.signal.correlate</code> function, I searched for an equivalent function in C# or C++, but I did not find it.</p>
<p>I can translate all the code to C# except for the <code>scipy.sig... | <python><c#><c++><fft><correlation> | 2023-05-18 15:43:01 | 0 | 1,839 | codeDom |
76,282,378 | 3,259,258 | Python RSA Signing not agreeing with Ruby or Bash | <p>I have 3 different scripts that should be basically identical logic wise, yet when run the RSA sig generated by python does not agree with the RSA sigs of the other two implementations. What am I doing differently in Python?</p>
<p>Ruby</p>
<pre><code>#!/usr/bin/ruby
# ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc... | <python><openssl><rsa> | 2023-05-18 15:42:29 | 1 | 823 | CaffeineAddiction |
76,282,370 | 5,924,264 | How to return the value from a 2 dicts when the key is guaranteed to exist in only one of the dicts? | <p>Suppose you have 2 dicts <code>d1, d2</code> and you want to query a key <code>k</code>. <code>k</code> is guaranteed to exist in exactly one of the dicts. Is there a way to return the value associated with <code>k</code> from <code>d1, d2</code> without using if statements?</p>
<p>Currently I use if statements:</p>... | <python><dictionary> | 2023-05-18 15:41:31 | 2 | 2,502 | roulette01 |
76,282,068 | 7,545,840 | Loop over a spark df and add new columns | <p>I have some data like below:</p>
<pre><code>
df = spark.createDataFrame(
[
("one two", "foo foo"),
("one two", "bar bar"),
],
["label1", "label2"]
)
df.show()
</code></pre>
<p>and I'm using <code>regex_replace()</code> to a... | <python><apache-spark><pyspark><apache-spark-sql> | 2023-05-18 15:04:28 | 2 | 493 | Mrmoleje |
76,282,066 | 4,019,495 | Pydantic: is there a way to specify predefined validation behavior on a field of a Model? | <p>I would like the behavior of</p>
<pre><code>class TestModel(BaseModel):
field1: StrictStr # we want to validate that this has length 5
@validator('field1', always=True)
def check_field1_length_5(cls, field1):
if len(field1) != 5:
raise ValueError(f'{field1=} does not have length... | <python><pydantic> | 2023-05-18 15:04:04 | 1 | 835 | extremeaxe5 |
76,282,003 | 1,194,864 | Binary image classifier in pytorch progress bar and way to check if the training was valid | <p>I would like to build and train a binary classifier in <code>PyTorch</code> that reads images from the path process them and trains a classifier using their labels. My images can be found in the following folder:</p>
<pre><code>-data
- class_1_folder
- class_2_folder
</code></pre>
<p>Hence, to read them in tenso... | <python><pytorch> | 2023-05-18 14:56:24 | 2 | 5,452 | Jose Ramon |
76,281,933 | 2,697,895 | How to check the drive power state? | <p>I'm trying to read the drive power state (active/standby/sleep) using Python under Linux/Raspberry Pi.</p>
<p>I found <a href="https://stackoverflow.com/a/65995054/2697895">here this answer</a> and it says that I can do it using <code>udisks2 dbus</code>:</p>
<pre><code>you can get around this by invoking a dbus met... | <python><linux><raspberry-pi><dbus><hard-drive> | 2023-05-18 14:47:05 | 1 | 3,182 | Marus Gradinaru |
76,281,639 | 4,002,204 | Python - When saving text to a file, it adds redundant characters | <p>In my Linux server, I have a Python code that tracks an SSH connection, copies every character the user enters or is generated by the system, and saves it in a file.</p>
<p>This is the function that is called to store new text:</p>
<pre><code>async def writeToFile(filename, data):
try:
path = f'{RECORDINGS_PATH}... | <python><linux><ssh> | 2023-05-18 14:10:09 | 1 | 1,106 | Zag Gol |
76,281,636 | 7,887,590 | How can I use Pygame to display the URL of a request captured by mitmproxy? | <p>I am using mitmproxy for debugging purposes and I want to display the captured request URL in almost real-time through a GUI framework. The following is my add-on script:</p>
<pre class="lang-py prettyprint-override"><code>import threading
import pygame
from mitmproxy import http
# initialize pygame
pygame.init()
... | <python><pygame><mitmproxy> | 2023-05-18 14:09:10 | 0 | 470 | mingchau |
76,281,633 | 4,865,723 | Migrate a QKeySequence from PyQt5 to PyQt6 | <p>I'm in the middle of migrating a quit simple GUI application from <code>PyQt5</code> to <code>PyQt6</code>. I'm stuck on the following problem about combining Keys and Modifiers.</p>
<p>The original <code>PyQt5</code> code looked like this</p>
<pre><code>self.button.setShortcuts(QKeySequence(Qt.CTRL + Qt.Key_S))
</c... | <python><pyqt5><migration><pyqt6> | 2023-05-18 14:09:05 | 1 | 12,450 | buhtz |
76,281,431 | 197,726 | Testing AsyncIO MongoDB function (Asyncio Motor Driver) | <p>I am pretty new to AsyncIO, and looking for a bit of help. I have a basic class that runs an aggregation pipeline, which works perfectly in production:</p>
<pre class="lang-py prettyprint-override"><code>class BasePipeline2:
client: motor.AsyncIOMotorClient
db: motor.AsyncIOMotorDatabase
collection: moto... | <python><mongodb><testing><pytest><motor-asyncio> | 2023-05-18 13:43:43 | 1 | 1,482 | garyj |
76,281,424 | 5,924,264 | How to query from a dataframe using caching? | <p>I have a dataframe <code>df</code>. This dataframe consists of columns <code>id</code>, <code>time</code> and <code>quantity</code>. I have to make repeated queries to this <code>df</code> based on <code>time</code>, and the query should return the <code>id-quantity</code> pairs corresponding to the query time.</p>
... | <python><pandas><dataframe> | 2023-05-18 13:42:43 | 1 | 2,502 | roulette01 |
76,281,299 | 12,435,792 | convert dataframe to dictionary with multiple values | <p>I have a dataframe with values as:</p>
<pre><code> Agent Name Team Available for production Product Type Air/Non-Air PCC key
0 Anjani Aggarwal APAC True Fresh AIR 0R0B 0R0B_AIR_Fresh
1 Anjani Aggarwal APAC True Fresh AIR 4H9B 4H9B_AIR_Fresh
2 Anjani Aggarwal APAC True F... | <python><dataframe><dictionary> | 2023-05-18 13:26:39 | 1 | 331 | Soumya Pandey |
76,281,217 | 559,827 | How to monitor the total size of output produced by a subprocess in real time? | <p>The code below is a toy example of the actual situation I am dealing with<sup>1</sup>. (Warning: this code will loop forever.)</p>
<pre><code>import subprocess
import uuid
class CountingWriter:
def __init__(self, filepath):
self.file = open(filepath, mode='wb')
self.counter = 0
def __enter_... | <python><subprocess><ipc><io-buffering> | 2023-05-18 13:16:37 | 1 | 35,691 | kjo |
76,280,682 | 13,589,242 | simpy Resource attributes | <p>Is there a way we can add attributes to simpy Resource objects, and use their values after simulation for further analysis?</p>
<p>For example, in a call centre, I have two agents. I'll declare them as <code>agents = simpy.Resource(env, capacity=2)</code>. I'll call them as <code> with agents.request() as req:</code... | <python><simulation><simpy> | 2023-05-18 12:04:19 | 1 | 572 | mufassir |
76,280,610 | 6,357,916 | Accessing browser IP address in django | <p>I want to log an IP address from where particular url is accessed. I am implementing this functionality in django middleware. I tried obtaining IP address using method given in <a href="https://stackoverflow.com/a/4581997/6357916">this answer</a>:</p>
<pre><code>def get_client_ip(request):
x_forwarded_for = requ... | <python><django><django-rest-framework> | 2023-05-18 11:56:11 | 1 | 3,029 | MsA |
76,280,539 | 813,946 | Getting column names from a SELECT | <p>I wanted to get the names of the created columns from an SQL SELECT query. (My final goal is to create the INSERT ... SELECT from a complex SELECT query.)</p>
<p>I started with the <a href="https://pypi.org/project/sqlparse/" rel="nofollow noreferrer">sqlparse</a> package, but I don't mind to use other one. So far I... | <python><sql><parsing> | 2023-05-18 11:46:20 | 1 | 1,982 | Arpad Horvath -- Π‘Π»Π°Π²Π° Π£ΠΊΡΠ°ΡΠ½Ρ |
76,280,511 | 1,477,418 | Pyspark group rows with sequential numbers ( with duplicates) | <p>I have data which has a sequential time slot of customers arrivals</p>
<pre class="lang-py prettyprint-override"><code>df = spark.createDataFrame(
[(0, 'A'),
(1, 'B'),
(1, 'C'),
(5, 'D'),
(8, 'A'),
(9, 'F'),
(20, 'T'),
(20, 'S'),
(21, 'C')],
['time_slot', 'customer'])
... | <python><apache-spark><pyspark> | 2023-05-18 11:42:59 | 1 | 1,880 | Islam Elbanna |
76,280,474 | 2,575,155 | how to remove double quotes from null in dataframe | <p>I'm trying to replace blank with null and converting the dataframe and writing it as parquet file using awswrangler. This parquet loads in Snowflake table as JSON file. In Snowflake table null is coming with double quotes "null" instead json object null(without double quotes). It will be simple thing I'm m... | <python> | 2023-05-18 11:39:01 | 1 | 736 | marjun |
76,280,434 | 10,033,921 | python docker image main.py not found | <p>I am trying to create python image and run the container as pod, referring to the steps</p>
<p>The python file main.py is as follows</p>
<pre><code>from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello from Python!"
if __name__ == "__main__":
... | <python><kubernetes> | 2023-05-18 11:33:53 | 2 | 776 | Sudhir Jangam |
76,280,394 | 2,987,552 | dynamically constructing client side content from server in flask | <p>I am trying to setup client side content from server in a flask app. Here is my code</p>
<pre><code># Importing flask module in the project is mandatory
# An object of Flask class is our WSGI application.
from flask import Flask, send_file, Response, render_template, redirect, url_for, request
import random
import t... | <javascript><python><html><flask><client-server> | 2023-05-18 11:28:16 | 1 | 598 | Sameer Mahajan |
76,280,371 | 15,239,717 | How Can I add Extra Login Field to Django App and use session to identify User | <p>I am working a Django Real Estate Management website where I want users to choice their Categories (Landlord, Agent, Prospect) upon registration and login. For the Registration I did it but for the User login I am unable to add extra user login field for successful login.
Django Form Code:</p>
<pre><code>USER_TYPE_C... | <python><django> | 2023-05-18 11:24:50 | 2 | 323 | apollos |
76,280,112 | 1,194,864 | Read images from folder to tensors in torch and run a binary classifier | <p>I would like to load images from a local directory in Torch in order to train a binary classifier. My directory looks as follows:</p>
<pre><code>-data
- class_1_folder
- class_2_folder
</code></pre>
<p>My folders <code>class_1</code> and <code>class_2</code> contain the .jpg images for each class. My images do... | <python><pytorch><classification> | 2023-05-18 10:56:12 | 1 | 5,452 | Jose Ramon |
76,280,108 | 6,357,916 | Accessing logged in user name inside django middleware | <p>I am trying to access <code>request.user.username</code> inside following django middleware:</p>
<pre><code>class MyMiddleware():
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
user_id = request.us... | <python><django><django-rest-framework><django-views><django-middleware> | 2023-05-18 10:56:04 | 1 | 3,029 | MsA |
76,279,973 | 11,471,439 | Problems with interactive kernel in vscode conda environment | <p>I am having problems with using interactive jupyter kernels within vscode when in a conda environment.</p>
<p>I create a new conda environment, activate it and install jupyter. Then try Ctrl+Shift+p and "Jupyter: Create interactive window" in command palette. Initially everything works fine. However, later... | <python><visual-studio-code><jupyter><conda> | 2023-05-18 10:39:56 | 1 | 324 | goblinshark |
76,279,929 | 4,473,615 | Image to PDF using pdfkit | <p>I am facing issues while adding image to PDF.</p>
<pre><code>result = """
<h1>Image</h1>
<img src="static/images/image.png">
"""
pdfkit.from_string(result, "static/images/foo.pdf")
</code></pre>
<p>Error:</p>
<pre><code>raise IOError('... | <python><pdfkit> | 2023-05-18 10:34:47 | 1 | 5,241 | Jim Macaulay |
76,279,889 | 8,930,395 | How to use Background Tasks inside a function that is called by a FastAPI endpoint? | <p>I have the below FastAPI endpoint:</p>
<pre><code>@app.post("/abcd", response_model=abcdResponseModel)
async def getServerDetails(IncomingData: serverModel) -> abcdResponseModel:
"""
Get Server Details
"""
result = ServerDetails(IncomingData.dict())
retu... | <python><fastapi><background-task><starlette> | 2023-05-18 10:29:31 | 1 | 4,606 | LOrD_ARaGOrN |
76,279,830 | 5,070,879 | Snowflake Python Worksheet - main handler with additional arguments | <p>The goal is to develop and Deploy Snowpark code inside Python Worksheet code that could take user input.</p>
<p>If we try to provide additional user-defined arguments we get:</p>
<pre><code>import snowflake.snowpark as snowpark
def main(session: snowpark.Session, param):
df = session.table('snowflake_sample_dat... | <python><snowflake-cloud-data-platform> | 2023-05-18 10:21:13 | 1 | 180,782 | Lukasz Szozda |
76,279,739 | 2,682,273 | _NoDefault.no_default in pandas library | <p>I have recently seen this in the panda's documentation. Can someone explain this and how can I access the value?</p>
<p><a href="https://i.sstatic.net/MLcBU.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MLcBU.png" alt="enter image description here" /></a></p>
| <python><pandas> | 2023-05-18 10:08:28 | 1 | 1,624 | TPArrow |
76,279,329 | 6,014,330 | Checking if pinned package in requirements.txt is latest or not | <p>Consider you have the following <code>requirements.txt</code>:</p>
<pre><code>pydantic==1.10.7
mypy==1.2.0
pylint>=2.17.3
</code></pre>
<p>when installing this requirements, pydantic and mypy will install the versions they are pinned to and pylint will install <code>2.17.4</code> instead of <code>2.17.3</code> be... | <python><pip> | 2023-05-18 09:12:19 | 1 | 2,570 | Keegan Cowle |
76,279,304 | 1,191,545 | Configure Pylance to stop prefixing project directory on import auto-complete | <p>When working in a Git repository where my Python/Django source is in a subfolder <code>{$workspace}/app</code>, as seen below.</p>
<ul>
<li>project/
<ul>
<li><em>.vscode/</em></li>
<li><em>.git/</em></li>
<li><strong>app/</strong> -- the app source code (not a Python module)</li>
<li><em>docs/</em></li>
<li><em>.git... | <python><visual-studio-code><pylance> | 2023-05-18 09:09:12 | 1 | 1,932 | Brylie Christopher Oxley |
76,279,225 | 13,328,553 | Unit tests for FastAPI - how to use breakpoints? | <p>I have a code base that is using FastAPI. The unit tests use the <code>TestClient</code> as recommended in the <a href="https://fastapi.tiangolo.com/tutorial/testing/" rel="noreferrer">FastAPI docs</a>.</p>
<p>When debugging with VS Code, I add breakpoints to the code of my routes. However the debugger does not stop... | <python><visual-studio-code><pytest><fastapi> | 2023-05-18 08:58:16 | 2 | 464 | SoftwareThings |
76,278,747 | 11,725,056 | Out of 4 methods for Document Question Answering in LangChain, which one if the fastest and why (ignoring the LLM model used)? | <p><strong>NOTE:</strong>: My <em>reference document</em> data changes periodically so if I use Embedding Vector space method, I have to Modify the embedding, say once a day</p>
<p>I want to know these factors so that I can design my system to compensate my <em>reference document data</em> generation latency with creat... | <python><openai-api><gpt-3><langchain> | 2023-05-18 07:45:43 | 2 | 4,292 | Deshwal |
76,278,737 | 6,828,329 | Searching the current working directory and retrieving all of the files in a list in ascending order of the number at the end of the file name | <p>I have the following list of files in my current working directory:</p>
<pre><code>Java_question_1.txt
Java_question_2.txt
Java_question_3.txt
</code></pre>
<p>and so on ...</p>
<p>I want to search the current working directory and retrieve all of these file objects / names in a list in ascending order of the num... | <python> | 2023-05-18 07:44:43 | 1 | 2,406 | The Pointer |
76,278,620 | 9,500,955 | Create the array of integer with consecutive number in PySpark | <p>I have a dataframe like this one:</p>
<pre><code>+---+-----+------------+
| ID| pos| value|
+---+-----+------------+
| A1| 0| ABC|
| A1| 1| BCD|
| A1| 2| CDF|
| A1| 5| ABC|
| A1| 8| FGR|
| A1| 9| EFD|
| A2| 0| L_1|
| A2| 1| ... | <python><pyspark> | 2023-05-18 07:24:53 | 1 | 1,974 | huy |
76,278,583 | 5,686,015 | Querying snowflake table with sqlalchemy adds redundant database name prefix to table names | <p>I'm using sqlalchemy to query tables in a snowflake db.The sql queries are constructed through code. When it runs something like <code>conn.execute('SELECT COUNT(*) FROM dbname.purchase')</code> it throws the following error:</p>
<pre><code>ProgrammingError: (snowflake.connector.errors.ProgrammingError) 002003 (0200... | <python><sqlalchemy><snowflake-cloud-data-platform> | 2023-05-18 07:19:21 | 1 | 1,874 | Judy T Raj |
76,278,578 | 8,236,050 | selenium webdriver connection problems (not connected to DevTools) | <p>I am running a Selenium webdriver program that needs a lot of time to complete. My problem is that, for some reason, whenever I run this script as a headless browser, I end up having issues. For example, if I use Firefox driver I get this after a short time:</p>
<pre><code>urllib3.exceptions.MaxRetryError: HTTPConne... | <python><selenium-webdriver><selenium-chromedriver><undetected-chromedriver> | 2023-05-18 07:18:49 | 0 | 513 | pepito |
76,278,577 | 6,394,055 | 404 Error: "The empty path didnβt match any of these" | <p>I am very new in Django & trying to run my first project. But I am stuck with this error:</p>
<blockquote>
<p>The empty path didnβt match any of these.</p>
</blockquote>
<p>In my app urls I have the following code:</p>
<pre><code>from django.urls import path
from . import views
urlpatterns=[
path('members/',v... | <python><django><django-views><django-urls> | 2023-05-18 07:18:47 | 2 | 709 | ssajid.ru |
76,278,575 | 3,257,218 | Mock Dependency class or class method per test case wise but not globally in FastAPI | <p>I have my router method in FastAPI which depends on some JWT authentication mechanism. I want to mock my authentication to bypass the auth to test my API easily. To mock, I am using <a href="https://pypi.org/project/pytest-fastapi-deps/" rel="nofollow noreferrer">pytest-fastapi-deps 0.2.3</a>
. Here is my router</p>... | <python><pytest><fastapi> | 2023-05-18 07:18:07 | 1 | 337 | Arif |
76,278,545 | 438,755 | python loop a list of class objects | <p>I have class:</p>
<pre><code>class Services:
def __init__(self,a1,b1):
self.a1 = a1
self.b1 = b1
def do_something(self):
print('hello')
obj1 = Services('aaa','bbb')
obj2 = Services('aaa1','bbb1')
objlist =['obj1','obj2']
for i in objlist:
... | <python> | 2023-05-18 07:14:20 | 1 | 745 | miojamo |
76,278,439 | 6,293,886 | refined selection of log-level of modules in Hydra | <p>I'm trying to debug a <code>Hydra</code> application, setting <code>hydra.verbose=true</code> will set the logging level of all modules to <code>Debug</code>.<br />
Is there a way to get rid of some of the modules debug messages that produce lengthy and non-informative Debug logs?<br />
I can imagine a syntax like t... | <python><logging><fb-hydra> | 2023-05-18 06:55:46 | 1 | 1,386 | itamar kanter |
76,278,377 | 3,878,377 | How to add a new dataframe column to an increasing integer for every group in dataframe | <p>Assume I have a following dataframe:</p>
<pre><code>date group value
2022-11-01. 1 4
2022-11-02. 1 12
2022-11-03. 1 14
2022-11-04. 1 25
2021-11-01. 2 9
2021-11-02. 2 7
2019-10-01. 3 ... | <python><pandas><group-by> | 2023-05-18 06:46:06 | 1 | 1,013 | user59419 |
76,278,237 | 855,059 | PyMongo alternatives for Google App Engine | <p>I had wrote a web site which accesses MongoDB Atlas using PyMongo, and now am trying to move it onto Google App Engine(GAE).</p>
<p>Since GAE allows only single-thread process and PyMongo is multi-threading implementation, I failed to move it naively.</p>
<p>Are there any good alternative packages of PyMongo, which ... | <python><mongodb><google-app-engine> | 2023-05-18 06:22:46 | 1 | 724 | Yuji |
76,278,086 | 264,632 | Is it good practice to add optional arguments to AWS lambda function? | <p>For example, a python AWS lambda, the documented signature is:</p>
<p><code>def handler(event, context):</code></p>
<p>But the following is valid python syntax:</p>
<p><code>def handler(event, context, *args, **kwargs):</code></p>
<p>I've tested this and the lambda does not crashes. (BTW default arguments is also va... | <python><amazon-web-services><aws-lambda><dependency-injection><optional-parameters> | 2023-05-18 05:54:30 | 1 | 11,947 | Javier Novoa C. |
76,277,938 | 10,508,542 | csv.reader escape not working as expected | <p>So I have this line in my CSV file</p>
<pre><code>zeroconf.net,TXT,rockview\032entrance._http._tcp.ietf98,"\"path=/\"",2023-05-14T01:41:55.954Z,""
</code></pre>
<p>and I want to parse it to this</p>
<pre><code>['zeroconf.net', 'TXT', 'rockview\032garage._http._tcp.ietf98', '"path=/... | <python><python-3.x><csv> | 2023-05-18 05:20:57 | 0 | 301 | Thong Nguyen |
76,277,517 | 14,109,040 | Group pandas dataframe and flag corresponding rows where all values from a list exist in a column | <p>I have a dataframe with the following structure:</p>
<pre><code>Group1 Group2 Label
G1 A1 AA
G1 A1 BB
G1 A1 CC
G1 A2 AA
G1 A2 CC
G2 A1 BB
G2 A1 DD
G2 A2 AA
G2 A2 CC
G2 A2 DD
G2 A2 BB
l1 = ['AA','BB','CC','DD']
</code></pre>
<p>I want to gr... | <python><pandas><dataframe> | 2023-05-18 03:21:16 | 3 | 712 | z star |
76,277,473 | 1,942,868 | Update database partially by patch, django rest framework | <p>I have my <code>CustomUser</code> model which extend <code>AbstractUser</code></p>
<pre><code>class CustomUser(AbstractUser):
detail = models.JSONField(default=dict)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
pass
</code></pre>
<p>then ... | <javascript><python><django> | 2023-05-18 03:06:50 | 1 | 12,599 | whitebear |
76,277,328 | 6,824,121 | Can't install tesserocr using pip on buster docker | <p>Here is my Dockerfile:</p>
<pre><code>FROM python:3.11-buster AS app
WORKDIR /srv/app
ENV PYTHONPATH /srv/app
RUN apt update -y && \
apt install -y libegl1 libgl1 libxkbcommon-x11-0 dbus tesseract-ocr liblept5 leptonica-progs libleptonica-dev libtesseract-dev
RUN pip install --upgrade pip
</code></pre... | <python><docker><pip><tesseract><python-tesseract> | 2023-05-18 02:18:31 | 1 | 1,736 | Lenny4 |
76,277,286 | 1,631,414 | How does Kafka store messages offsets on a local computer? | <p>How does Kafka store messages on a local server or laptop?</p>
<p>I'm new to Kafka and just playing around with the tech for now but I'm curious to the answer because I started by looking at the Kafka Quickstart page to just start a Kafka service on my laptop. I sent several test messages and from some code, saw my... | <python><apache-kafka><apache-zookeeper><kafka-python> | 2023-05-18 02:07:22 | 1 | 6,100 | Classified |
76,277,200 | 8,354,181 | Better way to index through list of dictionaries | <p>I have this awful awful code where I am trying to parse through a list of dictionaries which contain a list of dictionaries.</p>
<p>I need to output a list of dictionaries with the id and name like this if the id matches a certain id. Something like this:</p>
<pre><code>[{"id": 123}, {'name': 'bob'}]
</cod... | <python> | 2023-05-18 01:38:54 | 3 | 367 | shxpark |
76,276,576 | 504,877 | Python decorator parameter scope | <p>I've implemented a retry decorator with some parameters:</p>
<pre><code>def retry(max_tries: int = 3, delay_secs: float = 1, backoff: float = 1.5):
print("level 1:", max_tries, delay_secs, backoff)
def decorator(func):
print("level 2:", max_tries, delay_secs, backoff)
@fun... | <python><variables><scope><decorator> | 2023-05-17 22:28:36 | 1 | 765 | Tyn |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.