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,052,497 | 10,044,690 | Pyomo calling functions when creating constraints | <p>I'm trying to use a loop that creates constraints, where within each constraint, 2 functions are called that perform simple operations on some pyomo variables at a particular index, and then return a vector. An example code is as follows:</p>
<pre><code>import pyomo.environ as pyo
def f(x, y):
x0 = 2.0*x[1]
... | <python><optimization><pyomo> | 2023-04-19 08:48:34 | 1 | 493 | indigoblue |
76,052,283 | 19,276,569 | How to mass produce PDF's efficiently in Python with different variable inputs into each PDF | <p>I have recently begun a task of automating the PDF generation for investor relations clients. We need to send out PDF's en masse, but each PDF needs to have a unique logo and company name at the bottom corner (I have the logos stored in a folder and corresponding names stored in a txt file).</p>
<p>Furthermore, each... | <python><pdf><pdf-generation> | 2023-04-19 08:27:21 | 1 | 856 | juanpethes |
76,052,153 | 14,705,072 | How to fill a column with random values in polars | <p>I would like to know how to fill a column of a polars dataframe with random values.
The idea is that I have a dataframe with a given number of columns, and I want to add a column to this dataframe which is filled with different random values (obtained from a random.random() function for example).</p>
<p>This is what... | <python><dataframe><python-polars> | 2023-04-19 08:13:04 | 5 | 319 | Haeden |
76,052,051 | 11,514,484 | Postgresql UPSERT while encrypting column by python encryption | <p>I am using BULK UPSERT to insert record into new table while data of column is being encrypting by python lib CryptoDome.
here is what I done</p>
<pre><code>def bulk_upsert_query(data, table_name=None):
values_list = []
add = values_list.append
for i in data:
encrypt_user_id = encryption_fnc(str... | <python><postgresql><encryption><upsert> | 2023-04-19 08:01:53 | 2 | 331 | Sohel Reza |
76,052,034 | 14,457,833 | Why maximize button get removed when I click or try to maximize window in PyQt5 | <p>I've a simple pyqt application in which I've some code for UI which is responsible for realtime speech-to-text in application everything works fine but when I try to maximize my application by clicking on maximize icon it get remove and window does not maximized here is output how it looks</p>
<p><a href="https://i.... | <python><qt><pyqt><pyqt5><qt5> | 2023-04-19 07:59:41 | 1 | 4,765 | Ankit Tiwari |
76,051,928 | 3,769,802 | Docker run throws error AttributeError: 'cimpl.Producer' object has no attribute 'service_name' | <p>I have a base resource class</p>
<pre class="lang-py prettyprint-override"><code>../baselayer/baseresource/resource.py
class Resource:
def __init__(self, *args, service_name: str, client_name: str = "Resource", log: Logger = None,
error_notifier: ErrorNotifier = None, **kwargs):
... | <python><dockerfile><fastapi><gunicorn><confluent-kafka-python> | 2023-04-19 07:47:21 | 0 | 533 | Sab |
76,051,851 | 2,836,333 | Scheduling a python script with Windows task scheduler | <p><strong>Overview of the setup:</strong></p>
<ul>
<li>W10 professional within a domain</li>
<li>All scripts and files within 1 folder (not local but network drives connected to the file server)</li>
<li>2 python scripts: one to filter an Excel file (removing columns and stuff), another to edit an HTML file and fill i... | <python><scheduled-tasks><windows-task-scheduler> | 2023-04-19 07:36:25 | 1 | 739 | Onovar |
76,051,799 | 11,938,023 | I have a numpy and or pandas array that repeats, how do i find out where and when it does? | <p>Ok, this is pandas but i don't care if there is a pandas or numpy solution, i'm just looking for a solution to see where the pattern repeats: Here is what is have:</p>
<pre><code>Out[713]:
sf sx sz ss
0 12 15 5 6
1 15 1 13 3
2 13 10 6 1
3 9 14 8 15
4 2 2 6 6
5 8... | <python><arrays><list><numpy><append> | 2023-04-19 07:28:47 | 1 | 7,224 | oppressionslayer |
76,051,674 | 2,793,602 | Frequency encoding - should I make dummy columns? | <p>I am busy prepping data to train a machine learning model. Many of the features can work well with one-hot encoding. For one feature, the frequency is related to the target variable. I have been reading up a bit about frequency encoding and everything I find has to do with replacing the category with the frequency, ... | <python><pandas><machine-learning> | 2023-04-19 07:13:34 | 2 | 457 | opperman.eric |
76,051,470 | 10,967,961 | Perform inner_join() of R in Python | <p>I have a Pandas database Network with a network structure like this:</p>
<pre><code>{'Sup': {0: 1002000157,
1: 1002000157,
2: 1002000157,
3: 1002000157,
4: 1002000157,
5: 1002000157,
6: 1002000157,
7: 1002000157,
8: 1002000157,
9: 1002000157,
10: 1002000157,
11: 1002000157,
12: 1002000157,
... | <python><join><inner-join> | 2023-04-19 06:46:53 | 2 | 653 | Lusian |
76,051,467 | 12,118,546 | Valid Python line with undefined variable and annotation | <p>I have come accros <a href="https://pythonetc.orsinium.dev/posts/isinstance.html" rel="nofollow noreferrer">a post</a> with undefined variable name with some type annotation. The line is valid. What it does and what are possible usages?</p>
<pre class="lang-py prettyprint-override"><code>>>> x: int
>>... | <python><python-typing> | 2023-04-19 06:46:03 | 1 | 4,251 | Roman Pavelka |
76,051,358 | 13,403,510 | Accessing month data in pandas | <p>My data looks like following;</p>
<pre><code>Month Target Efficiency Actual
Aug-18 95% 0.4500
Sep-18 95% 0.3000
</code></pre>
<p>I'm running pandas.
when i run code;</p>
<pre><code>df['Efficiency Actual']
</code></pre>
<p>I get correct output.</p>
<p>But when i run;</p>
<pre><code>df['Month']
</code></p... | <python><pandas><data-analysis> | 2023-04-19 06:30:08 | 0 | 1,066 | def __init__ |
76,051,317 | 7,766,024 | Is there any way to add Google Sheet formatting to an Excel file, then upload that to Google Sheets? | <p>I have multiple CSV files that I want to combine into one Excel file that has multiple sheets (one sheet for each CSV file).</p>
<p>I want to use some custom formatting like borders, conditional formatting for colors and certain cells, etc. Right now I'm downloading the CSV files separately from my server, importing... | <python><google-sheets> | 2023-04-19 06:24:55 | 1 | 3,460 | Sean |
76,051,277 | 9,525,238 | numpy Mask 2d array rows by ranges from 1d array | <p>I have this 1d array which represents the ranges of valid values.</p>
<pre><code>ranges = np.array([1, 2, 0])
</code></pre>
<p>and i have multiple 2d arrays that have values, which i want to mask by index based on the ranges above.</p>
<pre><code>matrixes = np.array([[0, 1, 2],
[3, 4, 5],
... | <python><numpy> | 2023-04-19 06:17:54 | 1 | 413 | Andrei M. |
76,051,250 | 13,939,843 | How to remove unused packages installed with pip in Python? | <p>I have Python project and have installed hundreds of packages using pip over time. However, I have since improved my code and suspect that some of these packages are no longer in use. I want to remove all of the unused packages.</p>
<p>I am already familiar with the <code>pip uninstall package-name</code> command an... | <python><python-3.x><requirements.txt> | 2023-04-19 06:13:04 | 1 | 357 | iihsan |
76,051,233 | 2,252,356 | Python Multilevel Treemap | <p>Treemap Mutlilevel plot of car make , type and count dataset shown below. I found few packages using plotly.express and matplotlib-extra. But it did not help.</p>
<p>I want to have a customized lables in the format</p>
<p>Squarify does not support multilevel</p>
<pre><code>#labels = [f'{make}\n{count}' for make, ... | <python><machine-learning> | 2023-04-19 06:10:39 | 1 | 2,008 | B L Praveen |
76,051,126 | 47,936 | Nearest neighbour(closest point) search using vtkKdTree | <p>I am using vtk's kdtree to search closest point, here is a simple example that, to my surprise, returned a value that was not what I was expecting</p>
<pre><code>import vtk
points = vtk.vtkPoints()
points.InsertNextPoint(1, 0, 0)
points.InsertNextPoint(0, 1, 0)
points.InsertNextPoint(0, 0, 1)
kdtree = vtk.vtkKdTre... | <python><algorithm><vtk><kdtree> | 2023-04-19 05:47:08 | 1 | 7,908 | zhongshu |
76,051,046 | 15,632,586 | What should I do to load all-mpnet-base-v2 model from sentence-transformers? | <p>I am trying to run <code>all-mpnet-base-v2</code> model with <code>sentence-transformers</code> 1.2.1 from my Anaconda framework (in Python 3.8). My first prompt for the model is like this:</p>
<pre><code>bert_model = SentenceTransformer('all-mpnet-base-v2')
</code></pre>
<p>However, when I run this model, after dow... | <python><huggingface-transformers><sentence-transformers> | 2023-04-19 05:33:51 | 0 | 451 | Hoang Cuong Nguyen |
76,051,008 | 128,618 | how to pivot table from excel to pandas | <p>My csv contain like (df) :</p>
<pre><code>item_group item_code total_qty total_amount cost_center
0 Drink IC06-1P 1 3.902 Cafe II
1 Drink IC09-1 1 2.927 Cafe II
2 BreakFast FS04-2 1 6.463 Cafe II
3 Drink IC... | <python><python-3.x><pandas><pivot-table> | 2023-04-19 05:26:20 | 1 | 21,977 | tree em |
76,050,948 | 2,998,077 | pyttsx3 produced mp3 not recognizable by pydub | <p>In using pyttsx3 to produce mp3 audio files, it seems there's a problem that the mp3 file is not recognizable by pydub.</p>
<p>pyttsx3: text to speech package
pydub: audio handling package</p>
<p>The error message says a lot of "Header missing".</p>
<p>The code is below.</p>
<p>What went wrong, and how can... | <python><audio><mp3><pydub><pyttsx3> | 2023-04-19 05:13:30 | 2 | 9,496 | Mark K |
76,050,912 | 9,218,680 | pivot table in pandas with a subtraction function on all possible combinations | <p>I have a dataframe that looks something like</p>
<pre><code>Strike. Strike2 Price
15000. 15000. 100
15100. 15100. 150
15200. 15200. 170
</code></pre>
<p>I want to create a matrix like df such that the output looks like</p>
<pre><code>Strike. 15000. 15100. 15200.
15000. 0. 50. 120
15100. -50 ... | <python><pandas><pivot> | 2023-04-19 05:05:55 | 1 | 2,510 | asimo |
76,050,901 | 14,173,197 | Haystack: save InMemoryDocumentStore and load it in retriever later to save embedding generation time | <p>I am using InMemory Document Store and an Embedding retriever for the Q/A pipeline.</p>
<pre><code>from haystack.document_stores import InMemoryDocumentStore
document_store = InMemoryDocumentStore(embedding_dim =768,use_bm25=True)
document_store.write_documents(docs_processed)
from haystack.nodes import Embed... | <python><nlp><haystack> | 2023-04-19 05:04:30 | 2 | 323 | sherin_a27 |
76,050,717 | 7,133,942 | How to use the at() method in Pyomo | <p>I am using Pyomo and I have the following lines</p>
<pre><code>outputVariables_list = [model.param1, model.variable1]
optimal_values_list = [[pyo.value(model_item[key]) for key in model_item] for model_item in outputVariables_list]
</code></pre>
<p>When I run it I get a warning that I don't understand:</p>
<pre><co... | <python><mathematical-optimization><pyomo> | 2023-04-19 04:16:14 | 1 | 902 | PeterBe |
76,050,699 | 6,702,598 | Pytest: How to specify package root directory | <p>This is my project structure (simplified):</p>
<pre><code>my-project
├── __init__.py
├── my_code.py
└── tests
├── __init__.py
└── test_foo.py
</code></pre>
<p>When I run pytest ( with <code>pytest .</code> from within <em>my-project</em> or <code>pytest my-project</code> from its parent direct... | <python><pytest> | 2023-04-19 04:12:15 | 2 | 3,673 | DarkTrick |
76,050,491 | 1,302,465 | How to dynamically change loss function between epochs in tensorflow model | <p>I want to change loss function for every alternative epoch or every 5 epochs. I tried using loss wrapper method suggested in <a href="https://stackoverflow.com/questions/55406146/resume-training-with-different-loss-function/55978428#55978428">this</a>. This didn't work. It is keeping <strong>current_epoch</strong> v... | <python><tensorflow><keras><loss-function> | 2023-04-19 03:09:38 | 1 | 477 | Keerthi Jayarajan |
76,050,236 | 2,961,927 | Python equivalent to R's layout() for arbitrary grids | <p>What's Python's equivalent to R's <code>layout()</code> function which can create a plotting grid of any shape?</p>
<p>Consider the following 3 figures made by <code>layout()</code>:</p>
<pre class="lang-r prettyprint-override"><code>set.seed(123)
layout(t(matrix(c(
1, 1, 2, 2, 3, 3,
4, 5, 5, 6, 6, 7
), ncol = 2... | <python><r><matplotlib><equivalent> | 2023-04-19 02:03:39 | 1 | 1,790 | user2961927 |
76,049,984 | 11,065,874 | What is the difference between calling dict of a Pydantic model and passing it to the jsonable_encoder function? | <p>I have this Pydantic model:</p>
<pre class="lang-py prettyprint-override"><code>from pydantic import BaseModel
class Student(BaseModel):
name: str
id: str
</code></pre>
<p>I see in the <a href="https://fastapi.tiangolo.com/advanced/response-directly/#using-the-jsonable_encoder-in-a-response" rel="nofollow n... | <python><fastapi><pydantic> | 2023-04-19 00:48:52 | 1 | 2,555 | Amin Ba |
76,049,807 | 7,318,120 | websockets.sync.client - No module named 'websockets.sync' | <p>I am looking at websockets and have tried the official docs here: <a href="https://pypi.org/project/websockets/" rel="nofollow noreferrer">https://pypi.org/project/websockets/</a></p>
<p>I do a <code>pip install websockets</code> to make sure that I have the latest module.</p>
<p>I then run the template code (from t... | <python><websocket> | 2023-04-18 23:51:56 | 1 | 6,075 | darren |
76,049,760 | 3,792,360 | Processing csv file via pandas | <p>This is my csv file contents</p>
<pre><code>1.1.1.Top Header
Attribute,Field Description,Table,Column, Filter
Quarter,Fiscal Current Quarter,tableA,col1,A=B
Blah, Blah, Blah, Blah, Blah
Blah, Blah, Blah, Blah, Blah
Blah, Blah, Blah, Blah, Blah
1.1.2.Next Level
Attribute,Field Description,Table,Column, Filter
... | <python><pandas> | 2023-04-18 23:39:54 | 2 | 713 | paddu |
76,049,510 | 13,436,451 | Size of seeds for numpy.random | <p>I want to run some code using <code>numpy.random</code> and keep track of what the seed is so that if the output is interesting, I can recreate and play around with that randomly generated instance. Therefore, I want the setup to involve something like</p>
<pre><code>import numpy as np
s = np.random.randint(10000000... | <python><numpy><random><random-seed> | 2023-04-18 22:32:26 | 1 | 327 | zjs |
76,049,443 | 12,436,050 | Convert dataframe to turtle format in python | <p>I am new to rdf and triples and I am looking for a way to load some triples in a triple store. I have a dataframe with following columns.</p>
<pre><code> mesh_code skos_rel MDR_code
0 <http://id.nlm.nih.gov/mesh/D000012> <http://www... | <python><rdf><turtle-rdf> | 2023-04-18 22:21:30 | 1 | 1,495 | rshar |
76,049,388 | 14,294,527 | How can I create a variable containing the numbers of each quadrant of a scatterplot? | <p>I have a scatterplot, just like the one below:</p>
<p><img src="https://www.econometrics-with-r.org/ITER_files/figure-html/unnamed-chunk-128-1.png" alt="graph" /></p>
<p>Let's say I want to create a new column, named QUADRANT, which contains the number that represents a quadrant. For instance, if the point has the y... | <python><pandas><numpy><matplotlib><coordinates> | 2023-04-18 22:07:31 | 1 | 307 | dummyds |
76,049,387 | 10,426,490 | Unable to import test modules, Python Azure Function | <p>Seems like there has been a lot of movement with the <code>import</code> of tests and shared modules. I tried the <a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=asgi%2Capplication-level&pivots=python-mode-configuration#import-behavior" rel="nofollow noreferrer">d... | <python><azure-functions><python-unittest> | 2023-04-18 22:07:29 | 1 | 2,046 | ericOnline |
76,049,331 | 13,436,451 | Will constructing a sparse graph in NetworkX automatically store the full adjacency matrix? | <p>If I have a sparse graph that I would like to instantiate as a NetworkX graph and currently have stored as a (say) adjacency dictionary, will it automatically store the data also as a full adjacency matrix (which is very large and thus costly to instantiate), or will the adjacency matrix only be created when explici... | <python><networkx> | 2023-04-18 21:56:20 | 1 | 327 | zjs |
76,049,326 | 1,251,549 | How add depedency for PyElementVisitor for Intellij Idea plugin? | <p><strong>The goal</strong></p>
<ol>
<li>create a plugin for Python files</li>
<li>debug this plugin with Intellij Idea (not PyCharm) for 2 reasons: a) IntelliJ Idea is the main development IDE b) I do not have/want an additional license for PyCharm</li>
<li>The plugin should rely on <a href="https://mvnrepository.com... | <python><intellij-idea><intellij-plugin> | 2023-04-18 21:55:26 | 0 | 33,944 | Cherry |
76,049,257 | 2,642,356 | Missing symbol error after compiling a library that references another precompiled library | <p><strong>tl;dr</strong>: I'm trying to compile a .cpp file that references another compiled API (.so + .h files), and I get a missing symbol when I try to load it. Below is a simple example of how I created the modules, and all the steps that I made along the way. Help would be very appreciated.</p>
<p><strong>NOTE:<... | <python><c++><linker><g++><cython> | 2023-04-18 21:43:49 | 1 | 1,864 | EZLearner |
76,049,158 | 3,822,090 | Wasserstein distance in scipy - definition of support | <p>I want to use the Wasserstein distance from scipy.stats.wasserstein_distance to get a measure for the difference between two probability distribution. However, I do not understand how the support matters here.</p>
<p>For example, I would have expected
<code>stats.wasserstein_distance([0,1,0],[1,0,0])</code>
to be 1 ... | <python><scipy.stats> | 2023-04-18 21:25:31 | 1 | 2,194 | mzzx |
76,049,155 | 6,457,862 | Is it possible to bind a name inside a python function after the function has been compiled? | <p>I know this pattern is would be very bad, I'm asking the question out of curiosity not because I'm planning on doing this in production code.</p>
<p>Suppose I define a function:</p>
<pre class="lang-py prettyprint-override"><code>def function(x, y):
return x + y + z
</code></pre>
<p>And the variable <code>z</cod... | <python><python-3.x><function><name-binding> | 2023-04-18 21:24:31 | 1 | 437 | Ignacio |
76,049,129 | 5,168,463 | Tensorflow: Issue with training size in each epoch | <p>I am building a basic neural network using Keras and Tensorflow using mnist dataset using the following code:</p>
<pre><code>import os
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.datasets import mnist
(x_train, y_train), (x_test, y_test) = mnist.lo... | <python><keras><tensorflow2.0> | 2023-04-18 21:20:44 | 1 | 515 | DumbCoder |
76,048,814 | 1,810,940 | Referencing class attributes inside of class body | <p>I have an API that uses abstract class attributes, essentially attributes that exist for all instances of a class & are defined in the class body.</p>
<p>I would like to programmatically generate some of these attributes. They aren't <em>dynamic</em> in the sense that they don't change at runtime.</p>
<p>For exa... | <python><python-3.x><oop><attributes> | 2023-04-18 20:29:02 | 0 | 503 | jay |
76,048,682 | 1,218,317 | Python script skips certain lines when run without shell | <p>I have some code like this:</p>
<pre><code>from stomp import *
from stomp.listener import ConnectionListener
from stomp.utils import parse_frame
class MyListener(ConnectionListener):
_counter=0
def on_message(self, frame):
if self._counter > 10:
return
print(self._counter)
self._counter += ... | <python><python-3.x><stomp> | 2023-04-18 20:10:42 | 1 | 1,908 | ritratt |
76,048,657 | 3,509,416 | Preservation of multiline yaml string in exact format when opening file | <p>I'm developing an app where I preserve the response of an api call in a yaml file and then as a second part open that yaml file to access the response.</p>
<p>These are two independent runs so can't preserve the response in memory.</p>
<p>The response comes out as a string <code>"- dashboard: new_dashboard\n t... | <python><yaml><ruamel.yaml> | 2023-04-18 20:07:09 | 0 | 1,899 | hselbie |
76,048,534 | 750,510 | How to create AWS Graviton (ARM) Python Lambda on Intel machine with Poetry | <p>I'm trying to build a Python Lambda with Poetry. My function depends on <code>psycopg2</code>. This library, in turn, depends on a platform binary: <code>libpq</code>. So, I need to bundle it in my distro (a ZIP file). There is a <a href="https://pypi.org/project/psycopg2-binary" rel="nofollow noreferrer">psycopg2-b... | <python><python-poetry><python-wheel><aws-graviton> | 2023-04-18 19:49:09 | 1 | 33,782 | madhead |
76,048,531 | 10,266,106 | Numpy ndenumerate A Shared Array With Multiprocessing | <p>I have two arrays named <code>arrayone</code> & <code>arraytwo</code>, both of which are identical in dimensions, static, and will not need to be altered. A third array <code>masterarray</code> is pre-assembled, in which the compilation of integers are cast to a third array, then placed into the pre-assembled th... | <python><numpy><python-multiprocessing><numpy-ndarray> | 2023-04-18 19:48:37 | 1 | 431 | TornadoEric |
76,048,526 | 10,044,690 | Pyomo initializing and constraining 2xN variables | <p>I have the following code, where I am trying to create a <code>2xN</code> variable called <code>x</code> and initialize all columns in the first row to <code>x0_init</code>, and all columns in the second row to <code>x1_init</code>. After that I want to add initial and final boundary constraints to each row:</p>
<pr... | <python><optimization><pyomo> | 2023-04-18 19:48:06 | 1 | 493 | indigoblue |
76,048,462 | 3,768,822 | Display Plotly HTML inside a Jupyter Notebook | <p>I have a <code>.html</code> file created as</p>
<pre><code>import plotly.express as px
fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
fig.write_html("px.html", full_html=False, include_plotlyjs='cdn')
</code></pre>
<p>I can open this file from the filesystem and it displays fine in Chrome.</p>
<p... | <python><jupyter-notebook><plotly> | 2023-04-18 19:37:42 | 1 | 1,357 | Jonathan |
76,047,921 | 1,637,894 | Why do Qt timers fire less frequently when not updating the GUI? | <p>Below is a simple Qt for Python (PySide6) application that tries to count the number of times a slot gets called in one second:</p>
<pre class="lang-py prettyprint-override"><code>import time
from PySide6.QtCore import *
from PySide6.QtTest import *
from PySide6.QtWidgets import *
class MainWindow(QWidget):
d... | <python><qt><pyqt><pyside> | 2023-04-18 18:22:55 | 1 | 515 | sammosummo |
76,047,913 | 505,328 | OPC UA asyncua python: new file directory created but it lacks the CreateFile method among its children | <p>My problem appears to be very similar to this unanswered question: <a href="https://stackoverflow.com/questions/75117089/opc-ua-asyncua-python-new-folder-created-but-server-never-returns-the-methods">OPC UA asyncua python: new folder created but server never returns the methods</a> but I have tried something slightl... | <python><file-transfer><opc-ua> | 2023-04-18 18:21:49 | 0 | 379 | WindowsWeenie |
76,047,825 | 4,670 | Boto3 Client Creation is Slow | <p>I am running boto3 on AWS Lambda but getting a boto3 client is very slow. I am currently running a python3.9 runtime on AWS Lambda that creates handfuls of presigned url for s3 resources.</p>
<p>A key line of code required to generate the url with boto3 is</p>
<pre><code>print("Getting boto3")
self.s3_clie... | <python><amazon-web-services><boto3> | 2023-04-18 18:10:16 | 0 | 4,127 | Steve |
76,047,654 | 6,583,606 | KSComp with variable-size constraint vector input | <h1>Summary</h1>
<p>I'm trying to perform structural optimization coupling Nastran SOL 106 and OpenMDAO. I want to minimize mass subject to nonlinear stress and stability constraints. My structure is a box beam reinforced with ribs and stiffeners clamped at the root and loaded with a concetrated force at the tip. At th... | <python><openmdao><nastran> | 2023-04-18 17:48:28 | 1 | 319 | fma |
76,047,620 | 6,930,441 | Multiprocessing or multithreading a for loop | <p>I'm brand new to the idea of multithreading vs multiprocessing. I would like to run a for loop, which runs a single function (with two input args) either across several threads or several processors (very unclear about that, despite reading all day). It's also further complicated by the fact that the function append... | <python><multithreading><function><for-loop><multiprocessing> | 2023-04-18 17:44:01 | 0 | 456 | Rainman |
76,047,580 | 3,398,324 | Replace row values in Panda columns temporarily and convert back | <p>I have a dataframe column which is a date and I would like to replace it with ordered integers like this and then back (not one way but roundtrip)</p>
<p>Current DataFrame:</p>
<pre><code>data = {'date': ['1/1/2022', '1/2/2022,1/3/2022]}
df = pd.DataFrame(data)
</code></pre>
<p>Target DataFrame:</p>
<pre><code>data ... | <python><pandas><dataframe> | 2023-04-18 17:40:32 | 1 | 1,051 | Tartaglia |
76,047,509 | 10,426,490 | How to troubleshoot a Python Azure Function "An unhandled exception has occurred"? | <p>I have an Azure Function with Python runtime. It works well with no big issues. I have an alert setup for times when failures occur. The alert went off and I can't figure out why.</p>
<p><strong>Scenario</strong>:</p>
<ul>
<li>The function executed just fine 4/18/2023 ~07:23:13 (shown below)</li>
<li>Then the next <... | <python><azure-functions><kql> | 2023-04-18 17:32:26 | 0 | 2,046 | ericOnline |
76,047,250 | 236,081 | What else goes in a Python src folder, according to actual or de facto standards? | <p>When using <a href="https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#src-layout" rel="noreferrer">src layout</a> rather than flat layout in a Python project, is anything other than the project module expected to live in the <code>src</code> folder?</p>
<p>My understanding is that if I added <cod... | <python><python-packaging> | 2023-04-18 17:00:56 | 1 | 17,402 | lofidevops |
76,047,227 | 3,826,115 | Keep axis limits/zoom level when switching between two Points plots in holoviews/bokeh in Python | <p>Say I have the following code, which switches between two holoviews Points plots based on a Radio Button. If you click on one of the points, a corresponding timeseries plot pops up to the right.</p>
<pre><code>import pandas as pd
import holoviews as hv
import panel as pn
import numpy as np
hv.extension('bokeh')
... | <python><bokeh><holoviews> | 2023-04-18 16:58:12 | 1 | 1,533 | hm8 |
76,047,135 | 12,340,367 | Python CLI tool is not added to path after installation with pip | <p>I have developed a small CLI tool and it works fine for Linux users. However, Mac and sometimes Windows users struggle with the installation using pip.</p>
<p>They usually find the package inside their installed global packages, but somehow their shell is not auto discovering the commands from the <code>.toml</code>... | <python><windows><macos><pip><python-packaging> | 2023-04-18 16:46:27 | 1 | 582 | Snake_py |
76,047,104 | 2,741,711 | How to sublass ndarray to transform as rvalue, but preserve lvalue | <p>I would like to subclass <code>np.ndarray</code> such that my new custom array has the following properties,</p>
<ol>
<li>When defining the array, I would also provide a <code>transform_fwd</code> function, as a class parameter.</li>
<li>Whenever this array is used in any computation, it applies and provides the tra... | <python><numpy><numpy-ndarray> | 2023-04-18 16:41:36 | 0 | 382 | ipcamit |
76,047,043 | 2,789,334 | How to annotate grouped bars in a facetgrid with custom strings | <p>My seaborn plot is shown below. Is there a way to add the info in the <code>flag</code> column (which will always be a single character or empty string) in the center (or top) of the bars? Hoping there is an answer which would not need redoing the plot as well.</p>
<p><a href="https://stackoverflow.com/questions/5... | <python><matplotlib><seaborn><bar-chart><catplot> | 2023-04-18 16:34:16 | 1 | 1,068 | ironv |
76,046,921 | 10,966,677 | Django: while updating record: ValueError: Cannot force an update in save() with no primary key | <p>There are similar issues on SO, but none alike this.</p>
<p>I would like to update a field in a record of a m2m model which has a unique constraint on <code>attendee</code> + <code>training</code>. This model is defined as (<code>model.py</code>):</p>
<pre><code>class Occurrence(models.Model):
attendee = models.... | <python><django> | 2023-04-18 16:20:46 | 2 | 459 | Domenico Spidy Tamburro |
76,046,749 | 15,414,616 | Falcon API - process respond after client gets it | <p>I have a <code>falcon</code> API (WSGI) that I wrote that needs to be as fast as possible.</p>
<p>At one part of the code I have the respond that I need to send to the client, but I have a datalake where I send all of responses + some more calculation results using kafka.
I want to separate the extra calculations + ... | <python><gunicorn><falconframework> | 2023-04-18 16:02:19 | 1 | 437 | Ema Il |
76,046,700 | 3,798,897 | How can you quickly find all the nodes connected to a subset of a bipartite graph? | <p>Given a set of left nodes and right nodes, and edges between them (a bipartite graph), I need to support quick lookups from sets of left nodes to the subset of right nodes connected to anything on the left.</p>
<p>That's easy if the graph is very sparse or dense. Below is a sample adjacency-list implementation that ... | <python><algorithm><math><graph-theory> | 2023-04-18 15:54:51 | 2 | 7,191 | Hans Musgrave |
76,046,538 | 18,769,241 | Is there a way to check if a dataframe is contained within another? | <p>I am using pandas to check wether two dataframes are contained within each others. the method <code>.isin()</code> is only helpful (e.g., returns <code>True</code>) only when labels match (ref: <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.isin.html" rel="nofollow noreferrer">https://pandas.... | <python><pandas> | 2023-04-18 15:41:04 | 2 | 571 | Sam |
76,046,536 | 607,846 | Filter a Query Set by Reverse Foreign Key | <p>If I have the following:</p>
<pre><code>class Asset(models.Model):
name = models.TextField(max_length=150)
project = models.ForeignKey('Project')
class Project(models.Model):
name = models.TextField(max_length=150)
</code></pre>
<p>What argument do I pass to <code>Project.objects.filter()</code> to get ... | <python><django><django-queryset> | 2023-04-18 15:40:53 | 2 | 13,283 | Baz |
76,046,452 | 11,143,781 | Tensorflow CNN MaxPooling1D is incompatible with the layer error | <p>I have 2D signal data that is shaped as follows: <code>(number of signal combinations x number of signals x number of signal points x channel)</code>, so more clearly, it is: <code>(10000 x 2 x 51 x 1)</code>.
I treat my data as an image (basically, its height is 2, its width is 51), and I process it through the CNN... | <python><tensorflow><machine-learning><conv-neural-network> | 2023-04-18 15:31:28 | 0 | 316 | justRandomLearner |
76,046,434 | 8,182,381 | How to a read camera video stream and store on FTP server using python | <p>I'm new to onvif streaming using python.
I would like to read a video stream from a camera and directly store the video on my ftp server. I could come up with the following piece of code.</p>
<pre><code>from ftplib import FTP
from io import BytesIO
import cv2
ftp = FTP('my-ftp-host-server')
ftp.login('my-ftp-user-i... | <python><ftp><video-streaming><ip-camera><onvif> | 2023-04-18 15:29:33 | 1 | 303 | Herval NGANYA |
76,046,238 | 6,002,560 | How to pass to from_json a dynamic json schema stored in a column | <p>I have this dataframe schema:</p>
<pre><code>root
|-- data: array (nullable = false)
| |-- element: string (containsNull = true)
|-- schema: string (nullable = false)
</code></pre>
<p>and the dataframe looks like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>data</th>
<th>s... | <python><json><apache-spark><pyspark> | 2023-04-18 15:08:34 | 1 | 302 | Federico Rizzo |
76,046,234 | 2,059,689 | Pytest - asserts at teardown of class scoped fixture | <p>I have a parametrized test suite that is organized as a class containing multiple test cases and class-scoped fixture. I'm looking for a way to run some assertions after all tests complete for a given fixture instance. Any ideas on how I can achieve that?</p>
<p>I tried putting <code>assert</code> / <code>pytest.fai... | <python><pytest> | 2023-04-18 15:08:14 | 1 | 3,200 | vvv444 |
76,046,148 | 8,219,760 | Why is `obj.__del__()` not being called when collection containing object reference is deleted | <p>I am trying to build a <code>Process</code> subclass to utilize multiple GPUs in my desktop.</p>
<pre class="lang-py prettyprint-override"><code>class GPUProcess(mp.Process):
used_ids: list[int] = []
next_id: int = 0
def __init__(self, *, target: Callable[[Any], Any], kwargs: Any):
gpu_id = GPUP... | <python><multiprocessing><del> | 2023-04-18 14:59:34 | 1 | 673 | vahvero |
76,046,058 | 5,057,022 | Numpy H Stacking | <p>I have these arrays:</p>
<pre><code>co_ords = np.random.rand(10,2)
labels = np.random.choice(2,10)
</code></pre>
<p>which look like</p>
<pre><code>array([[0.27195884, 0.95210374],
[0.86416174, 0.88711233],
[0.97141129, 0.22182439],
[0.85683001, 0.85308369],
[0.45731582, 0.24709513],
... | <python><arrays><numpy> | 2023-04-18 14:50:42 | 1 | 383 | jolene |
76,046,035 | 6,930,441 | Combining one entire list with iterations of a second list | <p>I'm stuck on a seemingly simple problem. I have two lists and would like to generate tuples of the entirety of list with individual elements from list2. I.e.:</p>
<pre><code>list1 = [a,b,c,d]
list2 = [1,2,3]
</code></pre>
<p>Desired output</p>
<pre><code>output_list = [([a,b,c,d],1), ([a,b,c,d],2),([a,b,c,d],3)]
</c... | <python><list><iteration> | 2023-04-18 14:48:46 | 1 | 456 | Rainman |
76,045,880 | 21,420,742 | What is an alternative to using map function in python | <p>I have a dataset and I need to get a count of reports and I am using map but does not seem to be working.</p>
<p>Sample Data:</p>
<pre><code>ID Manager_ID Manger_Pos_Num
101 103 1111
102 103 1111
103 106 2222
104 103 ... | <python><python-3.x><pandas><dataframe><numpy> | 2023-04-18 14:32:45 | 1 | 473 | Coding_Nubie |
76,045,724 | 5,711,995 | awaiting a future which never resolves: set_result called by a callback triggered by an event emitter from a background coroutine / task | <p>I have some code for communicating with a websocket connection. I want to send a message to the server and returns a future which will resolve with the data sent by the server once the server sends an end signal. The code collecting the responses should run in the background, in a non-blocking way, collecting the re... | <python><events><websocket><python-asyncio><future> | 2023-04-18 14:17:49 | 1 | 1,609 | SomeRandomPhysicist |
76,045,438 | 1,860,222 | Algorithm for matching collection items in python | <p>I'm working on a game program in python. On their turn, a player can purchase a card from a collection of 12 available cards. Each card has a cost consisting of varying quantities of 5 different colored 'gems'. The player has a bank of gems in the same 5 colors (plus gold 'wildcards'). I need to design a method that... | <python><algorithm><sorting><search> | 2023-04-18 13:51:06 | 1 | 1,797 | pbuchheit |
76,045,431 | 1,484,601 | pushing to pypi via github actions: how to manage changes with no version number update? | <p>One can use github actions to publish to PyPI everytime there is an updated on the master branch.</p>
<p>For example, one can use: <a href="https://github.com/marketplace/actions/publish-python-poetry-package" rel="nofollow noreferrer">https://github.com/marketplace/actions/publish-python-poetry-package</a></p>
<p>F... | <python><github-actions><versioning><pypi> | 2023-04-18 13:50:13 | 1 | 4,521 | Vince |
76,045,413 | 8,628,566 | Why does time to compute a single training step increase over time for some seeds/configurations of ADAM but not for SGD in PyTorch? | <p>I'm working on a PyTorch project using PyTorch Lightning (version 1.8.4) to train a neural network. I've noticed that the time it takes to compute a single training step increases over time for some seeds and configurations of the ADAM optimizer, but not for SGD.</p>
<pre><code>conda create --name my_env python=3.9.... | <python><deep-learning><pytorch><pytorch-lightning><adam> | 2023-04-18 13:48:20 | 1 | 333 | Pablo Sanchez |
76,045,330 | 5,841,817 | How to change/suppress server header with gunicorn and uvicorn worker class? | <p>I'm running my python asgi application with <code>gunicorn</code> and <code>uvicorn</code> worker class with this command line:</p>
<p><code>unicorn -c gunicorn_conf.py my.asgi:application -k uvicorn.workers.UvicornWorker</code></p>
<p>I want to obfuscate the <code>server</code> HTTP header.</p>
<p>The <a href="http... | <python><gunicorn><uvicorn><asgi> | 2023-04-18 13:40:05 | 1 | 1,066 | sgargel |
76,045,250 | 20,051,041 | How to add watemark in a video with ffmpeg, Python? | <p>I would like to add a .png watemark with 50% opacity over all my video. I would prefer using a ffmpeg filter over merging the watemark image with video-to-be images.</p>
<pre><code>audio = f'{PROJECT_PATH}/data/ppt-elements/audio_{file_id}.txt'
images = f'{PROJECT_PATH}/data/ppt-elements/images_{file_id}.txt'
image... | <python><ffmpeg><watermark> | 2023-04-18 13:33:13 | 1 | 580 | Mr.Slow |
76,045,128 | 21,787,377 | getting model object returned matching query does not exist | <p>I want to display what user is posted from a <code>Book</code> model when others user visited his public_profile page, to do that, i had to use this method:</p>
<pre><code>def public_profile(request, slug):
profile = get_object_or_404(Profile, slug=slug)
book = Book.objects.get(slug=slug)
context = {
... | <python><django> | 2023-04-18 13:20:24 | 1 | 305 | Adamu Abdulkarim Dee |
76,045,075 | 10,557,442 | How can I unpivot a dataframe with variable date columns? | <p>I have some input dataframe as the following example:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
{
"Name":["Ale", "Dan", "Hel"],
"Project": ["A", "A", "B"],
"10/04/2023 Formation": [24, 4... | <python><pandas><pivot><unpivot> | 2023-04-18 13:14:46 | 3 | 544 | Dani |
76,044,989 | 903,051 | Shap beeswarm plot: Colour criterion for regression | <p>Back in the day, I came up with the following code to export a Shap beeswarm as an interactive HTML file using Plotly:</p>
<pre><code>explainer = shap.Explainer(best_model.predict, X_test)
shap_values = explainer(X_test)
shap_df = pd.DataFrame(
np.c_[shap_values.base_values, shap_values.values],
columns = [... | <python><machine-learning><plotly><regression><shap> | 2023-04-18 13:05:39 | 1 | 543 | mirix |
76,044,839 | 5,576,083 | How to group selections and repalcements in a Pandas dataframe? | <p>I wrote a similar post here <a href="https://stackoverflow.com/questions/75778855/how-to-add-data-in-new-columns-based-on-existing-column-in-a-data-frame">How to add data in new columns based on existing column in a data frame?</a> but regarding R.
Now I need the same help with python pandas</p>
<p>I have a datafram... | <python><pandas> | 2023-04-18 12:49:42 | 1 | 301 | ilFonta |
76,044,678 | 2,599,301 | Detect deletion of instance variable or its element (list of objects)? | <p>I came across this OOP exercise in Python which states following:</p>
<pre><code>Class Battery:
def __init__(self, member1: int, member2: int, lead: str):
self.member1 = member1
self.member2 = member2
self.lead = lead
Class Robot:
def __init__(self, robot_name: str, leads: tuple[s... | <python><oop><overriding> | 2023-04-18 12:34:07 | 1 | 439 | Jumpman |
76,044,403 | 17,530,552 | How to adjust sp.signal.spectrogram so that the x-axis starts at 0? | <p>I am plotting a spectrogram of a time-series <code>data</code> with a sampling rate of 2.16 seconds using <code>scipy.signal.spectrogram</code>.</p>
<p>My problem is that the x-axis of the plot <code>plt.pcolormesh(time, freq, spec, shading="gouraud")</code> does not start at <code>0</code>, but instead at... | <python><scipy><spectrogram> | 2023-04-18 12:06:04 | 0 | 415 | Philipp |
76,044,398 | 3,990,145 | How to exclude redundant validation errors for pydantic fields which allow empty dict as value? | <p>I have following models</p>
<pre><code>from typing import Union
from pydantic import BaseModel, Extra, Field
from typing_extensions import Annotated, Literal
class Empty(BaseModel):
class Config:
extra = Extra.forbid
class ModelX(BaseModel):
member: Literal["x"]
q: str
class Mode... | <python><pydantic> | 2023-04-18 12:05:33 | 0 | 4,717 | xiº |
76,044,370 | 813,750 | How to bin on timeframe with pyspark? | <p>I have following (oversimplified) dataset :</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>userid</th>
<th>program_id</th>
<th>program_start</th>
<th>program_end</th>
<th>viewing_start</th>
<th>viewing_end</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>1</td>
<td>2023-01-01 00:00:00</t... | <python><apache-spark><pyspark><binning> | 2023-04-18 12:02:40 | 2 | 1,129 | Wokoman |
76,044,317 | 7,425,726 | find a sequence of values within a pandas series | <p>I am looking for the best way to find a sequence of values of varying lengths within a longer pandas Series. For example, I have the values <code>[92.6, 92.7, 92.9]</code> (but could also be length 2 or 5) and would like to find all the cases where this exact sequence occurs within the longer Series</p>
<pre><code>s... | <python><pandas><series> | 2023-04-18 11:57:51 | 1 | 1,734 | pieterbons |
76,044,254 | 14,015,493 | How to provide only one of multiple optional parameters in FastAPI? | <p>The API should serve an endpoint where a user can either provide a <code>guid</code>, a <code>path</code> or a <code>code</code>. This is what the url scheme should look like:</p>
<pre><code>api/locations?code={str}&guid={str}&path={str}
</code></pre>
<p>The current code is as follows:</p>
<pre class="lang-p... | <python><fastapi><optional-parameters> | 2023-04-18 11:51:22 | 2 | 313 | kaiserm99 |
76,044,230 | 5,597,037 | Selenium in headless mode with Flask and Celery throws WebDriverException: Process unexpectedly closed with status 127 | <p>I am trying to run Selenium in headless mode within a Flask app and using Celery tasks. When I execute my script, I get the following error message:</p>
<pre><code>selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127
</code></pre>
<p>Here is a minimal working example of... | <python><selenium-webdriver><celery> | 2023-04-18 11:48:42 | 1 | 1,951 | Mike C. |
76,044,171 | 10,504,555 | Identifying minor swings with major swings - Price charts | <p>I am developing a stock analysis program in Python</p>
<p>One of the fundamental things I need to is to recognise swings from price feed (open, high, low, close data)</p>
<p>Price data is fractal by nature - smaller structures are found within larger structures.</p>
<p><a href="https://i.sstatic.net/4g0n5.png" rel="... | <python><trading><algorithmic-trading><candlestick-chart><backtrader> | 2023-04-18 11:43:22 | 2 | 389 | neo-technoker |
76,044,117 | 4,865,723 | Create a grouped Seaborn Box plot without pandas.melt() or pandas.stack() | <p>I want to create a "grouped box plot" like this without using <code>pandas.melt()</code> (or <code>pandas.stack()</code>) and with only one seaborn function :</p>
<p><a href="https://i.sstatic.net/oVJ6n.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/oVJ6n.png" alt="enter image description h... | <python><pandas><seaborn> | 2023-04-18 11:38:40 | 1 | 12,450 | buhtz |
76,044,061 | 12,297,666 | Input Shape for Dense Layer in Keras | <p>I have a question regarding the input shape for Dense layers in Keras. I have received a code that uses Dense layers to solve a timeseries prediction problem.</p>
<p>The input data, <code>x_train</code> array has shape <code>(5829, 18)</code>. After this, there's this piece of code:</p>
<pre><code># Reshaping the in... | <python><tensorflow><keras> | 2023-04-18 11:32:58 | 1 | 679 | Murilo |
76,044,038 | 1,901,071 | Visual Studio Code: The term 'conda' is not recognized as the name of a cmdlet | <p>I have a python script which I open up in visual studio code. When I first open Visual Studio Code, the following appears in the terminal where it tries to run it under the project folder location.</p>
<pre><code>PS C:\Users\foo\Github-int\project> conda activate spyder-env
conda activate spyder-env
conda : The ... | <python><anaconda><conda> | 2023-04-18 11:30:26 | 0 | 2,946 | John Smith |
76,044,004 | 21,404,794 | Drop rows with all zeroes in a pandas dataframe | <p>I'm trying to drop the rows of a dataframe where the value of one column is 0, but I don't know how</p>
<p>The table I start with looks like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
<th>e</th>
</tr>
</thead>
<tbody>
<tr>
<td>99.08</td>... | <python><pandas><dataframe> | 2023-04-18 11:27:10 | 4 | 530 | David Siret Marqués |
76,043,992 | 12,760,550 | Combine duplicated rows by unique values in column to fill blank columns in another value | <p>Imagine I have the following data (slice as example):</p>
<pre><code>ID Salary Component 1 Value1 Salary Component 2 Value2
10000 Basic Salary 22000
10000 Housing Allowance 13200
</code></pre>
<p>How can I combine rows per ID in a way that... | <python><pandas><group-by><merge><duplicates> | 2023-04-18 11:25:50 | 1 | 619 | Paulo Cortez |
76,043,940 | 3,515,174 | Type hints for generic class union Callable | <p>Given:</p>
<pre class="lang-py prettyprint-override"><code>from typing import Callable, Generic, TypeVar
T = TypeVar("T")
class Factory(Generic[T]):
def __call__(self) -> T:
...
class TruthyFactory(Factory[bool]):
def __call__(self) -> bool:
return True
def falsey_factory()... | <python><type-hinting> | 2023-04-18 11:20:42 | 2 | 4,502 | Mardoxx |
76,043,938 | 12,435,792 | How do I search for emails with a subject prefix using python | <p>I have an inbox which receives mails every 15 mins.
The subject of each is different - it has a fixed prefix and then concatinated with date and time.
for example:
subject : [External] PNR Assignment File-JAPA-1_4/18/2023 8:34:37 AM</p>
<p>The <em><strong>[External] PNR Assignment File-JAPA</strong></em> part is con... | <python><outlook><win32com> | 2023-04-18 11:20:18 | 1 | 331 | Soumya Pandey |
76,043,860 | 18,782,190 | Python multiple inheritance does not work as expected | <p>I get an error <code>TypeError: __init__() missing 1 required positional argument: 'label_text'</code> in line <code>QLineEdit.__init__(self)</code> which doesn't make sense to me. I create <code>Input</code> object by passing one keyword argument <code>label_text</code> as <code>Input(label_text="Example label... | <python><python-3.x><pyqt5> | 2023-04-18 11:11:52 | 1 | 593 | Karolis |
76,043,852 | 10,504,555 | mplfinance - add_artist raises AttributeError: 'dict' object has no attribute 'axes' | <p>I am using <code>mplfinance</code> to create a OHLC chart (stock prices)</p>
<p>This is implemented as a custom class as I need to add additional elements to the final chart</p>
<pre><code>class CandlestickChart:
def __init__(self, data):
self.data = data
self.fig, self.ax = mpf.plot(
... | <python><matplotlib><mplfinance> | 2023-04-18 11:10:48 | 1 | 389 | neo-technoker |
76,043,814 | 20,220,485 | How should you name columns when transposing a dataframe? | <p>I am initialising a dataframe with lists, having followed the advice <a href="https://stackoverflow.com/questions/13784192/creating-an-empty-pandas-dataframe-and-then-filling-it">here</a>. I then need to transpose the dataframe.</p>
<p>In the first example I take the column names from the lists used to initialise th... | <python><pandas><dataframe><transpose> | 2023-04-18 11:07:24 | 1 | 344 | doine |
76,043,784 | 1,804,173 | How to add pydantic serialization/deserialization support for a foreign (third-party) class? | <p>Consider a third-party class that doesn't support pydantic serialization, and you're not under control of the source code of that class, i.e., you cannot make it inherit from <code>BaseModel</code>. Let's assume the entire state of that class can be constructed and obtained via its public interface (but the class ma... | <python><pydantic> | 2023-04-18 11:04:37 | 1 | 27,316 | bluenote10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.