QuestionId int64 74.8M 79.8M | UserId int64 56 29.4M | QuestionTitle stringlengths 15 150 | QuestionBody stringlengths 40 40.3k | Tags stringlengths 8 101 | CreationDate stringdate 2022-12-10 09:42:47 2025-11-01 19:08:18 | AnswerCount int64 0 44 | UserExpertiseLevel int64 301 888k | UserDisplayName stringlengths 3 30 ⌀ |
|---|---|---|---|---|---|---|---|---|
76,214,347 | 8,849,071 | Can I run an ORM module import in Django without setting up a database? | <p>in our application (a big monolith), we have a lot of "unit tests" that inherit from django <code>TestCase</code>. They are something like this:</p>
<pre><code>from django.test import TestCase
class SomeTestCase(TestCase):
def test_something(self):
self.assertTrue(1)
</code></pre>
<p>Running t... | <python><django><unit-testing><python-unittest> | 2023-05-10 01:26:39 | 1 | 2,163 | Antonio Gamiz Delgado |
76,214,242 | 8,281,276 | How does Flask flash message work and why does it require a cookie? | <p>A web framework, Flask, in Python has a functionality to flash messages. It requires to access signed cookie, but I'm not sure why it needs to access cookie. The document states as quoted below. When does it store and how? Does it need a cookie to identify which user is accessing?</p>
<blockquote>
<p>The flashing sy... | <python><flask> | 2023-05-10 00:55:24 | 0 | 1,676 | Wt.N |
76,214,137 | 240,443 | Homebrew Gstreamer, Python and video | <p>I am trying to go through the Gstreamer tutorial, but I got stuck on the first two already (<a href="https://gstreamer.freedesktop.org/documentation/tutorials/basic/hello-world.html?gi-language=python" rel="nofollow noreferrer">1st</a>, <a href="https://gstreamer.freedesktop.org/documentation/tutorials/basic/concept... | <python><macos><gstreamer><python-gstreamer> | 2023-05-10 00:19:03 | 1 | 199,494 | Amadan |
76,214,066 | 3,388,962 | How to plot time series data within a fixed period? | <p>Is it possible to plot time series data within a fixed time period?</p>
<p>Assume I have the following sample dataset:</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
date_rng = pd.date_range(start="1.1.2023", end="10.1.2023", freq="15T")
df = pd.DataFrame(date_r... | <python><plot><time-series><seaborn> | 2023-05-09 23:58:39 | 1 | 9,959 | normanius |
76,213,952 | 2,217,612 | In Python, how can I create an in-memory Kubernetes pod object by reading YAML? | <p>I have a Kubernetes pod YAML file. I want to read this file and create a Kubernetes pod object in memory, run some additional checks on this object and then submit this object to the K8s cluster.</p>
<p>I see some options such as <a href="https://github.com/kubernetes-client/python/blob/master/kubernetes/utils/creat... | <python><kubernetes> | 2023-05-09 23:23:30 | 0 | 327 | Shri Javadekar |
76,213,942 | 396,014 | numpy: how to smooth x,y,z values in columns of an array? | <p>I have accelerometer data—to keep it simple just acceleration—loaded into a numpy array like so (toy data; columns are x,y,z):</p>
<pre><code>import numpy as np
import pandas as pd
from scipy.interpolate import make_interp_spline, BSpline
idx = [1,2,3,4]
idx = np.array(idx,dtype=int)
accel = [[-0.7437,0.1118,-0.5367... | <python><arrays><numpy><spline> | 2023-05-09 23:21:17 | 2 | 1,001 | Steve |
76,213,873 | 6,664,872 | How to finetune a zero-shot model for text classification | <p>I need a model that is able to classify text for an unknown number of classes (i.e. the number might grow over time). The <a href="https://arxiv.org/abs/1909.00161" rel="nofollow noreferrer">entailment approach</a> for zero-shot text classification seems to be the solution to my problem, the model I tried <a href="h... | <python><nlp><huggingface-transformers> | 2023-05-09 23:01:11 | 1 | 19,975 | cronoik |
76,213,819 | 15,355,758 | AttributeError: module 'ray.rllib.algorithms.ppo' has no attribute 'DEFAULT_CONFIG' | <p>When running software on Python 3.8.16, I had to change "ray.rllib.agents.ppo" into "ray.rllib.algorithms.ppo". Now it throws:
AttributeError: module 'ray.rllib.algorithms.ppo' has no attribute 'DEFAULT_CONFIG'.</p>
<p>How this issue can be approached?
Thank you.</p>
| <python><attributeerror><ray> | 2023-05-09 22:44:46 | 1 | 351 | Fusen |
76,213,817 | 2,302,262 | Split a python class over multiple files | <p>There is a situation I constantly run into when refactoring python classes, and I am starting to wonder if I'm using some antipattern or if I'm missing some fundamental trick. The problem arises when I try to split large classes over multiple files, causing dependency pains.</p>
<p>Here is a small contrived example.... | <python><class> | 2023-05-09 22:43:16 | 2 | 2,294 | ElRudi |
76,213,791 | 1,096,900 | OpenTelemetry Python Metric Counter not picked up by Prometheus | <p>I have a simple python app, that I'm trying to use to learn about instrumentation. This is a short live app that I will run just by running <code>python3 app.py</code>, my goal is to keep track in metric counter about how many times I run this app, at least this is the goal for this simple app. But it seems like the... | <python><prometheus><metrics><instrumentation><open-telemetry> | 2023-05-09 22:35:43 | 0 | 4,113 | Harts |
76,213,724 | 2,897,989 | Displaying dynamic text on a Rect in PyGame | <p>I want to display a dynamically changing <code>energy</code> score text on a moving Rect in Pygame. I'm doing:</p>
<pre><code>class Creature(pygame.sprite.Sprite):
def __init__(self, x, y, color=RED, agent=None, size=(30, 20)):
super().__init__()
self.image = pygame.Surface([size[0], size[1]])
... | <python><pygame> | 2023-05-09 22:20:13 | 1 | 7,601 | lte__ |
76,213,664 | 8,849,755 | Plotly express contour | <p>Consider the following example of a heatmap plot taken from <a href="https://plotly.com/python/heatmaps/" rel="nofollow noreferrer">the documentation</a>:</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
import numpy as np
import plotly.express as px
# Create the index for the data frame
x = ... | <python><plotly><contour> | 2023-05-09 22:06:26 | 1 | 3,245 | user171780 |
76,213,501 | 21,865,432 | Python packages imported in editable mode can't be resolved by pylance in VSCode | <p>I have several Python packages developed locally, which I often use in VSCode projects. For these projects, I create a new virtualenv and install these packages with <code>pip install -e ../path/to/package</code>. This succeeds, and I can use these packages in the project. However, VSCode underlines the package's im... | <python><visual-studio-code> | 2023-05-09 21:31:04 | 2 | 353 | Austin de Coup-Crank |
76,213,486 | 11,922,765 | Python Parse weather station data to dataframe and save in Postgresql | <p>How do I pasre the following data obtained as result of API query into a column name (column units) followed by values as cell values.</p>
<pre><code>wea_data = [{'observation_time': '2023-05-09T15:55:00.000000+00:00',
'station': 'KCOF',
'weather_results': {'@id': 'https://api.weather.gov/stations/KCOF/observati... | <python><pandas><dataframe><numpy><parsing> | 2023-05-09 21:28:36 | 1 | 4,702 | Mainland |
76,213,454 | 11,748,924 | Hide Ultralytics' Yolov8 model.predict() output from terminal | <p>I have this output that was generated by <code>model.predict()</code></p>
<pre><code>0: 480x640 1 Hole, 234.1ms
Speed: 3.0ms preprocess, 234.1ms inference, 4.0ms postprocess per image at shape (1, 3, 640, 640)
0: 480x640 1 Hole, 193.6ms
Speed: 3.0ms preprocess, 193.6ms inference, 3.5ms postprocess per image at shap... | <python><output><stdout><yolo><yolov8> | 2023-05-09 21:23:28 | 2 | 1,252 | Muhammad Ikhwan Perwira |
76,213,385 | 2,540,204 | Geopandas gets creative when it can't find the street | <p>I have noticed an interesting behavior when when working with Geopandas. When Geopandas is fed a street that it presumably cannot find, it will somehow substitute an existing street that seems to be near the city of the address. See below input/output:</p>
<pre><code>> getGeoLoc(["2502 asdfasdf St, Albany ... | <python><geopandas><geopy> | 2023-05-09 21:09:21 | 1 | 2,703 | neanderslob |
76,213,367 | 13,630,879 | How to use gnupg python library within Docker container for AWS Lambda Function | <p>I am trying to run a python lambda function that is being deployed as a docker container. The purpose of the function is to connect to an ftp server, retrieve encrypted files, and then decrypt them. The part that is causing issues is the decryption. I am using <a href="https://gnupg.org/" rel="nofollow noreferrer">g... | <python><amazon-web-services><docker><aws-lambda><gnupg> | 2023-05-09 21:05:59 | 1 | 403 | Jeff Gruenbaum |
76,213,293 | 18,203,813 | Lock row for very large time interval on SqlAlchemy | <p>I have to lock a row for a long period of time, for example an hour. My code look like this:</p>
<pre><code>with get_orm().session() as session:
instance = session.query(Model).filter(Model.id=1).with_for_update().first()
very_slow_process() # duration: one hour
instance.retry = instance.retry +1
</code>... | <python><mysql><sqlalchemy> | 2023-05-09 20:49:57 | 0 | 399 | Pablo Estevez |
76,213,177 | 12,415,855 | VSCode / Pylance / Disable TypeChecking? | <p>I would like to disable the underlining of errors like .text in this example
<a href="https://i.sstatic.net/i2IKv.png" rel="noreferrer"><img src="https://i.sstatic.net/i2IKv.png" alt="enter image description here" /></a></p>
<p>But it would be ok for me when eg. driver is wrong written like that</p>
<p><a href="http... | <python><visual-studio-code><beautifulsoup><pylance> | 2023-05-09 20:28:38 | 3 | 1,515 | Rapid1898 |
76,213,164 | 19,506,623 | How to order big list in tabulate form to avoid memery error? | <p>I have the input list <code>data</code> like below, for which I'd like to tabulate based on letters order, locating each value in correct column for each row. The code below it works, but when I have a big input list (a <code>data</code> list with more than 10K sublists and <code>letters</code> list has about 12 ele... | <python><pandas><dataframe><list> | 2023-05-09 20:25:55 | 1 | 737 | Rasec Malkic |
76,213,077 | 981,981 | Extract joined urls but not if redirect exists | <p>I'm looking for a regex for extracting urls when they are not separated by a space or whatever, but keep the "redirect" ones a a complete url.</p>
<p>Let me show you an example:</p>
<pre><code>http://foo.barhttps://foo.bazhttp://foo.bar?url=http://foo.baz
</code></pre>
<p>should result in the following arr... | <python><regex> | 2023-05-09 20:12:45 | 2 | 2,975 | Guillaume Cisco |
76,213,011 | 11,064,604 | Pandas Centric Way to Find Previous Value in a Pandas Dataframe | <p>I have an ordered pandas dataframe called <strong>keys</strong> containing columns <code>group_1</code>, <code>group_2</code>, ..., <code>group_N</code>, and <code>number</code>.</p>
<p>I have a second, ordered, pandas dataframe called <strong>fill_in</strong> having identical columns but different values. For each... | <python><python-3.x><pandas><group-by> | 2023-05-09 20:04:30 | 2 | 353 | Ottpocket |
76,212,928 | 612,580 | Numpy: Packing N bits per byte | <p>I'm using numpy in GNURadio, where there are variable numbers of bits that should be packed into a given byte based on the type of modulation. Not really relevant for this question, but that's the background.</p>
<p>With numpy, how can I take an array of bits, and repack it into <code>N</code> bits per byte?</p>
<p>... | <python><numpy> | 2023-05-09 19:51:32 | 1 | 4,640 | Jordan |
76,212,720 | 9,403,794 | How to remove similar items from a list of lists | <p>EDITED DESCRIPTION:</p>
<blockquote>
<p>Let's say I have a set of linear functions. I am tasked with comparing
features. Let's say our "length" is going to be the slope of the
linear function. Let's say "multi" is going to be a factor of b. Now:</p>
<ol>
<li>I don't want to compare the same linea... | <python><list><product> | 2023-05-09 19:12:41 | 1 | 309 | luki |
76,212,641 | 5,942,100 | Tricky rounding conditional rounding conversions to dataframe using Pandas | <p>I wish to round each value under columns: Q1 24 - Q4 24 to the nearest even # with the exception if: the value is between 0.75 - 3 round to 2 , while creating a new column that captures
its sum.</p>
<p><strong>Data</strong></p>
<pre><code>state range type Q1 24 Q2 24 Q3 24 Q4 24 rounded_sum
NY ... | <python><pandas><numpy> | 2023-05-09 19:02:02 | 1 | 4,428 | Lynn |
76,212,538 | 15,481,917 | Python: how to schedule a task to happen after 1 hour? | <p>I am creating a user registration that requires an activation code. I want the activation code to expire after 1 hour, so I did this:</p>
<pre><code>def register(request):
form = CreateUserForm()
if request.method == "POST":
form = CreateUserForm(request.data)
if form.is_valid():
... | <python><django> | 2023-05-09 18:46:30 | 0 | 584 | Orl13 |
76,212,338 | 5,942,100 | Conditionally sum and round to nearest even value row by row using Pandas | <p>I wish to round the sum of a row of values to the nearest even number, except if the value is between 0.75 and 3, then the value should round to 2.</p>
<p><strong>Data</strong></p>
<pre><code>Location range type Q1 24 Q2 24 Q3 24 Q4 24
NY low SS 0 0.79 0 0
NY ... | <python><pandas><numpy> | 2023-05-09 18:17:03 | 4 | 4,428 | Lynn |
76,212,158 | 19,328,707 | Python - API request works in __init__ but not in function | <p>im implementing <code>api requests</code> to my tkinter app. At the <code>Gui Class init</code> there is one <code>api request</code> running that works without problems. But when im calling a <code>function</code> inside the <code>class</code> that is running the same <code>api request</code> im getting back an <co... | <python><tkinter> | 2023-05-09 17:50:44 | 1 | 326 | LiiVion |
76,212,145 | 15,559,492 | Exclude duplicate elements with lower priority (Django) | <p>I have the following model:</p>
<pre><code>class Action(BaseModel):
action_id = models.IntegerField(unique=True, db_index=True)
name = models.CharField(max_length=25)
object = models.CharField(max_length=25)
priority = models.IntegerField(default=0)
</code></pre>
<p>Suppose there are two 4 objects:</... | <python><django><django-orm> | 2023-05-09 17:49:22 | 1 | 426 | darl1ne |
76,212,128 | 7,700,802 | Create a dictionary from key value, where the keys and values are pair types | <p>Suppose I have this dictionary object</p>
<pre><code>{('ABE2', '170xi iii plus'): (1, '1178.55', 1178.55),
('ABE2', '170xi4+'): (1, '2844.12', 2844.12),
('ABE2', '1900gsr-1'): (30, '115.0', 3450.0)}
</code></pre>
<p>and I have a empty dataframe that looks like this</p>
<pre><code>df_test = pd.DataFrame(columns=['l... | <python><pandas> | 2023-05-09 17:47:02 | 3 | 480 | Wolfy |
76,212,084 | 5,790,653 | How to run a simple python http server as service | <p>This is my <code>script.py</code>:</p>
<pre><code>from http.server import HTTPServer, BaseHTTPRequestHandler
class Serv(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/':
self.path = '/index.html'
try:
file_to_open = open(self.path[1:]).read()
s... | <python><linux> | 2023-05-09 17:42:07 | 1 | 4,175 | Saeed |
76,212,074 | 16,978,454 | "Connection refused" Boost.Beast library for the C++ WebSocket client | <p>I have this Python code:</p>
<pre><code>Server.py
import asyncio
import websockets
import random
async def random_number(websocket, path):
while True:
number = random.randint(1, 100)
await websocket.send(str(number))
await asyncio.sleep(1)
start_server = websockets.serve(random_number,... | <python><c++><websocket><boost> | 2023-05-09 17:40:20 | 1 | 303 | IceCode |
76,211,854 | 4,377,095 | In Pandas how can I increment values correctly for each row and column | <p>assuming I have this table:</p>
<pre><code>data = {'column1': ['A1', 'A1', 'A1', 'A1'],
'column2': ['A2', 'A1', 'A2', 'A3'],
'column3': ['A1', 'A3', 'A3', 'A3'],
'column4': ['A4', 'A4', 'A1', 'A4'],
'column5': ['A5', 'A5', 'A5', 'A5']}
df = pd.DataFrame(data)
</code></pre>
<p>which l... | <python><pandas><dataframe> | 2023-05-09 17:08:35 | 1 | 537 | Led |
76,211,832 | 8,378,817 | Extract doi from multiple pages with scrapy | <p>I have this webpage (<a href="https://academic.oup.com/plphys/search-results?q=photosynthesis&allJournals=1&fl_SiteID=6323&page=1" rel="nofollow noreferrer">https://academic.oup.com/plphys/search-results?q=photosynthesis&allJournals=1&fl_SiteID=6323&page=1</a>) from which I want to extract in... | <python><web-scraping><beautifulsoup><scrapy><web-crawler> | 2023-05-09 17:05:47 | 1 | 365 | stackword_0 |
76,211,651 | 1,872,565 | Robotframework - AttributeError: 'str' object has no attribute '_parent' | <p>Iam working on the robotframework, i want to highlight the element on the page below is the code
i am getting the error</p>
<p>"AttributeError: 'str' object has no attribute '_parent' "</p>
<p>Below is the code,</p>
<pre><code>import time
def highlight(element):
"""Highlights (blinks) a... | <python><selenium-webdriver><robotframework> | 2023-05-09 16:41:40 | 1 | 947 | Learner |
76,211,473 | 396,014 | pandas accessing elements of the first row of a df | <p>I am still learning pandas and am trying to access the first element of the first row of a named array like so:</p>
<pre><code>import numpy as np
import pandas as pd
accel = [[-0.7437,0.1118,-0.6367],
[-0.7471,0.1162,-0.6338],
[-0.7437,0.1216,-0.6255]]
accel = np.array(accel,dtype=float)
angle = [... | <python><pandas> | 2023-05-09 16:17:51 | 2 | 1,001 | Steve |
76,211,456 | 373,121 | Intermittent PermissionError opening file in append mode in Python program | <p>I have a Python program that opens a text file in append mode (think of it being something like a log file) and writes some new output to it before closing it. Occasionally, a <code>PermissionError</code> exception is raised at the line <code>with open(log_file_path, "a") as f</code>.</p>
<p><strong>NB</st... | <python><file> | 2023-05-09 16:15:15 | 1 | 475 | Bob |
76,211,421 | 4,035,257 | Explicit formula for EWMA(n) in Python | <p>I have the following <code>pandas.core.series.Series</code>:
<code>x=pd.Series([17.39, 8.70, 2.90, 1.45, 1.45])</code> for <code>t=0,1,2,3,4</code>.
When I try <code>x.ewm(span=2).mean()</code> I get the following results:</p>
<p><code>17.39, 10.87, 5.35, 2.71, 1.86</code></p>
<p>My understanding is that <code>.ewm.... | <python><pandas><smoothing><moving-average><exponential> | 2023-05-09 16:11:05 | 1 | 362 | Telis |
76,211,404 | 21,346,793 | How to restrict user access to prevent visiting other user profiles | <p>In my app, no anonimus uzer can switch to another profile, he only should know the pers_id.
How can I forbid doing this?
my views.py:</p>
<pre><code>@login_required
def home(request):
pers_id = request.GET.get('pers_id', None)
if pers_id is None:
return redirect('/')
user_profile = Profile.objec... | <python><django><django-views><django-authentication> | 2023-05-09 16:09:19 | 0 | 400 | Ubuty_programmist_7 |
76,211,229 | 21,420,742 | Getting Count grouped by ID in Pandas | <p>I know their are extensive amount of answers and questions related to count, I just can't find the one I am looking for. I have a dataset about employment history and I need to see How many times the number 1 appears by ID grouped by manager.</p>
<p>DF</p>
<pre><code> ID Date Job Manager Full-Time
1... | <python><python-3.x><pandas><dataframe><count> | 2023-05-09 15:50:14 | 1 | 473 | Coding_Nubie |
76,211,013 | 10,481,744 | Standardize the text in the pandas column with some common string | <p>I have following DataFrame df</p>
<pre><code>id1 id2 text_column
key1 220 ABC corp
key1 220 ABC Pvt Ltd
key2 300 PQR Ltd
key2 300 PQR
key2 300 PQR something else
key2 400 XYZ company
</code></pre>
<p>I don't know what kind of text will be in the Text_Column, bu... | <python><pandas><nlp><text-processing> | 2023-05-09 15:29:52 | 1 | 340 | TLanni |
76,210,988 | 3,821,009 | Shorter way to simulate dropWhile in polars | <p>Say I have this:</p>
<pre class="lang-py prettyprint-override"><code>>>> import polars as pl
>>> df = pl.DataFrame(dict(j=[1,1,1,2,1,2,1,2,2], k=[1,2,3,4,5,6,7,8,9]))
>>> df
shape: (9, 2)
┌─────┬─────┐
│ j ┆ k │
│ --- ┆ --- │
│ i64 ┆ i64 │
╞═════╪═════╡
│ 1 ┆ 1 │
│ 1 ┆ 2 │
│ 1 ... | <python><dataframe><python-polars> | 2023-05-09 15:26:58 | 2 | 4,641 | levant pied |
76,210,895 | 15,067,358 | Issues installing packages from requirements.txt for Django project | <p>I'm working with Python 3.11.3 and I'm having difficulty installing from my requirements.txt file, this is what my output is:</p>
<pre><code>2023-05-09 10:04:59.539 [info] Running Env creation script: [
'c:\\Users\\alex\\AppData\\Local\\Programs\\Python\\Python311\\python.exe',
'c:\\Users\\alex\\.vscode\\extens... | <python><django><pip> | 2023-05-09 15:17:09 | 1 | 364 | code writer 3000 |
76,210,821 | 424,957 | How to plot a data on half of Y axis in log scale? | <p>At final, my son give this asnwer, <code>y = sqrt(y / 2)</code>, I think it is right answer, do you think so?
<a href="https://i.sstatic.net/PHhKb.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/PHhKb.jpg" alt="enter image description here" /></a>
At last, I found <code>y = sqrt(h) + log(0.5, 10)</cod... | <python><matplotlib> | 2023-05-09 15:10:16 | 1 | 2,509 | mikezang |
76,210,742 | 1,717,931 | PySpark concat a column of lists over a weekly or monthly timeperiod | <p>I am new to PySpark/Databricks. I have a question related to concatenating a column of lists based on weekly or monthly time-periods. Here is the code I have with expected results.</p>
<pre><code>dates = ['2023-04-01', '2023-04-02', '2023-04-03', '2023-04-04', '2023-04-05', '2023-04-06', '2023-04-07', '2023-04-08', ... | <python><pyspark><concatenation><aggregate> | 2023-05-09 15:01:09 | 2 | 2,501 | user1717931 |
76,210,727 | 15,452,601 | How to find out which object a name is resolved to at runtime | <p>To patch an object one needs to use the right path from the call site. This is sufficiently fiddly to get its own section in the <a href="https://docs.python.org/3/library/unittest.mock.html#id6" rel="nofollow noreferrer">unittest docs</a>.</p>
<p>Sometimes when this is a pain to figure out I'd rather just set a br... | <python><unit-testing><pytest><introspection><monkeypatching> | 2023-05-09 14:59:50 | 1 | 6,024 | 2e0byo |
76,210,610 | 7,253,901 | Replacing entire column value in Pandas series based on regex condition | <p><strong>What I need</strong></p>
<p>I need to replace an entire column value in a Pandas series, when the condition is met. For example, consider the following Series:</p>
<pre><code>d = ["foo", "bar", "bbl dklha", "bbl hoi", "bbl lala ho", "bbl ljhkh"]
ser... | <python><pandas> | 2023-05-09 14:48:18 | 3 | 2,825 | Psychotechnopath |
76,210,593 | 1,497,720 | Extract text from chat windows | <p>I tried to parse <a href="https://i.sstatic.net/gX4iX.png" rel="nofollow noreferrer">this image</a> attached followed,
<a href="https://i.sstatic.net/gX4iX.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/gX4iX.png" alt="enter image description here" /></a></p>
<p>with the desired outcome of</p>
<pre><... | <python><ocr><tesseract><python-tesseract> | 2023-05-09 14:45:58 | 1 | 18,765 | william007 |
76,210,582 | 17,561,414 | string indices must be integers ERROR python | <p>I have pyspark dataframe created this way:</p>
<pre><code>dfquery=sqlContext.sql("""
SELECT CONCAT('CAST(', target_column_name, ' AS ',
CASE
WHEN target_column_data_type IN ('NVARCHAR', 'VARCHAR', 'CHAR', 'NCHAR') THEN 'STRING'
WHEN target_column_data_typ... | <python><pyspark> | 2023-05-09 14:45:06 | 1 | 735 | Greencolor |
76,210,546 | 5,573,294 | Resolving conflicts in python library dependency versions in apache/airflow docker image (due to dbt-bigquery library) | <pre><code>#15 ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
#15 google-cloud-aiplatform 1.16.1 requires google-cloud-bigquery<3.0.0dev,>=1.15.0, but you have google-cloud-bigquery 3.1... | <python><dockerfile><conflicting-libraries><dbt-bigquery> | 2023-05-09 14:42:16 | 1 | 10,679 | Canovice |
76,210,399 | 3,399,638 | Inserting Python List to Pandas dataframe rows and setting row values to NaN | <p>Pandas way of inserting python list into specific Pandas dataframe column as new rows. After inserting, fil in the remaining values as NaN.</p>
<p>For example, the list appears simlar to the below:</p>
<pre><code>list_dates = ['2021-12-01', '2021-12-02', '2021-12-03', '2021-12-06', '2021-12-08']
</code></pre>
<p>The... | <python><pandas> | 2023-05-09 14:26:11 | 1 | 323 | billv1179 |
76,210,344 | 534,238 | Is it possible in Python to pass keyword arguments to a function and use them *only* if the function has them | <p>I am trying to make a functional map-like function which fully traverses a list or dict of arbitrary depth / shape, then map the provided function over it.</p>
<p>I have the map function working, and I have the function to feed to it working, but I do not like how "un-generalized" it is, in case I want to ... | <python><functional-programming> | 2023-05-09 14:20:34 | 1 | 3,558 | Mike Williamson |
76,210,258 | 42,508 | Fail to authorize my request when using TickTick API | <p>I'm using the API described <a href="https://developer.ticktick.com/docs/index.html#/openapi?id=getting-started" rel="nofollow noreferrer">here</a> , using the default Python version in Google Collab notebook.</p>
<p>I have a client_id created as they recommend, but I can't figure out how to get the token back witho... | <python><python-requests><openapi> | 2023-05-09 14:11:16 | 1 | 1,139 | akapulko2020 |
76,209,929 | 2,458,922 | Fast AI Api doc for leaner.fine_tune | <p>I was looking for FastAI API Docs.</p>
<p>I could see code as ,</p>
<pre><code>dls = ImageDataLoaders.from_name_func('.',
get_image_files(path), valid_pct=0.2, seed=42,
label_func=is_cat,
item_tfms=Resize(192)) # Data Loader
learner = vision_learner(dls, resnet18, metrics=error_rate)
learner.fine_tune(3... | <python><pytorch><fast-ai> | 2023-05-09 13:32:28 | 1 | 1,731 | user2458922 |
76,209,871 | 9,008,261 | How to create a DataFrame if the executor nodes do not have python | <p>Due to a limitation in the hadoop cluster I am using with YARN, the execute nodes do not have python.</p>
<pre class="lang-py prettyprint-override"><code>df = spark.createDataFrame([[0]], ['foo'])
print(df)
df.collect()
</code></pre>
<pre><code>DataFrame[foo: bigint]
... java.io.IOException: Cannot run program "... | <python><scala><apache-spark><pyspark> | 2023-05-09 13:26:14 | 0 | 305 | Todd Sierens |
76,209,744 | 4,665,335 | Unable to test a celery chain when tasks are executed by different celery apps | <p>I have two celery apps in my environment that are :</p>
<pre class="lang-py prettyprint-override"><code>app1 = Celery('app1', broker=BROKER_URL1, backend=BROKER_URL1)
app2 = Celery('app2', broker=BROKER_URL2, backend=BROKER_URL2)
</code></pre>
<p>From a Django app within a <code>web</code> container I need to call a... | <python><django><testing><celery><django-celery> | 2023-05-09 13:10:59 | 1 | 400 | michal111 |
76,209,695 | 3,104,621 | Pipe two subprocesses in Python with asyncio and interrupt them | <p>I have two subprocesses launched by my <code>asyncio</code>-based Python code with <code>asyncio.create_subprocess_exec</code>. I want one to output data to stdout and the other one to read it through a pipe as soon as it's available (in my case, the first process outputs video frames and the second process encodes ... | <python><subprocess><python-asyncio> | 2023-05-09 13:06:23 | 1 | 1,134 | Joald |
76,209,600 | 9,470,099 | SSH Remote Port Forwarding using Python | <p>I am trying to expose a local port on my laptop to be accessed by everyone through Python, this python script will be run by someone without ssh installed (Windows). I try to use <code>paramiko</code> module but it only allow me to do Local port forwarding.</p>
<pre class="lang-py prettyprint-override"><code>import ... | <python><ssh><paramiko> | 2023-05-09 12:55:26 | 0 | 4,965 | Jeeva |
76,209,426 | 2,399,158 | Running an keyword on Robotframework throw an error: ValueError: Timeout value connect was <object object at 0x106cc5b50> | <p>When I try to launch an app from robotframework using appium</p>
<p>I got the following error</p>
<pre><code>ValueError: Timeout value connect was <object object at 0x106cc5b50>, but it must be an int, float or None.
</code></pre>
<p>This never happen. I do not know the reason why, all I did is just trying a s... | <python><robotframework> | 2023-05-09 12:34:27 | 3 | 591 | user2399158 |
76,209,235 | 1,186,739 | Pandas styling of rows | <p>Hi I am trying to style a pandas data frame based on some condition and write the output to excel. I followed the solution here and got it partially done: <a href="https://stackoverflow.com/questions/57574409/applying-style-to-a-pandas-dataframe-row-wise">applying-style-to-a-pandas-dataframe-row-wise</a>.</p>
<p>But... | <python><pandas><dataframe><pandas-styles> | 2023-05-09 12:12:33 | 2 | 391 | Soumya |
76,209,122 | 509,868 | How to detect a Windows network path? | <p>I am writing a script which runs a Windows executable file in a directory supplied by a user. If this script is a network path, making it the current directory will look like it worked, but running any commands in this directory will fail:</p>
<pre><code>>>> import os
>>> os.chdir(r'\\server\share\... | <python><windows><path> | 2023-05-09 12:02:29 | 3 | 28,630 | anatolyg |
76,209,050 | 9,457,900 | unable to consume asynchronous msg from producer & consumer | <p>Kafka , zookeeper is running successfully</p>
<p>This is my producer.py</p>
<pre><code>async def publish():
producer = AIOKafkaProducer(bootstrap_servers='localhost:9092',
enable_idempotence=True)
await producer.start()
consumer = AIOKafkaConsumer(
topicAKG,
bootstrap_servers='localhost:90... | <python><apache-kafka><aiokafka> | 2023-05-09 11:55:06 | 1 | 2,644 | Tanjin Alam |
76,208,898 | 487,993 | Docstring for toml file in Python | <p>Since 3.11, Python <a href="https://docs.python.org/3/library/tomllib.html" rel="nofollow noreferrer">tomblib</a> provides support for TOML files.
I would like to know if there is a way to add docstrings to the fields in the TOML file.</p>
<p>In particular, to be rendered with Sphinx.
I am looking for something like... | <python><python-sphinx><documentation-generation><toml> | 2023-05-09 11:37:21 | 0 | 801 | JuanPi |
76,208,784 | 5,015,382 | Docker on GCloud Vertex AI: We receive no predictions in our answer | <p>We try to deploy a Docker container on Google Cloud Vertex AI. However, every time we send a request to the Vertex AI, we only get a response with the model specifications but not the predictions by the model (see picture)</p>
<p><a href="https://i.sstatic.net/gPuVz.png" rel="nofollow noreferrer"><img src="https://i... | <python><docker><google-cloud-platform><google-cloud-vertex-ai> | 2023-05-09 11:23:34 | 1 | 452 | Jan Janiszewski |
76,208,676 | 5,834,316 | How to count throttled requests on a per endpoint in Locust? | <p>I am currently creating a custom TUI dashboard to extend the data I can see in the terminal with <a href="https://locust.io/" rel="nofollow noreferrer">locust</a>.</p>
<p>Currently, I am using the following logic to capture all data:</p>
<pre class="lang-py prettyprint-override"><code>@events.init.add_listener
def o... | <python><load-testing><metrics><locust> | 2023-05-09 11:09:50 | 1 | 1,177 | David Ross |
76,208,396 | 15,518,834 | Pyrebase4 error cannot import name 'gaecontrib' | <p>I have been trying to install <code>pyrebase4</code> using <code>pip install pyrebase4</code> but when ran it throws below error</p>
<p><code>"C:\Users\ChodDungaTujheMadhadchod\anaconda3\envs\sam_upgraded\lib\site-packages\requests_toolbelt\adapters\appengine.py", line 42, in <module> from .._compat ... | <python><pyrebase><python-requests-toolbelt> | 2023-05-09 10:34:37 | 2 | 564 | Hack Try |
76,208,229 | 405,818 | Aggregate and group dataframe rows in python | <pre><code># import the module
import pandas as pd
# creating a DataFrame
df = pd.DataFrame({'name' :['C1', 'C2', 'C3', 'C4', 'C5'],
'Size' :[200, 70, 60, 140, 40],
"CPU":[25.7, 5.1, 6.2, 15.1, 10]})
df
</code></pre>
<p>#Need to find rows where the sum of Size <= 100... | <python><dataframe><optimization><linear-programming> | 2023-05-09 10:14:54 | 1 | 7,065 | Amit |
76,208,111 | 13,154,650 | python serial communication stops until ctrl c | <p>I want to print what is coming on my serial port on Windows, I have tried this on linux before and haven't had problems. This is my code</p>
<pre class="lang-py prettyprint-override"><code>import serial
ser = serial.Serial(
port="COM4", baudrate=115200, bytesize=8, timeout=0.1, stopbits=serial.STOPBIT... | <python><windows><pyserial> | 2023-05-09 10:02:01 | 0 | 450 | afvmil |
76,207,954 | 17,596,179 | Importing from few directories down python | <p>This is my file structure.</p>
<pre><code>- scraper_backend
- jobs
- bronze
- extract_bronze.py
-tests
- jobs
- bronze
- extract_bronze_test.py
</code></pre>
<p>Now when I try to import this <code>extract_bronze.py</code> file I get this error.</p>
<pre><code>Impor... | <python><python-3.x><modulenotfounderror> | 2023-05-09 09:46:13 | 0 | 437 | david backx |
76,207,832 | 1,293,127 | How to use S3 in China? | <p>I have a Python app that uses boto3 to list & read objects from AWS S3 buckets:</p>
<pre class="lang-py prettyprint-override"><code>session = boto3.session.Session(aws_access_key_id=XYZ, aws_secret_access_key=ABC)
client = session.resource('s3').meta.client
listing = client.list_objects(…)
</code></pre>
<p>The a... | <python><python-3.x><amazon-web-services><amazon-s3><boto3> | 2023-05-09 09:32:09 | 1 | 8,721 | user124114 |
76,207,766 | 16,389,095 | Kivy/KivyMD : How to reset a drop down item to its original state before the user selection | <p>I developed a simple app in Kivy/KivyMD/Python. The interface contains only a DropDownItem ddi and a button. The ddi displays a text, that acts as a header, and a menu with three options. Once the user selects one of the three options, the button should reset the ddi to its original state: in other words, when the b... | <python><kivy><kivy-language><kivymd> | 2023-05-09 09:25:14 | 2 | 421 | eljamba |
76,207,660 | 2,966,197 | 'PandasExcelReader' object has no attribute '_concat_rows' in llama-index excel reader | <p>I am trying to read an excel file with multiple sheets using llama-index. Here is my code:</p>
<pre><code>from pathlib import Path
from llama_index import download_loader
PandasExcelReader = download_loader("PandasExcelReader")
loader = PandasExcelReader()
documents = loader.load_data(file=Path('dir1/exc... | <python><excel><llama-index> | 2023-05-09 09:15:15 | 1 | 3,003 | user2966197 |
76,207,581 | 12,990,185 | Python - list of lists - check if unique combination of values has last different value in the list | <p>we have a list of lists</p>
<pre><code>links_list = [['project1','repo1', 'folder1', 'target1', 'link1', 'branch1'],
['project1', 'repo1', 'folder1', 'target1', 'link1', 'branch1'],
['project1', 'repo1', 'folder1', 'target1', 'link1', 'branch2'],
['project2', 'repo2', 'folder... | <python><python-3.8> | 2023-05-09 09:05:47 | 2 | 1,260 | vel |
76,207,539 | 14,427,714 | How to scroll popup dialog in instagram and scrape followers? | <p>I am trying to scrape followers from an account. I did everything but I am stuck is scrolling the popup dialog. When I click the followers button a popup comes. Then I have to scroll down to the end and scrape all the followers name.</p>
<p>Here is my code:</p>
<pre><code>driver = webdriver.Chrome()
driver.get("... | <python><selenium-webdriver><web-scraping> | 2023-05-09 09:01:35 | 0 | 549 | Sakib ovi |
76,207,341 | 5,547,553 | How to get first n chars from a str column in python polars? | <p>What's the alternative of pandas :</p>
<pre><code>data['ColumnA'].str[:2]
</code></pre>
<p>in python polars?</p>
<pre><code>pl.col('ColumnA').str[:3]
</code></pre>
<p>throws <code>TypeError: 'ExprStringNameSpace' object is not subscriptable
</code>
error.</p>
| <python><dataframe><python-polars> | 2023-05-09 08:36:47 | 2 | 1,174 | lmocsi |
76,207,323 | 14,256,643 | While storing pdf text in csv how to avoid spreading text to multiple row | <p>I am storing pdf text (extracted with pypdf) in a CSV file. the problem is few pdf file is very long and the text spreads into multiple rows for those long pdf file instead of keeping a single row. How to keep them in a single row? here my output looks like</p>
<pre><code>column1 column2
long pdf ... | <python><python-3.x><pdf><pypdf> | 2023-05-09 08:32:43 | 1 | 1,647 | boyenec |
76,207,071 | 10,232,932 | Sktime TimeSeriesSplit with pandas dataframe | <p>I try to use <code>cross-validation</code>with a timeseries for a pandas dataframe with the <code>sktime</code> <code>TimeSeriesSplit</code>. The dataframe <code>df</code> has a daily format:</p>
<pre><code> timepoint balance
0 2017-03-01 1.0
1 2017-04-01 0.0
2 2017-05-01 2.0
3 2017-06-01 3.0
4 2... | <python><pandas><dataframe><scikit-learn><time-series> | 2023-05-09 07:58:15 | 2 | 6,338 | PV8 |
76,206,987 | 2,932,907 | Group together key value pairs in dictionary with a common value | <p>Given the following dictionary:</p>
<pre><code> my_dict = {
'Admin.Email': 'admin@domein.nl',
'Admin.Name': 'Admin Account',
'Admin.Phone': '+31 6 12345678',
'Admin.RipeID': 'nan',
'Loc.Address': 'Testraat 100',
'Loc.Country': 'Nederland',
'Loc.Place': 'Plaatsnaam',
'Loc.Postalcode': '1234AB',
'Org.Address'... | <python><dictionary> | 2023-05-09 07:48:31 | 1 | 503 | Beeelze |
76,206,956 | 3,016,709 | Map two mixed columns with another dataframe | <p>I have a dataframe where two columns, <code>User</code> and <code>Code</code>, have their values mixed or not correctly filled.</p>
<pre><code>df = pd.DataFrame({"User":['Dan', 'Mary','003','010','Luke','Peter'],"Code":['001','035','003','Martin','Luke','AAA'],"Job":['astronaut','biolog... | <python><pandas><dataframe><mapping> | 2023-05-09 07:44:17 | 1 | 371 | LRD |
76,206,927 | 2,966,197 | Wrong output in writing list of pandas dataframe to separate sheets in same excel | <p>I have a code where I am using <code>tabula-py</code> to read tables from pdf and then write the resulting list of <code>dataframes</code> to a single excel with each <code>dataframe</code> in a separate sheet.</p>
<p>Here is my current code:</p>
<pre><code>def read_pdf(pdf_file):
output_filepath = "ou... | <python><pandas><excel><tabula-py> | 2023-05-09 07:40:43 | 2 | 3,003 | user2966197 |
76,206,905 | 9,202,251 | Sympy does not seem to integrate exponentials of the variable (MATLAB does it) | <p>I am trying to integrate my function S(w)</p>
<pre><code>import sympy as sym
w = sym.Symbol('w')
Spm = 0.95**4/w**5*sym.exp(-5/4*(0.95/w)**4)
S = sym.Piecewise(
(Spm**sym.exp(-1/2*((w-0.95)/(0.07*0.95))**2), w<=0.95),
(Spm**sym.exp(-1/2*((w-0.95)/(0.09*0.95))**2), w>0.95))
S_int = sym.integrate(S... | <python><python-3.x><numpy><matlab><sympy> | 2023-05-09 07:37:58 | 1 | 490 | J. Serra |
76,206,798 | 3,734,059 | How to throw a validation error with Pydantic StrictFloat on float("nan")? | <p>I am using Pydantic's <a href="https://docs.pydantic.dev/latest/usage/types/#strict-types" rel="nofollow noreferrer">strict types</a> and want to throw an error when a <code>StrictFloat</code> field is assigned a <code>float("nan")</code> value.</p>
<p>Here's an example:</p>
<pre class="lang-py prettyprint... | <python><pydantic> | 2023-05-09 07:22:54 | 2 | 6,977 | Cord Kaldemeyer |
76,206,666 | 11,748,924 | Unable to display mp4 after process video opencv | <p>I have this code</p>
<pre><code>import cv2
from .inference import inference
def create_video_from_frames(frames, output_path, fps):
# Get the dimensions of the first frame
height, width, _ = frames[0].shape
# Resize all frames to have the same dimensions
resized_frames = [cv2.resize(frame, (width, height)... | <python><opencv><video><mp4> | 2023-05-09 07:05:20 | 0 | 1,252 | Muhammad Ikhwan Perwira |
76,206,605 | 3,943,600 | python setup.py with root folder directories | <p>I have a python project folder with a setup.py in below structure.</p>
<pre><code>root
|_app
|__main.py__
|__init.py__
|_ other.py files
|_inputs
|_.py files
|_logger
|_.py files
|_setup.py
</code></pre>
<p>I need to package all these folders into one directory when build the list in following format.... | <python><setup.py> | 2023-05-09 06:55:52 | 0 | 2,676 | codebot |
76,206,579 | 5,800,969 | How to use aws_lambda_powertools logger to filter/disable specific api endpoint logs like health check /ping api | <p>I tried to follow this general logging class filter() method but the method doesn't exist in aws_lambda_powertools logging and it throws an error. I am doing this to discard <code>INFO: 127.0.0.1:51927 - "GET /ping HTTP/1.1" 200 OK</code> rows in the aws cloud watch log as it gets fired every 20 sec t... | <python><logging><amazon-cloudwatchlogs><health-check><aws-lambda-powertools> | 2023-05-09 06:52:42 | 2 | 2,071 | iamabhaykmr |
76,206,555 | 9,990,621 | How to know my Python script is being run by another script or directly in a shell? | <p>I have this Python script for formatting and coloring output:</p>
<pre><code>def error(message):
print(f"\033[91m{message}\033[00m")
def warning(message):
print(f"\033[93m{message}\033[00m")
def info(message):
print(f"\033[96m{message}\033[00m")
def success(message):
... | <python> | 2023-05-09 06:48:48 | 1 | 339 | Fatemeh motlagh |
76,206,290 | 2,156,784 | Unable to query BigQuery data in Apache Superset - queries executed successfully at BigQuery but results not returned at Superset | <p>Unable to query BigQuery data. I could see the executed queries at the BigQuery project history. Even simple SQL statements are not returning results at Superset.</p>
<p><strong>How to reproduce the error:</strong></p>
<ul>
<li>Installed latest version of Apache Superset (2.1) & tried with older previous version... | <python><flask><google-bigquery><sqlalchemy><apache-superset> | 2023-05-09 06:05:15 | 0 | 1,412 | Rathish Kumar B |
76,206,099 | 12,017,769 | imblearn library BorderlineSMOTE module does not generate any synthetic data | <p>I tried to generate synthetic data with Border line SMOTE in imblearn library but no synthetic data was generated. I am working with a multiclass based dataset, for purposes of generating data I split my dataframe into the minority class and majority class such like binary classification. Then I put the features to ... | <python><imblearn><smote><oversampling> | 2023-05-09 05:27:59 | 1 | 1,243 | Dulangi_Kanchana |
76,206,069 | 4,314,265 | Python Interpreter can't import files until exited and restarted | <p>I have my python files all saved in one directory ('F:\code').</p>
<p>When I enter the Python interpreter from the Windows command prompt :</p>
<pre><code>F:\python
>>>
</code></pre>
<p>I can import any .py files created when I entered the interpreter. But I can't import any files created after the interpre... | <python><import><module><interpreter><restart> | 2023-05-09 05:20:32 | 0 | 434 | Jeeves |
76,205,988 | 16,780,162 | Why my views.py doesn't save submitted csv file in data folder in my app directory in Django project? | <p>Hello I am working on a project Django.</p>
<p>I am trying to save a file after users submits it from webpage.</p>
<p>I created views and HTML..</p>
<p>part of the views.py, html and urls.py are provided below.</p>
<p>Can i get some help why my code is not saving file in data folder in my app directory?</p>
<p>views... | <python><django><server><django-views><http-post> | 2023-05-09 05:02:44 | 1 | 332 | Codeholic |
76,205,844 | 1,187,968 | Python: pip install pip install --platform manylinux_2_28_x86_64 --only-binary=:all: | <p>I'm using this pip command to install a binary version of cryptography.</p>
<p><code>python3.9 -m pip install --platform manylinux_2_28_x86_64 --only-binary=:all: cryptography -t build</code></p>
<p>However, I'm getting the following error. How should I fix it without version locking?</p>
<pre><code>Collecting cryp... | <python><pip> | 2023-05-09 04:25:44 | 1 | 8,146 | user1187968 |
76,205,611 | 1,734,097 | Python Dataframe Tuple to insert data | <p>i have the following <code>tuple</code> in python <code>dataframe</code>:</p>
<pre><code> (array(['2023-04-01', '2023-06-01',
'item1', 10, 2,
'Promo1', 'NULL'], dtype=object),
array(['2023-04-01', '2023-06-01',
'item2', 10, 2,
'Promo1', 'NULL'], dtype=object),
array(['2023-04-01'... | <python><dataframe><tuples> | 2023-05-09 03:15:58 | 1 | 1,099 | Cignitor |
76,205,494 | 8,321,207 | shifting columns in dataframe and adding zeros at the start | <p>I have a data frame with more than 700 columns. I have an array whose length is equal to the rows of data frame so each array value corresponds to one row of data frame. the value in the array is basically a random column from the data frame. This is what I am looking for:</p>
<p>I want to shift all the columns ment... | <python><pandas><dataframe> | 2023-05-09 02:36:19 | 2 | 375 | Kathan Vyas |
76,205,477 | 3,532,564 | Local Jax variable not updating in `jit`ted function, but updating in standard? | <p>So, I've got some code and I could really use help deciphering the behavior and how to get it to do what I want.</p>
<p>See my code as follows:</p>
<pre class="lang-py prettyprint-override"><code>from typing import Callable, List
import chex
import jax.numpy as jnp
import jax
Weights = List[jnp.ndarray]
@chex.da... | <python><jax> | 2023-05-09 02:30:32 | 1 | 2,258 | IanQ |
76,205,305 | 3,821,009 | Updating non-trivial structures in polars cells | <p>Say I have this:</p>
<pre><code>>>> polars.DataFrame([[(1,2),(3,4)],[(5,6),(7,8)]], list('ab'))
shape: (2, 2)
┌────────┬────────┐
│ a ┆ b │
│ --- ┆ --- │
│ object ┆ object │
╞════════╪════════╡
│ (1, 2) ┆ (5, 6) │
│ (3, 4) ┆ (7, 8) │
└────────┴────────┘
</code></pre>
<p>How would I go with u... | <python><python-polars> | 2023-05-09 01:32:14 | 2 | 4,641 | levant pied |
76,205,294 | 5,942,100 | Tricky conversion within dataframe using Pandas (compress and de-aggregate) | <p>I wish to compress the columns within my dataframe and de aggregate values:</p>
<p><strong>Data</strong></p>
<pre><code>state range type Q1 24 Q2 24 stat
NY up AA 2 2 grow
NY up AA 1 0 re
NY up BB 1 1 grow
NY up BB ... | <python><pandas><numpy> | 2023-05-09 01:27:18 | 1 | 4,428 | Lynn |
76,205,288 | 3,821,009 | Row-wise updates in polars | <p>Say I have this dataframe:</p>
<pre><code>>>> pl.DataFrame([[1,2,3],[4,5,6],[7,8,9]],list('abc'))
shape: (3, 3)
┌─────┬─────┬─────┐
│ a ┆ b ┆ c │
│ --- ┆ --- ┆ --- │
│ i64 ┆ i64 ┆ i64 │
╞═════╪═════╪═════╡
│ 1 ┆ 4 ┆ 7 │
│ 2 ┆ 5 ┆ 8 │
│ 3 ┆ 6 ┆ 9 │
└─────┴─────┴─────┘
</code></pre>
<p... | <python><python-polars> | 2023-05-09 01:24:11 | 3 | 4,641 | levant pied |
76,205,099 | 447,457 | How do I update a value of a key in a list of dictionaries in python? | <p>I have following dictionary,</p>
<pre class="lang-py prettyprint-override"><code> result =
[{'Img Entropy': 0.4759365334486925,
'Avg Row Entropy': 0.4756050513785311,
'Comp Size, B': 9675063,
'COMP RATIO, out/in': 0.10262087228128054,
'Stack Pos': 3},
{'Img Entropy': 0.475936533... | <python><dictionary><key-value> | 2023-05-09 00:07:54 | 2 | 830 | shparekh |
76,204,981 | 1,068,223 | Managing a long-running API listener using Python / Flask | <p>My python script (e.g. <strong>downloader.py</strong>) listens to a streaming REST API endpoint which continuously sends it data. After making an initial <code>GET</code> request, it uses a function such as <code>requests</code> <code>iter_content()</code> to read the stream and then writes the downloaded data into ... | <python><rest><flask><redis><celery> | 2023-05-08 23:22:09 | 1 | 1,478 | BYZZav |
76,204,928 | 8,241,568 | Loading multiple json files and add path name as column | <p>I am currently loading into a spark DataFrame all the json files present in my_folder using the following code:</p>
<pre><code>data = spark.read.option("multiline", "true").json("/path/my_folder")
</code></pre>
<p>Example with two json files:</p>
<ul>
<li>filename1: aaa.json</li>
<li>fi... | <python><json><pyspark> | 2023-05-08 23:05:42 | 1 | 1,257 | Liky |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.