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,311,309 | 1,506,763 | Fitting a wave function to time-series data | <p>I have velocity data sampled over time and I'd like to find some equation/function that can be used to describe it. My data looks like this figure</p>
<p><a href="https://i.sstatic.net/OTOvP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/OTOvP.png" alt="Velocity time series data" /></a></p>
<p>As you... | <python><scipy><signal-processing><curve-fitting><scipy-optimize> | 2024-04-11 15:01:04 | 2 | 676 | jpmorr |
78,311,240 | 1,726,832 | SQLAlchemy query error when column type FBTEXT exists | <p>Table:<br/>
...<br/>
<code>name BLOB SUB_TYPE TEXT(0),</code></p>
<p>Class generated:</p>
<pre><code>class Users(Base):
__tablename__ = 'users'
__table_args__ = (
PrimaryKeyConstraint('userid', name='pk_userid'),
)
name = mapped_column(FBTEXT(1, 'NONE', 'NONE'))
</code></pre>
<p>Query:</p>
<pre><... | <python><sqlalchemy><firebird><sqlacodegen> | 2024-04-11 14:49:46 | 1 | 6,263 | rubStackOverflow |
78,311,118 | 7,419,139 | How to write stateful tests in python unittest? | <p>I want to create a test suite for an existing library that is using <code>unittest</code> and is very hierarchical.</p>
<p>The Class hierarchy looks a bit like this:</p>
<pre><code>A
|_B
|_C
|_D
|_E
</code></pre>
<p>Class <code>A</code> is created with an instance of <code>B</code> and <code>C</code> where <code... | <python><python-unittest> | 2024-04-11 14:33:48 | 1 | 746 | iaquobe |
78,310,933 | 1,630,244 | Pytest reports missing lines in coverage for imports and constant assignments | <p>I'm baffled by differences in coverage behavior for different files in my project and hope someone will please suggest how to debug this more effectively than I am doing now. This is basically the same question as <a href="https://stackoverflow.com/questions/72738672/pytest-incorrectly-reports-missing-lines-in-cove... | <python><pytest><tox><coverage.py><pytest-cov> | 2024-04-11 14:06:14 | 1 | 4,482 | chrisinmtown |
78,310,768 | 276,168 | numpy Polynomial.fit with degree zero produces unexpected result | <pre><code>import numpy as np
f = np.array(
[481.62900766, 511.94542042, 647.40216379, 686.10402156, 849.9420538, 888.64398048, 1029.26087049, 1071.18799217,
1210.51481107, 1266.63254274, 1409.54282743])
s = np.array(
[457.90057373, 520.90911865, 666.19372559, 709.64898682, 862.48828125, 892.19934082, 103... | <python><numpy><linear-regression><least-squares> | 2024-04-11 13:40:09 | 1 | 3,425 | Dženan |
78,310,673 | 8,430,733 | Dynamically change order of nested loops containing business logic in Python | <p>I'm developing a script for a lab instrumentation campaign. The instrument we're working with takes in various parameters such as x and y coordinates, power, delay, pulse, and so forth.</p>
<p>One crucial aspect of the operation involves 2d scanning an object, which requires iterating over both x and y coordinates. ... | <python> | 2024-04-11 13:23:49 | 2 | 1,011 | Raphael |
78,310,666 | 12,439,683 | Adjust yaml.Dumper to export dataclasses and their docstrings | <p>I would like to export dataclass objects <strong>including their docstrings</strong> (as <em>#</em> commented description above) to yaml.</p>
<p>So far I've figured out that I need a custom dumper or adjust the current one.</p>
<pre><code>from dataclasses import dataclass
@dataclass
class foo:
"""Thi... | <python><yaml><python-dataclasses><pyyaml><docstring> | 2024-04-11 13:23:12 | 1 | 5,101 | Daraan |
78,310,611 | 11,335,032 | Python typing Protocol with default | <p>I have a simple function which simply executes a callback:</p>
<pre class="lang-py prettyprint-override"><code>def callback(*, arg1: float | None = None) -> float:
return arg1 or 1.0
def callback2(*, arg1: int | None = None) -> int:
return arg1 or 1
def func(arg1 = callback, arg2 = None):
return ... | <python><python-typing> | 2024-04-11 13:16:50 | 2 | 3,335 | maxbachmann |
78,310,446 | 10,461,632 | Fixing mypy error - Incompatible types in assignment (expression has type "xxx", variable has type "yyy") | <p>I am running into the following <code>mypy</code> error and cannot figure out how to fix it.</p>
<pre><code>test.py:30: error: Incompatible types in assignment (expression has type "list[str] | list[Path]", variable has type "list[Path]") [assignment]
</code></pre>
<p>Code versions: <code>Python... | <python><mypy> | 2024-04-11 12:47:57 | 2 | 788 | Simon1 |
78,310,379 | 4,343,563 | How to convert multi-page PDF file to image without using pdf2Image? | <p>I am trying to use pdf2image to convert a multi-page PDF to since image variable like it is done in Textractor code so that I can use it in LazyDocument:</p>
<pre><code>import pdf2image
from pdf2image import convert_from_path, convert_from_bytes
import boto3
from textractcaller import call_textract, OutputConfig
fro... | <python><image><pdf><pdf2image> | 2024-04-11 12:35:59 | 1 | 700 | mjoy |
78,310,370 | 9,665,565 | Check internet button and print a message whether it is checked or not | <p>I am trying to do the following exercise: open <a href="https://www.google.com/about/careers/applications/jobs/results?location=Chile&location=Santiago%2C%20Chile" rel="nofollow noreferrer">this page</a> on Python, and check what happens when the "Remote eligible" button is on; are there positions disp... | <python><html><css><selenium-webdriver><web-scraping> | 2024-04-11 12:33:53 | 2 | 701 | Paula |
78,310,300 | 10,086,915 | Sympy mapping defined functions | <p>I have a userdefined language containing mathematical expressions in python syntax but with wrapper special mathematical functions, e.g.
instead of
<code>sqrt(y) - x</code> I have <code>_math.foo(y) - x</code></p>
<p>I want to be able to use sympy.parse_expr on these strings and handle them the same way.
I tried two... | <python><sympy> | 2024-04-11 12:20:14 | 1 | 638 | Max Ostrowski |
78,310,292 | 16,723,655 | Substitute numpy array values for specific index | <p>I have an image array (shape : 256, 256, 3).</p>
<p>There is an index as below.</p>
<pre><code>array([[ 2, 254],
[ 2, 255],
[ 3, 252],
...,
[148, 169],
[148, 170],
[149, 169]], dtype=int64)
</code></pre>
<p>I could know index values of image array with below code.</p>
<pr... | <python><numpy> | 2024-04-11 12:19:10 | 1 | 403 | MCPMH |
78,310,106 | 1,472,407 | Handling XML default namespace in Python using Pydantic | <p>I am trying to convert some JSON data into XML in Python using the Pydantic-XML library (<a href="https://pydantic-xml.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer">https://pydantic-xml.readthedocs.io/en/latest/index.html</a>). However, I am having trouble getting the default namespaces according to... | <python><xml><xml-namespaces><pydantic> | 2024-04-11 11:46:28 | 1 | 386 | dksr |
78,310,014 | 8,030,794 | Some manipulations with groupby Pandas | <p>I have this Dataframe</p>
<pre><code>import pandas as pd
import math
from pandas import Timestamp
Date = [Timestamp('2024-03-16 23:59:42'), Timestamp('2024-03-16 23:59:42'), Timestamp('2024-03-16 23:59:44'), Timestamp('2024-03-16 23:59:44'), Timestamp('2024-03-16 23:59:44'), Timestamp('2024-03-16 23:59:47'), Timest... | <python><pandas><group-by> | 2024-04-11 11:28:11 | 1 | 465 | Fresto |
78,309,826 | 536,262 | python playwright block inline elements | <p>I can block loading resources, but what about inline svgs:</p>
<pre><code>page.route(re.compile(r"\.(jpg|png|svg)$"), lambda route: route.abort())
page.goto(url)
</code></pre>
<p>This element:</p>
<pre><code><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16&q... | <python><css><playwright> | 2024-04-11 10:50:04 | 1 | 3,731 | MortenB |
78,309,687 | 7,495,742 | how to get textarea value in Python that doesn't have value field | <p>I'm trying to parse html page and get the value from a textarea, but i can't achieve it, i will put my code (i started with selenium but it didn't work either). I don't really understand where this value is in the DOM <a href="https://i.sstatic.net/xHWPq.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net... | <python><parsing><textarea><lxml><urllib> | 2024-04-11 10:23:17 | 2 | 357 | Garbez François |
78,309,521 | 4,551,325 | Dataframe column-wise replace values above cutoff with max values below cutoff | <p>I have a sample dataframe:</p>
<pre><code>import pandas as pd
df = pd.DataFrame({
'A': [10, 18, 30, 40],
'B': [50, 20, 40, 6]
})
</code></pre>
<p>Given a cutoff number, say, 25, how to replace all values above the cutoff with max values below cutoff column wise?</p>
<p>A working solution:</p>
<pre><code>impo... | <python><pandas><numpy> | 2024-04-11 09:58:07 | 2 | 1,755 | data-monkey |
78,309,513 | 824,624 | UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b when paring the downloaded json | <p>trying to parse json file on the web using python, but get into a problem saying :</p>
<blockquote>
<p>UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position
1: invalid start byte</p>
</blockquote>
<p>here is the code</p>
<pre><code>import json
import urllib.request
with urllib.request.urlopen('https:... | <python> | 2024-04-11 09:57:12 | 1 | 8,168 | user824624 |
78,309,501 | 1,942,868 | speed up by multiple rsync at the same time | <p>I am doing rsync command over internet.</p>
<p>however <code>rsync</code> is a bit slow ,and when I use multiple <code>rsync</code> total speed is faster.</p>
<p>So I made this script.</p>
<pre><code>import subprocess
cmd = "ssh root@my.hopto.org ls /media/"
output = subprocess.run(cmd,shell=True, capture... | <python><rsync> | 2024-04-11 09:53:49 | 0 | 12,599 | whitebear |
78,309,174 | 10,143,378 | Dash input number with thousand separator | <p>I have doing a simple Dash application, and I have one component to get the input from the User as an integer.</p>
<p>The issue is that the integer should be between 1,000,000 and 1,000,000,000. So for an easy way to read it, I would love to display the thousand separated by comma instead of 1000000 or 1000000000.</... | <python><plotly-dash> | 2024-04-11 08:53:17 | 2 | 576 | kilag |
78,309,170 | 6,221,742 | How to fix relative import module error in VSCode | <p>I am trying to import a local module in my code using VSCode in my langcahin app but I am getting the following error</p>
<p><a href="https://i.sstatic.net/XJp7d.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/XJp7d.png" alt="enter image description here" /></a></p>
<p>here is my file structure</p>
<p... | <python><visual-studio-code><langchain> | 2024-04-11 08:52:47 | 1 | 339 | AndCh |
78,309,105 | 2,633,803 | Python Pandas read CSV file where dd/mm/yyyy date is shown as mm/dd | <p>I've got a CSV file where it keeps the date column in the format of DD/MM, however, when I click the cell, the real value is in the format of DD/MM/YYYY.</p>
<p>For example:</p>
<pre><code>28/03; 182409; 7579480; 1000; 1100; 1200; 1300
28/03; 220000; 0480000; 1000; 1100; 1200; 1300
28/03; 220000; 0760000; 1000; 1100... | <python><pandas><date><openpyxl> | 2024-04-11 08:40:24 | 1 | 7,498 | ChangeMyName |
78,309,090 | 3,433,875 | Need help understanding how the xycoord axes system works in matplotlib | <p>I am always confused on how to annotate things in matplotlib and doing a deeper dive and discovered the magical world of the different coordinate systems that exist in matplotlib, but I am having trouble understanding it all.</p>
<p>Starting with the axes system, when annotating this is what I got so far:</p>
<pre><... | <python><matplotlib> | 2024-04-11 08:36:46 | 1 | 363 | ruthpozuelo |
78,309,015 | 16,798,185 | IPython installation on Mac | <p>I have uninstalled Anaconda on Mac and am now trying to install IPython using pip3.</p>
<p>When I try to install IPython, I get a prompt, "User for us-central1-python.pkg.dev: ". This asks for username and password. What should I enter here? I use <a href="https://en.wikipedia.org/wiki/Google_Cloud_Platfor... | <python><python-3.x><gsutil> | 2024-04-11 08:22:23 | 2 | 377 | user16798185 |
78,309,013 | 9,097,114 | changing xpath dynamically in selenium - python | <p>Hi Unable code / automate the python script in a loop with dynamically changing xpath's
So, each time i need to input the path manually.<br />
Below are the sample xpath's (actually i have more xpaths to input) and code</p>
<p>HTML Element looks like below:</p>
<pre><code><i data-v-36de69d2="" aria-labe... | <python><selenium-webdriver> | 2024-04-11 08:22:01 | 1 | 523 | san1 |
78,309,010 | 19,500,571 | Remove everything in string after the first occurrence of a word | <p>I have a dataframe with a column consisting of strings. I want to trim the strings in the column such that everything is removed after the <strong>first</strong> appearance of a given word. The words are in this list:</p>
<pre><code>words_to_trim_after = ['test', 'hello', 'very good']
</code></pre>
<p>So if I have a... | <python><pandas> | 2024-04-11 08:21:14 | 6 | 469 | TylerD |
78,308,942 | 13,491,504 | Plotting a surface over lines plotly | <p>I have this code snipped, that should plot a surface over a few lines:</p>
<pre><code>import plotly.graph_objects as go
import plotly.io as pio
import math
import numpy as np
t_changes = np.linspace((0.005*2*math.pi)/60 , (1*2*math.pi)/60 , 10)
omega_all = np.linspace((1*2*math.pi)/60 ,(12*2*math.pi)/60 , 10)
ma... | <python><plotly><surface> | 2024-04-11 08:04:44 | 1 | 637 | Mo711 |
78,308,826 | 3,114,229 | sphinx docstrings and vscode | <p>I have the following docstring:</p>
<pre><code>def test(foo):
"""this is my function
.. code-block:: python
cool function
now I should be outside the codeblock.
But I'm not?
.. code-block:: python
next function
I'm still inside the origi... | <python><visual-studio-code><python-sphinx><docstring> | 2024-04-11 07:42:06 | 1 | 419 | Martin |
78,308,640 | 1,332,690 | Spacy matching countries in messy data | <p>I have some natural language text that I am trying to parse using <code>spacy</code> but having a hard time getting this to cover all possible variations.</p>
<p>Data is basically a set of recommendations for a set of countries, embedded together in a single text block. I want to extract the list of countries and th... | <python><nlp><spacy> | 2024-04-11 06:59:41 | 1 | 41,578 | Charles Menguy |
78,308,420 | 2,545,680 | Is it possible for state["response"] not raise KeyError: 'response' when the property is not there | <p>I'm looking at <a href="https://github.com/langchain-ai/langgraph/blob/main/examples/plan-and-execute/plan-and-execute.ipynb" rel="nofollow noreferrer">this</a> example here under the <code>Create the Graph</code> section:</p>
<pre><code>class PlanExecute(TypedDict):
input: str
plan: List[str]
past_steps... | <python> | 2024-04-11 05:58:42 | 1 | 106,269 | Max Koretskyi |
78,308,325 | 15,751,564 | Convert pandas Dataframe to 3D numpy matrix | <p>I have a pandas.DataFrame as given below you can read it as pd.DataFrame(data_dict):</p>
<pre><code>data_dict =
{'Elevation': {0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1},
'Azimuth': {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 0, 6: 1, 7: 2, 8: 3, 9: 4},
'median': {0: 255,
1: 255,
2: 255,
3: 255,
4:... | <python><pandas><numpy> | 2024-04-11 05:21:59 | 1 | 1,398 | darth baba |
78,308,082 | 3,078,313 | import osgeo: ImportError: DLL load failed while importing _gdal | <p>I'm loading <code>osgeo</code> in a conda python environment. Initially I installed again <code>gdal</code> and <code>libgdal</code> according to <a href="https://gis.stackexchange.com/questions/461363/modulenotfounderror-no-module-named-gdal-in-ubuntu-20-04-and-python-3-8">this</a> post and seems to work. I'm using... | <python><conda><gdal><miniconda><osgeo> | 2024-04-11 03:38:02 | 1 | 1,358 | gonzalez.ivan90 |
78,307,771 | 312,444 | Deploying a python websocket client in GCP | <p>I need to consume a websocket server using a python client. I need to deploy this client in GCP. As I need to hold the connection, and maintain it open, it seems that the only way is to have a Virtual machine. Is there any other option?</p>
| <python><google-cloud-platform><websocket> | 2024-04-11 00:59:26 | 1 | 8,446 | p.magalhaes |
78,307,569 | 1,149,813 | selenium in python: ElementNotInteractableException -- Element could not be scrolled into view (but it is) | <p>I have the following bit of code in python: it opens firefox on a specified page, closes the "accept cookies" window, and scrolls down to click on a button "Carica Altro". When I click the button I get : <code>ElementNotInteractableException: Message: Element <button class="button button... | <python><selenium-webdriver><web-scraping> | 2024-04-10 23:27:46 | 2 | 2,211 | simona |
78,307,330 | 3,127,059 | Stream OpenCv frames as video pipeline with Gstreamer | <p>I have to read frames from RealSense camera and make an <code>RTSP server</code> to stream frames as video, so other clients (multiple) can be able to see the video.
Platform: Windows10.</p>
<p>For doing so it seems that I have to use <code>Gstreamer</code> backend of <code>OpenCv VideoWriter</code>.
I have done the... | <python><opencv><gstreamer><rtsp> | 2024-04-10 22:05:31 | 0 | 808 | JuanDYB |
78,307,146 | 14,606,046 | Selenium in python Unable to locate element error 404 | <p>I am trying to use selenium in python to click the load more button to show all the reviews in a specific webpage, however, I am encountering some issues when finding the button element in selenium which always return an ** Error: 404 - No Such Element: Unable to locate element**</p>
<pre><code>import requests
from ... | <python><selenium-webdriver><web-scraping> | 2024-04-10 21:13:40 | 1 | 6,003 | Kristkun |
78,307,104 | 8,006,721 | Python: How to get SSRS Report Subscriptions published by different user via API | <p>I'm using the SSRS API with Python 3 and need to get all reports and their subscriptions.</p>
<p><a href="https://app.swaggerhub.com/apis/microsoft-rs/SSRS/2.0#/info" rel="nofollow noreferrer">https://app.swaggerhub.com/apis/microsoft-rs/SSRS/2.0#/info</a></p>
<pre><code>from requests_negotiate_sspi import HttpNegot... | <python><python-3.x><reporting-services> | 2024-04-10 21:00:41 | 1 | 332 | sushi |
78,307,099 | 7,809,915 | Data scraping fails: Seeking assistance | <p>I attempted the following:</p>
<ul>
<li>Utilize the German stock exchange's API (<a href="https://api.boerse-frankfurt.de/v1/search/equity_search" rel="nofollow noreferrer">https://api.boerse-frankfurt.de/v1/search/equity_search</a>) to retrieve index values.</li>
<li>The API can be accessed externally using paramet... | <python><web-scraping><python-requests><http-headers><stock> | 2024-04-10 20:59:35 | 1 | 490 | M14 |
78,307,073 | 7,903,456 | LangChain agent parsing error with structured_chat_agent and Wikipedia tool, handle_parsing_errors hits limit | <p>I am trying to ask GPT 4 to use Wikipedia for a prompt, using agents and tools via LangChain.</p>
<p>The difficulty I'm running into is the book I've been using, <em>Developing Apps with GPT-4 and ChatGPT: Build Intelligent Chatbots, Content Generators, and More</em>, while published in 2023, already has code exampl... | <python><nlp><openai-api><langchain><large-language-model> | 2024-04-10 20:52:34 | 2 | 1,543 | Mark White |
78,307,014 | 2,514,130 | Is there a way to weigh datapoints when doing LOESS/LOWESS in Python | <p>I would like to run a LOWESS function where different data points have different weights, but I don't see how I can pass weights to the <code>lowess</code> function. Here's some example code of using <code>lowess</code> without weights.</p>
<pre><code>import numpy as np
import statsmodels.api as sm
import matplotlib... | <python><statistics><statsmodels> | 2024-04-10 20:38:35 | 1 | 5,573 | jss367 |
78,306,973 | 6,458,245 | Time complexity of bisect on ordered dict? | <p>Given this code snippet, can anyone tell me the time complexity?</p>
<pre><code>import collections
a = collections.OrderedDict()
for i in range(100):
a[i] = i
import bisect
ind = bisect.bisect_left(a.keys(), 45.3)
</code></pre>
<p>Initially it may appear O(log(n)). However, ordered dict does not implement a BST... | <python><time-complexity> | 2024-04-10 20:27:12 | 0 | 2,356 | JobHunter69 |
78,306,866 | 2,153,235 | Python rule for parsing integer formatting specifier? | <p>I am trying to understand code that uses the following expression</p>
<pre><code>f"{current_file_start_time.year}{current_file_start_time.month:02}{current_file_start_time.day:02}"
</code></pre>
<p>Here is a minimum working example, pasted from a Spyder console:</p>
<pre><code>from datetime import datetime... | <python><formatting> | 2024-04-10 20:05:28 | 1 | 1,265 | user2153235 |
78,306,821 | 11,650,254 | How to call python functions compiled to C in C++ (Cython)? | <h4>Problem</h4>
<p>Everybody extends python with C, but I need opposite scenario. I want to use code in <code>C++</code> project.</p>
<h4>Cythonize</h4>
<p>It kinda works. I did convert simple <code>.pyx</code> file to <code>.c</code> using <code>Cython</code>.
Function is super simple with only print.</p>
<pre class=... | <python><c++><cython> | 2024-04-10 19:55:58 | 0 | 301 | Grzegorz Krug |
78,306,687 | 1,677,381 | In a Jupyter notebook, create an object from a class referenced using a string to use with ray | <p>My 3.6.3 Jupyterlab notebook is running Python 3.10.11. I am trying to use Ray to implement some asymmetrical code. This would be simple, except that in my remote function I am trying to implement a class object using a string holding the class name.</p>
<p>We have a number of triggers, each trigger causing a specif... | <python><asynchronous><jupyter-notebook><ray> | 2024-04-10 19:25:13 | 1 | 363 | Calab |
78,306,590 | 5,790,653 | How to count each value occurrences while having the same value of another key | <p>This is a list I have:</p>
<pre class="lang-py prettyprint-override"><code>list1 = [
{'city': 'Tehran', 'street': 'Ferdowsi'},
{'city': 'Tabriz', 'street': 'Imam'},
{'city': 'Sari', 'street': 'Qaran'},
{'city': 'Tehran', 'street': 'Enghelab'},
{'city': 'Tabriz', 'street': 'Imam'},
{'city': 'T... | <python> | 2024-04-10 19:02:08 | 1 | 4,175 | Saeed |
78,306,583 | 1,903,852 | Pipenv install fails due to deprecated package | <p>I've got a python package with the following Pipfile:</p>
<pre><code>[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
boto3 = "*"
s3urls = "*"
tabulate = "*"
surfaceutils = {editable = true, git = "ssh://git.... | <python><pipenv> | 2024-04-10 19:00:07 | 0 | 2,431 | Joris Kinable |
78,306,109 | 10,025,674 | Key Error when having spaces and "\n" in multiline f-string | <p>Trying to format SPARQL queries in python using f-strings in order to build different queries from a template,
but i'm getting <strong>KeyError</strong> when i try to format a multiline string:</p>
<pre><code>query = f'''SELECT ?age
WHERE {{
wd:{0} wdt:{1} ?birthdate.
BIND(now() - ?birthdate AS ?age)
}}'''
</cod... | <python><string><sparql><multiline><f-string> | 2024-04-10 17:26:01 | 1 | 748 | m.rp |
78,305,989 | 13,142,245 | async / await useful when independent network calls shouldn't block each other | <p>My understanding of Python's asyncio library (and async functions for Python in general) is that it uses threads. These threads are not processes, so division of CPU and parallelization is not possible.</p>
<p>However, if an application method has two network calls, A and B, it might be appropriate. If A must fin... | <python><async-await><fastapi> | 2024-04-10 17:03:29 | 1 | 1,238 | jbuddy_13 |
78,305,920 | 16,717,009 | Is there a way to put multiple steps into a polars expression function? | <p>I've been learning how to write expression functions in polars which are wonderful for creating self-documenting chained operations. But I'm struggling with more complex functions. Let's say I want to replace a value in column <code>bar</code> with the first value in column <code>baz</code> when <code>baz</code> is ... | <python><dataframe><python-polars> | 2024-04-10 16:49:36 | 2 | 343 | MikeP |
78,305,882 | 1,934,902 | Boto3 delete ebs snapshots script ...error for parameter snapshotId is invalid. Expected: 'snap-...' | <p>My script is trying to delete ebs snapshots, but I've gotten stuck at this point due to this error. I am not sure what the solution is.</p>
<pre><code>import boto3
import pprint
from openpyxl import load_workbook
AWS_REGION = "ap-southeast-2"
ec2 = boto3.client('ec2', region_name = AWS_REGION)
wb = load_... | <python><amazon-web-services><boto3> | 2024-04-10 16:39:51 | 0 | 333 | ficestat |
78,305,761 | 8,262,535 | Mlflow log_figure deletes artifact | <p>I am running mlflow with autologging to track an xgboost model. By default, under artifacts it saves the model, requirements, and feature importances. Cool stuff I want to keep.
<a href="https://i.sstatic.net/Ps4AA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Ps4AA.png" alt="enter image description... | <python><scikit-learn><sklearn-pandas><mlflow><mlops> | 2024-04-10 16:16:10 | 1 | 385 | illan |
78,305,752 | 11,801,298 | How to interact with matplotlib chart in PyCharm? | <p>I want to see in PyCharm good old matplotlib window with options. I mean buttons on the bottom. They let me zoom chart and move from one part to another.</p>
<p><a href="https://i.sstatic.net/mwnNX.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/mwnNX.png" alt="enter image description here" /></a></p>... | <python><matplotlib><pycharm> | 2024-04-10 16:14:28 | 0 | 877 | Igor K. |
78,305,720 | 3,590,067 | How to overlap a geopandas dataframe with basemap? | <p>I have a shapefile that I read as a geopandas dataframe</p>
<pre><code>import geopandas as gpd
gdf = gpd.read_file('myfile.shp')
gdf.plot()
</code></pre>
<p><a href="https://i.sstatic.net/VZ4FD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/VZ4FD.png" alt="enter image description here" /></a></p>
<p>... | <python><dataframe><matplotlib><geopandas><matplotlib-basemap> | 2024-04-10 16:08:16 | 1 | 7,315 | emax |
78,305,634 | 613,365 | How can I make a video restart (loop) after it is done playing? | <p>I'm trying to make a video which will stay pause on the first frame for 5 second, then play until the end, and rewind (then stay on the first frame for 5 sec, then play again)</p>
<p>So far I have this code, which detects when the video is done playing, but it does not go back to the beginning, it just stay on the l... | <python><python-vlc> | 2024-04-10 15:53:32 | 0 | 11,333 | FMaz008 |
78,305,406 | 3,156,085 | How does `issubclass` usually determine that a class is a subclass of another? | <p>How does <code>issubclass(cls, base_cls)</code> work?</p>
<p>Checking whether <code>base_cls</code> is in <code>cls.__mro__</code> or not? Or is it something else or more complicated?</p>
<p><code>issubclass(cls, base_cls)</code> is implemented by <code>base_cls.__subclasscheck__(self, cls)</code> and can have a tot... | <python><inheritance> | 2024-04-10 15:15:01 | 1 | 15,848 | vmonteco |
78,305,343 | 1,422,096 | Difference between lstrip and removeprefix? | <p>Why is <code>removeprefix</code> needed to remove a prefix from a string (or <code>text[text.startswith(prefix) and len(prefix):]</code> for Python < 3.9, see <a href="https://stackoverflow.com/questions/16891340/remove-a-prefix-from-a-string/16892491#16892491">Remove a prefix from a string</a>), when it seems w... | <python> | 2024-04-10 15:03:05 | 1 | 47,388 | Basj |
78,305,307 | 10,143,378 | Calendar Dash component outside box | <p>I am facing an issue in my application dash, a screenshot will show it directly :</p>
<p><a href="https://i.sstatic.net/sEMrM.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/sEMrM.png" alt="enter image description here" /></a></p>
<p>You can see that Calendar days are going outside the box of the cale... | <python><html><css><plotly-dash> | 2024-04-10 14:55:06 | 1 | 576 | kilag |
78,305,085 | 6,850,901 | How do I get the number of dimensions (aka order or degree) of a tensor in PyTorch? | <p>If I have a PyTorch tensor such as</p>
<pre class="lang-py prettyprint-override"><code>t = torch.rand((2,3,4,5))
</code></pre>
<p>how do I get the number of dimensions of this tensor? In this case, it would be 4.</p>
| <python><pytorch><tensor> | 2024-04-10 14:18:16 | 1 | 1,488 | Oskar |
78,305,001 | 8,237,838 | Using geographical coordinates, given an arbitrary point, how to find the closest existing point on a linestring? | <p>I'm working with shapely and django-gis. I'm given a linestring with full coordinates and a point with rounded to 6 coordinates.</p>
<p>What I need is to find the index of the nearest existing point from my linestring from the given arbitrary point, the nearest point on the linestring and add at index + 1 the coordi... | <python><geolocation><geo><shapely> | 2024-04-10 14:05:52 | 2 | 1,920 | May.D |
78,304,896 | 13,330,700 | When reading environment variables in Python from Docker's --env-file argument, there is an added '\' to each '\n'. How to not have that extra '\'? | <p>I'm in the process of containerizing my Python app. Normally, I'd load in my <code>.env</code> file and use <code>dotenv</code> to read in the variable.</p>
<p>Example:</p>
<pre><code>from dotenv import load_dotenv
import os
def test_env():
load_dotenv()
print(f"private_key : {repr(os.environ.get('PRI... | <python><docker><environment-variables> | 2024-04-10 13:47:21 | 1 | 499 | mike_gundy123 |
78,304,830 | 1,703,316 | Correct way to unzip the staged file in the Snowflake python UDF | <p>I'm working on implementing PyTorch model inference in the Snowflake UDF/UDTF. I'm following the official example <a href="https://docs.snowflake.com/en/developer-guide/udf/python/udf-python-examples#unzipping-a-staged-file" rel="nofollow noreferrer">https://docs.snowflake.com/en/developer-guide/udf/python/udf-pytho... | <python><multithreading><snowflake-cloud-data-platform> | 2024-04-10 13:36:02 | 1 | 727 | stys |
78,304,579 | 2,281,159 | Jupyter Notebook running in a local pyenv does not see PIP installed packages | <p>I am trying to use <code>python,</code> <code>pyenv,</code> and 'jupyter' notebooks on my MacBook.</p>
<p>Everything seems configured to use my <code>pyenv properly,</code> but when I run the Jupyter notebook, it can't find some packages I installed with <code>pip.</code> They are confirmed as installed as they show... | <python><pip><jupyter><pyenv> | 2024-04-10 12:53:31 | 1 | 360 | Mark_Sagecy |
78,304,473 | 8,428,634 | LangChain E-Mails with LLM | <p>I am quite new to LangChain and Python as im mainly doing C# but i am interested in using AI on my own data.
So i wrote some python code using langchain that:</p>
<ol>
<li><p>Gets my Emails via IMAP</p>
</li>
<li><p>Creates JSON from my E-Mails (JSONLoader)</p>
</li>
<li><p>Creates a Vectordatabase where each mail i... | <python><langchain> | 2024-04-10 12:36:24 | 1 | 621 | CrazyEight |
78,304,167 | 13,806,869 | Why does calling pd.ExcelWriter in this way create an invalid file format or extension? | <p>I am trying to export two Pandas dataframes to the same Excel file, in different sheets.</p>
<p>The code below runs ok, but the file it creates has a size of 0kb. When I try to open it in Excel, I get the message "<em>Excel cannot open the file myfile.xlsx because the file format or file extension is not valid.... | <python><pandas><pandas.excelwriter> | 2024-04-10 11:43:58 | 1 | 521 | SRJCoding |
78,304,081 | 13,174,189 | How to group rows in dataset by two timestamps rage sizes? | <p>I have a dataframe with two timestamps:</p>
<pre><code>timestamp1 timestamp2
2022-02-18 2023-01-02
2022-02-19 2023-01-04
2022-02-21 2023-01-11
2022-03-11 2024-02-05
2022-03-12 2024-02-06
2022-03-30 2024-02-07
</... | <python><python-3.x><dataframe><algorithm><function> | 2024-04-10 11:25:00 | 1 | 1,199 | french_fries |
78,304,004 | 2,397,542 | Exclude a Flask view from session creation? | <p>I have a Flask app that uses Flask-Session to store session data in Redis between a few containers running as a Kubernetes Deployment. That's all working fine, but I recently started looking closer at the Redis database and noticed it has <em>way</em> more keys than I expected, and it seems that the readiness and me... | <python><flask><prometheus> | 2024-04-10 11:11:42 | 1 | 832 | AnotherHowie |
78,303,879 | 6,936,682 | Typing Pydantic mutated @field_validator property | <p>Consider the following Pydantic class:</p>
<pre><code>from pydantic import BaseModel, field_validator
class UserAttributes(BaseModel):
user_groups: list[str]
...
@field_validator("user_groups", mode="before")
@classmethod
def make_user_group_list(cls, user_groups: str) ->... | <python><pydantic> | 2024-04-10 10:48:24 | 0 | 1,970 | Jeppe Christensen |
78,303,796 | 9,251,158 | YouTube upload documentation code fails to get authenticated service due to OAuth2client AttributeError | <p>I am uploading videos to YouTube programmatically following <a href="https://developers.google.com/youtube/v3/guides/uploading_a_video" rel="nofollow noreferrer">the official guide</a>. This worked three weeks ago when I first tried and I logged into my account on a browswer for the OAuth2 flow.</p>
<p>Now my creden... | <python><python-3.x><youtube-data-api> | 2024-04-10 10:33:16 | 1 | 4,642 | ginjaemocoes |
78,303,788 | 6,915,206 | Django Error DisallowedHost at / Invalid HTTP_HOST header: 'xx.xx.xx.xx' again and again | <p><strong>Error:</strong>
<strong>DisallowedHost at /
Invalid HTTP_HOST header: '3.17.142.65'. You may need to add '3.17.142.65' to ALLOWED_HOSTS.</strong></p>
<p>I am trying to deploy my django site om AWS EC2 while deploying through github using git clone on AWS live cli. I am getting the following errors again and ... | <python><django><amazon-web-services> | 2024-04-10 10:32:02 | 2 | 563 | Rahul Verma |
78,303,706 | 5,170,442 | What is a simple way to round all floats in an f-string to the same number of digits in one step? | <p>I have a long f-string with containing many float values, all of which I want to round to the same number of digits. Is there a way to do this in one go or in a smart way, or do I need to specify the digits at for each one separately?</p>
<p>I know that I can round a value in an f-string using</p>
<pre class="lang-p... | <python><string-formatting><f-string> | 2024-04-10 10:18:44 | 3 | 653 | db_ |
78,303,605 | 5,303,909 | Node-gyp prebuild-install || node-gyp rebuild falling with python 3.12 | <p>I'm working on a <code>React Native Expo</code> project, and I'm encountering an error from node-gyp when I try to install or build dependencies. The error occurs because node-gyp expects <code>Python 3.10</code>, but my system has <code>Python 3.12</code> installed. I've found that using <code>Python 3.10</code> re... | <python><node.js><react-native><npm><node-gyp> | 2024-04-10 10:00:27 | 1 | 1,800 | NicoleZ |
78,303,223 | 8,849,755 | Python logging loop without new lines | <p>Is it possible to use the <code>logging</code> module to display information about the progress in a loop without printing hundreds of new lines?</p>
<p>Let me illustrate with this snippet:</p>
<pre class="lang-py prettyprint-override"><code>for n in range(99999999):
if n%99999 == 0:
msg = f'Completed {n... | <python><logging> | 2024-04-10 08:58:41 | 1 | 3,245 | user171780 |
78,303,180 | 5,462,743 | Update Azure Machine Learning Compute Instances with Python SDKv2 | <p>At first, I have some terraform code that will deploy compute instances for AML. But there's a lack of update of the terraform code so we can not add the option of schedules and auto shutdown. <a href="https://github.com/hashicorp/terraform-provider-azurerm/issues/20973" rel="nofollow noreferrer">https://github.com/... | <python><azure-machine-learning-service><azure-sdk-python> | 2024-04-10 08:50:13 | 1 | 1,033 | BeGreen |
78,303,059 | 5,378,816 | Is deletion of no longer needed helper functions pythonic? | <p>I saw a .py file like this:</p>
<pre><code>def _initmodule():
...
def api_func1(): pass
def api_func2(): pass
_initmodule()
del _initmodule # <--- pythonic?
</code></pre>
<p>The init function is run once and after that it is not needed any more and gets deleted.</p>
<p>Wondering if it is a pythonic/idiomat... | <python> | 2024-04-10 08:29:44 | 0 | 17,998 | VPfB |
78,302,788 | 16,723,655 | How can I make fastest calculation speed for given condition for numpy array? | <p>I made category as below.</p>
<pre><code>1~4 : 0
5~9 : 1
10~15 : 2
</code></pre>
<p>I have a numpy array as below.</p>
<pre><code>np.array([2, 5, 10, 13, 7, 9])
</code></pre>
<p>How can I make fastest way to change above numpy array based on given conditioin as below?</p>
<pre><code>np.array([0, 1, 2, 2, 1, 1])
</co... | <python><numpy> | 2024-04-10 07:36:06 | 3 | 403 | MCPMH |
78,302,751 | 16,723,655 | How can I get values of specific indexes for numpy array? | <p>I have a numpy array (shape : (256, 256, 3)) of image and</p>
<p>I have numpy array for indexing as below.</p>
<pre><code>array([[ 3, 230],
[ 3, 231],
[ 3, 232],
...,
[114, 151],
[115, 149],
[115, 150]], dtype=int64)
</code></pre>
<p>However, I want to get values of numpy... | <python><numpy> | 2024-04-10 07:29:18 | 1 | 403 | MCPMH |
78,302,239 | 5,026,136 | How to POST using RobinHood Crypto API in Python? | <p>I'm using the new RobinHood crypto API documented here: <a href="https://docs.robinhood.com/crypto/trading/#tag/Trading/operation/api_v1_post_crypto_trading_order" rel="nofollow noreferrer">https://docs.robinhood.com/crypto/trading/#tag/Trading/operation/api_v1_post_crypto_trading_order</a></p>
<p>I am successful wi... | <python><post><request> | 2024-04-10 05:19:49 | 2 | 4,392 | Elliptica |
78,301,994 | 11,748,924 | Pillow draw line with gradient color where the color gradually from darkgreen to the lime as y position is increased relatively from starting y point | <p>How to draw line in Pillow, but the color of line is gradually became lighter (from darkgreen) as every dot of line go to the bottom relatively from starting point (y increase)?</p>
<p>I expect there is argument like this:</p>
<pre><code>img = Image.new('RGB', (1024, 800))
draw = ImageDraw.Draw(img)
draw.line([(p1x... | <python><python-imaging-library> | 2024-04-10 03:24:29 | 0 | 1,252 | Muhammad Ikhwan Perwira |
78,301,926 | 1,757,464 | Asyncio: Creating a producer-consumer flow with async generator output | <p>I am trying to set up a asyncio program that takes as its input, one <code>AsyncGenerator</code> and returns data via another <code>AsyncGenerator</code>. Here's a sample program that illustrates the basic flow of data:</p>
<pre class="lang-py prettyprint-override"><code>from collections.abc import AsyncGenerator
im... | <python><python-asyncio> | 2024-04-10 02:54:22 | 2 | 6,534 | jhamman |
78,301,692 | 20,386,110 | Godot: Target position of Ball changes upon calling new instance | <p>I'm working on Breakout which is a game with a ball and you use a paddle to hit some bricks with the ball.</p>
<p>My starting position of the ball is in the middle of the screen and as soon as the game begins, the ball shoots downwards toward the paddle. I also have a script on the bottom wall of the main scene whic... | <python><game-development><godot><gdscript> | 2024-04-10 00:53:05 | 1 | 369 | Dagger |
78,301,490 | 8,653,226 | Distinguishing between the landmarks (left hand and right hand) | <p>I have been trying to distinguish between the landmark with the same number for the left-hand and right-hand in mediapipe and opencv. The problem is that we have 20 id numbers but for both hands we have 40 landmarks. Eventually I want to extract the coordinates of for example landmark#8 on the left-hand and right-ha... | <python><mediapipe><pose-estimation> | 2024-04-09 23:21:51 | 1 | 519 | Leo |
78,301,391 | 11,618,586 | Splitting and bracketing months based on number of weeks and determine the beginning of the month | <p>I want to define each month of the year based on the number of weeks so as to avoid the confusion due to some months having 30 or 31 days.
For example, Jan to Dec would be have weeks of the following configuration:</p>
<pre><code>Jan - 4 wks
Feb - 4 wks
Mar - 5 wks
Apr - 4 wks
May - 4 wks
Jun - 5 wks
and so on...
</... | <python><python-3.x><datetime><calendar> | 2024-04-09 22:44:42 | 0 | 1,264 | thentangler |
78,301,370 | 2,774,885 | python multiprocessing equivalent for lots of bash ampersands and redirects? | <p>I've got a script where the functionality I need has outgrown bash (or at least outgrown my desire to maintain it in bash) so I'm looking at how to do this in python instead.</p>
<p>I've looked through the multiprocessing documentation to my ability to understand it, and I'm still not entirely sure which combination... | <python><multiprocessing><job-control> | 2024-04-09 22:36:57 | 2 | 1,028 | ljwobker |
78,301,339 | 8,521,346 | How to train Hugging Face Model On Multiple Datasets? | <p>I am trying to fine tune a model based on two datasets, following the example on the Hugging Face website, I have my model training on the Yelp Review dataset, but I also want to train my model on the Short Jokes dataset.</p>
<p>These two datasets are picked just to eximplify that the datasets I would like to fine t... | <python><nlp><huggingface-transformers><bert-language-model><huggingface-datasets> | 2024-04-09 22:28:18 | 0 | 2,198 | Bigbob556677 |
78,301,269 | 3,614,578 | pip install private package 403 azure databricks | <p>I'm trying to install a package from a private jfrog artifactory repo using the following command</p>
<pre><code>pip install -i https://user:pass@com.jfrog.io/artifactory/api/pypi/private-pypi/simple --trusted-host com.jfrog.io private_package==0.1.1
</code></pre>
<p>and getting a 403 when running it within Azure Da... | <python><pip><azure-databricks><artifactory> | 2024-04-09 22:04:50 | 1 | 4,360 | gary69 |
78,301,202 | 19,299,757 | How to find the text from a label in selenium pytest | <p>I've a requirement to capture the payment ID from the text in an element using Selenium, python, pytest UI. The text is in the form, "Payment 3022594".</p>
<p>I was trying something like this.</p>
<pre><code>PAYMENT_ID_TEXT_XPATH = "//div[@class='BottomLayoutHeaderWrapper']//h5[text()='Payment']"... | <python><selenium-webdriver><pytest> | 2024-04-09 21:44:51 | 1 | 433 | Ram |
78,301,114 | 412,234 | Wrapping a class method in a callable vs an ordinary function | <p>I am trying to decorate class methods. When I use an ordinary function, it works fine. However, when I use a class that implements __call__, it fails for instance level functions despite behaving identically when not used at the instance level. Here is the SSCCE:</p>
<pre><code>import random
class C():
"&qu... | <python><class> | 2024-04-09 21:13:51 | 1 | 3,589 | Kevin Kostlan |
78,301,049 | 1,040,092 | How to replace HTML with dynamically generated content containing the JS let keyword? | <p>I am currently going through older projects and upgrading them use jQuery 3.7. Many of the web pages use AJAX to dynamically generate and render HTML pages through Flask. The AJAX worked previously without any issues. However, after upgrading to jQuery 3.7, I am having issues rendering the content when the template ... | <python><jquery><flask> | 2024-04-09 20:54:30 | 0 | 7,912 | Wondercricket |
78,300,949 | 4,674,706 | How to unpack a string into multiple columns in a Polars DataFrame using expressions? | <p>I have a Polars DataFrame containing a column with strings representing 'sparse' sector exposures, like this:</p>
<pre class="lang-py prettyprint-override"><code>df = pl.DataFrame(
pl.Series("sector_exposure", [
"Technology=0.207;Financials=0.090;Health Care=0.084;Consumer Discretionary=0.... | <python><dataframe><python-polars> | 2024-04-09 20:25:28 | 3 | 464 | Azmy Rajab |
78,300,945 | 5,981,529 | Which is considered better practice for defining range() for a loop in python? Using len() or a defined variable? | <p>Can't seem to find a answer for this. Which is considered better practice?</p>
<p>For example, let's say I have an array of length = 6. Let's also say that it is a sorting algorithm that changes in place and I need the indexes.</p>
<pre><code>for i in range(len(array)):
</code></pre>
<p>or</p>
<pre><code>for i in ra... | <python><for-loop><range> | 2024-04-09 20:24:56 | 1 | 356 | spacedustpi |
78,300,917 | 12,553,917 | Checking the size of a file that's being downloaded by the browser causes it to get duplicated | <p>I'm writing a script which needs to download a file by hitting a URL. It would be easy enough to curl the URL, but I need to be logged in to the site when doing it, and I've given up on trying to solve the problem of sending a curl request as a logged in user. So what I've settled on doing is opening the URL in the ... | <python><firefox><browser><download> | 2024-04-09 20:18:30 | 0 | 776 | Verpous |
78,300,874 | 2,030,532 | Memory leakage in python? | <p>I have python scripts that calls a function <code>foo</code> that performs some operations that uses say 10GB of memory and returns the small object <code>res</code> to the main program. After printing res I delete the res, but top shows the ipython process is sill using about 1GB of memory. How can I ensure the pro... | <python><memory> | 2024-04-09 20:06:30 | 2 | 3,874 | motam79 |
78,300,839 | 9,251,158 | How to set video details when uploading to YouTube with Python API client | <p>Follow-up on <a href="https://stackoverflow.com/questions/78267481/how-to-set-video-language-when-uploading-to-youtube-with-python-api-client">How to set video language when uploading to YouTube with Python API client</a>, after successfully setting the video language.</p>
<p>I am uploading videos to YouTube program... | <python><python-3.x><youtube><youtube-api><youtube-data-api> | 2024-04-09 19:58:47 | 1 | 4,642 | ginjaemocoes |
78,300,823 | 1,183,542 | pipenv return odd error when installing packages | <p>I am new to python. Have multiple versions of python installed on my mac. When trying to use pipenv to manage dependencies for a legacy project (3.6 <= python <3.8). I ran</p>
<pre><code>/Users/user/.pyenv/shims/pipenv --python /Users/user/.pyenv/versions/3.7.16/bin/python install --dev
</code></pre>
<p>and he... | <python><python-3.x><pipenv><pipenv-install> | 2024-04-09 19:55:12 | 1 | 2,214 | gigi2 |
78,300,681 | 1,934,902 | Remove quotes from beginning and end from list | <p>I have an excel spreadsheet that has a column of AWS EBS volumes that I want to use as a list to delete using my boto3 python script. The script displays the volumes with initial and trailing quotes. I am getting a malformed string error, and learned I have to strip out the initial and trailing quotes out, but I am ... | <python><boto3> | 2024-04-09 19:23:21 | 1 | 333 | ficestat |
78,300,456 | 10,465,835 | OR-Tools CP-SAT conditional constraint | <p>In the problem I am trying to solve, I have a list of length <em>n</em> of boolean variables called <strong>x</strong>. Given an integer <em>m</em> where <em>m < n</em>, I need to define these two constraints:</p>
<ul>
<li>if <code>LinearExpr.Sum(x[m:]) > 0</code> then <code>LinearExpr.Sum(x[:m]) == 0</code></... | <python><boolean-logic><or-tools><constraint-programming><cp-sat> | 2024-04-09 18:30:35 | 2 | 646 | Zufra |
78,300,439 | 12,547,996 | Counting commas in two columns and showing the count side by side | <p>Based on the sample dataframe below how can I get the comma count of two columns?</p>
<p>Sample data:</p>
<pre><code> ID City Zipcode
1 A,B,C,D 1,2,3,4
2 A,B 1,2
3 A 1
4 B,C 2,3
</code></pre>
<p>Desired output:</p>
<pre><code>City Zipcode City_Count Zipcode_Cou... | <python><count> | 2024-04-09 18:27:16 | 1 | 2,043 | Ed_Gravy |
78,300,413 | 9,357,484 | Two different Cudatoolkit version and PyTorch version for same Conda environment | <p><code>Conda list</code> returned the following configuration:</p>
<pre><code># packages in environment at /home/user/anaconda3/envs/experiment2:
#
# Name Version Build Channel
_libgcc_mutex 0.1 main
_openmp_mutex 5.1 ... | <python><pytorch> | 2024-04-09 18:19:37 | 0 | 3,446 | Encipher |
78,300,398 | 2,475,195 | Pandas - calculate time series delta from at least 2 days ago | <p>For every row in a <code>pandas</code> dataframe, I want to calculate: what's the fraction change from the row that's at least <code>n</code> (say 2) days ago. I want to implement this using <code>shift()</code> rather than <code>for</code> loops. Example below:</p>
<pre><code> x change
Date
202... | <python><pandas><numpy><time-series> | 2024-04-09 18:17:04 | 3 | 4,355 | Baron Yugovich |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.