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 β |
|---|---|---|---|---|---|---|---|---|
78,171,831 | 9,363,441 | Reading of EEG file by mne shows - Channels contain different lowpass filters | <p>I have eeg files from BrainVision and would like to open it to dataset by mne (or any other pip lib) and I'm getting the error:</p>
<pre><code>RuntimeWarning: Channels contain different lowpass filters. Highest (weakest) filter setting (131.00 Hz) will be stored.
raw = mne.io.read_raw_brainvision('S01_base.vhdr', ... | <python><mne-python><eeglab> | 2024-03-16 12:52:32 | 1 | 2,187 | Andrew |
78,171,824 | 10,565,197 | tqdm nested progress bars with multiprocessing | <p>I'm using multiprocessing to do multiple long jobs, and an outer progress bar tracks how many jobs are completed. With an inner progress bar, I want to show the progress of an individual job, and also be able to print out when the inner progress bar completes.</p>
<p><a href="https://imgur.com/a/RqlCyLk" rel="nofoll... | <python><multiprocessing><tqdm> | 2024-03-16 12:50:15 | 2 | 429 | Taw |
78,171,813 | 4,429,265 | Qdrant filteration using nested object fields | <p>I have a data structure on Qdrant that in the payload, I have something like this:</p>
<pre><code>
{
"attributes": [
{
"attribute_value_id": 22003,
"id": 1252,
"key": "Environment",
"value": "... | <python><python-3.x><filtering><qdrant> | 2024-03-16 12:48:04 | 1 | 417 | Vahid |
78,171,674 | 6,455,731 | Pydantic: How to type hint a model constructor? | <p>How to properly type hint a model constructor, e.g. function that takes a model class and returns a model instance?</p>
<pre class="lang-py prettyprint-override"><code>from pydantic import BaseModel
class Point(BaseModel):
x: int
y: int
</code></pre>
<p>First approach:</p>
<pre class="lang-py prettyprint-... | <python><python-typing><pydantic> | 2024-03-16 12:06:01 | 0 | 964 | lupl |
78,171,645 | 6,151,828 | Python: memory consuption when passing data to a function vs. loading within the function | <p>I am working with a large dataset, in Python2, loading it via pandas. Occasionally the execution is spontaneously killed - likely to due to the high memory consumption. Thus I am trying to make my code more efficient in terms of not duplicating data in new variables, eliminating the variables that are no more needed... | <python><pandas><function><memory> | 2024-03-16 11:55:32 | 0 | 803 | Roger V. |
78,171,567 | 2,545,680 | Is uvicorn used for an external threadpool or an internal event loop which runs in the main (single) thread | <p>FastAPI uses <code>uvicorn</code> package to run the script:</p>
<pre><code>main:app --reload
</code></pre>
<p>The docs explain that:</p>
<blockquote>
<p>Uvicorn is an ASGI web server implementation for Python... The ASGI specification fills this gap, and means we're now able to start building a common set of toolin... | <python><multithreading><fastapi> | 2024-03-16 11:26:22 | 0 | 106,269 | Max Koretskyi |
78,171,527 | 5,938,276 | Populate class based on attribute value | <p>I have data that is streamed in a repeating fashion that I need to apply business logic to before populating a @dataclass.</p>
<p>The data class has the following structure:</p>
<pre><code>class Foo:
color: str
engine: int
petrol: int
diesel: int
</code></pre>
<p>The data consists of a enum color, and tw... | <python> | 2024-03-16 11:10:31 | 1 | 2,456 | Al Grant |
78,171,386 | 333,151 | how to plot calendar heatmap by month | <p>This seems quite simple, but for some reason, I'm struggling to get it working the way I want.</p>
<p>This is the data I have.</p>
<p><a href="https://i.sstatic.net/efRQ2.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/efRQ2.png" alt="Sales by Date" /></a></p>
<p>I want to show it as a heat map broken... | <python> | 2024-03-16 10:24:19 | 1 | 1,017 | Arun |
78,171,367 | 5,539,782 | How to Find and Decode URL Encoded Strings in Website's HTML/JavaScript for Scraping Live Odds from OddsPortal? | <p>I'm working on a project to scrape live odds for individual games from OddsPortal.
<a href="https://www.oddsportal.com/inplay-odds/live-now/football/" rel="nofollow noreferrer">https://www.oddsportal.com/inplay-odds/live-now/football/</a>
based on this helpful guide <a href="https://github.com/jckkrr/Unlayering_Odds... | <python><web-scraping><python-requests> | 2024-03-16 10:17:03 | 1 | 547 | Khaled Koubaa |
78,171,052 | 9,251,158 | Flip card animation in Python | <p>I have two still images, one for the front of a card, and one for the back. I want to create a video animation of the card flipping over and showing the back, similar to <a href="https://codepen.io/auroratide/pen/WNmmQzP" rel="nofollow noreferrer">this CodePen</a> that does it in CSS and JavaScript.</p>
<p>I am sure... | <python><animation><graphics> | 2024-03-16 08:15:45 | 1 | 4,642 | ginjaemocoes |
78,170,965 | 4,451,315 | Why does `.rename(columns={'b': 'b'}, copy=False)` followed by inplace method not update the original dataframe? | <p>Here's my example:</p>
<pre class="lang-py prettyprint-override"><code>In [1]: import pandas as pd
In [2]: df = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6]})
In [3]: df1 = df.rename(columns={'b': 'b'}, copy=False)
In [4]: df1.isetitem(1, [7,8,9])
In [5]: df
Out[5]:
a b
0 1 4
1 2 5
2 3 6
In [6]: df1
Out[6... | <python><pandas><dataframe> | 2024-03-16 07:45:23 | 2 | 11,062 | ignoring_gravity |
78,170,789 | 15,412,256 | Use the group max from another Polars dataframe to clip values to an upper bound | <p>I have 2 DataFrames:</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
df1 = pl.DataFrame(
{
"group": ["A", "A", "A", "B", "B", "B"],
"index": [1, 3, 5, 1, 3, 8],
}
)
df2 = pl.DataFrame(
... | <python><dataframe><python-polars> | 2024-03-16 06:22:41 | 1 | 649 | Kevin Li |
78,170,750 | 11,783,015 | Python tensorflow keras error when load a json model: Could not locate class 'Sequential' | <p>I've built and trained my model weeks ago and saved it on model.json dan model.h5</p>
<p>Today, when I tried to load it using model_from_json, it gives me an error</p>
<pre class="lang-py prettyprint-override"><code>TypeError: Could not locate class 'Sequential'. Make sure custom classes are decorated with `@keras.s... | <python><tensorflow><machine-learning><keras><deep-learning> | 2024-03-16 05:59:37 | 1 | 380 | Arvin |
78,170,536 | 13,325,046 | How to drop column from a pandas dataframe if it has a missing value after a specified row | <p>I have a dataframe with hundreds of columns and would like to drop a column if it contains any missing values after row <code>n</code>. How can this be done? Thanks</p>
| <python><python-3.x><pandas> | 2024-03-16 03:51:07 | 1 | 495 | te time |
78,170,492 | 1,676,217 | Python: bug in re (regex)? Or please help me understand what I'm missing | <p>Python 3.9.18. If the basic stuff below isn't a bug in <code>re</code> then how come I'm getting different results with what's supposed to be equivalent code (NOTE: I am not looking for alternative ways to achieve the expected result, I already have plenty such alternatives):</p>
<pre class="lang-py prettyprint-over... | <python><regex> | 2024-03-16 03:13:55 | 1 | 1,252 | Normadize |
78,170,429 | 3,282,758 | MySQLdb installation issue on Mac. Required for MySQL connectivity with Django | <p>I am creating a Django project on Mac. I want to use MySQL for database. I am trying to install MySQLdb which gives the following error:</p>
<pre><code>(djangodev) $ pip3 install MySQL-python
Collecting MySQL-python
Using cached MySQL-python-1.2.5.z... | <python><mysql-python><libmysqlclient> | 2024-03-16 02:40:05 | 1 | 1,493 | user3282758 |
78,170,272 | 1,440,349 | FileNotFoundError: [WinError 2] The system cannot find the file specified - FFMPEG | <p>I am running a script using conda environment on Windows and getting this error (stack trace below), which is apparently caused by python executable not being able to find the ffmpeg.exe. There are numerous questions about this, but none of the solutions unfortunately worked for me, so I hope someone has fresh ideas... | <python><ffmpeg><anaconda><subprocess><ffmpeg-python> | 2024-03-16 01:01:32 | 1 | 465 | shiftyscales |
78,170,266 | 3,813,064 | Python Decorator for Async and Sync Function without code duplication | <p>I have seen <a href="https://stackoverflow.com/questions/68410730/how-to-make-decorator-work-with-async-function">at least</a> <a href="https://stackoverflow.com/questions/66685788/decorator-for-all-async-coroutine-and-sync-functions">two examples</a> of decorator that work with both normal <code>def sync_func()</co... | <python><python-asyncio><python-typing><python-decorators> | 2024-03-16 00:59:24 | 1 | 2,711 | Kound |
78,170,072 | 4,089,351 | How can I render a scatter plot in Python with a "double-log" axis? | <p><a href="https://i.sstatic.net/NVtWg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/NVtWg.png" alt="enter image description here" /></a></p>
<p>This plot is from <a href="https://en.wikipedia.org/wiki/Birch_and_Swinnerton-Dyer_conjecture" rel="nofollow noreferrer">Wikipedia</a>, and the legend reads:... | <python><matplotlib><plot> | 2024-03-15 23:17:10 | 1 | 4,851 | Antoni Parellada |
78,169,969 | 10,181,236 | Get frames as observation for CartPole environment | <p>In Python, I am using <code>stablebaselines3</code> and <code>gymnasium</code> to implement a custom DQN. Using atari games I tested the agent and works, now I need to test it also on environments like <code>CartPole</code>
The problem is that this kind of environment does not return frames as observation but instea... | <python><reinforcement-learning><openai-gym><atari-2600> | 2024-03-15 22:40:09 | 2 | 512 | JayJona |
78,169,916 | 2,986,153 | After I unpivot a polars dataframe, how can I pivot it back to its original form without adding an index? | <pre class="lang-py prettyprint-override"><code>import polars as pl
df = pl.DataFrame({
'A': range(1,4),
'B': range(1,4),
'C': range(1,4),
'D': range(1,4)
})
print(df)
</code></pre>
<pre class="lang-none prettyprint-override"><code>shape: (3, 4)
βββββββ¬ββββββ¬ββββββ¬ββββββ
β A β B β C β D β
β --... | <python><python-polars> | 2024-03-15 22:23:55 | 2 | 3,836 | Joe |
78,169,841 | 9,538,589 | plotly parallel coordinates and categories | <p>In a dataframe, columns A and B are categorical data, while columns X and Y is numerical and continuous. How can I use plotly to draw a parallel coordinates+categories plot such that the first two y-axis corresponding to A and B are categorical, and the latter two corresponding to X and Y are numerical?</p>
<p>For e... | <python><pandas><plotly><parallel-coordinates> | 2024-03-15 21:58:21 | 1 | 369 | H.Alzy |
78,169,800 | 111,992 | Why PYTHONPATH need to be exported? | <p>I am getting some module not found excepiton when setting PYTHONPATH and <em>then</em> executing some py script :</p>
<pre><code>$ PYTHONPATH=somepath/a/b
$ python myscript.py
Exception has occurred: ModuleNotFoundError (note: full exception trace is shown but execution is paused at: _run_module_as_main)
No m... | <python><shell><environment-variables><pythonpath> | 2024-03-15 21:44:52 | 1 | 7,739 | Toto |
78,169,666 | 4,001,592 | Summing the values of leafs in XGBRegressor trees do not match prediction | <p>It was my understanding that the final prediction of an XGBoost model (in this particular case an XGBRegressor) was obtained by summing the values of the predicted leaves <a href="https://discuss.xgboost.ai/t/xgboost-trees-understanding/1822" rel="nofollow noreferrer">[1]</a> [<a href="https://stats.stackexchange.co... | <python><machine-learning><xgboost> | 2024-03-15 21:07:25 | 1 | 62,150 | Dani Mesejo |
78,169,571 | 4,379,593 | what does mean "NULL" in f-string specification in python? | <p>I open <a href="https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals" rel="nofollow noreferrer">python specification</a> at chapter 2. Lexical analysis and found</p>
<pre><code>format_spec ::= (literal_char | NULL | replacement_field)*
literal_char ::= <any code point e... | <python> | 2024-03-15 20:45:16 | 1 | 373 | Π€ΠΈΠ»Ρ Π£ΡΠΊΠΎΠ² |
78,169,456 | 11,793,491 | Can't activate Python environment after creating it in bash | <p>I have the following script <code>myenv.sh</code>:</p>
<pre class="lang-bash prettyprint-override"><code>#!bin/bash
echo "####### Install automated template ########"
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install ipykernel pandas seaborn scikit-learn
echo "#####... | <python><bash> | 2024-03-15 20:15:19 | 1 | 2,304 | Alexis |
78,169,454 | 6,587,318 | Best way to use re.sub with a different behavior when first called | <p>I'm trying to perform a number of replacements using <a href="https://docs.python.org/3.8/library/re.html#re.sub" rel="nofollow noreferrer"><code>re.sub()</code></a>, except I want the first replacement to be different. One straightforward approach would be to run <code>re.sub()</code> twice with <code>count = 1</co... | <python><function><global-variables><python-re> | 2024-03-15 20:14:49 | 2 | 326 | Zachary |
78,169,351 | 1,231,450 | Return two Enum states | <p>Suppose, I have</p>
<pre><code>class State(Enum):
TAKEPROFIT = 1
STOPPEDOUT = 2
WINNER = 3
LOSER = 4
</code></pre>
<p>How can I return the combination of e.g. <code>State.STOPPEDOUT</code> and <code>State.LOSER</code> ?<br />
The <code>|</code> does not seem to be supported:</p>
<pre><co... | <python> | 2024-03-15 19:46:28 | 3 | 43,253 | Jan |
78,169,254 | 1,709,440 | Resizing image from the center in moviepy | <p>So I have an issue with moviepy and applying resize effects.</p>
<p>Creating the image using:</p>
<pre><code>img_clip_pos = ("center", "center")
clip = ImageClip(image_path) \
.set_position(img_clip_pos) \
.set_duration(req_dur)
</code></pre>
<p>Then I want it to scale over time, like a ... | <python><moviepy> | 2024-03-15 19:25:25 | 1 | 325 | mhmtemnacr |
78,169,208 | 1,005,334 | Quart: how to get Server Sent Events (SSE) working? | <p>I'm trying to implement an endpoint for Server Sent Events (SSE) in Quart, following the example from the official documentation: <a href="http://pgjones.gitlab.io/quart/how_to_guides/server_sent_events.html" rel="nofollow noreferrer">http://pgjones.gitlab.io/quart/how_to_guides/server_sent_events.html</a></p>
<p>I'... | <python><fastapi><server-sent-events><starlette><quart> | 2024-03-15 19:16:27 | 1 | 1,544 | kasimir |
78,169,159 | 2,779,432 | PIL fromarray for single channel image | <p>I am trying to obtain an image shaped (1080, 1920, 1) from one shaped (1080, 1920, 3)
This is what I have been trying without success:</p>
<pre><code> for fr in fr_lst:
frame = cv2.imread(os.path.join(frame_root, fr))
#SPLIT CHANNELS
frame = (cv2.cvtColor(frame, cv2.COLOR_BGR2... | <python><numpy><opencv><python-imaging-library> | 2024-03-15 19:04:28 | 1 | 501 | Francesco |
78,169,114 | 12,240,037 | How To Buffer a Selected Point in pyQGIS | <p>I have a few random points that I generated within a polygon. I randomly selected one of the points and would like to buffer that point. In the case below, buffering will be applied to all points and not the selected point. Do I need to create a new memory layer of the selected point first? If so, how?</p>
<pre><cod... | <python><buffer><qgis><pyqgis> | 2024-03-15 18:57:17 | 1 | 327 | seak23 |
78,169,098 | 7,155,895 | Read a Weidmuller File and get data from it | <p>I have a file, created with the program "<a href="https://www.weidmuller.it/it/prodotti/workplace_accessories/software/m_print_pro.jsp" rel="nofollow noreferrer">M-Print Pro, for Weidmuller</a>". It has the file extension ".mpc" The file description given by the program is "Files with M-Prin... | <python><python-3.11> | 2024-03-15 18:53:51 | 1 | 579 | Rebagliati Loris |
78,169,083 | 12,904,817 | Preserve type hints (checked with mypy) for function decorated with aiocache's @cached decorator | <p>Python version: 3.9.17</p>
<p>When I decorate a function with @cached, mypy will simply accept calls to the decorated function with invalid args. Making the typed params in the decorated function useless. How do I make mypy understand that it should flag calls to the decorated function that don't follow it's functio... | <python><python-decorators> | 2024-03-15 18:50:19 | 0 | 595 | Vitor EL |
78,168,840 | 10,967,961 | Pandas dataset from dynamic website scraping | <p>This question is related to a previous question of mine, so here I am assuming that I was able to open all the "plus sigs" from <a href="http://data.europa.eu/esco/skill/f8c676de-c871-424f-9a65-77059d07910a" rel="nofollow noreferrer">this web page from esco</a>.
Once I have expanded the plus signs under &q... | <python><pandas><web-scraping> | 2024-03-15 17:56:39 | 1 | 653 | Lusian |
78,168,618 | 202,168 | Python 3.11 with no builtin pip module - what's going on? | <pre><code>.venv/bin/python -m pip uninstall mysqlclient
/Users/anentropic/dev/project/.venv/bin/python: No module named pip
</code></pre>
<p>and</p>
<pre><code>.venv/bin/python
Python 3.11.5 (main, Sep 18 2023, 15:04:25) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", &quo... | <python><pip> | 2024-03-15 17:07:33 | 1 | 34,171 | Anentropic |
78,168,594 | 13,126,794 | Conditional update in pandas dataframe column based on paragraph type | <p>I have a dataframe like this:</p>
<pre><code> data = {
'document_section_id': ['1', '1.1', None, None, None, None, None, None, None, '3', None, None, None, '4.1', None, None, None, None, None, None, None, None, None, None, None, None, None, None, '1.2', None, None, None, None, None, None, None, '1.3', '1.3.1', N... | <python><python-3.x><pandas><dataframe> | 2024-03-15 17:04:28 | 2 | 961 | Dcook |
78,168,551 | 10,200,497 | How to get the first instance of a mask if only it is in top N rows? | <p>This is my DataFrame.</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
{
'a': [100, 1123, 9999, 100, 1, 954, 1],
'b': [1000, 11123, 1123, 0, 55, 0, 1],
},
)
</code></pre>
<p>Expected output is creating column <code>c</code>:</p>
<pre><code> a b c
0 100 1000 NaN
1 ... | <python><pandas><dataframe> | 2024-03-15 16:57:06 | 3 | 2,679 | AmirX |
78,168,492 | 14,661,648 | Python: VSCode does not show docstring for inherited exceptions | <pre><code>class CustomNamedException(Exception):
"""Example docstring here."""
def __init__(self, name) -> None:
self._name = name
def __str__(self):
return("Error message.")
</code></pre>
<p>My exception above does not show the docstring when I ... | <python><visual-studio-code><pylance> | 2024-03-15 16:47:04 | 1 | 1,067 | Jiehfeng |
78,168,476 | 10,200,497 | How to get the index of the first row that meets the conditions of a mask? | <p>This is my DataFrame:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
{
'a': [100, 1123, 123, 100, 1, 0, 1],
'b': [1000, 11123, 1123, 0, 55, 0, 1],
},
index=range(100, 107)
)
</code></pre>
<p>And this is the expected output. I want to create column <code>c</code>:</p>
<pre><code> ... | <python><pandas><dataframe> | 2024-03-15 16:44:29 | 5 | 2,679 | AmirX |
78,168,451 | 13,491,504 | Derivative of a Derivative in sympy | <p>I am trying to do some calculations in python and now need to find the derivative of the a function, that I have derived prior and is now called derivative(x(t), t):</p>
<pre><code>t = sp.symbols('t')
x = sp.symbols('x')
B = sp.symbols('B')
C = sp.symbols('C')
x = sp.Function('x')(t)
Lx = B * sp.diff(x,t) * C
</cod... | <python><sympy><derivative> | 2024-03-15 16:40:39 | 1 | 637 | Mo711 |
78,168,443 | 12,198,665 | Errors with reading GTFS tripupdates.pb real time data using get() function | <p>We want to extract the stop arrival time and departure time from the list within entity using the following code. However, I am getting repeated errors.</p>
<pre><code>dict_obj['entity'][0]
Gives the following output
{'id': '8800314',
'tripUpdate': {'trip': {'tripId': '8800314',
'startTime': '11:30:00',
's... | <python><dataframe><get><protocol-buffers><gtfs> | 2024-03-15 16:39:03 | 1 | 518 | vp_050 |
78,168,362 | 10,967,961 | Selenium dynamic scraping and put in a database | <p>I am trying to scrape the following <a href="http://data.europa.eu/esco/skill/f8c676de-c871-424f-9a65-77059d07910a" rel="nofollow noreferrer">web page</a> (I actually have more of these types of uris butt for the sake of simplicity I am just posting one here). So, since the page is dynamic, the very first thing I ha... | <python><pandas><selenium-webdriver><beautifulsoup> | 2024-03-15 16:25:13 | 0 | 653 | Lusian |
78,168,290 | 984,621 | Scrapy: Where to init database connection, so it is available and accessible in spiders, pileines, and classes | <p>I have a fairly standard Scrapy project, its dir structure looks like this</p>
<pre><code>my_project
scrapy.cfg
my_project
__init__.py
items.py
itemsloaders.py
middlewares.py
MyStatsCollector.py
pipelines.py
settings.py
spiders
__init__.py
spider1.py
spider2.py
... | <python><database><scrapy> | 2024-03-15 16:10:45 | 1 | 48,763 | user984621 |
78,167,996 | 543,913 | Is os.makedirs(path, exist_ok=True) susceptible to race-conditions? | <p>Suppose two different processes simultaneously call <code>os.makedirs(path, exist_ok=True)</code>. Is it possible that one will raise a spurious exception due to a race condition?</p>
<p>My fear is the call might do something like this under the hood:</p>
<pre><code>if not dir_exists(d):
try_make_dir_and_raise_i... | <python> | 2024-03-15 15:23:25 | 1 | 2,468 | dshin |
78,167,938 | 9,318,323 | SqlAlchemy Correct way to create url for engine | <p>What is the best / correct way to create a <code>url</code> which needs to be passed to <code>sqlalchemy.create_engine</code>? <a href="https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine" rel="nofollow noreferrer">https://docs.sqlalchemy.org/en/20/core/engines.html#sqlalchemy.create_engine<... | <python><sql-server><sqlalchemy> | 2024-03-15 15:14:41 | 1 | 354 | Vitamin C |
78,167,866 | 12,520,740 | How to make pattern matching efficient for large text datasets | <p>I'm currently working on a project that involves processing large volumes of textual data for natural language processing tasks. One critical aspect of my pipeline involves string matching, where I need to efficiently match substrings within sentences against a predefined set of patterns.</p>
<p>Here's a mock exampl... | <python><substring> | 2024-03-15 15:03:18 | 1 | 1,156 | melvio |
78,167,748 | 1,945,486 | Python Protocol incompatible warning | <p>I would like to typehint, that my pure mixin (<code>MyMixin</code>) expects the super class to have the <code>get_context_data</code> method.</p>
<pre><code>class HasViewProtocol(Protocol):
kwargs: dict
@abstractmethod
def get_context_data(self, **kwargs) -> dict:
pass
class MyMixin(HasView... | <python><python-typing> | 2024-03-15 14:43:58 | 1 | 12,343 | ProfHase85 |
78,167,633 | 13,126,794 | How to generate the section id based on certain condition | <p>I have pandas dataframe with this input:</p>
<pre><code> data = {
'sec_id': ['1', '', '1.2', '1.3', '1.3.1', '1.3.2', '2', '2.1', '2.2', '2.3', '', '2.3.2', '2.3.3', '3', '4', '4.1', '4.1.1', '4.2', '4.3', '4.4', '5', '5.1', '5.2', '5.3', '5.3.1', '5.3.2', '5.3.3', '5.3.4', '5.3.5', '5.4', '5.5', '6', '6.1', ... | <python><python-3.x><pandas><dataframe> | 2024-03-15 14:25:43 | 1 | 961 | Dcook |
78,167,419 | 307,050 | How to determine frequency dependant amplitude with FFT | <p>I'm trying to measure and calculate the frequency response of an audio device by simply generating input signals and measuring the output with a frequency sweep.</p>
<p>Here's what I'm trying to achieve in pseudo code:</p>
<pre><code>for each frequency f in (10-20k):
generate reference signal s with frequency f
... | <python><numpy><matplotlib><fft> | 2024-03-15 13:52:35 | 1 | 1,347 | mefiX |
78,167,398 | 2,656,359 | Django: annotate query of one model with count of different non-related model which is filtered by a field of first model | <p>Long title in short : I have a complex annotate query to work with.
Example Models:</p>
<pre><code>class FirstModel(models.Model):
master_tag = models.CharField()
... other fields
class SecondModel(models.Model):
ref_name = models.CharField()
</code></pre>
<p>I want to fetch all objects from <strong>Fir... | <python><django><annotations> | 2024-03-15 13:50:15 | 1 | 456 | Dishant Chavda |
78,167,219 | 12,320,370 | Retrieve Extra parameters from Airflow Connection | <p>I have a Snowflake connection defined in Airflow.<a href="https://i.sstatic.net/uWFA6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uWFA6.png" alt="enter image description here" /></a></p>
<p>I am selecting the user, password and schema using the below:</p>
<pre><code>conn = BaseHook.get_connection(... | <python><airflow><connection><hook> | 2024-03-15 13:20:33 | 1 | 333 | Nairda123 |
78,167,201 | 2,725,810 | "matching query does not exist" when creating an object | <p>I have:</p>
<pre class="lang-py prettyprint-override"><code>class GoogleSignIn(APIView):
def post(self, request):
settings = request.settings
code = request.data['code']
# Verify the OAuth code with Google
try:
google_user_info = verify_user(code)
except Excep... | <python><django> | 2024-03-15 13:16:02 | 1 | 8,211 | AlwaysLearning |
78,167,174 | 1,296,783 | Pydantic V2 @field_validator is not executed | <p>I try to parse and validate a CSV file using the following Pydantic (V2) model.</p>
<pre><code>from typing import Optional
from pydantic import BaseModel, field_validator
class PydanticProduct(BaseModel):
fid: Optional[float]
water: Optional[float]
class ConfigDict:
from_attributes = True
... | <python><pydantic-v2> | 2024-03-15 13:10:43 | 1 | 798 | yeaaaahhhh..hamf hamf |
78,167,076 | 21,185,825 | Python - azure.devops - get branch/commits for a pull request | <p>I am parsing pull requests one by one with azure.devops python library</p>
<p><strong>for each PR I need the related branch and the commits</strong></p>
<p>is there a way to do this ?</p>
<pre><code>repositories = git_client.get_repositories(project=None, include_links=None, include_all_urls=None, include_hidden=Non... | <python><azure-devops> | 2024-03-15 12:54:57 | 1 | 511 | pf12345678910 |
78,166,924 | 4,792,022 | How to Improve Efficiency in Random Column Selection and Assignment in Pandas DataFrame? | <p>I'm working on a project where I need to create a new DataFrame based on an existing one, with certain columns randomly selected and assigned in each row with probability proportional to the number in that column.</p>
<p>However, my current implementation seems to be inefficient, especially when dealing with large d... | <python><pandas><performance><random> | 2024-03-15 12:28:59 | 1 | 544 | Abijah |
78,166,720 | 6,943,622 | Number of outstanding shares per query | <p>I came across this question and i was able to solve it but inefficiently. My solution is a naive o(m*n) where m is the number of queries and n is the number of orders.</p>
<blockquote>
<p>You are given a log (std:vector) of orders sent from our trading
system over a day. Each order has the following properties:</p>
... | <python><algorithm><intervals> | 2024-03-15 11:53:57 | 2 | 339 | Duck Dodgers |
78,166,642 | 13,381,632 | Append Columns From Multiple CSVs into One File - Python | <p>I am trying to use the Pandas library to append columns multiple CSV files of the same format into a single file, but cannot seem to get the syntax correct in my script. Here are the CSVs I am trying to parse, all located in the same file path, and the desired output csv file:</p>
<p>CSV #1:</p>
<pre><code>Applicat... | <python><pandas><csv><indexing><output> | 2024-03-15 11:39:42 | 0 | 349 | mdl518 |
78,166,627 | 87,416 | Failed to authenticate the user '' in Active Directory (Authentication option is 'ActiveDirectoryIntegrated') | <p>I am wanting to user the logged in Windows credentials of Visual Studio Code as a pass through to authenticate to an Azure SQL database.</p>
<p>Below is my python code using odbc driver 18.</p>
<pre><code>connectionString = f'Driver={{ODBC Driver 18 for SQL Server}};Server={SERVER};Database={DATABASE};Authentication... | <python><visual-studio-code><pyodbc> | 2024-03-15 11:37:10 | 0 | 15,381 | David |
78,166,612 | 9,749,124 | Installing ChromeDriver and Headless Chrome Driver with latest version of Selenium | <p>I am using <code>Python</code> and <code>Selenium</code> on <code>AWS Lambdas</code> for crawling.
I have updated <code>Python</code> to 3.11 and <code>Selenium</code> to 4.18.0, but then my crawlers stopped working.
This is the code for <code>Selenium</code>:</p>
<pre><code>import os
from selenium import webdriver
... | <python><selenium-webdriver><aws-lambda><selenium-chromedriver> | 2024-03-15 11:34:35 | 2 | 3,923 | taga |
78,166,510 | 9,097,114 | Filter data from df using date picker - tkinter python | <p>Hi I am trying to filter the data based on date range from below df and create output as df1 using tkinter - python</p>
<p><strong>df:</strong></p>
<div class="s-table-container"><table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>Date</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>361</td>
<td>10/15/2023</td>... | <python><tkinter> | 2024-03-15 11:16:15 | 0 | 523 | san1 |
78,166,405 | 16,815,358 | Reproducing the phase spectrum while using np.fft.fft2 and cv2.dft. Why are the results not similar? | <p>Another <a href="https://stackoverflow.com/q/78163775/16815358">question</a> was asking about the correct way of getting magnitude and phase spectra while using <code>cv2.dft</code>.</p>
<p>My answer was limited to the numpy approach and then I thought that using OpenCV for this would be even nicer. I am currently t... | <python><numpy><opencv><image-processing><fft> | 2024-03-15 10:57:48 | 2 | 2,784 | Tino D |
78,166,363 | 7,672,005 | Python data to dict memory concerns: how to efficiently load data into a dict? | <p>I'm trying to load a very large dataset (~560MB) into a dict in order to display it as a 3D graph.
I have run into memory issues that resulted in "Killed.", so I've added some logic to read my dataset in chunks and dump the dict to a json file periodically, I hoped this would avoid my RAM being filled up.
... | <python><dictionary><memory><memory-management> | 2024-03-15 10:49:36 | 1 | 534 | Zyzyx |
78,166,342 | 3,970,455 | Django: collectstatic is not collecting static files | <p>I found a github proyect. Copied it locally, but running collecstatic does not copy files to staticfiles folder. Why?</p>
<p>If I do the full path search:</p>
<p><code>python manage.py findstatic D:\web_proyects\imprenta_gallito\static\css\home.css</code></p>
<p>I get error:</p>
<p><code>django.core.exceptions.Suspi... | <python><django> | 2024-03-15 10:47:01 | 2 | 4,038 | Omar Gonzales |
78,166,304 | 4,599,620 | AKS - Cronjob use script file inside PVC | <p>I would like to create a cronjob that could get the script file inside PVC and run with it.<br />
Here I have created a PVC inside AKS as follows:</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
volume.beta.kubernetes.io/mount-options: dir_mode=0777,file_mode=0777,uid=9... | <python><dockerfile><kubectl><kubernetes-pvc><kubernetes-cronjob> | 2024-03-15 10:36:43 | 1 | 996 | Wing Choy |
78,166,245 | 202,335 | RuntimeError: This event loop is already running, 'Cannot run the event loop while another loop is running') | <p>Below is a minimal reproducible example.</p>
<pre><code>import asyncio
import aiohttp
from database_utils import connect_to_database
from pytdx.hq import TdxHq_API
api = TdxHq_API()
api.connect('119.147.212.81', 7709)
async def execute_main(conn, c):
try:
c.execute("SELECT stockCode, shsz FR... | <python><aiohttp><pytest-aiohttp> | 2024-03-15 10:26:06 | 0 | 25,444 | Steven |
78,166,162 | 3,735,871 | How to keep the date in Airflow execution date and convert time to 00:00 | <p>I'm using <code>time_marker = {{execution_date.in_timezone('Europe/Amsterdam')}}</code> in my dag.py program. I'm trying to keep the date part in execution date, and set the time to <code>"T00:00:00"</code>
So whenever during the execution date it runs, the time_marker will always be for example <code>2024... | <python><date><airflow> | 2024-03-15 10:16:19 | 1 | 367 | user3735871 |
78,165,987 | 13,491,504 | SymPy vector substraction not doing what expected | <p>I have this code in which I try to do a Vector calculation, but the code does not do what would be mathematically expected:</p>
<pre><code>import sympy as sp
from sympy.vector import CoordSys3D
N = CoordSys3D('N')
t = sp.symbols('t')
r = sp.symbols('r')
w = sp.symbols('w')
o = sp.symbols('o')
x = sp.Function('x'... | <python><math><sympy> | 2024-03-15 09:48:49 | 1 | 637 | Mo711 |
78,165,961 | 5,985,798 | Firestore Trigger Python Cloud Functions (gen2) - takes 1 positional argument but 2 were given | <p>I have deployed the <strong>firestore trigger function <em>on_document_created</em></strong> as per the example: <a href="https://firebase.google.com/docs/reference/functions/2nd-gen/python/firebase_functions.firestore_fn#functions" rel="nofollow noreferrer">https://firebase.google.com/docs/reference/functions/2nd-g... | <python><firebase><google-cloud-firestore><google-cloud-functions> | 2024-03-15 09:44:13 | 1 | 835 | Carlo |
78,165,946 | 447,426 | why Pydantic construcor only accepts model_dump - error Input should be a valid dictionary or instance of | <p>I have some pydantic classes and try to construct objects using the constructor.
i get this error:</p>
<pre><code>> part: PartOut = PartOut(type="battery", position="l", correlation_timestamp=datetime.now().isoformat(), kpis=kpis)
E pydantic_core._pydantic_core.ValidationError: 1 v... | <python><pydantic> | 2024-03-15 09:41:17 | 0 | 13,125 | dermoritz |
78,165,875 | 2,542,516 | How to broadcast a tensor from main process using Accelerate? | <p>I want to do some computation in the main process and broadcast the tensor to other processes. Here is a sketch of what my code looks like currently:</p>
<pre class="lang-py prettyprint-override"><code>from accelerate.utils import broadcast
x = None
if accelerator.is_local_main_process:
x = <do_some_computat... | <python><pytorch><huggingface><accelerate> | 2024-03-15 09:30:29 | 2 | 2,937 | Priyatham |
78,165,778 | 1,662,268 | How to define an `Index()` in SqlAlchemy+Alembic, on a column from a base table | <p>I am a python novice.</p>
<p>My project is using SqlAlchemy, Alembic and MyPy.</p>
<p>I have a pair of parent-child classes defined like this (a bunch of detail elided):</p>
<pre><code>class RawEmergency(InputBase, RawTables):
__tablename__ = "emergency"
id: Mapped[UNIQUEIDENTIFIER] = mapped_colum... | <python><inheritance><indexing><sqlalchemy><alembic> | 2024-03-15 09:12:39 | 2 | 8,742 | Brondahl |
78,165,650 | 10,396,491 | Rotations using quaternions and scipy.spatial.transform.Rotation for 6 degree of freedom simulation | <p>I am writing a simple simulator for a remotely operated underwater vehicle (ROV). I want to use <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.html" rel="nofollow noreferrer">scipy</a> implementation of quaternions instead of my previous approach based on constructing ... | <python><scipy><rotation><physics><rotational-matrices> | 2024-03-15 08:47:43 | 1 | 457 | Artur |
78,165,559 | 1,870,832 | How to write a polars dataframe to DuckDB | <p>I am trying to write a Polars DataFrame to a duckdb database. I have the following simple code which I expected to work:</p>
<pre><code>import polars as pl
import duckdb
pldf = pl.DataFrame({'mynum': [1,2,3,4]})
with duckdb.connect(database="scratch.db", read_only=False) as con:
pldf.write_database(ta... | <python><uri><python-polars><duckdb> | 2024-03-15 08:31:15 | 2 | 9,136 | Max Power |
78,165,556 | 3,030,926 | PyUno and calc/spreadsheet: how to export single sheet to csv? | <p>I need to automate some spreadsheet manipulation and exporting via PyUNO, but I'm struggling on exporting a single sheet to CSV.</p>
<p>I made a simple shell script that first launch LibreOffice to open a given .xlsx file and then run a python3 script to execute all the needed logic.</p>
<p>Now I need to just export... | <python><csv><spreadsheet><pyuno> | 2024-03-15 08:30:10 | 1 | 3,034 | fudo |
78,165,544 | 14,345,081 | Linear regression model of scikit-learn not working as expected | <p>I'm trying to understand the internal working of the Linear-regression model in Scikit-learn.</p>
<p>This is my dataset</p>
<p><a href="https://i.sstatic.net/ngx1v.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ngx1v.png" alt="before 1 hot encoding" /></a></p>
<p>And this is my dataset after performi... | <python><pandas><numpy><machine-learning><scikit-learn> | 2024-03-15 08:26:45 | 2 | 304 | Saptarshi Dey |
78,165,495 | 11,945,463 | use SeamlessM4Tv2Model, I want to slow down the rate of speech of audio output | <pre><code>text_inputs = processor(text="I have a daughter 2 years old, I wanted her name to be HΖ°Ζ‘ng Ly", src_lang="eng", return_tensors="pt").to(device)
audio_array = model.generate(**text_inputs, tgt_lang=language)[0].cpu().numpy().squeeze()
file_path = 'audio_from_text.wav'
sf.write(fi... | <python><pytorch><text-to-speech><huggingface> | 2024-03-15 08:17:22 | 0 | 649 | lam vu Nguyen |
78,165,465 | 2,372,467 | Niftyindices.com not able to scrape Index data | <p>I was able to scrape data from NSE India's Niftyindices.com website earlier. this is the historical Index Data I need.
The website is <a href="http://www.niftyindices.com" rel="nofollow noreferrer">www.niftyindices.com</a> and the historical data can be found under Reports Section of the home page under Historical D... | <python><post><python-requests> | 2024-03-15 08:10:13 | 1 | 301 | Kiran Jain |
78,165,358 | 8,968,910 | Python: faster way to do Geocoding API | <p>It almost takes 1 mimute to convert 60 addresses to coordinates with my code. I want the result to contain address, latitude and longtitude in order. Is there other faster ways? Thanks</p>
<p>code:</p>
<pre><code>import time
import requests
import json
import pandas as pd
import numpy as np
import string
addressLis... | <python><google-geocoding-api> | 2024-03-15 07:45:07 | 1 | 699 | Lara19 |
78,165,006 | 4,470,126 | How to display dash_table for a selected radio item | <p>I am new python Dash programming, and i have taken reference from plotly.community. I am able display list of s3 buckets from my AWS account, and for a selected bucket I am showing list of all CSV files.</p>
<p>The next step is, for a selected CSV file, I need to display CSV contents as a dash table on the same pag... | <python><python-3.x><plotly-dash><plotly> | 2024-03-15 06:25:25 | 1 | 3,213 | Yuva |
78,164,994 | 17,015,816 | Navigation across the site using scrapy | <p>So I am working on a personal project where i am learning Web Scraping. I have chose this as my website to scrape. I am using scrapy as it seemed like a good library. For this website. I need to loop through each page in A-Z to open each sublink and get title and description. I was able to do the sublink part. I am ... | <python><scrapy><pagination> | 2024-03-15 06:21:54 | 0 | 479 | Sairam S |
78,164,916 | 2,604,247 | How to Implement Dependency Inversion and Interface Segregation for a Concrete Class that Needs to Be Initiated? | <h4>Context</h4>
<p>So far as I understand, the Dependency Inversion and Interface Segregation principles of SOLID OOP tell us to write our program according to the <em>interface</em>, not internal details. So, I am trying to develop a simple stock-market data collector in Python, roughly with the following object diag... | <python><oop><solid-principles><dependency-inversion><interface-segregation-principle> | 2024-03-15 05:57:19 | 1 | 1,720 | Della |
78,164,847 | 12,390,973 | How to add param values along with variable values in the objective function using PYOMO? | <p>I have written a program to maximize the revenue, where there is a facility that contains Solar and Wind power plants. They serve a demand profile. To serve that demand profile they get some revenue based on <strong>PPA(Power Purchasing Agreement)</strong>. There are three components which affect the revenue:</p>
<o... | <python><pyomo> | 2024-03-15 05:32:12 | 1 | 845 | Vesper |
78,164,659 | 8,364,971 | Python UTC America/New York Time Conversion | <p>Working on a problem where I have to evaluate whether a time stamp (UTC) exceeds 7PM <code>Americas/New_York</code>.</p>
<p>I naively did my check as:</p>
<pre><code>if (timestamp - timedelta(hours=4)).time() > 19:
__logic__
</code></pre>
<p>Which obviously failed with daylight savings EST/EDT.</p>
<p>I thin... | <python><datetime><timezone><utc><pytz> | 2024-03-15 04:20:36 | 1 | 342 | billash |
78,164,251 | 4,450,134 | Dividing each column in Polars dataframe by column-specific scalar from another dataframe | <p>Polars noob, given an <code>m x n</code> Polars dataframe <code>df</code> and a <code>1 x n</code> Polars dataframe of scalars, I want to divide each column in <code>df</code> by the corresponding scalar in the other frame.</p>
<pre><code>import numpy as np
import polars as pl
cols = list('abc')
df = pl.DataFrame(n... | <python><numpy><python-polars> | 2024-03-15 01:38:17 | 2 | 3,386 | HavelTheGreat |
78,164,196 | 2,115,971 | MinGW ld linking error - undefined reference | <p>I hope that in the age of AI, there are at least a few humans who can still help troubleshoot a problem that the "all-knowing" GPT cannot.</p>
<p><strong>The Problem</strong>:</p>
<p>I'm trying to create a Python interface for a C++ library, and a few modules give me linking errors. The error details are g... | <python><c++><mingw><swig> | 2024-03-15 01:12:30 | 1 | 5,244 | richbai90 |
78,164,093 | 2,735,009 | Store quantile ranges in a new column | <p>I have written the following code to grab the quantile ranges and store it in a new column:</p>
<pre><code>df_temp = pd.DataFrame(data_train['paper_mentions'])
df_temp['q_dr_du'] = pd.Series(pd.qcut(df_temp['paper_mentions'], q=4, duplicates='drop'))
df_temp['q_rank'] = pd.Series(pd.qcut(df_temp['paper_mentions'].ra... | <python><pandas><dataframe> | 2024-03-15 00:23:03 | 0 | 4,797 | Patthebug |
78,164,024 | 3,362,074 | Converting depth map to distance map (Python OpenCV) | <p>I am trying to estimate the distance between objects in a scene and the camera. I have generated a depth map from a rectified stereo pair, but if I understand correctly, that's the distance between the plane where the sensor is located and the objects, but not the camera point specifically.</p>
<p>I am currently sol... | <python><opencv> | 2024-03-14 23:49:20 | 0 | 579 | Kajuna |
78,163,936 | 2,648,947 | How to chain jobs in Dagster? | <p>I need to chain several jobs. Some have to be started right after other have finished and some need results of other jobs as an input.</p>
<p>Seems that I can start one job after the other by using sensors. AI suggests using <code>@solid</code> and <code>@pipeline</code> decorators, but I was unable to find suitable... | <python><python-3.x><jobs><job-scheduling><dagster> | 2024-03-14 23:16:26 | 0 | 1,384 | SS_Rebelious |
78,163,914 | 2,862,945 | Rotating a 3D body in python results in holes in the body | <p>I have a 3D body, let's say a cuboid, which I want to rotate. For simplicity, let's assume it's just rotation around the x-axis. So I use the corresponding rotation matrix <code>R</code> and multiply it with the coordinate vector <code>v</code> to get the new coordinate vector <code>v'</code>: <code>v'=R*v</code>. A... | <python><geometry><rotation><computational-geometry><rotational-matrices> | 2024-03-14 23:10:01 | 1 | 2,029 | Alf |
78,163,868 | 15,412,256 | Polars Expressions Failed to Access Intermediate Column Creation Expressions | <p>I want to encode the <code>non-zero</code> binary events with integer numbers. Following is a demo table:</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
df = pl.DataFrame(
{
"event": [0, 1, 1, 0],
"foo": [1, 2, 3, 4],
"boo": [2, 3, 4,... | <python><pandas><dataframe><python-polars> | 2024-03-14 22:57:39 | 2 | 649 | Kevin Li |
78,163,832 | 1,925,652 | Why does PDB incorrectly report location of exceptions? | <p>I've run into this problem countless times and I've tried to just overlook it but it's infuriating. About 25% of the time that I use the python debugger (usually on the command line, haven't tested elsewhere) it will report that an exception occurred in a location where it obviously didn't occur... (e.g. on the very... | <python><pdb> | 2024-03-14 22:46:48 | 0 | 521 | profPlum |
78,163,694 | 9,718,199 | Python sqlalchemy connection fails with "socket.gaierror: [Errno -2] Name or service not known" | <p>I'm trying to use a local postgres database connection through sqlalchemy. It manages to get inside the <code>with</code> statement, but then starts crashing as soon as I try to do anything with the connection.</p>
<pre class="lang-py prettyprint-override"><code>async with database.async_session.begin() as db_sessio... | <python><sqlalchemy> | 2024-03-14 22:10:10 | 1 | 369 | ConfusedPerson |
78,163,337 | 9,951,273 | How to release Python memory back to the OS | <p>I have a long running Python script that takes 1-2 hours to complete. It's running on a 4gb container with 1 CPU.</p>
<p>The script fetches and processes data in a for loop. Something like the following:</p>
<pre><code>for i in ENOUGH_API_CALLS_TO_TAKE_2_HOURS:
data = fetch_data()
process_data(data)
</code><... | <python><memory> | 2024-03-14 20:37:30 | 1 | 1,777 | Matt |
78,162,990 | 1,712,287 | How to make bitcoin compressed public key | <p>This is my code</p>
<pre><code>from bitcoinlib.keys import PrivateKey
from bitcoinlib.encoding import pubkeyhash_to_addr
# Example WIF private key
wif_private_key = "5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf"
# Decode the WIF private key to obtain the raw private key
raw_private_key = PrivateKe... | <python><blockchain><bitcoin> | 2024-03-14 19:30:00 | 1 | 1,238 | Asif Iqbal |
78,162,964 | 424,333 | Why is the Python IMAP library failing with Outlook? | <p>I'm trying to use Python to create a draft email programmatically in Office365. I have a similar code for Gmail that works fine. However, I'm getting the error <code>b'LOGIN failed.'</code>.</p>
<p>I thought the issue might be having 2FA enabled, but it's still not working with an app secret.</p>
<p>Here's my code e... | <python><email><office365> | 2024-03-14 19:24:54 | 0 | 3,656 | Sebastian |
78,162,874 | 17,729,094 | Losing "type" information inside polars dataframe | <p>Sorry if my question doesn't make a lot of sense. I don't have much experience in python.</p>
<p>I have some code that looks like:</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
from typing import NamedTuple
class Event(NamedTuple):
name: str
description: str
def event_table(num)... | <python><python-polars> | 2024-03-14 19:05:01 | 1 | 954 | DJDuque |
78,162,861 | 4,547,189 | Pandas rolling average - Leading and Trailing | <p>I was wondering if Pandas had a simple syntax to do the Leading and Trailing average calculation?</p>
<p>If I wanted to do a Trailing 30 days and leading 3 days to calculate the rolling average, is there a simple way to do this?</p>
<p>e.g:</p>
<div class="s-table-container"><table class="s-table">
<thead>
<tr>
<th>... | <python><pandas> | 2024-03-14 19:01:23 | 1 | 648 | tkansara |
78,162,851 | 6,580,142 | How does Python logging library get lineno and funcName efficiently? | <p>In my Python service I'm using a logging library that's built in-house and not compatible with Python's logging module. While using this library, I want to add additional info to the logs like lineno and funcName. I have been using the <code>inspect</code> library to get this info like below:</p>
<pre><code>frame = ... | <python><python-logging> | 2024-03-14 18:59:59 | 2 | 895 | David Liao |
78,162,830 | 14,875,896 | How to create cronjob such that reminders are triggered as per user timezone? | <p>I have an app where I need to send reminders for upcoming sessions. Now, users are spread across the globe. There session timing is stored in UTC in the database. Now, I am getting confused as to how should I design the cronjob such that notifications are sent at 4pm as per user local timezone?</p>
<p>Thanks in adva... | <python><cron><utc><reminders> | 2024-03-14 18:56:32 | 0 | 354 | lsr |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.