QuestionId int64 74.8M 79.8M | UserId int64 56 29.4M | QuestionTitle stringlengths 15 150 | QuestionBody stringlengths 40 40.3k | Tags stringlengths 8 101 | CreationDate stringdate 2022-12-10 09:42:47 2025-11-01 19:08:18 | AnswerCount int64 0 44 | UserExpertiseLevel int64 301 888k | UserDisplayName stringlengths 3 30 ⌀ |
|---|---|---|---|---|---|---|---|---|
77,493,478 | 9,974,205 | How can I identify changes in stock in a pandas dataframe | <p>I am working with a pandas data frame. This data frame has 3 important columns, one is <code>AmountOfStock</code>, which indicates the amount of available units, other is <code>ProductType</code>, which is the code of the specified product, finally <code>DateTime</code>, indicates the date and time at which the data... | <python><pandas><database><row><delete-row> | 2023-11-16 09:06:33 | 2 | 503 | slow_learner |
77,493,349 | 17,438,511 | How to launch `python -m MY_MODULE` in debug mode in pycharm | <p>I have a script that can only be run as <code>python -m path.to.my_script</code>, due to the use of relative imports. Running it as <code>python path/to/my_script.py</code> gives "Attempted relative import with no known parent package" error.</p>
<p>How can I launch such script in PyCharm debug mode?</p>
| <python><pycharm> | 2023-11-16 08:45:45 | 1 | 647 | Boschie |
77,493,160 | 13,836,083 | why we cannot use alone starred target while assignment in python | <p>I was going through the python docs on simple assignment.</p>
<p>I found below from the docs.</p>
<blockquote>
<p>Assignment of an object to a target list, optionally enclosed in
parentheses or square brackets, is recursively defined as follows.</p>
<p>If the target list is a single target with no trailing comma,
op... | <python> | 2023-11-16 08:13:47 | 2 | 540 | novice |
77,493,052 | 435,093 | Testing ansible "to_nice_json" filter within Python - "No filter named 'to_nice_json'" | <p>I want to test an Ansible Jinja2 template using a Python script, based on the answer provided here: <a href="https://stackoverflow.com/questions/35407822/how-can-i-test-jinja2-templates-in-ansible">How can I test jinja2 templates in ansible?</a></p>
<p>This code <em>used</em> to work, however I don't remember in whi... | <python><ansible><jinja2> | 2023-11-16 07:52:55 | 1 | 39,571 | slhck |
77,492,920 | 16,405,935 | Count unique value for each group and subtotal | <p>I have a simple dataframe as below:</p>
<pre><code>import pandas as pd
import numpy as np
df = pd.DataFrame({'BR_NM': ['HN', 'HN', 'HP'],
'CUS_ID': ['12345', '12345', '12345'],
'ACC_ID': ['12345_1', '12345_2', '12345_3'],
'REGION': ['North', 'North', 'North']... | <python><pandas><pivot> | 2023-11-16 07:25:27 | 2 | 1,793 | hoa tran |
77,492,750 | 10,200,497 | Change the background color of every other group in Excel using Pandas | <p>This is my dataframe:</p>
<pre><code>import pandas as pd
import numpy as np
df = pd.DataFrame(
{
'p': ['short', np.nan, 'short', np.nan, np.nan, 'long', 'long', np.nan, np.nan],
's': [13, 13, 14, 15, 100, 1, 1000, 12, 1111]
}
)
</code></pre>
<p>I want to change the background color of ever... | <python><pandas> | 2023-11-16 06:43:47 | 1 | 2,679 | AmirX |
77,492,156 | 13,994,829 | How to calculate the "Engagement Rate" in GA4 connected to BigQuery? | <h2>Description</h2>
<ul>
<li>I have connected the <a href="https://support.google.com/analytics/answer/9823238?hl=en#zippy=%2Cin-this-article" rel="nofollow noreferrer">GA4 to BigQuery</a>.</li>
<li>The GA4 data in bigquery include: <code>ga_session_id</code>, <code>page_location</code>, <code>user_pseudo_id</code>, <... | <python><dataframe><google-bigquery><google-analytics><google-analytics-4> | 2023-11-16 03:37:43 | 1 | 545 | Xiang |
77,492,144 | 1,942,868 | conditional constraints for django model | <p>I have database model like this</p>
<pre><code>ActionType = (
(1,"PostBack"),
(2,"Uri"),
)
class RichMenu(BaseModel):
key = m.CharField(max_length=64,unique=True)
action_type = m.IntegerField(choices=ActionType,default=1)
url = m.CharField(max_length=255,blank=True,null=True)... | <python><django><model> | 2023-11-16 03:34:45 | 2 | 12,599 | whitebear |
77,492,026 | 10,018,602 | Query GPT4All local model with Langchain and many .txt files - KeyError: 'input_variables' | <p><code>python 3.8, Windows 10, neo4j==5.14.1, langchain==0.0.336</code></p>
<p>I'm attempting to utilize a local Langchain model (GPT4All) to assist me in converting a corpus of loaded <code>.txt</code> files into a <code>neo4j</code> data structure through querying. I have provided a minimal reproducible example cod... | <python><neo4j><langchain> | 2023-11-16 02:51:54 | 2 | 1,335 | wildcat89 |
77,491,948 | 9,500,955 | Pass a whole dataset contains multiple files to HuggingFace function in Palantir | <p>I am using the pre-trained model from HuggingFace (<a href="https://huggingface.co/dslim/bert-base-NER/tree/main" rel="nofollow noreferrer">dslim/bert-base-NER</a>). Normally when working locally or in a Colab notebook, we can use the code below to load the model:</p>
<pre class="lang-py prettyprint-override"><code>... | <python><palantir-foundry><foundry-code-repositories> | 2023-11-16 02:25:18 | 1 | 1,974 | huy |
77,491,941 | 2,850,913 | Llama 2 with Langchain tools | <p>I am trying to follow <a href="https://www.pinecone.io/learn/llama-2/" rel="nofollow noreferrer">this tutorial</a> on using Llama 2 with Langchain tools (you don't have to look at the tutorial all code is contained in this question).</p>
<p>My code is very similar to that in the tutorial except I am using a local mo... | <python><langchain><llama> | 2023-11-16 02:23:05 | 1 | 750 | tail_recursion |
77,491,924 | 699,467 | Is it possible to skip loop iterations for itertools.product() if i know the ID of the iteration? | <p>I have the following code:</p>
<pre><code>import math
import numpy as np
import itertools
s = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 40... | <python><loops> | 2023-11-16 02:15:03 | 1 | 2,406 | Sir D |
77,491,831 | 748,493 | Pandas DataFrame from a list of strings and n-th order tuples | <p>I am dealing with data that can contain stings, tuples of strings, tuples of tuples of strings, etc., e.g.</p>
<pre><code>values = ['a0'] + [('b0', 'b1')] + [(('c0', 'c1'), ('c2', 'c3'))]
</code></pre>
<p>and I need to construct a dataframe from these values that has as many columns as the maximum number of strings ... | <python><pandas><dataframe> | 2023-11-16 01:42:18 | 4 | 522 | Confounded |
77,491,797 | 5,363,840 | How does Pycharm handle virtual enviroments and their variables set in activate script? | <p>I'm running into an issue in pycharm. I'm using a virtual enviroment and I have added the following line to my activate script</p>
<pre><code>source /home/me/environment.sh
</code></pre>
<p>environment.sh only contains some lines with exports for variables such as:</p>
<pre><code>#!/bin/bash
export USERNAME="GU... | <python><pycharm><python-venv> | 2023-11-16 01:30:09 | 0 | 462 | Dr.Tautology |
77,491,665 | 12,474,157 | How to Add Authentication Mock to Pytest in a FastAPI Application? | <p>I am working on testing a FastAPI application using pytest and need to integrate authentication mocking. I have an endpoint <code>/roles</code> which requires authentication, but I'm not sure how to correctly add a mock for the authentication in my pytest setup.</p>
<h3>pytest code I have:</h3>
<pre class="lang-py p... | <python><authentication><mocking><pytest><fastapi> | 2023-11-16 00:31:16 | 0 | 1,720 | The Dan |
77,491,623 | 12,474,157 | How to Correctly Implement Mocked Authentication in Pytest for FastAPI Application? | <p>I am working with FastAPI and pytest to test an endpoint in my application. I need to mock the authentication dependency, but I'm facing challenges in implementing it correctly. My primary goal is to ensure that the mocked authentication is properly set up so that my tests can run without hitting the actual authenti... | <python><unit-testing><mocking><pytest><fastapi> | 2023-11-16 00:15:35 | 1 | 1,720 | The Dan |
77,491,414 | 3,083,830 | What does n_jobs=-1 do in XGBClassifier from xgboost? | <p>What does the n_jobs=-1 means do when creating a XGBClassifier object?</p>
<pre><code>xgbc = XGBClassifier(n_jobs=-1)
</code></pre>
| <python><scikit-learn><xgboost><xgbclassifier> | 2023-11-15 23:09:12 | 1 | 641 | Ivan Verges |
77,491,346 | 1,934,510 | cannot import name 'Job' from partially initialized module 'models' (most likely due to a circular import) | <p>I'm trying to build a Flask app but I'm receiving this error</p>
<p>ImportError: cannot import name 'Job' from partially initialized module 'models' (most likely due to a circular import)</p>
<p>This my code:</p>
<p>app.py</p>
<pre><code>from flask import Flask, render_template, redirect, url_for, flash
from flask_s... | <python><flask> | 2023-11-15 22:52:39 | 1 | 8,851 | Filipe Ferminiano |
77,491,336 | 1,663,528 | How to search results of PyMySQL query with IN operator when it returns a tuple of tuples? | <p>I have a MySQL database table of ipv4 addresses I want to search against, I pull it in to a Python using an SQL query (PyMySQL library) with a single column in the SELECT and cursor.fetchall() but when I loop through the resulting tuple.</p>
<pre><code>with conn.cursor() as cur:
sqlQuery = 'SELECT ipv4_address F... | <python><pymysql> | 2023-11-15 22:50:12 | 1 | 8,579 | Mr Fett |
77,491,117 | 5,519,012 | Using cross join of subquery in python Peewee | <p>I want to convert the following sql query to python peewee -</p>
<pre><code>WITH common_subquery AS (
SELECT
t1.fly_from,
t1.airlines as first_airline,
t1.flight_numbers as first_flight_number,
t1.link_to as first_link,
t1.departure_to,
t1.fly_to AS connection_at,... | <python><sql><peewee> | 2023-11-15 21:59:09 | 1 | 365 | Meir Tolpin |
77,491,078 | 5,036,928 | PyVista: 3D Gaussian Smoothing of PolyData | <p>I would like to replicate the example here <a href="https://docs.pyvista.org/version/stable/examples/01-filter/gaussian-smoothing.html" rel="nofollow noreferrer">https://docs.pyvista.org/version/stable/examples/01-filter/gaussian-smoothing.html</a> using my own data but trying to apply the <code>gaussian_smooth()</c... | <python><3d><surface><gaussianblur><pyvista> | 2023-11-15 21:51:27 | 1 | 1,195 | Sterling Butters |
77,490,979 | 9,100,431 | Python - Datetime Problem printing '%p' with locale | <p>I have a simple script that fetches a UTC datetime from an API and then I try to parse it to</p>
<pre><code>"%I:%M:%S %p . %d de %B del %Y"
</code></pre>
<p>I get the correct format without a locale set (12:35:01 PM. 15 de November del 2023).
But when I try to get the Spanish month, the %p suddenly disappe... | <python><datetime><python-datetime> | 2023-11-15 21:28:41 | 0 | 660 | Diego |
77,490,678 | 11,163,122 | SQL Alchemy v2 is after_transaction_end needed for nested session | <p>In <a href="https://aalvarez.me/posts/setting-up-a-sqlalchemy-and-pytest-based-test-suite/" rel="nofollow noreferrer">Setting Up a SQLAlchemy and Pytest Based Test Suite</a> (published May 2022 with SQLAlchemy v1), for the transactional testing, it uses the below code snippet. Note I cleaned it up a bit for this po... | <python><sqlalchemy> | 2023-11-15 20:21:38 | 1 | 2,961 | Intrastellar Explorer |
77,490,677 | 1,309,005 | Can I use a symbol other than the equal sign in self-documenting f-strings | <p>Self-documenting f-strings in Python allow you to write a print statement like this:</p>
<pre class="lang-py prettyprint-override"><code>print(f"{result=}")
</code></pre>
<p>This works fine, but the <code>=</code> sign is not just used to tell Python you want a self-documenting f-string...it is also the sy... | <python><f-string> | 2023-11-15 20:21:33 | 1 | 1,707 | RSW |
77,490,543 | 3,233,017 | Can TQDM track the output of a subprocess? | <p>As part of a long pipeline (all orchestrated in Python), I'm calling an external program using the subprocess module. This program takes a while to finish, so I'd like to show the user a nice progress bar, to reassure them that it hasn't frozen.</p>
<p>This program also sends a whole lot of information to stdout—muc... | <python><subprocess><tqdm> | 2023-11-15 19:52:04 | 0 | 3,547 | Draconis |
77,490,435 | 13,086,128 | AttributeError: cython_sources | <p>I am using:</p>
<pre><code>python: 3.12
OS: Windows 11 Home
</code></pre>
<p>I tried to install <code>catboost==1.2.2</code></p>
<p>I am getting this error:</p>
<pre><code>C:\Windows\System32>py -3 -m pip install catboost==1.2.2
Collecting catboost==1.2.2
Downloading catboost-1.2.2.tar.gz (60.1 MB)
------... | <python><python-3.x><pip><catboost><python-3.12> | 2023-11-15 19:31:56 | 1 | 30,560 | Talha Tayyab |
77,490,281 | 11,981,718 | How to group 2d spatial grid data based on their elevation using clustering: clusters have to be contiguous | <p><a href="https://i.sstatic.net/W6nfd.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/W6nfd.png" alt="enter image description here" /></a></p>
<p>I have 2d gridded data that I want to group based on elevation, but the clusters have to be continuous and have a minimum number of data in the (4). A visual... | <python><scikit-learn><cluster-analysis> | 2023-11-15 18:59:21 | 1 | 412 | tincan |
77,490,265 | 1,497,199 | How to run celery workers with sequential task execution with "per-child" bounds | <p>The context is that I'm using kubernetes for parallelism and workload balancing, similar to <a href="https://miguescri.com/post/2021-05-22-celery-hpa/" rel="nofollow noreferrer">this</a>. Given this, it is desirable to have no concurrency within the celery workers -- we get that by k8s horizontal scaling. In addi... | <python><kubernetes><celery> | 2023-11-15 18:55:24 | 0 | 8,229 | Dave |
77,490,225 | 4,542,117 | python matrix traversal expanding outwards concentric squares | <p>Let's say I have a 5x5 matrix as follows:</p>
<pre><code>0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
</code></pre>
<p>Based on some location, I am given an index in both the (x,y) coordinate where I want to start building concentric squares outwards of values. A few examples below:</p>
<pre><code>3 3 3 3 3
3 2... | <python><numpy> | 2023-11-15 18:46:56 | 1 | 374 | Miss_Orchid |
77,490,131 | 5,840,173 | Different headers in the same session | <p>After I ran the following python script,</p>
<pre><code>import requests
header_1 = {"Authorization":"Bearer abc123"}
header_2 = {"Authorization":"Bearer def456"}
url = "https://notify-api.line.me/api/notify"
session = requests.session()
a = session.post(url, heade... | <python><http> | 2023-11-15 18:31:10 | 0 | 511 | bfhaha |
77,490,095 | 688,954 | ModuleNotFoundError when running coverage run -m pytest . in GitHub Actions | <p>I have a very simple project like below</p>
<pre><code>//
├─ src/
│ ├─ sample/
│ │ ├─ __init__.py
│ │ ├─ simple.py
├─ tests/
│ ├─ __init__.py
│ ├─ test_simple.py
</code></pre>
<p>When I tried running the coverage command below in the my local laptop, it runs okay and generates <code>coverage.xml</code></p>
<p... | <python><pytest><github-actions><code-coverage> | 2023-11-15 18:23:00 | 2 | 4,033 | Petra Barus |
77,490,071 | 6,067,528 | How can I divide these two sparse matrices together? | <p>I am trying to move dense matrix operations to be sparse. I was using numpy broadcasting to divide an array of shape (432,) to (591, 432) when they were dense, but how can do I this with sparse matrices?</p>
<pre><code><591x432 sparse matrix of type '<class 'numpy.int64'>'
with 3876 stored elements in C... | <python><numpy><scipy> | 2023-11-15 18:18:38 | 1 | 1,313 | Sam Comber |
77,490,002 | 3,782,911 | How to calculate a rolling function of only defined values in pandas/numpy? | <p>I've found <a href="https://stackoverflow.com/questions/69269582/how-to-ignore-nan-when-applying-rolling-with-pandas">How to ignore NaN when applying rolling with Pandas</a></p>
<p>But it didn't help.</p>
<ul>
<li>I have arrays where each line item is a specific value for a specific time index for a specific column.... | <python><pandas><numpy> | 2023-11-15 18:07:27 | 0 | 2,795 | David Boshton |
77,489,981 | 458,742 | How should mysql.connector be shared correctly with threads in Django applications? | <p>This concerns a potential solution to <a href="https://stackoverflow.com/questions/77487774/commands-out-of-sync-you-cant-run-this-command-now-on-first-use-of-cursor">my earlier question</a> in which I was getting <code>commands out of sync; you can't run this command now</code> after wrapping mysql cursors in <code... | <python><mysql><django><multithreading> | 2023-11-15 18:04:28 | 1 | 33,709 | spraff |
77,489,961 | 4,256,677 | pdoc3 incorrectly rendered Args section | <p>Recently migrated from an M1 to M2 mac. Previous successful invocation of pdoc was on M1 with Ventura 13.6, same python version. Is there a prerequisite I'm missing, or maybe need to downgrade a dependency, or is this due to an unreported error in my docstrings somewhere else in the module?</p>
<p>Example Source c... | <python><docstring><pdoc> | 2023-11-15 18:00:23 | 1 | 1,179 | varontron |
77,489,899 | 8,869,570 | How to check that a dataframe consists of all 0 entries? | <p>I know one way is to loop through all the columns, e.g.,</p>
<pre><code>for col in df.columns:
assert (df[col] != 0).sum() == 0
</code></pre>
<p>Is there better approach that can operate on the entire dataframe without looping through each individual column?</p>
| <python><python-3.x><pandas><dataframe> | 2023-11-15 17:47:26 | 5 | 2,328 | 24n8 |
77,489,728 | 19,276,472 | Helper functions in another file, ModuleNotFoundError when trying to import | <p>I have a simple Python project using scrapy. My file structure looks like this:</p>
<pre><code>top_level_folder
|-scraper
|--spiders
|---help_functions.py
|---<some more files>
|--items.py
|--pipelines.py
|--settings.py
|--<some more files>
</code></pre>
<p>help_functions.py has a couple functions define... | <python><scrapy> | 2023-11-15 17:16:44 | 3 | 720 | Allen Y |
77,489,704 | 2,556,795 | Groupby giving same aggregate value for all groups | <p>I am trying to take mean of each group and trying to assign those to a new column in another dataframe but the first group's mean value is populating across all groups.</p>
<p>Below is my dataframe <code>df1</code></p>
<pre><code>level value
CF 5
CF 4
CF 6
EL 2
EL 3
EL 1
... | <python><pandas><group-by> | 2023-11-15 17:12:10 | 2 | 1,370 | mockash |
77,489,554 | 8,443,357 | correct incorrect serilization in django | <p>After serialization,I tried to call Django-rest api by connecting 3 tables, then I got issue Original exception text was: <strong>'Store' object has no attribute 'Storeimage'.</strong>, I'm expecting to get api by connecting 3 models.</p>
<p>My models</p>
<pre><code>class Store(models.Model):
user = models.Forei... | <python><django><serialization><django-rest-framework> | 2023-11-15 16:50:35 | 1 | 652 | selvakumar |
77,489,523 | 1,753,640 | Python Regex extract paragraph text between number | <p>I have text as follows and I want to extract just the text</p>
<pre><code>1. foobar
2. foo
3. bar
</code></pre>
<p>The result should be <code>[foobar, foo, bar]</code>.</p>
<p>What python regex will extract the results I want? I tried the following but no luck</p>
<p><code>r'\d+.*?(?=\d|$)'</code></p>
| <python><regex> | 2023-11-15 16:45:40 | 2 | 385 | user1753640 |
77,488,946 | 6,843,153 | argparse to accept random arguments | <p>I have a Python application that implements <code>argparse</code> with a set of arguments declared:</p>
<pre class="lang-py prettyprint-override"><code>if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--arg1",
default="dev",
... | <python><argparse> | 2023-11-15 15:23:08 | 1 | 5,505 | HuLu ViCa |
77,488,891 | 2,741,831 | Subquery from pypika documentation not working | <pre><code>from pypika import Query, Table, Field, Tables, Order
history, customers = Tables('history', 'customers')
last_purchase_at = Query.from_(history).select(
history.purchase_at
).where(history.customer_id==customers.customer_id).orderby(
history.purchase_at, order=Order.desc
).limit(1)
q = Query.from_(... | <python><pypika> | 2023-11-15 15:16:33 | 1 | 2,482 | user2741831 |
77,488,835 | 14,723,580 | Gradient descent stuck in local minima? | <p>I'm running gradient descent to find a root for a system of nonlinear equations and I am wondering how you might detect if the method is stuck at the local minima, because I believe with the settings I am using this might be the case? my initial values are [-2, -1], tolerance of 10^-2 and 20 iterations. One thing I ... | <python><numerical-methods><gradient-descent><root-finding> | 2023-11-15 15:08:09 | 2 | 753 | Krellex |
77,488,813 | 4,966,886 | Gradients and Laplacian of an image using skimage vs. open-cv | <p>I compare the vertical and horizontal gradients and Laplacian of an image using skimage and cv2 with the following code:</p>
<pre><code>import sys
import matplotlib.pyplot as plt
from matplotlib.image import imread
import skimage
import cv2
def plot(ax, img, title):
ax.imshow(img) # cmap = 'gray'
ax.set_tit... | <python><opencv><matplotlib><scikit-image><laplacian> | 2023-11-15 15:04:12 | 1 | 306 | user11634 |
77,488,627 | 3,416,725 | How to unit test mocking SQLAlchemy engine in Python for an update query | <p>I have a function called <code>update_worker_data</code>. This simply updates a table in PostgreSQL, however if the row does not exist in the db, it then inserts it. This is checked by getting the <code>rowcount</code> after the query is executed:</p>
<pre><code>def update_worker_data(db: engine, data: List[dict]) -... | <python><unit-testing><pytest><pytest-mock> | 2023-11-15 14:38:29 | 0 | 493 | mp252 |
77,488,626 | 6,246,426 | Reformat long list in PyCharm to have one item per line | <p>When I do the code formatting in Pycharm it reformats the long lists in this manner:</p>
<pre class="lang-py prettyprint-override"><code>style1 = [
'Email:', 'SSN:', 'Address:', 'Home Phone:',
'Mobile Phone: ', 'DOB:', 'Date of Surgery:',
'Date of Service:', 'Facility of Service:', 'Clinic Number:',
... | <python><pycharm> | 2023-11-15 14:38:04 | 0 | 1,208 | Victor Di |
77,488,611 | 1,936,538 | Jupyter Notebook export to HTML + Crontab doesn't show plots | <p>I am automating the automatic execution and HTML export of a Jupyter Notebook.
The Jupyter Notebook was created in VS Code and when I export it from the terminal in Ubuntu (jupyter nbconvert --execute --to html) I get the correct HTML with all the plots.
However this does not happen when I execute it in the crontab... | <python><pandas><matplotlib><jupyter-notebook><cron> | 2023-11-15 14:35:52 | 0 | 403 | husvar |
77,488,578 | 3,734,059 | SQAlchemy>2.0 does not INSERT or UPSERT into MySQL when using text() function | <p>We have recently updated to <code>SQLAlchemy==2.0.23</code> which requires the usage of <a href="https://docs.sqlalchemy.org/en/20/core/sqlelement.html#sqlalchemy.sql.expression.text" rel="nofollow noreferrer"><code>sqlalchemy.sql.expression.text</code></a> to format executed queries.</p>
<p>In older versions e. g. ... | <python><mysql><sqlalchemy> | 2023-11-15 14:30:52 | 1 | 6,977 | Cord Kaldemeyer |
77,488,576 | 5,309,827 | django userprofile nested relationship is empty in django REST | <p>Hello I have an UserProfile model in django, and I want to serialize my User model with its UserProfile nested to receive it via ajax in my template but it cames empty.</p>
<p>Model UserProfile</p>
<pre><code>class UserProfile(models.Model):
user = models.OneToOneField(User, related_name='profile', on_delete=mod... | <python><django><django-rest-framework> | 2023-11-15 14:30:38 | 1 | 323 | Jaime |
77,488,275 | 4,120,777 | Filter by list's element in payload | <p>In Qdrant DB I have a payload containing a list. How can I filter results of a search limiting to the ones where the list contain a specific element?</p>
<p>As example, if the set of points is:</p>
<pre class="lang-json prettyprint-override"><code>[
{ "id": 1, "Fruit": ["apple", "... | <python><vector-database><qdrant><qdrantclient> | 2023-11-15 13:51:39 | 1 | 2,136 | Vincenzo Lavorini |
77,488,178 | 17,136,258 | Calculating the duration of an event | <p>I have a problem. I have a list that is full of events (note: the list does not have to be sorted by date and can contain multiple IDs).
I would like to "know" how long an event lasted.
The calculation can be represented as follows</p>
<pre><code>Duration of Event1 = Take the ID(Timestamp Event 2 - Timesta... | <python><pandas><dataframe> | 2023-11-15 13:40:28 | 2 | 560 | Test |
77,488,173 | 5,040,775 | Can you create some kind of execution file (e.g., exe) to run a python code on a computer that does not have python? | <p>I am writing python code to automatically generate some report. Ultimately, I want other people at my firm to be able to run this easily by using some kind of execution file. None of them have python on their PC and I don't want them to install it (for operational difficult reason). Is it even possible to do that?</... | <python> | 2023-11-15 13:40:07 | 1 | 3,525 | JungleDiff |
77,488,041 | 22,538,132 | change background color in open3d.visualization.draw_geometries | <p>I want to change the background color in Open3D when I draw geometries using <code>open3d.visualization.draw_geometries</code>, but I can't figure out how to that, as <a href="http://www.open3d.org/docs/release/python_api/open3d.visualization.draw_geometries.html" rel="nofollow noreferrer">the documentation</a> is n... | <python><colors><background><open3d> | 2023-11-15 13:21:12 | 1 | 304 | bhomaidan90 |
77,488,011 | 22,221,987 | How to fill dynamically expanding HTML file with templates filled with python data | <p>I have a HTML template for one message (i receive messages via <code>Slack-API</code>).
I want to fill the template with information from API and than stick templates together, in new HTML file (Output file will look like a chat-wall with every message from the chat).</p>
<p>Because of the chats different size, i ca... | <python><html><python-3.x><parsing><jinja2> | 2023-11-15 13:16:12 | 0 | 309 | Mika |
77,488,002 | 14,244,437 | Make inner joins by using Q objects in Django | <p>I'm customizing a model's Admin change list page in my project.</p>
<p>This model contains a Many to Many field and I want to allow multi-selection filtering.</p>
<p>I've used the <a href="https://github.com/JobDoesburg/django-admin-multi-select-filter" rel="nofollow noreferrer">Django Admin Multi Select Filter pack... | <python><django><django-orm> | 2023-11-15 13:14:43 | 1 | 481 | andrepz |
77,487,973 | 1,936,752 | How to deal with off-by-one issues in convolution (Python)? | <p>I'm trying to write a function to add two random varibles <code>X1</code> and <code>X2</code>. In my case, they are both uniform random variables from <code>0</code> to <code>a1</code> and <code>0</code> to <code>a2</code>. To compute the random variable <code>Y = X1 + X2</code>, I need to take a convolution of the ... | <python><probability><convolution><off-by-one> | 2023-11-15 13:10:22 | 1 | 868 | user1936752 |
77,487,776 | 1,608,765 | Fittig a rice distribution using scipy | <p>I'm trying to write a fitter for some rice distributed data that I have, but it is not working for some, probably stupid, reason.</p>
<p>The distribution gets created fine, and the fitting routing seems to work from what I am used to with Gaussians. However, when I fit the curve, I just get nonsense. Can't seem to s... | <python><scipy><curve-fitting> | 2023-11-15 12:38:53 | 1 | 2,723 | Coolcrab |
77,487,774 | 458,742 | "commands out of sync; you can't run this command now" on first use of cursor | <p>I am using MySQL in Django (Python).</p>
<p>The draft version of this code worked and was stable, but it created cursors without closing them, and I just rewrote it to manage the cursor with enter/exit. Now it is unstable.</p>
<pre><code>class Cursor:
def __init__ (self, db):
self.db = db
self.cursor ... | <python><mysql><django><database-cursor> | 2023-11-15 12:38:29 | 0 | 33,709 | spraff |
77,487,393 | 10,522,901 | scikit-learn fit function returns immediately with 0 training samples processed | <p>I am experiencing an issue with <code>scikit-learn</code> version <code>1.3.2</code>, where the <code>fit()</code> function of the <code>MLPClassifier</code> returns almost instantly without processing any training samples. This is evident as the model's <code>t_</code> parameter (indicating the number of training s... | <python><scikit-learn> | 2023-11-15 11:38:02 | 0 | 316 | vegarab |
77,487,354 | 9,353,682 | How suppress `unused-property` error in vulture | <p>I have noticed that <a href="https://github.com/jendrikseipp/vulture" rel="nofollow noreferrer">vulture</a> package started to report new error <code>vulture: unused-property</code>.
The <a href="https://github.com/jendrikseipp/vulture/blob/main/README.md" rel="nofollow noreferrer">documentation</a> specifies follow... | <python> | 2023-11-15 11:31:00 | 1 | 722 | Maciek |
77,487,326 | 9,110,646 | Why does dict comprehension doesn't works when for-loops do? | <p>When calling the sample function <code>func</code> in this module, why does it throw an exception
when I use comprehension (can be toggled with parameter)? Can someone explain the meaning of the exception? <code>cycle</code>seems to be overwritten and I can not wrap my head around it.</p>
<h1>Example function with ... | <python><pandas><dictionary><dictionary-comprehension> | 2023-11-15 11:26:51 | 1 | 423 | Pm740 |
77,487,292 | 15,452,601 | How do I quiet mypy when testing inheritence from a generic? | <p>The following MWE constructs a mapping between the typevars used in a generic class and their declared values on an instance:</p>
<pre class="lang-py prettyprint-override"><code>from typing import Generic, TypeVar, get_args
T = TypeVar("T")
class Derived(Generic[T]):
def method(self, val: T) -> T... | <python><generics><types> | 2023-11-15 11:21:10 | 1 | 6,024 | 2e0byo |
77,487,139 | 929,122 | pyarrow.lib.ArrowTypeError: Expected bytes, got a 'LOB' object - How can I convert CLOBs to Strings at operator level? | <p>I'm trying to copy data from an Oracle database to GCS using Airflow's OracleToGCSOperator:</p>
<pre class="lang-py prettyprint-override"><code>copy_data = OracleToGCSOperator(
task_id='copy_data_task',
oracle_conn_id='my_conn',
sql="SELECT * FROM MY_TABLE",
bucket=MY_BUCKET,
filename=FILEPA... | <python><oracle-database><google-cloud-platform><airflow><google-cloud-composer-2> | 2023-11-15 10:55:56 | 1 | 437 | drake10k |
77,486,881 | 6,448,412 | Flask-CORS returns random Access-Control-Allow-Origin if Origin request header is not provided | <p>I want to enable CORS in my Flask application with a predefined set of allowed origins, as documented <a href="https://flask-cors.corydolphin.com/en/latest/api.html" rel="nofollow noreferrer">here</a>:</p>
<pre><code>from flask import Flask
from flask_cors import CORS
app = Flask(__name__)
CORS(app, origins=['http:... | <python><flask><cors><flask-cors> | 2023-11-15 10:18:59 | 1 | 398 | Laugslander |
77,486,849 | 1,521,241 | PyDLL does not work across different Python versions | <p>I am using PyDLL function to bind DLL to Python.</p>
<p>From Python side:</p>
<pre><code>import ctypes as _ct
_path = _parent_path(__file__) / "scisuit_pybind"
pydll = _ct.PyDLL(str(_path))
pydll.c_root_bisect.argtypes = [_ct.py_object, _ct.c_double, _ct.c_double, _ct.c_double, _ct.c_int, _ct.c_char_p, _c... | <python><c++> | 2023-11-15 10:15:25 | 1 | 1,053 | macroland |
77,486,675 | 628,228 | How to validate a TextIO argument? | <p>I am just coming to terms with Python type hinting and I am confused how to implement argument validation for the following function signature:</p>
<pre class="lang-py prettyprint-override"><code>def read_file(file: Union[str, PathLike, TextIO]) -> str:
</code></pre>
<p>My initial attempt at a pythonic implementa... | <python><python-typing> | 2023-11-15 09:49:25 | 1 | 4,430 | glopes |
77,486,577 | 6,813,417 | Stop pyspark aggregation if condition triggers | <p>Let's say I want to check if a pyspark dataframe has any constant column. Let's work with the dataframe from <a href="https://stackoverflow.com/questions/52113821/fastest-way-to-know-if-a-column-has-a-constant-value-in-a-pyspark-dataframe">this question</a>:</p>
<pre><code>+----------+----------+
| A | B ... | <python><apache-spark><pyspark> | 2023-11-15 09:35:18 | 1 | 1,058 | Let's try |
77,486,432 | 8,554,611 | `setuptools_scm` includes a committed `.gitignore` to an `sdist` package | <p>I have a flat-layout project like this:</p>
<pre><code>├── project_name
│ └── ...
├── .gitignore
├── pyproject.toml
└── ...
</code></pre>
<p>I follow <a href="https://setuptools.pypa.io/en/latest/userguide/datafiles.html#exclude-package-data" rel="nofollow noreferrer">the <code>setuptools</code> docs</a> to compos... | <python><setuptools><pyproject.toml><setuptools-scm> | 2023-11-15 09:13:01 | 0 | 796 | StSav012 |
77,486,242 | 21,309,333 | Ctypes 2d array of strings in python stores different strings at same memory address | <p>the python code i have is pretty simple:</p>
<pre class="lang-py prettyprint-override"><code>from ctypes import *
from random import randint
class uni(Union):
_fields_ = [('p', c_char_p),
('a', c_longlong)]
#initializing the array of strings
x = ((c_char_p * 3) * 10) ()
for i in range(10):
... | <python><c++><arrays><string><ctypes> | 2023-11-15 08:42:00 | 0 | 365 | God I Am Clown |
77,486,146 | 7,699,037 | Load element as string when it ends with a colon | <p>I have a YAML document where some values end with a colon, something like:</p>
<pre class="lang-yaml prettyprint-override"><code>foo:
- bar
- baz::
</code></pre>
<p>When I load the document with <code>yaml.load</code>, the <code>baz::</code> element gets converted to a dictionary <code>{'baz:' : ''}</code>. Howe... | <python><yaml><pyyaml> | 2023-11-15 08:20:37 | 1 | 2,908 | Mike van Dyke |
77,486,094 | 736,662 | Printing using on_start and self in Locust | <p>Having this code:</p>
<pre><code>class MyUser(HttpUser):
host="http://localhost"
def on_start(self):
self.data = data.sample().to_dict()
self.ts_value_random = random.randrange(10000)
@task
def send_request(self):
print("Sending request with data: ", self.data)
print("Rand... | <python><locust> | 2023-11-15 08:10:08 | 0 | 1,003 | Magnus Jensen |
77,485,951 | 7,254,635 | Can any dynamic language can write the some prog like the book<Type-Driven Development with idris>'s Chapter6's datastore? | <p>The book's Chapter6's datastore:</p>
<pre>
module Main
import Data.Vect
infixr 5 .+.
data Schema = SString | SInt | (.+.) Schema Schema
SchemaType : Schema -> Type
SchemaType SString = String
SchemaType SInt = Int
SchemaType (x .+. y) = (SchemaType x, SchemaType y)
record DataStore where
constructor MkData
... | <python><ruby><idris> | 2023-11-15 07:39:53 | 1 | 1,757 | wang kai |
77,485,901 | 3,139,811 | Pytest - how to find the test result after a test | <p>After a test has been executed I need to collect the result of that test. But I don't find the result in the FixtureRequest object. I can find the test name and some additional data but nowhere I see something that shows if a test has been passed or failed. Nor if there were some exceptions</p>
<p>example code:</p>
... | <python><pytest> | 2023-11-15 07:30:01 | 2 | 857 | John |
77,485,752 | 4,158,016 | Python pandas add column with values based on condition and pattern | <br>
My python pandas dataframe originally using openpyxl engine to handle excel processing,
can be described in simple form as
<pre><code>df1 = pd.DataFrame({"col1":["",99,88,np.nan,66,55,np.nan,11,22],"col2":['Catg0','Asset1','Other','Catg1','H & F','Large Item','Catg2','Fragile','D... | <python><pandas><pivot> | 2023-11-15 06:53:48 | 2 | 450 | itsavy |
77,485,192 | 6,025,866 | Unable to run pm.sample() function using PyMC Python library even though I re-installed the libraries | <p>I am trying to run a Bayesian Linear Regression , but I am unable to create a posterior distribution using the sample() function from pymc. The code is as follows</p>
<pre><code>import pandas as pd
from random import randint
# Generate date range
dates = pd.date_range(start="2021-01-01", end="2021-01... | <python><bayesian><pymc> | 2023-11-15 04:00:50 | 0 | 441 | adhok |
77,485,146 | 3,214,482 | vscode cannot reconnect to existing jupyter notebook server when waking my laptop | <p>I recently switched from browser to vs code for using jupyter notebook and the IDE-like features (e.g. auto-complete, debugging, etc) provided by VS code is really so much better than a browser. But one thing bothers me is that <strong>whenever I wake my laptop from sleep mode</strong>, it often has issue re-connect... | <python><visual-studio-code><jupyter-notebook> | 2023-11-15 03:48:02 | 0 | 983 | username123 |
77,485,121 | 15,155,978 | Why Python version is not been shown correctly when using pyenv for Python environments? | <p>I have installed pyenv in MacOS Sonoma 14.1.1 version. I have added the following to <code>~/.zshrc</code> and <code>~/.bashrc</code> files according to this <a href="https://stackoverflow.com/questions/71188577/having-trouble-switching-python-versions-using-pyenv-global-command">answer</a>:</p>
<pre><code>export PY... | <python><python-3.x><pyenv><macos-sonoma><pyenv-virtualenv> | 2023-11-15 03:39:56 | 0 | 922 | 0x55b1E06FF |
77,485,119 | 3,600,487 | Changing the encryption settings of EC2 EBS devices while creating a launch template using AWS CDK with Python | <p>In my AWS environment, I have an unencrypted AMI. When I launch EC2 instances from it, their EBS volumes are unencrypted, as expected. I'm trying to change the encryption settings of the EBS volumes to be encrypted at the launch time from this unencrypted AMI. I am using AWS CDK (version 2.66.0) with Python (3.9).</... | <python><amazon-ec2><aws-cloudformation><aws-cdk> | 2023-11-15 03:36:56 | 0 | 1,710 | Rafiq |
77,485,108 | 6,361,531 | Force insert statement in sqlalchemy to use quotes around all columns | <p>Is there a parameter in sqlalchemy when doing an insert using the ORM that you can force the python library to quote all columns?</p>
<p>For example,</p>
<pre><code>INSERT INTO DATABASE_A.SCHEMA_A.TABLE_A (date, col1, "col 2") values (:data1, :data2, :data3)
</code></pre>
<p>is the statement that is curren... | <python><sqlalchemy> | 2023-11-15 03:32:50 | 1 | 154,219 | Scott Boston |
77,485,101 | 704,262 | SqlAlchemy extending an existing query with additional select columns from raw sql | <p>I'm quite new to SQLAlchemy and Python, and have to fix some bugs in a legacy environment so please bear with me..</p>
<p><strong>Environment</strong>:
<br/>Python 2.7.18
<br/>Bottle: 0.12.7
<br/>SQLAlchemy: 1.3.24
<br/>MySQL: 5.7</p>
<p><strong>Scenario</strong>: I have this SQL Statement below that pivots a linked... | <python><sql><mysql><python-2.7><sqlalchemy> | 2023-11-15 03:30:59 | 0 | 784 | hreimer |
77,484,996 | 10,620,003 | Build a df based on another df which only has 1/0 | <p>I have a df which only has 1/0. I want to build a df with the same shape.
I want to consider the first two 1 in the case which we have consecutive 1.
For example, in a case we have 0,0,1,1,1,1, 0,0 I want to convert it to 0,0,1,1,0,0,0,0. Here is an example,</p>
<pre><code>import pandas as pd
df_dr = pd.DataFrame()... | <python><pandas> | 2023-11-15 03:00:59 | 1 | 730 | Sadcow |
77,484,926 | 22,371,917 | How to scroll in a nav element using seleniumbase in python | <pre class="lang-html prettyprint-override"><code><nav class="flex h-full w-full flex-col p-2 gizmo:px-3 gizmo:pb-3.5 gizmo:pt-0" aria-label="Menu">
</code></pre>
<p>This is the nav although, its a-lot longer its full of divs</p>
<p>I just want to know how to scroll till the end of the menu.
E... | <python><html><selenium-webdriver><scroll><seleniumbase> | 2023-11-15 02:35:23 | 2 | 347 | Caiden |
77,484,746 | 9,905,667 | Getting an error when installing tensorflow | <p>I am getting an error when trying to download tensorflow through pip.</p>
<pre><code>PS C:\Users\12158> pip install tensorflow
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions:
none)
ERROR: No matching distribution found for tensorflow
</code></pre>
<p>Very strange. Throug... | <python><powershell><tensorflow><pip> | 2023-11-15 01:32:55 | 1 | 726 | SantiClaus |
77,484,738 | 5,635,892 | Loss function doesn't have requires_grad=True in pytorch | <p>Hello I have the following code (simplified version of my code but able to reproduce the error):</p>
<pre><code>import numpy as np
from numpy import linalg as LA
import torch
import torch.optim as optim
import torch.nn as nn
def func(x,pars):
a = pars[0]
b = pars[1]
c = pars[2]
d = pars[3]
x =... | <python><python-3.x><pytorch><gradient><loss-function> | 2023-11-15 01:29:06 | 2 | 719 | Silviu |
77,484,622 | 9,905,667 | ValueError: 'editdistance/bycython.pyx' doesn't match any files when downloading keras_ocr | <p>When trying to download kera_ocr through pip, I get the following error:</p>
<pre><code>ValueError: 'editdistance/bycython.pyx' doesn't match any files
</code></pre>
<p>I have tried everything I can think of.</p>
<ol>
<li>Upgrading pip</li>
<li>Upgrading python</li>
<li>Installing dependencies</li>
</ol>
| <python><keras><pip> | 2023-11-15 00:47:29 | 1 | 726 | SantiClaus |
77,484,490 | 11,091,148 | Pydantic optinal throws `Field required` in nested json list | <p>I have a nested json that I validate with pydantic:</p>
<pre><code>app_dict={'apps': [{'app_id': 'a_1',
'group_id': '123',
'report_id': '456',
'principal_id': 'p_1'},
{'app_id': 'a_2',
'group_id': '789',
'report_id': '987'}]}}
class PbiApps(BaseModel):
app_id: ty.Required[pty.StrictStr]
gr... | <python><python-typing><pydantic> | 2023-11-14 23:56:00 | 2 | 526 | Bennimi |
77,484,372 | 437,456 | asyncpg DataError: invalid input for query argument expected str, got int | <p>I admittedly don't understand how asyncpg's codecs work, but it seems to work counter to how I'd expect:</p>
<pre><code>import asyncio
import asyncpg
async def main():
conn = await asyncpg.connect('postgresql://postgres@localhost/test')
print(await conn.fetchval("select $1", 'a')) # this works:... | <python><postgresql><asyncpg> | 2023-11-14 23:12:40 | 1 | 5,340 | DMac the Destroyer |
77,484,338 | 20,235,789 | How can I mock an imported dependency from my function file? | <p>I'm attempting to mock a config that is being imported in my security file here:</p>
<pre><code>import aiohttp
from fastapi import Header, HTTPException
from .util.config import config
async def get_user_profile_details(
user_profile_id: str, ..., ...
):
user_profile_url = f"{config.entity.ENTITY_... | <python><python-unittest><python-unittest.mock> | 2023-11-14 23:02:15 | 0 | 441 | GustaMan9000 |
77,484,062 | 836,026 | Read Image from numpy and display it: ValueError: conversion from L to PNG not supported | <p>I have a 2D array of an image (<strong>slice</strong>). The array dimension is (224, 224) and when I read it as an image as shown below, <em><strong>the image mode is shown as "F"</strong></em>, for some reason I need to save as "PNG" and display it. I'm gettig error message "ValueError: con... | <python><image><matplotlib> | 2023-11-14 21:53:44 | 1 | 11,430 | user836026 |
77,484,060 | 9,415,459 | efficient iteration & application of a function in pandas, polars or torch? Is lazy possible? | <p><strong>Goal</strong>:
Find an efficient/fastest way to iterate over a table by column and run a function on each column, in python or with a python library.</p>
<p><strong>Background</strong>:
I have been exploring methods to improve the speed of my functions. This is because I have two models/algorithms that I wan... | <python><python-3.x><pandas><pytorch><python-polars> | 2023-11-14 21:53:14 | 1 | 385 | Aaron C |
77,484,040 | 10,664,542 | With Python unittest OOP base & child class, when executed the base class is observed to run the constructor & test_ method more times than expected | <p><strong>Technical areas:</strong></p>
<ul>
<li>Python Programming</li>
<li>Python OOP</li>
<li>Python unittest</li>
</ul>
<hr />
<p><strong>Description:</strong></p>
<p>With Python OOP (unittest scenario), I am a little confused.</p>
<p>I have a base/parent class. I run it and see the constructor called once and a ... | <python><python-3.x><oop><python-unittest> | 2023-11-14 21:49:38 | 0 | 1,346 | user10664542 |
77,483,936 | 356,875 | How can I convert from string, apply the timezone offset, make naive and convert back to string a Pandas Series Index in Python? | <p>I have a Pandas time-series object with an Index like this:</p>
<pre><code>Index(['2023-05-31T00:05:00+0300', '2023-05-31T00:06:00+0300',
...
'2023-09-15T13:48:00+0300', '2023-09-15T13:49:00+0300'],
dtype='object', length=76106)
</code></pre>
<p>and I need to convert into this:</p>
<pre><c... | <python><pandas><datetime><timezone> | 2023-11-14 21:28:59 | 1 | 8,468 | xpanta |
77,483,933 | 18,020,941 | Django base.html block overwriting | <p>I want to define, and append to blocks defined in the base.html template.</p>
<p>Say I have the following template</p>
<pre class="lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<title>My Project</title>
{% block append_to_me %}{% endblock %}
... | <python><django><django-templates><wagtail><templatetags> | 2023-11-14 21:28:02 | 0 | 1,925 | nigel239 |
77,483,917 | 2,823,719 | Scopes confusion using SMTP to send email using my Gmail account with XOAUTH2 | <p>My application has an existing module I use for sending emails that accesses the SMTP server and authorizes using a user (email address) and password. Now I am trying to use Gmail to do the same using my Gmail account, which, for the sake of argument, we say is booboo@gmail.com (it's actually something different).</... | <python><oauth-2.0><gmail><google-oauth><smtp-auth> | 2023-11-14 21:24:30 | 1 | 45,536 | Booboo |
77,483,914 | 9,021,875 | How to maintain a pool of processes | <p>I have a project in which I run multiple processes to do multiple jobs, the jobs are distributed via a queue.</p>
<pre><code>queue = multiprocessing.Queue()
process = multiprocessing.spawn(
run_alg,
args=(queue,),
nprocs=process_num,
join=False,
)
process.join()
</code></pre>
<p>However, it is possib... | <python><multiprocessing><python-multiprocessing><multiprocessing-manager> | 2023-11-14 21:23:28 | 0 | 1,839 | Yedidya kfir |
77,483,889 | 5,036,928 | PyVista: Getting mesh indices (triangles) | <p>I was originally using <a href="https://github.com/pmneila/PyMCubes" rel="nofollow noreferrer">https://github.com/pmneila/PyMCubes</a> which conveniently outputs the mesh points and indices but have since moved to PyVista since for whatever reason PyMCubes applied some sort of weird transformation that isn't ideal. ... | <python><3d><mesh><pyvista> | 2023-11-14 21:16:45 | 0 | 1,195 | Sterling Butters |
77,483,721 | 8,998,172 | Is it possible to continuously substract values from two different columns in a pandas dataframe? | <p>I have two pandas dataframes; one dataframe contains orders, the other one contains items that are in stock.</p>
<pre><code># Sample DF 1 - Orders
# +--------------+------------+---------------+----------------+
# | T-Shirt Size | Ordered By | Shop Location | Order Quantity |
# +--------------+------------+---------... | <python><pandas> | 2023-11-14 20:44:10 | 1 | 1,005 | holger |
77,483,713 | 5,013,143 | How can I change from the interpreter a variable value which is contained in a module of a python project? | <p>Say I have a project with a main.py file like this</p>
<pre><code>from pyFiles.module1 import v
from pyFiles.module1 import myClass1
from pyFiles.module2 import myClass2
def main():
#main function
print("start up!")
if __name__ == "__main__":
main()
</code></pre>
<p>a folder "p... | <python> | 2023-11-14 20:43:22 | 1 | 7,483 | Stefano Fedele |
77,483,427 | 267,482 | How to implement a optional last arguments for a command with Typer in Python? | <p>How do I achieve the syntax similar to</p>
<pre><code>my_app --named_arg1=val1 -- misc_arg1 misc_arg2 ...
</code></pre>
<p>or the same without <code>--</code>?</p>
| <python><typer> | 2023-11-14 19:47:28 | 1 | 18,954 | bobah |
77,483,100 | 3,611,472 | Tensorflow terribly slow on Mac Studio M1 Ultra | <p>I have a Mac Studio M1 Ultra and I am trying to train a simple RNN to forecast time series.</p>
<p>The code is the following</p>
<pre><code>import numpy as np
import keras
import tensorflow as tf
def generate_time_series(batch_size, n_steps):
freq1, freq2, offsets1, offsets2 = np.random.rand(4, batch_size, 1)
... | <python><tensorflow><keras><apple-m1> | 2023-11-14 18:42:16 | 0 | 443 | apt45 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.