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 ⌀ |
|---|---|---|---|---|---|---|---|---|
74,771,961 | 13,983,136 | Fit linear model on all data after doing it just on training data in order to make predictions about future data | <p>In linear regression (but in general on any other model) is there a need to use <code>.fit()</code> on all input data after using it only on training data? I'll try to explain it better with an example. I will artificially create a trivial set of input and output data:</p>
<pre><code>import numpy as np
from random i... | <python><machine-learning><scikit-learn><model><linear-regression> | 2022-12-12 13:39:03 | 0 | 787 | LJG |
74,771,939 | 12,546,311 | How to set xlim in seaborn barplot? | <p>I have created a barplot for given days of the year and the number of people born on this given day (figure a). I want to set the x-axes in my seaborn barplot to <code>xlim = (0,365)</code> to show the whole year.
But, once I use <code>ax.set_xlim(0,365)</code> the bar plot is simply moved to the left (figure b).</p... | <python><seaborn><bar-chart> | 2022-12-12 13:36:43 | 1 | 501 | Thomas |
74,771,737 | 20,732,098 | Group by timestamp and get mean Dataframe | <p>I generate for each week as csv file. The weeks are then merged into one. The merged CSV with the Dataframe looks like this:</p>
<pre><code> machineId | id | mean | min | max
machine1 | 2 | 00:00:03.47 | 00:00:00.02 | 00:00:06.11
machine1 | 1 ... | <python><pandas><dataframe><group> | 2022-12-12 13:19:34 | 1 | 336 | ranqnova |
74,771,507 | 12,709,265 | Parallelize a task on gpu | <p>I have a task in which I have to read in some images, perform some trasformations such as resizing the images, etc, and then write the image back on the disk. I can parallelize this operation over my cpu. However, I was wondering if there is a possible way to parallelize this over gpu. Since, this would make my task... | <python><python-3.x><parallel-processing><gpu> | 2022-12-12 13:01:27 | 0 | 1,428 | Shawn Brar |
74,771,447 | 7,969,193 | How to integrate Kafka and Flink in Python? | <p>I am trying to develop a test Flink application that reads from and writes to a Kafka topic.</p>
<p>However, I have been getting this error:</p>
<pre><code>start writing data to kafka
Traceback (most recent call last):
File "teste.py", line 71, in <module>
write_to_kafka(env)
File "teste... | <python><apache-kafka><apache-flink><pyflink> | 2022-12-12 12:56:44 | 1 | 1,385 | Laura Corssac |
74,771,398 | 12,871,587 | Numpy datetime64[D] array to polars date series/column | <p><strong>Update:</strong> <code>pl.Series(datetime_array)</code> now creates a <code>date</code> type as expected.</p>
<hr />
<p>Numpy datetime array seems to be converted to object series in Polars, but numerical or string arrays keeps the proper format when converted to pl.Series. Am I using it wrong or could this ... | <python><numpy><datetime><python-polars> | 2022-12-12 12:52:32 | 2 | 713 | miroslaavi |
74,771,345 | 7,195,897 | SQLAlchemy update rows based on key:value like queries? | <p>I am using the SQLAlchemy session to handle some updates to the database.
I am having two lists:</p>
<pre><code>keys = [1, 2, 3, 4, 5]
values = [6, 7, 8, 9, 0]
</code></pre>
<p>I want to set the value of <code>keys[0]</code> to be set to <code>values[0]</code>, and so on. From what I am used to do, this would be th... | <python><sqlalchemy><flask-sqlalchemy> | 2022-12-12 12:47:37 | 3 | 303 | Stefan Wobbe |
74,771,143 | 2,947,600 | Segmentation fault when creating custom autograd function that calls Julia code | <p>I have a (vector-to-scalar) function and corresponding derivative function written in Julia that I am unable to translate to Python. I would like to use these within PyTorch by defining a custom autograd function. For simplicity, lets assume this function is <code>sum()</code>. This gives the following MRE:</p>
<pre... | <python><pytorch><julia> | 2022-12-12 12:31:25 | 0 | 342 | Tim Hargreaves |
74,771,050 | 4,153,059 | Overwrite specific value with previous row value in Pandas | <p>I need to overwrite a spurious noise value every time it occurs in a Pandas data frame column. I need to overwrite it with a clean value from the previous row. If multiple adjacent noise values are encountered, all should be overwritten by the same recent good value.</p>
<p>The following code works but is too slow. ... | <python><pandas><signal-processing> | 2022-12-12 12:22:52 | 2 | 3,574 | CodeCabbie |
74,771,032 | 6,013,700 | How to test an element from a generator without consuming it | <p>I have a generator <code>gen</code>, with the following properties:</p>
<ul>
<li>it's quite expensive to make it yield (more expensive than creating the generator)</li>
<li>the elements take up a fair amount of memory</li>
<li>sometimes all of the <code>__next__</code> calls will throw an exception, but creating the... | <python><generator><yield> | 2022-12-12 12:21:33 | 1 | 1,602 | Marses |
74,770,983 | 972,647 | dagster: how do I get modified assets only? (external api) | <p>I'm learning dagster so maybe I haven't fully grasped the concepts.</p>
<p>my goal is to query an external web services / api and get the modified records only. I can make the external call a resource or put it into the asset directly, right? The external resource has filter option for last modified.</p>
<p>For me t... | <python><dagster> | 2022-12-12 12:17:42 | 1 | 7,652 | beginner_ |
74,770,982 | 7,713,770 | How to format template with django? | <p>I have a django application. And I try to format some data.</p>
<p>So I have this method:</p>
<pre><code>
from __future__ import print_function
import locale
import re
from fileinput import filename
from itertools import zip_longest
from locale import LC_NUMERIC, atof
import pandas as pd
from tabulate import tabul... | <python><html><django> | 2022-12-12 12:17:27 | 1 | 3,991 | mightycode Newton |
74,770,956 | 12,559,770 | Assign unique group per consecutive values under a threshold in pandas | <p>I have a dataframe such as:</p>
<pre><code>Groups Names Values
G1 SP1 1
G1 SP1 5
G1 SP1 -2
G1 SP1 30
G1 SP1 50
G1 SP1 50
G1 SP1 -1
G1 SP1 2
G1 SP2 2
G1 SP2 20
G1 SP2 1
G2 SP3 30
G2 SP3 9
G2 SP3 3
G3 SP3 2
</code... | <python><python-3.x><pandas> | 2022-12-12 12:14:55 | 2 | 3,442 | chippycentra |
74,770,810 | 10,729,292 | what does @ mean in case of `pip install <package> @ path`? | <p>I just came across this from a project on GitHub</p>
<pre><code>pip install colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1602866480661/work
</code></pre>
<p>what does @ do ?
assuming it decides the path where to install, I tried using any path and it wouldn't work like that</p>
<p>Also, why ... | <python><pip> | 2022-12-12 12:01:41 | 1 | 1,558 | Sadaf Shafi |
74,770,752 | 354,255 | mock psycopg2 fetchone and fetchall to return different dataset doesn't work | <p>I'm trying to mock fetchone/fetchall to return different data set for different cases within a suite but it seems the first mock is global and can't be overwritten. All I get for the subsequent tests is the same value.</p>
<p>The first test case which sets up the mock:</p>
<pre><code>def test_rejected_scenario():
... | <python><mocking><pytest><psycopg2> | 2022-12-12 11:56:11 | 0 | 641 | Lys |
74,770,697 | 17,762,566 | Extracting values from complex and deeply nested list of dictionaires using python? | <p>I have a complex data structure consisting of list of dictionaries and these dictionaries consists of list of dictionaries further. Now, I am trying to extract specific <code>key:value</code> pairs from internal nested dicts (from list of dictionaries). Hopefully below example shows what I am trying to achieve</p>
<... | <python><python-3.9> | 2022-12-12 11:51:11 | 1 | 793 | Preeti |
74,770,686 | 11,167,163 | Unable to label inside ring pie chart | <p>The following code :</p>
<pre><code>import matplotlib.pyplot as plt
import numpy as np
def autopct_format(values):
def my_format(pct):
total = sum(values)
val = int(round(pct*total/100.0)/1000000)
if val == 0:
return ""
else:
return '{:.1f}%\n({v... | <python><matplotlib> | 2022-12-12 11:49:42 | 0 | 4,464 | TourEiffel |
74,770,647 | 12,285,101 | Replace character in python string every even or odd occurrence | <p>I have the following python string:</p>
<pre><code>
strng='1.345 , 2.341 , 7.981 , 11.212 , 14.873 , 7.121...'
</code></pre>
<p>How can I remove all the ',' that their occurrence is odd, to get the following string:</p>
<pre><code>strng='1.345 2.341 , 7.981 11.212 , 14.873 7.121,...'
</code></pre>
<p>(Removed &quo... | <python><string><replace> | 2022-12-12 11:46:44 | 3 | 1,592 | Reut |
74,770,604 | 4,896,449 | Conditional in keras model based on input data / features | <p>I have a keras model which I would like to accept two input features, each feature would be encoded via its own embedding and dense layers. The two features are then summed to create the final output.</p>
<p>Dataset:</p>
<pre><code>row1 -> {x1: 'tag', x2: null, y: 'y1'}
row2 -> {x1: null, x2: 'long text field'... | <python><tensorflow><keras> | 2022-12-12 11:43:12 | 1 | 3,408 | dendog |
74,770,373 | 2,604,247 | How to Make Column Names Dynamic and Deal with them As Strings in SQLAlchemy ORM? | <p>I am learning some SQL from the book Essential SQLAlchemy by Rick Copeland</p>
<p>I have not really used SQL much, and relied on frameworks like Pandas and Dask for data-processing tasks. As I am going through the book, I realise all the column names of a table are often part of the table attributes, and hence seems... | <python><sql><database><sqlalchemy> | 2022-12-12 11:22:56 | 1 | 1,720 | Della |
74,770,219 | 17,639,970 | How to import a subset of a zip file into colab? | <p>I have a very big zip file in my google drive which contain several subfloders. Now, I'd like to extract only a few subfolders (not all folder into colab). Is there any way for this?</p>
<p>For instance, suppose the zip file name is "MyBigFile.zip" which contain "folder1", "folder2", &... | <python><google-drive-api><google-colaboratory> | 2022-12-12 11:08:57 | 2 | 301 | Rainbow |
74,770,208 | 12,242,085 | How to aggregate 3 columns in DataFrame to have count and distribution of values in separated columns in Python Pandas? | <p>I have Pandas DataFrame like below:</p>
<p>data types:</p>
<ul>
<li><p>ID - int</p>
</li>
<li><p>TIME - int</p>
</li>
<li><p>TG - int</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>TIME</th>
<th>TG</th>
</tr>
</thead>
<tbody>
<tr>
<td>111</td>
<td>20210101</td>
<td>0</td>
</... | <python><pandas><dataframe><group-by><aggregation> | 2022-12-12 11:08:19 | 2 | 2,350 | dingaro |
74,770,033 | 3,678,257 | Increase utilization of GPU for Sentence Transformer inference | <p>We'are using a Sentence Transformer model to calculate 1024-dim vectors for the purpose of similarity search. The model is served by a FastAPI web server exposing an API for other services to request a vector for a given text.</p>
<p>So we are planning to calculate vectors for a large document set (about 10_000_000 ... | <python><nlp><gpu><bert-language-model> | 2022-12-12 10:54:16 | 0 | 664 | ruslaniv |
74,769,960 | 2,051,392 | How does the Pandas Histogram Data Get to the Graph without Passing it In? | <p>Pretty straight forward question here.</p>
<p>I'm loading data in from a csv. The csv column for age is then converted into a histogram. Finally I'm showing a graph and the data is populated to it.</p>
<p>For the life of me though, I don't understand how the matplotlib <code>plt</code> is getting the data from the p... | <python><pandas><csv><matplotlib> | 2022-12-12 10:48:04 | 2 | 9,875 | DotNetRussell |
74,769,915 | 5,101,926 | Error Initalizing Stable diffusion with python 3.10.6. 'str' object has no attribute 'isascii' | <p>I'm trying to set Up Stable Diffusion 1.5 from GIT <a href="https://github.com/AUTOMATIC1111/stable-diffusion-webui" rel="nofollow noreferrer">https://github.com/AUTOMATIC1111/stable-diffusion-webui</a>.
I've followed a tutorial <a href="https://www.youtube.com/watch?v=ycQJDJ-qNI8&t=0s" rel="nofollow noreferrer"... | <python><encoding><python-3.10><stable-diffusion> | 2022-12-12 10:45:10 | 1 | 996 | Ale |
74,769,873 | 12,559,770 | Add overlapping coordinates within groups in pandas | <p>I have a dataframe such as :</p>
<pre><code>Gps1 Gps2 start end
G1 GA 106 205
G1 GA 102 203
G1 GA 106 203
G1 GA 106 203
G2 GB 9 51
G2 GB 48 135
G2 GB 131 207
G2 GB 207 279
G3 GC 330 419
G3 GC 266 31... | <python><python-3.x><pandas> | 2022-12-12 10:41:19 | 1 | 3,442 | chippycentra |
74,769,732 | 6,119,375 | AttributeError: 'list' object has no attribute 'strftime' in Python | <p>I have the following data:</p>
<pre><code>costs_for_roi.index.values
array(['2017-03-05T00:00:00.000000000', '2017-03-12T00:00:00.000000000',
'2017-03-19T00:00:00.000000000', '2017-03-26T00:00:00.000000000',
'2017-04-02T00:00:00.000000000', '2017-04-09T00:00:00.000000000',
'2017-04-16T00:00:00.0... | <python><datetime><strftime> | 2022-12-12 10:30:58 | 1 | 1,890 | Nneka |
74,769,325 | 8,760,298 | Amazon Sagemaker - Create USA map by States using Jupyter notebook | <p>I been trying creating USA map in Amazon Sagemaker Jupyter notebook instance, I have used the code</p>
<pre><code>import plotly.express as px
import numpy as np
import pandas as pd
dff = pd.read_excel("fold/map_data.xlsx",engine='openpyxl')
# Strip out white spaces
dff.columns = dff.columns.to_series().... | <python><jupyter-notebook><amazon-sagemaker> | 2022-12-12 09:55:02 | 0 | 333 | Tpk43 |
74,769,262 | 6,535,324 | python validate input with decorator for functions with varying inputs | <p>I have many functions that all expected <code>config</code> as a parameter but vary with regards to other parameters. I would like to validate <code>config</code>. I wrote another function for this, but seems a decorator might be a cleaner solution:</p>
<pre class="lang-py prettyprint-override"><code>def validate_co... | <python> | 2022-12-12 09:48:18 | 1 | 2,544 | safex |
74,769,052 | 15,852,600 | How to get a new df constituted by partialy transposed fragments of another dataframe | <p>I am struggling to get my dataframe transposed, not simply transposed but I want to limit the number of columns to the number of rows in index <code>slices</code>, in order to well explain my problem I give you my dataframe here :</p>
<pre><code>df=pd.DataFrame({
'n' : [0,1,2, 0,1,2, 0,1,2],
'col1' : ['A... | <python><pandas><dataframe> | 2022-12-12 09:29:50 | 3 | 921 | Khaled DELLAL |
74,768,892 | 15,537,675 | Read truncated json file to pandas dataframe | <p>I have a json file that is truncated. I have been looking for a way to read it into a pandas dataframe, but not been successfull. Several post refers to the <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_json.html#pandas.read_json" rel="nofollow noreferrer">read_json</a>.</p>
<p>I've... | <python><json><pandas> | 2022-12-12 09:15:20 | 0 | 472 | OLGJ |
74,768,805 | 1,780,761 | python opencv - filter contours by position | <p>I use this code to find some blobs, and pick the biggest one.</p>
<pre><code>contours, hierarchy = cv2.findContours(th1, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
if len(contours) != 0:
c = max(contours, key=cv2.contourArea)
</code></pre>
<p>Now, I would need to change this code in a way so it returns the conto... | <python><opencv><image-processing><computer-vision><contour> | 2022-12-12 09:06:38 | 2 | 4,211 | sharkyenergy |
74,768,715 | 17,192,324 | How to register multiple message handlers in aiogram | <p>I'm trying to make multiple different message handlers, <strong>is this an acceptable way to register multiple ones?</strong>:</p>
<pre class="lang-py prettyprint-override"><code>import asyncio
from aiogram import Bot, Dispatcher, types
from settings import BOT_TOKEN
async def start_handler(event: types.Message):... | <python><python-3.x><telegram><aiogram><telebot> | 2022-12-12 08:57:52 | 2 | 331 | Kirill Setdekov |
74,768,599 | 13,618,407 | Error when calling AUTOTUNE from tensorflow version 2.9.2 | <p>I am using AUTOTUNE in my TensorFlow project for a long time ago. The project is in google colab. It runs fine in the past. Now when I try to run the project, it has an error. I think the tensorflow version is changed causing the error.</p>
<p>In the AUTOTUNE line it shows me:</p>
<blockquote>
<p>AttributeError: mod... | <python><tensorflow><image-processing><deep-learning><computer-vision> | 2022-12-12 08:47:19 | 0 | 561 | stic-lab |
74,768,557 | 19,303,365 | Extracting Experience Section from resume | <p>Below is the Code to extract the Experience section from the Resume , but its not giving the desired output :</p>
<pre><code>import re
def extract_experience(resume_text):
experience_pattern = r"(?:EXPERIENCE|Employment experience)\n(.*?)\n(?:Skills|Education)"
experience_match = re.search(experie... | <python><regex> | 2022-12-12 08:42:55 | 1 | 365 | Roshankumar |
74,768,505 | 1,930,543 | Get the frequency of all combinations in Pandas | <p>I am trying to get the purchase frequency of all combinations of products.</p>
<p>Suppose my transactions are the following</p>
<pre><code>userid product
u1 A
u1 B
u1 C
u2 A
u2 C
</code></pre>
<p>So the solution should be</p>
<pre><code>combination count_of_distinct_users
A ... | <python><pandas> | 2022-12-12 08:37:20 | 2 | 5,951 | dimitris_ps |
74,768,475 | 17,277,677 | divide columns vertically by max value in a dataframe | <p>I have a following table:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>summary</th>
<th>summary_len</th>
<th>apple</th>
<th>book</th>
<th>computer</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>....</td>
<td>210</td>
<td>2</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td>2</td>
... | <python><pandas><dataframe> | 2022-12-12 08:34:41 | 1 | 313 | Kas |
74,768,423 | 9,778,828 | Pandas sparse dataframe multiplication | <p>I have two pandas sparse dataframes, big_sdf and bigger_sdf.</p>
<p>When I try to multiply them:</p>
<pre><code>result = big_sdf @ bigger_sdf
</code></pre>
<p>I get an error:</p>
<pre><code>"numpy.core._exceptions.MemoryError: Unable to allocate 3.6 TiB for an array with shape (160815, 3078149) and data type in... | <python><pandas><scipy><sparse-matrix><sparse-dataframe> | 2022-12-12 08:29:17 | 0 | 505 | AlonBA |
74,768,399 | 4,652,534 | FastAPI app still process the request though the connection has been disconnected from the client end | <p>I have a FastAPI app that runs on Gunicorn Webserver and the gateway interface is ASGI.</p>
<p>I try to simulate a response that takes a long time in my FastAPI App, and I expect that when I disconnect from the request connection currently under processing (e.g. close the tab), ASGI should abort or terminate the job... | <python><fastapi><gunicorn><uvicorn><asgi> | 2022-12-12 08:27:07 | 0 | 911 | Dayo Choul |
74,768,346 | 1,354,398 | read_csv() not retaining 'NUL' (C '\0') at the end of the string | <p>I am reading tsv data into dataframe using read_csv function.
My tsv file has col 'Name' (size of 6 bytes, shorter string is padded with C '\0'). When opened using notepad++, content looks like:</p>
<p>Name</p>
<p><a href="https://i.sstatic.net/MDUft.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MDU... | <python><pandas><dataframe> | 2022-12-12 08:21:51 | 1 | 403 | Arti |
74,768,014 | 20,732,098 | Round and Remove 3 digits Python Dataframe | <p>i have the following Dataframe:
<a href="https://i.sstatic.net/KDKoC.png" rel="nofollow noreferrer">Dataframe</a></p>
<pre><code>print (df)
time
0 00:00:04.4052727
1 00:00:06.5798
</code></pre>
<p>and my goal is to round the microseconds to 2 digits and remove the other digits so there are only 2... | <python><pandas><dataframe> | 2022-12-12 07:45:21 | 1 | 336 | ranqnova |
74,767,745 | 2,975,438 | Python Regex replace but only if two or more characters precede regex expression | <p>I have a pattern: <code>"two_or_more_characters - zero_or_more_characters"</code> and I want to replace it with <code>"two_or_more_characters"</code>, where <code>"-"</code> is a dash.</p>
<p>I created regex for it:</p>
<pre><code>re.sub(r'-[\w(){}\[\],.?! ]+', '', t)
</code></pre>
<p>a... | <python><regex> | 2022-12-12 07:13:40 | 1 | 1,298 | illuminato |
74,767,700 | 12,667,229 | not able to remove duplicate image with hashing | <p>My aim is to remove identical images like the following:</p>
<p>Image 1: <a href="https://i.sstatic.net/8dLPo.png" rel="nofollow noreferrer">https://i.sstatic.net/8dLPo.png</a></p>
<p>Image 2: <a href="https://i.sstatic.net/hF11m.png" rel="nofollow noreferrer">https://i.sstatic.net/hF11m.png</a></p>
<p>Currently, I ... | <python><image-processing><computer-vision><duplicates><imagehash> | 2022-12-12 07:09:23 | 2 | 330 | Sahil Lohiya |
74,767,568 | 3,668,129 | How to print index with decreased font size? | <p>I want to print equation on screen and print the indexes with decreased font size.</p>
<p>For example (<code>i</code> and <code>i-1</code> have smaller font):</p>
<p><a href="https://i.sstatic.net/nCZC8.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/nCZC8.png" alt="enter image description here" /></a... | <python><python-3.x> | 2022-12-12 06:54:07 | 1 | 4,880 | user3668129 |
74,767,555 | 10,229,754 | Taking equal number of elements from two arrays, such that the taken values have as few duplicates as possible | <p>Consider we have 2 arrays of size <code>N</code>, with their values in the range <code>[0, N-1]</code>. For example:</p>
<pre><code>a = np.array([0, 1, 2, 0])
b = np.array([2, 0, 3, 3])
</code></pre>
<p>I need to produce a new array <code>c</code> which contains exactly <code>N/2</code> elements from <code>a</code> ... | <python><arrays><numpy><vectorization> | 2022-12-12 06:52:21 | 2 | 4,171 | Mercury |
74,767,539 | 18,360,265 | How to resolve eth-utils and eth-tester installation issues? | <p>While installing the web3.py I am getting the following error message.
I am new to blockchain development. Can Someone help me to resolve this Error?</p>
<p>Error:</p>
<p><a href="https://i.sstatic.net/uBePm.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uBePm.png" alt="enter image description here" ... | <python><ethereum><web3py> | 2022-12-12 06:51:12 | 2 | 409 | Ashutosh Yadav |
74,767,354 | 607,407 | How can I ensure type hints still work for my class that inherits UserList from collections? | <p>I have a class that adds something on top of standard list behavior. To avoid re-implementing everything, I used <code>UserList</code>:</p>
<pre><code>from collections import UserList
class MyList(UserList):
...stuff...
</code></pre>
<p>But now, when I do something like:</p>
<pre><code>my_list = MyL... | <python><python-3.x><type-hinting> | 2022-12-12 06:27:39 | 1 | 53,877 | Tomáš Zato |
74,767,298 | 10,937,025 | How to merge two DataFrame containing same keys but different values in same columns in python | <p>I have one dataframe that contains all ids</p>
<pre><code>df1 = pd.DataFrame({'id': ['A01', 'A02', 'A03', 'A04', 'A05', 'A06','A07'],
'Name': ['', '', '', '', 'MKI', 'OPU','']})
</code></pre>
<p>Second DataFrame that contains some Ids has different name in them</p>
<pre><code>df2 = pd.DataFra... | <python><pandas><dataframe><merge><concatenation> | 2022-12-12 06:21:52 | 1 | 427 | ZAVERI SIR |
74,767,053 | 4,876,561 | Converting word2vec output into dataframe for sklearn | <p>I am attempting to use <a href="https://radimrehurek.com/gensim/models/word2vec.html" rel="nofollow noreferrer">gensim's word2vec</a> to transform a column of a pandas dataframe into a vector that I can pass to a <a href="https://scikit-learn.org/stable/supervised_learning.html" rel="nofollow noreferrer"><code>sklea... | <python><scikit-learn><nlp><gensim><word2vec> | 2022-12-12 05:48:08 | 1 | 7,351 | artemis |
74,766,991 | 6,283,073 | how to receive whatsapp message in twilio | <p>i am trying to build an application that can recieve and respond to an sms or whatsapp message. i have been able to setup and connect the twilio number to WhatsApp API.</p>
<p>i was able to successful send a WhatsApp message with this function</p>
<pre><code>def send_with_whatsapp():
client = Client(account... | <python><twilio><whatsapp> | 2022-12-12 05:38:18 | 1 | 1,679 | e.iluf |
74,766,757 | 4,733,871 | Pytorch Expected more than 1 value per channel when training when using BatchNorm | <p>I've written this code:</p>
<pre><code>import numpy as np
import torch
from torch.utils.data import TensorDataset, dataloader
inputDim = 10
n = 1000
X = np.random.rand(n,inputDim)
y = np.random.rand(0,2,n)
tensor_x = torch.Tensor(X)
tensor_y = torch.Tensor(y)
Xy = (tensor_x, tensor_y)
XyLoader = dataloader.DataLoa... | <python><pytorch><batch-normalization> | 2022-12-12 04:57:19 | 1 | 1,258 | Dario Federici |
74,766,701 | 4,451,521 | Error while using kats module packaging version has no attribute legacyversion | <p>I am trying to use kats for the first time in order to run the code of <a href="https://towardsdatascience.com/how-to-detect-seasonality-outliers-and-changepoints-in-your-time-series-5d0901498cff" rel="nofollow noreferrer">this article</a></p>
<p>However I had the same error as in <a href="https://stackoverflow.com/... | <python><kats> | 2022-12-12 04:45:57 | 1 | 10,576 | KansaiRobot |
74,766,562 | 15,982,771 | Why does SendMessage not work for some applications? | <h2>Background:</h2>
<p>I was trying to program an auto clicker to click in the background to an application (<a href="https://en.wikipedia.org/wiki/Roblox" rel="nofollow noreferrer">Roblox</a>, not trying to do anything malicious). I was able to get the window and perform commands like closing it. However, when trying... | <python><winapi><win32gui> | 2022-12-12 04:14:57 | 1 | 1,128 | Blue Robin |
74,766,520 | 12,458,212 | Mapping dict values based on keys in a list comprehension | <p>Lets say I have a dictionary where the keys are substring I want to use for a str search. I want to see if the keys exist in the elements of a list, and if they do, I'd like to set them equal to the value of that key and if there is no str match, set it equal to 'no match'.</p>
<pre><code>d = {'jun':'Junior', 'jr':'... | <python> | 2022-12-12 04:03:56 | 3 | 695 | chicagobeast12 |
74,766,512 | 1,812,993 | async test does not run in pytest | <p>I am trying to test an async function. Thus, I have an async test. When I use pycharm to set breakpoints in this test, they don't break. The things which are supposed to print to console do not print. And, the test takes 0 seconds. pytest lists the test as <code>PASSED</code>, but it clearly isn't actually executing... | <python><pytest><python-asyncio> | 2022-12-12 04:02:18 | 1 | 7,376 | melchoir55 |
74,766,332 | 6,291,976 | Python: Understanding indexing in the use of enumerate with readline | <p>Python code:</p>
<pre><code>myfile = open("test-file.csv", "r")
for k, line in enumerate(myfile,0):
if k == 0:
myline = myfile.readline()
print(myline)
break
myfile.close()
</code></pre>
<p>and test-file.csv is:</p>
<pre><code>0. Zeroth
1. First
2. Second
3. Third
</code></pr... | <python><readline><enumerate> | 2022-12-12 03:17:32 | 2 | 509 | mike65535 |
74,766,283 | 11,229,812 | How to detect button pressed and kept down and button up in Tkniter GUI? | <p>I am trying to build a GUI tkiner and use it to control my Raspberry Pi robot.
The robot will have several functions but the main one will be to move forward, backward, left, and right using W, S, A, and D keys on the keyboard respectively, or by clicking the buttons on the GUI.
Here is my current code and screensho... | <python><python-3.x><tkinter> | 2022-12-12 03:08:05 | 1 | 767 | Slavisha84 |
74,766,267 | 4,095,108 | Pandas - create new column from values in other columns on condition | <p>I'm trying to create a new column by merging non nans from two other columns.<br />
I'm sure something similar has been asked and I've looked at many questions but most of them seems to check the value and return a hard coded values.<br />
Here is my sample code:</p>
<pre><code> test_df = pd.DataFrame({
'col1... | <python><pandas> | 2022-12-12 03:04:29 | 1 | 1,685 | jmich738 |
74,766,212 | 17,103,465 | Distribute data equally in all the bins based on a column : Pandas | <p>I have large pandas dataframe; sample shown below :</p>
<p>I want to evenly distribute the "Good" flag between the ranges; so that each score range has equal number of goods.</p>
<pre><code>Score Good
100 0
100 0
100 0
300 0
400 0
400 0
600 1
600 1
600 0
650 0
650 0
650 ... | <python><pandas> | 2022-12-12 02:51:53 | 2 | 349 | Ash |
74,766,171 | 8,416,255 | What is the correct type hint to use when exporting a pydantic model as a dict? | <p>I'm writing an abstraction module which validates an excel sheet against a pydantic schema and returns the row as a dict using <code>dict(MyCustomModel(**sheet_row))</code>
. I would like to use type hinting so any function that uses the abstraction methods gets a type hint for the returned dictionary with its keys ... | <python><python-typing><pydantic> | 2022-12-12 02:45:11 | 1 | 409 | rsn |
74,765,958 | 607,407 | What is a nice, python style way to yield ranged subsets of a string/bytes/list several items at a time? | <p>I want to loop over bytes data, and I'd hope the same principle would apply to strings and lists, where I don't go item by item, but a few items at a time. I know I can do <code>mystr[0:5]</code> to get the first five characters, and I'd like to do that in a loop.</p>
<p>I can do it the C style way, looping over ran... | <python><python-3.x><list-comprehension> | 2022-12-12 01:50:40 | 1 | 53,877 | Tomáš Zato |
74,765,880 | 1,330,810 | Cloudtrail console resources missing from event record | <p>I need to get all the resources referenced by the action per each AWS event record. I use Python and cloudaux/boto.
The documentation states a "resources" field: <a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-record-contents.html" rel="nofollow noreferrer">ht... | <python><amazon-web-services><amazon-cloudtrail> | 2022-12-12 01:33:01 | 1 | 5,825 | Idan |
74,765,857 | 9,477,246 | How to count columns by row in python pandas? | <p>I am not certain how to describe this situation.
Suppose I have the well-defined following table in dataframe pandas,</p>
<pre><code> 0 1 2 3 4 5 ... 2949 2950 2951 2952 2953 2954
0.txt html head meta meta meta meta ...
107.txt html hea... | <python><html><pandas><tags> | 2022-12-12 01:26:49 | 1 | 393 | Hannah Lee |
74,765,845 | 1,064,843 | convert for loop to while (remove break <-- this is key) | <p>The <code>break</code> here is bothering me; after extensive research I want to ask if there is a pythonic way to convert this to a <code>while</code> loop:</p>
<pre><code>import re
file = open('parse.txt', 'r')
html = file.readlines()
def cleanup():
result = []
for line in html:
if "<l... | <python><loops> | 2022-12-12 01:22:03 | 2 | 1,553 | Snerd |
74,765,825 | 1,077,539 | Recursively traverse json and trim strings in Python | <p>I have a json like which has extra spaces</p>
<pre><code>{"main": "test ","title": {"title": "something. ","textColor": "Dark"},"background": {"color": "White "}}
</code></pre>
<p>I want to make a new json by rem... | <python><json><python-3.x> | 2022-12-12 01:16:43 | 1 | 4,390 | sadat |
74,765,507 | 5,041,045 | How to properly close an http connection from python requests | <p>I saw the answers in <a href="https://stackoverflow.com/questions/44665767/closing-python-requests-connection">Closing python requests connection</a>
but I don't think the answers really specify how to close the connection, or maybe I am not really understanding what it does.
For example, the following code:</p>
<pr... | <python><http><tcp><python-requests> | 2022-12-12 00:04:26 | 2 | 3,022 | Simon Ernesto Cardenas Zarate |
74,765,215 | 4,844,184 | Make pip install .[option] install less packages than the default pip install . (so-called negative extra_requires) | <p>First of all let's assume the following:</p>
<ul>
<li>I am building a python package <code>mypackage</code> and want to make it available broadly</li>
<li>My package has the following python dependencies: "A","B","C" and "D" and we assume further that each dependency covers an... | <python><pip><setuptools><python-packaging> | 2022-12-11 23:01:35 | 1 | 2,566 | jeandut |
74,765,171 | 19,989,634 | Updating my live project to python 3.10 - ERROR python setup.py bdist_wheel did not run successfully | <p>I've been having some trouble when trying to install certain packages on my live version of my project and realized its because its running version 3.7 instead of my up to date version 3.10 on Windows 10.
Wheels and setup are both up to date.</p>
<p>When I try to pip install -r requirements.txt I get a number of err... | <python><mysql><django> | 2022-12-11 22:51:39 | 0 | 407 | David Henson |
74,765,166 | 8,312,634 | MagicMock Mock'ed Function is not 'called' | <p>I an trying to mock an api function <code>send_message</code> from <code>stmplib.SMTP</code> in Python using MagicMock.</p>
<p>a simplified version of my function looks like</p>
<pre><code>#email_sender.py
def sendMessage():
msg = EmailMessage()
#Skipping code for populating msg
with smtplib.SMTP("... | <python><pytest><python-unittest> | 2022-12-11 22:50:21 | 1 | 447 | N0000B |
74,765,120 | 12,064,467 | Empty Result on Pandas Merge? | <p>I have one large DataFrame <code>prices</code> with three columns - id, date, and price. See a sample below:</p>
<pre><code> id date price
0 1st 2022-09-11 3.4
1 1st 2022-09-10 43.2
2 1st 2022-09-09 8.1
3 1st 2022-09-08 32.2
4 2nd 2022-09-11 10.4
5 2nd 2022-09-10 41.1
6 2nd 2022-09-09 ... | <python><pandas><dataframe> | 2022-12-11 22:41:30 | 1 | 522 | DataScienceNovice |
74,765,022 | 15,587,184 | R Tidyverse Alternative Code in Python for data wrangling | <p>I am trying to do the following in Python:</p>
<ol>
<li>Import iris data base</li>
<li>create a new column with the name target_measure that will be the multiplication of the natural log of Sepal.Width times the squeared Petal.Width</li>
<li>create a new variable called categorical_measure that will clasify the prev... | <python><r><pandas> | 2022-12-11 22:22:05 | 1 | 809 | R_Student |
74,764,791 | 7,585,973 | How two create label column, based on index number (odd/even) on pySpark | <p>Here's my Input</p>
<pre><code> index date_id year month day hour minute
0 156454 20200801 2021 12 31 12 38
1 156454 20200801 2021 12 31 12 39
</code></pre>
<p>What I want is just make label 'poi1' for odd rows and 'poi2' for even rows</p>
<p>Here's my... | <python><pandas><pyspark> | 2022-12-11 21:49:22 | 1 | 7,445 | Nabih Bawazir |
74,764,724 | 11,092,636 | Text below a figure with matplotlib | <p>I managed to add text on the figure with</p>
<pre class="lang-py prettyprint-override"><code> fg_ax.text(
0.05,
0.1,
f"n = {len(df)}",
)
</code></pre>
<p><code>fg_ax</code> being my <code>matplotlib.axes</code> object</p>
<p>But I want it below the figure.... | <python><matplotlib> | 2022-12-11 21:39:29 | 2 | 720 | FluidMechanics Potential Flows |
74,764,610 | 1,012,010 | Is there a way to generate combinations, one at a time? | <p>I can generate combinations from a list of numbers using itertools.combinations, such as the following:</p>
<pre><code>from itertools import combinations
l = [1, 2, 3, 4, 5]
for i in combinations(l,2):
print(list(i))
</code></pre>
<p>This generates the following:</p>
<pre><code>[1, 2]
[1, 3]
[1, 4]
[1, 5]
[2, ... | <python><combinations> | 2022-12-11 21:19:22 | 1 | 730 | Alligator |
74,764,480 | 815,612 | How do I write a Python function that returns a given (json) body with a given HTTP response code? | <p>I have the following (default) code in an AWS lambda function:</p>
<pre><code>def lambda_handler(event, context):
return {"statusCode": 200, "body": "\"Hello from Lambda!\""}
</code></pre>
<p>I also have this hooked up to an HTTP endpoint in the REST API section of the AWS... | <python><amazon-web-services><aws-lambda> | 2022-12-11 21:00:06 | 1 | 6,464 | Jack M |
74,764,305 | 16,977,407 | PackageNotFoundError even though required channel added to anaconda config? | <p>I am working with Ubuntu in WSL and tried to install the required packages for a repo with:</p>
<pre><code>$ conda install --file requirements.txt
</code></pre>
<p>I got a <code>PackageNotFoundError</code> for a bunch of different packages. I search on <a href="https://anaconda.org" rel="nofollow noreferrer">anacond... | <python><linux><openssl><anaconda><conda> | 2022-12-11 20:33:52 | 1 | 364 | Gandhi |
74,764,302 | 4,450,498 | What event is associated with zooming an interactive matplotlib plot? | <p>As I understand it, when a user interacts with an interactive <code>matplotlib</code> plot (i.e. by clicking, pressing a key, etc.), an <a href="https://matplotlib.org/stable/api/backend_bases_api.html#matplotlib.backend_bases.Event" rel="nofollow noreferrer"><code>Event</code></a> is triggered, which can be <a href... | <python><matplotlib><event-handling> | 2022-12-11 20:33:12 | 1 | 992 | L0tad |
74,764,189 | 1,302,551 | Setting global variables from a dictionary within a function | <p>I am looking to use .yaml to manage several global parameters for a program. I would prefer to manage this from within a function, something like the below. However, it seems <code>globals().update()</code> does not work when included inside a function. Additionally, given the need to load an indeterminate number of... | <python><python-3.x><global-variables> | 2022-12-11 20:17:38 | 1 | 1,356 | WolVes |
74,764,174 | 403,748 | Pandas get rank on rolling with FixedForwardWindowIndexer | <p>I am using Pandas 1.51 and I'm trying to get the rank of each row in a dataframe in a rolling window that looks ahead by employing FixedForwardWindowIndexer. But I can't make sense of the results. My code:</p>
<pre><code>df = pd.DataFrame({"X":[9,3,4,5,1,2,8,7,6,10,11]})
window_size = 5
indexer = pd.api.in... | <python><pandas><dataframe><rank><rolling-computation> | 2022-12-11 20:15:49 | 1 | 1,380 | davej |
74,764,170 | 16,056,216 | How can I use my model for a single picture? | <p>I trained a machine and I got the model now.
This is my code:( It works fine but i wanna use it for a single picture.)</p>
<pre><code>import numpy as np
import pandas as pd
import os
import cv2
import matplotlib.pyplot as plt
from tqdm import tqdm
from random import shuffle
from keras.utils import to_categorical
i... | <python><machine-learning><deep-learning><artificial-intelligence> | 2022-12-11 20:15:12 | 0 | 362 | Amirreza Hashemi |
74,764,099 | 7,802,034 | Having trouble solving this problem recursively | <p>Assume we are given a string variable named word.
We are playing a game with 2 players, player A, and player B.</p>
<p>Each player, at their respective turn (with player A always beginning), chooses either the first or the last letter of the string and gets points based on the ordered count of that letter in the ABC... | <python><string><recursion> | 2022-12-11 20:05:48 | 1 | 551 | EliKatz |
74,764,012 | 470,081 | Add HTML linebreaks with Python regex | <p>I need to add HTML linebreaks (<code><br /></code>) to a string at all line endings which are not followed by a blank line. This simple pattern works:</p>
<pre><code>body = re.sub(r'(.)\n(.)', r'\1<br />\2', body)
</code></pre>
<p>But I realized it will not work for an edge case where a line contains onl... | <python><regex><regex-lookarounds> | 2022-12-11 19:53:56 | 1 | 461 | janeden |
74,763,944 | 14,509,475 | When indexing a DataFrame with a boolean mask, is it faster to apply the masks sequentially? | <p>Given a large DataFrame <code>df</code>, which is faster in general?</p>
<pre class="lang-py prettyprint-override"><code># combining the masks first
sub_df = df[(df["column1"] < 5) & (df["column2"] > 10)]
</code></pre>
<pre class="lang-py prettyprint-override"><code># applying the masks... | <python><pandas><dataframe> | 2022-12-11 19:43:34 | 1 | 496 | trivicious |
74,763,652 | 14,374,599 | Performing operations on column with nan's without removing them | <p>I currently have a data frame like so:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>treated</th>
<th>control</th>
</tr>
</thead>
<tbody>
<tr>
<td>9.5</td>
<td>9.6</td>
</tr>
<tr>
<td>10</td>
<td>5</td>
</tr>
<tr>
<td>6</td>
<td>0</td>
</tr>
<tr>
<td>6</td>
<td>6</td>
</tr>
</tbody>
</... | <python><pandas><nan><method-chaining> | 2022-12-11 19:01:51 | 3 | 497 | KLM117 |
74,763,527 | 16,142,058 | how to install requirement with pip | <p>I have a problem with <strong>pip</strong>. I have created my enviroment by miniconda. I have run this command</p>
<pre><code>conda env create --file enviroment.yml
</code></pre>
<p>enviroment.yml</p>
<pre><code>name: data-science-handbook
channels:
- conda-forge
dependencies:
- python=3.10
</code></pre>
<p>req... | <python> | 2022-12-11 18:44:55 | 0 | 497 | summerisbetterthanwinter |
74,763,451 | 5,850,635 | ValueError: x must be a label or position when I try to Plot 2 columns in x axis grouped in area stacked chart using Pandas | <p>I have set of data with 3 columns Label, Year and Total. My total count is based on the group of label and year.</p>
<pre><code>+--------------------+-------+-------+
| Label| Year| Total|
+--------------------+-------+-------+
| FTP|02/2018| 193360|
| BBBB |01/1970| ... | <python><pandas><dataframe><matplotlib><pyspark> | 2022-12-11 18:31:33 | 1 | 1,032 | Kavya Shree |
74,763,392 | 14,293,274 | Error when recording sound with sounddevice | <p>I want to use sounddevice to capture (record?) audio that is coming out of my speakers. My speakers have two channels.</p>
<p>This is my code (which I found here <a href="https://realpython.com/playing-and-recording-sound-python/#python-sounddevice_1" rel="nofollow noreferrer">https://realpython.com/playing-and-reco... | <python><python-sounddevice> | 2022-12-11 18:23:53 | 1 | 594 | koegl |
74,763,112 | 20,078,696 | How to fix the screen size for a matplotlib plot | <p>I am trying to plot a tangent function (see below) and am trying to stop the plot 'jumping around':</p>
<pre><code>import numpy as np
import matplotlib.pyplot as plt
lowerBound = 0
plt.ion()
while True:
x = np.arange(lowerBound, lowerBound + 50, 0.1)
y = np.tan(x / 2)
plt.cla()
plt.plot(x, y)
... | <python><matplotlib> | 2022-12-11 17:43:58 | 1 | 789 | sbottingota |
74,762,955 | 7,386,609 | Managing contents of defaultdict with concurrency in python | <p>Some questions have looked at non-nested <code>defaultdict</code> behavior when multiprocessing:</p>
<p><a href="https://stackoverflow.com/questions/9256687/using-defaultdict-with-multiprocessing">Using defaultdict with multiprocessing?</a></p>
<p><a href="https://stackoverflow.com/questions/9372007/python-defaultdi... | <python><multithreading><concurrency><multiprocessing><defaultdict> | 2022-12-11 17:24:17 | 1 | 312 | Estif |
74,762,905 | 2,302,911 | Mediapipe Pose: How to slice the pose.process(<imageRGB>).pose_landmarks? in order to draw only selected keypoints? | <p>Given the following example:</p>
<pre><code>import cv2 #OpenCV is the library that we will be using for image processing import mediapipe as mp #Mediapipe is the framework that will allow us to get our pose estimation import time
mpDraw = mp.solutions.drawing_utils mpPose = mp.solutions.pose
pose = mpPose.Pose()
... | <python><typeerror><mediapipe><pose> | 2022-12-11 17:17:56 | 1 | 348 | Dave |
74,762,806 | 9,974,205 | I cannot change the values of a column using python pandas | <p>I am working with the [UCI adult dataset][1]. I have added a row as a header to facilitate operation. I need to change the last column, which can take two values, '<=50k' and '>50k' and whose name is 'etiquette'. I have tried the following</p>
<pre><code>num_datos.loc[num_datos.loc[:,"etiquette"]==&q... | <python><pandas><string><variables><integer> | 2022-12-11 17:04:33 | 1 | 503 | slow_learner |
74,762,737 | 10,516,773 | How to import Python Class or Function from parent directory? | <p>I have this project structure,</p>
<pre><code>.\src
.\api
test.py
.\config
config.py
app.py
</code></pre>
<p>when i'm trying to import a function or class from <code>test.py</code> inside <code>config.py</code>, using this statement</p>
<p><code>from src.api.test import tes_func</code></p>
<p>I get thi... | <python> | 2022-12-11 16:54:54 | 1 | 1,120 | pl-jay |
74,762,618 | 16,527,170 | Sum of Maximum Postive and Negative Consecutive rows in pandas | <p>I have a dataframe <code>df</code> as below:</p>
<pre><code># Import pandas library
import pandas as pd
# initialize list elements
data = [10,-20,30,40,-50,60,12,-12,11,1,90,-20,-10,-5,-4]
# Create the pandas DataFrame with column name is provided explicitly
df = pd.DataFrame(data, columns=['Numbers'])
# print... | <python><pandas><dataframe> | 2022-12-11 16:39:50 | 1 | 1,077 | Divyank |
74,762,578 | 4,225,430 | How to integrate 'append' and 'print' Python code in a line? | <p>python newbie here. I wonder if I can write the <code>append</code> and <code>print</code> syntax in a line instead of two. I tried twice but failed, as shown below:</p>
<pre><code>a = [1,2,3,4]
y = 7
a.append(y)
print(a) #correct [1, 2, 3, 4, 7]
</code></pre>
<p>(1)</p>
<pre><code>print(a.append(y)) #retuns None
</... | <python><append> | 2022-12-11 16:34:28 | 2 | 393 | ronzenith |
74,762,418 | 1,219,322 | Supervised ML to extract keywords from short texts | <p>I have a lot training data ready and looking for an ML algorithm to replace the current algorithms.
The input is a paragraph containing a short biography of a person and the output is their dates of birth and name.
What algorithm can output a set of keywords based on short texts?</p>
| <python><machine-learning><supervised-learning> | 2022-12-11 16:14:21 | 0 | 1,998 | dirtyw0lf |
74,762,417 | 14,789,957 | Get body from POST in Flask | <p>I am very new to Flask and have the following Flask code:</p>
<pre class="lang-py prettyprint-override"><code>from flask import Flask
from flask import request
app = Flask(__name__)
@app.route('/')
def home():
return 'Hello, World!'
@app.route('/test/<email>', methods = ['GET', 'POST'], strict_slashes=F... | <python><flask> | 2022-12-11 16:14:18 | 0 | 785 | yem |
74,762,188 | 10,829,044 | Hurdle models - gridsearchCV | <p>I am currently trying to build a hurdle model - zero inflated regressor to predict the revenue from each of out customers.</p>
<p>We use zero inflated regressor because most (80%) of our customers have 0 as revenue and only 20% have revenue > 0.</p>
<p>So, we build two models like as shown below</p>
<pre><code>zi... | <python><machine-learning><regression><cross-validation><grid-search> | 2022-12-11 15:43:45 | 1 | 7,793 | The Great |
74,761,823 | 13,954,738 | How can I pick the value from list of dicts using python | <p>I have a sample dict in the below format. I want to append more values in the <code>headers</code>. How should I proceed?</p>
<pre><code>data = {'heading': 'Sample Data', 'MetaData': [{'M1': {'headers': ['age', 'roll_no'], 'values': [15, 5]}}, {'M2': {'headers': [], 'values': []}}]}
</code></pre>
<p>To access, I can... | <python> | 2022-12-11 14:52:19 | 1 | 336 | ninjacode |
74,761,701 | 11,459,517 | How to put measures on x-axis with date and time combine in python using tkinter and matplotlib and numpy | <p>I have a small GUI application using tkinter, matplotlib and numpy. Here user will upload an excel file and get multi line graph. But the main problem is I couldn't put the measures on x-axis. Here date and time combination will be the measure of x-axis. But only year is coming as measure. Here I am sharing my code:... | <python><pandas><numpy><matplotlib><tkinter> | 2022-12-11 14:35:16 | 1 | 321 | Sanghamitra Lahiri |
74,761,664 | 8,162,211 | Coherence values do not agree when trying to calculate using different methods | <p>I'm trying to see if I can obtain identical coherence values for two signals when computing them two different ways:</p>
<p><strong>Method 1:</strong> I first compute the cross-correlation and the two auto-correlations. Then I take the DFT of the results to obtain the cross-spectral density and the power spectral de... | <python><scipy><spectrum> | 2022-12-11 14:30:51 | 1 | 1,263 | fishbacp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.