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,043,774 | 4,045,275 | How to add multiple empty columns (no names) to a dataframe? To export to Excel | <h1>The issue</h1>
<p>I have a dataframe which summarises certain data, and I am exporting it to Excel.</p>
<p>There is a logical order to the columns, whereby it would be useful to separate certain blocks: e.g. first 3 columns related to a, then an empty column as separator, then 2 columns related to b, then an empty ... | <python><pandas><dataframe> | 2023-04-18 11:03:40 | 2 | 9,100 | Pythonista anonymous |
76,043,761 | 5,180,644 | How can I serialize/deserialize SQLAlchemy.Column object | <p>I searched around and couldn't find an answer, forgive me if I missed something obvious. Any pointers will be helpful. :)</p>
<p>The issue is around the serialization of <code>sqlalchemy.Column</code> object. I'm representing a database table in the below class</p>
<pre><code>from sqlalchemy import Column
Class Tab... | <python><sqlalchemy> | 2023-04-18 11:01:59 | 1 | 367 | Utkarsh Sharma |
76,043,689 | 1,307,905 | pkg_resources is deprecated as an API | <p>When I try to install from a .tar.gz package, while making warnings into errors:</p>
<pre><code>python -W error -m pip install /some/path/nspace.pkga-0.1.0.tar.gz
</code></pre>
<p>I get this error:</p>
<pre><code>ERROR: Exception:
Traceback (most recent call last):
File "/opt/util/nspace1/lib/python3.11/site-... | <python><pip><setuptools><deprecation-warning> | 2023-04-18 10:53:23 | 4 | 78,248 | Anthon |
76,043,027 | 2,562,137 | Load Python Tensorflow saved_model with Tensorflow.js | <p>I've saved a model I created with Python Tensorflow. Is it possible to load this with Tensorflow.js?</p>
<p><strong>Save</strong></p>
<pre><code>tf.saved_model.save(translator, 'ipa_translator',
signatures={'serving_default': translator.tf_translate})
</code></pre>
<p><strong>Load</strong></p>
<p... | <python><tensorflow><tensorflow.js><tensorflowjs-converter> | 2023-04-18 09:37:57 | 1 | 3,898 | OrderAndChaos |
76,042,956 | 10,844,937 | What kind of lock should I use when update and insert the same table? | <p>I use MySQL's default engine <code>innodb</code> and MySQL's default transaction <code>REPEATABLE READS</code>.</p>
<p>My table <code>Job</code> has two fields, <code>job_id</code> and <code>queue</code>. Here are the data in it.</p>
<pre><code>+--------------------------------------+-------+
| job_id ... | <python><mysql> | 2023-04-18 09:29:46 | 0 | 783 | haojie |
76,042,924 | 16,389,095 | Python/Kivy - How to add a drop down item when a button is pressed: AttributeError 'super' object has no attribute '__getattr__' | <p>I developed a simple UI in Kivy/KivyMD - Python. When a button is pressed a dropdown item should be visualized <a href="https://kivymd.readthedocs.io/en/1.1.1/components/dropdownitem/" rel="nofollow noreferrer">https://kivymd.readthedocs.io/en/1.1.1/components/dropdownitem/</a>. Whilst the majority of examples consi... | <python><kivy><kivy-language><kivymd> | 2023-04-18 09:25:59 | 1 | 421 | eljamba |
76,042,888 | 15,452,168 | scraping reviews from playstore using google_play_scraper | <p>I am trying to scrap the reviews for an app using google_play_scraper, the play store says 16thousand reviews but I am only able to scrap 4869 reviews. what could be the reason?</p>
<p>As you can see I am trying to use all the languages available via a function.</p>
<p>I am using the below code</p>
<pre><code># Impo... | <python><pandas><web-scraping><google-play-services> | 2023-04-18 09:21:45 | 2 | 570 | sdave |
76,042,884 | 18,091,040 | Pandas DataFrame.to_csv creating a new line when saving a dataframe to file | <p>I have a dataframe <code>df_new</code> which looks like:</p>
<p><a href="https://i.sstatic.net/25Usn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/25Usn.png" alt="enter image description here" /></a></p>
<p>And when I use the command:</p>
<pre><code>df_new.to_csv(csv+'_filtered.csv', index=False)
</... | <python><pandas><csv> | 2023-04-18 09:20:59 | 1 | 640 | brenodacosta |
76,042,579 | 12,242,085 | How to compare values between columns in 2 DataFrames in Python Pandas? | <p>I have 2 DataFrames in Python Pandas like below:</p>
<p><strong>Input:</strong></p>
<pre><code>df1 = pd.DataFrame({"col1":["APPLE", "BANANA", "ORANGE"]})
df2 = pd.DataFrame({"col_x":["APPLEXX", "BANANA", "CARROT"]})
</code></pre>
<p>df1:... | <python><pandas><dataframe><merge><isin> | 2023-04-18 08:47:33 | 1 | 2,350 | dingaro |
76,042,566 | 12,903,729 | Run function when a file is externally closed python | <p>I am trying to run a function when a .txt file is closed. This file is opened in notepad using <code>os.startfile()</code>. Before using this I tried to using <code>subprocess</code> like this:</p>
<pre><code>import subprocess
def on_file_closed():
print("The external file has been closed")
path2file... | <python><file><winapi><operating-system> | 2023-04-18 08:46:05 | 2 | 1,212 | Thomas |
76,042,527 | 4,417,586 | GitHub Actions workflow for Python project on Google Cloud Build/Run | <p>I have a Python/Django project deployed on GCP Cloud Run. To deploy it, I use a gcloud config file <code>cloudbuild.yaml</code> which builds then pushes the image using <code>gcr.io/cloud-builders/docker</code>, then executes some project-specific Python commands using <code>gcr.io/google-appengine/exec-wrapper</cod... | <python><google-cloud-platform><continuous-integration><github-actions><gcloud> | 2023-04-18 08:42:02 | 0 | 1,152 | bolino |
76,042,472 | 14,896,591 | Invalid redirect_uri in instagram oauth | <p>I am using python django and django-allauth to implement oauth to instagram.
I think I have set all the required things in instagram app setting and got the application id and secret.
<a href="https://i.sstatic.net/GdYxB.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/GdYxB.png" alt="enter image descr... | <python><django><instagram><django-allauth> | 2023-04-18 08:35:40 | 0 | 315 | Fortdev |
76,042,419 | 5,931,672 | Generator map methods implementation | <p>So I have a generator of a sine wave that returns two values like <code>yield time, sine</code>.
I would like to be able to use point functions to add stuff to this generator like the following:</p>
<pre><code>my_generator.add_noise(mean=0, std=1).shuffle().to_pandas()
</code></pre>
<p>Where <code>add_noise</code> w... | <python><generator> | 2023-04-18 08:30:40 | 1 | 4,192 | J Agustin Barrachina |
76,042,381 | 4,045,275 | PyCharm: formatting dataframes in SciView: what are the options? Can I separate the thousands with a comma? | <p>The Scientific View mode of PyCharm displays pandas dataframes and numpy arrays.</p>
<p>At the bottom right there is an option to change the format (see screenshot below). E.g.</p>
<p><code>%.2f</code> = 2 decimal digits</p>
<p><code>%.3e</code> = scientific notation with 3 decimal digits. e.g. 3.456e-2 for 3.456%</... | <python><pandas><pycharm> | 2023-04-18 08:25:38 | 0 | 9,100 | Pythonista anonymous |
76,042,303 | 7,767,306 | How to edit claims in ID Token supplied with access token in django Oauth toolkit? | <p>When working with Django OAuth Toolkit, using OIDC if you supply <code>openid</code> as the <code>scope</code> in request you get a <code>id_token</code> with access token.
This ID Token can initially be used to identify the user you have got access token for and also create a session.</p>
<p><a href="https://i.ssta... | <python><django><django-oauth-toolkit> | 2023-04-18 08:17:17 | 1 | 407 | Dushyant Deshwal |
76,042,259 | 784,433 | high F1 score and low values in confusion matrix | <p>consider I have 2 classes of data and I am using sklearn for classification,</p>
<pre class="lang-py prettyprint-override"><code>def cv_classif_wrapper(classifier, X, y, n_splits=5, random_state=42, verbose=0):
'''
cross validation wrapper
'''
cv = StratifiedKFold(n_splits=n_splits, shuffle=True,
... | <python><scikit-learn> | 2023-04-18 08:13:20 | 2 | 1,237 | Abolfazl |
76,042,258 | 8,973,609 | Counting consecutive values without interruption in pandas/Python | <p>I am working on my pandas skills and have been stuck on an exercise for a while:</p>
<p>I have created a DF with bike test data. Tests are ordered by time (ascending test_id). I would like to get the most recent fail test (max <code>test_id</code>) for each <code>bike</code> + <code>test_type</code> group and count ... | <python><pandas> | 2023-04-18 08:13:14 | 3 | 507 | konichiwa |
76,042,113 | 1,734,097 | GSpread error when inserting to Google Sheet: Out of range float values are not JSON compliant | <p>i have the following functions:</p>
<pre><code>import os,sys
import configparser
from mystrings import *
from mypandas import *
import gspread
import gspread_dataframe as gd
from oauth2client.service_account import ServiceAccountCredentials
def send_data_gsheet(file_id,worksheet_name,df,mode='a'):
g... | <python><google-sheets><gspread> | 2023-04-18 07:57:05 | 1 | 1,099 | Cignitor |
76,041,993 | 2,147,823 | Runging own Telgram bot based on PTB 13x and local Telegram bot API behind nginx | <p>Try to use local Telegram bot API to take benefits of larger files for my bot serving and helping users in supergroup with files <a href="https://core.telegram.org/bots/api#using-a-local-bot-api-server" rel="nofollow noreferrer">as described here</a>
Build stack with Telegram Bot API, nginx as reverse proxy and my b... | <python><nginx><telegram><telegram-bot><python-telegram-bot> | 2023-04-18 07:42:31 | 1 | 540 | Topper |
76,041,978 | 5,567,893 | Does extension in vscode affect to the remote server? | <p>I'm wondering if the VSCode extension installation affects the remote server.</p>
<p>I already connected to the server using remote ssh and tried debugging the Python file.<br />
When I tried to run the Python code in VSCode, there was an error message that I should install the Python extension for the following pro... | <python><visual-studio-code><vscode-remote> | 2023-04-18 07:40:17 | 1 | 466 | Ssong |
76,041,926 | 19,989,634 | Using http methods with django rest framework | <p>I'm looking for some advice on how to correctly use my DRF API I have built, specifically the PATCH method at present. I am trying to formulate a script to patch the quantity of a Product / Cart Item that has been successfully added to the cart but I cannot get it to work.</p>
<p>For context of my project: My goal o... | <javascript><python><django-rest-framework><django-rest-viewsets> | 2023-04-18 07:33:22 | 1 | 407 | David Henson |
76,041,810 | 6,525,686 | Spark Transitive Equality Mapping Usecase | <p>I have the following use case where based on the Comp_Key Column, we will have multiple Comp_Name's and their associated Comp_Value's and ID column, which is unique for a given Comp_Name - Comp_Value combination.</p>
<p>The task is to reassign the generated ID column based on the combination of the Comp_value across... | <python><scala><apache-spark><pyspark><bigdata> | 2023-04-18 07:19:52 | 1 | 319 | marc |
76,041,346 | 1,643,537 | For loop overwrites value when appending to list in Python | <p>I am trying to create a nested dictionary out of a list of postcodes and locations. Somehow I keep overwriting the value in the loop leaving only the last value on the list.</p>
<p>Code snippet</p>
<pre><code>postcode_dict = {}
postcode_list = [['01000', 'location1', 'district1', 'state1'],
['01000... | <python><dictionary><for-loop> | 2023-04-18 06:18:19 | 4 | 3,205 | Cryssie |
76,041,282 | 4,688,722 | How to use view control in non-blocking visualization for zoom in? | <p>I followed <a href="https://stackoverflow.com/questions/70842338/playing-sequence-of-ply-files-in-open3d">this link</a> to visualize multiple .pcd as a video via open3d. It is working fine. However, I am unable to zoom in the generated output.</p>
<p>I have tried to use <code>o3d.visualization.Visualizer.get_view_co... | <python><3d><open3d> | 2023-04-18 06:07:15 | 1 | 926 | Ammar Ul Hassan |
76,041,179 | 2,981,639 | python -m build including additional folders | <p>I have src-layout package with pyproject.toml and setup.cfg which I'm building use <code>python -m build</code></p>
<p>It builds and installs fine, but when I open the archive file it includes the contents of a bunch of additional folders that I don't want, i.e.</p>
<p>my project has the following structure</p>
<pre... | <python><setup.py> | 2023-04-18 05:54:09 | 1 | 2,963 | David Waterworth |
76,041,149 | 5,677,298 | Generators seems to skip a step when sending data | <p>I am trying to understand why the below is happening.</p>
<p>Let us assume that we have this simple <code>is_even</code> function:</p>
<pre class="lang-py prettyprint-override"><code> def is_even(num):
return num % 2 == 0
</code></pre>
<p>And then we also have this generator function:</p>
<pre class="lang... | <python><python-3.x><generator> | 2023-04-18 05:49:41 | 0 | 702 | kakou |
76,041,127 | 14,103,418 | Why is version number 0.10.0 considered as older than 0.9.0 in setuptools_scm? | <p>I have a Python package that is going through frequent changes and it brought us to version <code>0.9.3</code> currently. My team is not confident to bump it to <code>1.0.0</code> yet.</p>
<p>The team agreed to version number <code>0.10.0</code> but why <code>setuptools_scm</code> seems to consider <code>0.10.0</cod... | <python><version-control><git-tag><setuptools-scm> | 2023-04-18 05:46:09 | 2 | 380 | yuenherny |
76,040,957 | 610,569 | How to use pipeline for multiple target language translations with M2M model in Huggingface? | <p>The <a href="https://huggingface.co/facebook/m2m100_418M" rel="nofollow noreferrer">M2M model</a> is trained on ~100 languages and able to translate different languages, e.g.</p>
<pre><code>from transformers import pipeline
m2m100 = pipeline('translation', 'facebook/m2m100_418M', src_lang='en', tgt_lang="de&qu... | <python><nlp><huggingface-transformers><machine-translation><large-language-model> | 2023-04-18 03:45:45 | 1 | 123,325 | alvas |
76,040,912 | 2,604,247 | How to Concatenate PDFs via Pikepdf and Python without Unnecessary Disk Read-Write? | <p><strong>Current technology stack</strong></p>
<ul>
<li>img2pdf==0.4.4</li>
<li>pikepdf==7.1.2</li>
<li>Python 3.10</li>
<li>Ubuntu 22.04</li>
</ul>
<p><strong>The requirement</strong></p>
<p>A pdf file (let's call it <code>static.pdf</code>) exists in the disk. Another pdf (let's call it <code>dynamic.pdf</code>) is... | <python><pdf><qpdf><pikepdf> | 2023-04-18 03:36:34 | 1 | 1,720 | Della |
76,040,850 | 610,569 | Can mT5 model on Huggingface be used for machine translation? | <p>The <code>mT5</code> model is pretrained on the mC4 corpus, covering 101 languages:</p>
<blockquote>
<p>Afrikaans, Albanian, Amharic, Arabic, Armenian, Azerbaijani, Basque, Belarusian, Bengali, Bulgarian, Burmese, Catalan, Cebuano, Chichewa, Chinese, Corsican, Czech, Danish, Dutch, English, Esperanto, Estonian, Fili... | <python><nlp><huggingface-transformers><machine-translation><large-language-model> | 2023-04-18 03:20:07 | 1 | 123,325 | alvas |
76,040,803 | 14,923,024 | Python polars dataframe transformation: from flat dataframe to one dataframe per category | <p>I have a flat dataframe representing data in multiple databases, where each database has multiple tables, each table has multiple columns, and each column has multiple values:</p>
<pre class="lang-py prettyprint-override"><code>df = pl.DataFrame(
{
'db_id': ["db_1", "db_1", "db_1... | <python><dataframe><python-polars><data-transform> | 2023-04-18 03:08:40 | 3 | 457 | AAriam |
76,040,672 | 2,605,327 | Optional chaining in Python | <p>Javascript has a useful pattern called optional chaining, that lets you safely traverse through a deeply nested object without key errors.</p>
<p>For example:</p>
<pre><code>const foo= {
correct: {
key: 'nested'
}
}
const correct = foo?.correct?.key
const incorrect = foo?.incorrect?.key
</code></... | <javascript><python> | 2023-04-18 02:37:56 | 0 | 718 | Ucinorn |
76,040,523 | 13,099,964 | Auto-GPT Command evaluate_code returned: Error: The model: `gpt-4` does not exist | <p>I'm working with <a href="https://github.com/Significant-Gravitas/Auto-GPT" rel="noreferrer">auto-gpt</a> and I got this error:</p>
<pre><code>Command evaluate_code returned: Error: The model: `gpt-4` does not exist
</code></pre>
<p>and it's like it can't go furthermore.</p>
<p>what should I do?</p>
| <python> | 2023-04-18 01:57:23 | 1 | 2,299 | Raskul |
76,040,475 | 395,857 | How can I split the column of a panda dataframe so that each new column correspond to a single value in the split column? | <p>I have this panda dataframe:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>System name</th>
<th>Rating</th>
<th>Count</th>
</tr>
</thead>
<tbody>
<tr>
<td>system1</td>
<td>1</td>
<td>12</td>
</tr>
<tr>
<td>system1</td>
<td>2</td>
<td>156</td>
</tr>
<tr>
<td>system1</td>
<td>3</td>
<td>... | <python><pandas><dataframe> | 2023-04-18 01:47:09 | 0 | 84,585 | Franck Dernoncourt |
76,040,325 | 736,312 | Pytorch forward hook on FCN-ResNet50 architecture | <p>I am using the FCN-Resnet50 model from Pytorch framework and I would like to extract the features vector of one layer using the <code>register_forward_hook</code> function.<br>
I am using the following code to load the model.</p>
<pre><code>import torch
model = torch.hub.load("pytorch/vision:v0.10.0", &quo... | <python><pytorch> | 2023-04-18 00:59:51 | 1 | 796 | Toyo |
76,040,306 | 2,348,503 | ModuleNotFoundError: No module named 'llama_index.langchain_helpers.chatgpt' | <p>I'd like to use <code>ChatGPTLLMPredictor</code> from <code>llama_index.langchain_helpers.chatgpt</code>, but I got an error below on M1 Macbook Air.</p>
<pre><code>ModuleNotFoundError: No module named 'llama_index.langchain_helpers.chatgpt'
</code></pre>
<p>My code looks like this and line 3 is the problem.</p>
<pr... | <python><python-3.x><openai-api><chatgpt-api><llama-index> | 2023-04-18 00:54:02 | 1 | 420 | Taishi Kato |
76,040,205 | 3,769,033 | How to dynamically inspect a GenericAlias (Type) object to determine the types it contains? | <p>I have a dataclass with typed <code>tuple</code> fields, and I'd like to dynamically see the types of their elements. When I print the types, I see them as containers (whose contents are exactly what I want):</p>
<pre><code>from dataclasses import dataclass, fields
@dataclass
class TupleContainer:
tuple2: tuple... | <python><python-3.x><python-typing> | 2023-04-18 00:23:07 | 1 | 1,245 | JoshuaF |
76,040,150 | 3,103,957 | Python type metaclass __call__() method | <p>The type meta class in Python has a <code>__call__()</code> method. And the same method is used to create object of a class and for a class. For example:</p>
<pre><code>class Animal:
pass
</code></pre>
<p>In creating an object <strong>for</strong> the class Animal (in the notion that every class is stored as an ... | <python><metaprogramming> | 2023-04-18 00:12:13 | 1 | 878 | user3103957 |
76,040,071 | 11,475,651 | Write a python function to return a differential equation: cannot assign to operator? | <p>I would like to write a Python function which simply returns a differential equation. Basically, my ODE is a function of wind speed, solar insolation and ambient temperature. I want this first function to take in those values and to produce an equation; I then want to take multiple such equations and solve them simu... | <python><ode> | 2023-04-17 23:49:22 | 1 | 317 | Abed |
76,040,055 | 11,277,108 | TypeError: boolean value of NA is ambiguous when using np.where() to compare string columns | <p>I'm importing a feather into a pandas dataframe and then looking to compare two string columns using np.where(). However, I'm getting the following error: <code>TypeError: boolean value of NA is ambiguous</code>. An MRE is below:</p>
<pre><code>import pandas as pd
import numpy as np
d = {"col1": [np.NaN, ... | <python><pandas><dataframe><numpy> | 2023-04-17 23:45:11 | 2 | 1,121 | Jossy |
76,039,831 | 10,184,783 | How to detect line using radon transformation using python? | <p>MATLAB solutions are available elsewhere on the internet, but there is need for the open-source python based solution.</p>
<p>Starter code to create a blank image with a white line.</p>
<pre><code>import cv2
import numpy as np
from skimage.transform import radon
from matplotlib import pyplot as plt
blank = np.zeros... | <python><image-processing><computer-vision><transform><transformation> | 2023-04-17 22:47:22 | 1 | 4,763 | Abhi25t |
76,039,805 | 6,368,579 | How to set __len__ method for an itertools.chain object? | <p>Let's say I'm building an <code>itertools.chain</code> instance as follows:</p>
<pre class="lang-py prettyprint-override"><code>from itertools import chain
list_1 = list(range(5, 15))
list_2 = list(range(20, 30))
chained = chain(list_1, list_2)
</code></pre>
<p>Now, since I already know the length of the lists cont... | <python><attributeerror> | 2023-04-17 22:42:35 | 2 | 483 | DSantiagoBC |
76,039,374 | 2,791,346 | Concatenate tf.range in Keras model | <p>I would like to create a Keras model and add sequencial number to a input tensor.</p>
<p>What I would like to do is something like this:</p>
<pre><code>input_layer = Input(shape=(3, 3))
seq = tf.range(3)
seq = tf.reshape(seq, (3, 1))
concatenated = Concatenate(axis=-1)([input_layer, seq])
additional_layer = Dense... | <python><tensorflow><keras><concatenation> | 2023-04-17 21:22:14 | 1 | 8,760 | Marko Zadravec |
76,039,364 | 3,130,747 | Extract raw sql from SqlAlchemy with replaced parameters | <p>Given a sql query such as</p>
<pre><code>query = """
select some_col from tbl where some_col > :value
"""
</code></pre>
<p>I'm executing this with sqlalchemy using</p>
<pre><code>connection.execute(sa.text(query), {'value' : 5})
</code></pre>
<p>Though this does what's expected, I wo... | <python><postgresql><sqlalchemy> | 2023-04-17 21:19:52 | 1 | 4,944 | baxx |
76,039,198 | 1,810,940 | Properties with single dispatch | <p>Is it possible to compose a <code>property</code> with <code>singledispatch</code> / <code>singledispatchmethod</code> features? I have tried the obvious patterns (nesting <code>@singledispatchmethod</code> with <code>@prop.setter</code>, etc) and get various errors. Here's a MWE of what I'd like to do, which only a... | <python><properties><decorator><functools><single-dispatch> | 2023-04-17 20:50:02 | 0 | 503 | jay |
76,039,042 | 5,111,234 | OpenMDAO Specifying DOEDriver Number of Processors | <p>I am trying to use the in-built DOEDriver in OpenMDAO. I know there is a setting called <code>procs_per_model</code> which determines the number of processors given to the model to run. However, is there a way to set the max number of processors that the DOE itself can use? E.g. I have 10 cores on my machine, but I ... | <python><parallel-processing><openmdao> | 2023-04-17 20:25:53 | 1 | 679 | Jehan Dastoor |
76,039,015 | 2,367,231 | Pyscript: How to load a file via html input and passing it to Python Pandas | <p>I try to implement a webpage which has a button (file input dialogue) to load an Excel/ODF file and pass it to pandas for processing.</p>
<p>The problem is, that I do not have any glue how to pass the file (<code>f in fileList</code>) to <code>pandas.ExcelFile(...)</code>.</p>
<p>Here is the not fully working exampl... | <python><pandas><pyscript> | 2023-04-17 20:21:53 | 0 | 3,975 | Alex44 |
76,038,966 | 315,168 | Type hinting Pandas DataFrame content and columns | <p>I am writing a function that returns a Pandas <code>DataFrame</code> object. I would like to have a type hint that specifies which columns this <code>DataFrame</code> contains, besides just specifying in the docstring, to make it easier for the end user to read the data.</p>
<p>Is there a way to type hint <code>Data... | <python><pandas><dataframe><python-typing> | 2023-04-17 20:15:30 | 5 | 84,872 | Mikko Ohtamaa |
76,038,944 | 9,883,236 | Type Hinting Python3 How to Decorate a function based on whether its a method or a function, and transform an argument? | <p>Hi I'm trying to have a decorator that takes the first or second argument (depending on whether its in a class), and then transforming it before invoking the function, so the minimum code would be like this:</p>
<pre class="lang-py prettyprint-override"><code>from typing import Callable, Concatenate, ParamSpec, Type... | <python><mypy><python-typing><pyright> | 2023-04-17 20:12:03 | 0 | 345 | YousefZ |
76,038,772 | 5,094,207 | One of two flask apps deployed on the same server with unresponsive '/' route | <h1>Problem</h1>
<p>I have two flask applications deployed to the same GCP compute engine with an nginx server.</p>
<p>The first app on the main domain: <code>myapp.com.</code></p>
<p>The second is on a subdomain: <code>example.myapp.com.</code></p>
<p>All the routes from the first app on the main domain are accessible... | <python><nginx><flask><deployment> | 2023-04-17 19:47:03 | 1 | 647 | null-point-exceptional |
76,038,371 | 5,879,640 | Websocket to Serial bridge in python getting stuck | <p>I am working on writing a websocket to serial bridge in Python for which I have used the <code>websockets</code> and <code>pyserial</code> library.</p>
<p>My ultimate goal is to have a websocket that forwards incoming messages to the serial device and also is constantly reading the serial port for incoming messages ... | <python><websocket><python-asyncio><pyserial> | 2023-04-17 18:51:02 | 0 | 471 | Trantidon |
76,038,225 | 9,473,350 | Figure created using axes of another figure not dynamically updating axes | <p>If you run the below code in ipython, you will find that the first window that pops up can be resized and the plots all adjust as usual.</p>
<p>The second figure is created by trying to copy over the axis objects from the first figure. It seems to work, but the second window that pops up doesn't readjust the size of... | <python><matplotlib><matplotlib-gridspec> | 2023-04-17 18:34:23 | 0 | 321 | MaanDoabeDa |
76,038,131 | 3,799,923 | Type check ignore not working for multiline code | <p>When checking for type using <code>mypy</code> I want to ignore a line by adding <code>type: ignore</code>. But the problem is it's not working when I break the line of code into multiple lines.</p>
<p>This works</p>
<pre class="lang-py prettyprint-override"><code>items["a"]["b"] = "value&qu... | <python><mypy> | 2023-04-17 18:19:50 | 1 | 2,888 | dhilmathy |
76,038,104 | 11,530,571 | Problem with library for quick Wasserstein distance calculation | <p>I need a tool to quickly calculate the Wasserstein distance between two two-dimensional point sets. I have been using Gudhi, but it appears to be too slow, and I need a faster alternative. I found the geomloss library, which appears to be fast enough, but the results differ, e.g.</p>
<pre class="lang-py prettyprint-... | <python><pytorch><data-analysis> | 2023-04-17 18:16:13 | 1 | 456 | guest |
76,038,058 | 86,638 | Why isn't widgets in the BoxLayout laid out correctly when only using Python? | <p>I am trying to get my head around Kivy and was playing with making some Widgets in Python, to make the structure of the kv file a bit lighter.</p>
<p>I have created a small compound widget, with a BoxLayout containing a label, and another label between two buttons.</p>
<p>To my confusion if I add this code by itself... | <python><kivy> | 2023-04-17 18:10:24 | 1 | 6,175 | daramarak |
76,037,730 | 10,308,565 | How to disable periodic DAG parsing in Apache Airflow | <p>We are facing an issue where dynamically-generated DAGs are periodically disappearing from the UI for some time (usually they are gone for a couple of minutes). DAGs keep being scheduled and executed correctly in this period, so it seems like it only affects the UI.</p>
<p>We think this is due to Airflow periodicall... | <python><airflow> | 2023-04-17 17:24:42 | 1 | 394 | Alexander |
76,037,675 | 21,420,742 | Managing count grouped by another column in python | <p>I have a dataset and I want to see the amount of Unique IDs go to another ID and create a new column showing the count. Here is a sample.</p>
<pre><code> ID Reporting ID
101 103
102 103
103 107
104 103
105 107
106 103
107 110
108 103
10... | <python><python-3.x><pandas><dataframe><numpy> | 2023-04-17 17:16:32 | 1 | 473 | Coding_Nubie |
76,037,448 | 710,955 | How to use json_each with alias() to query in SQLAlchemy/SQLite? | <p>I'm storing JSON documents in one of the columns of an SQLite table. The following query works fine if executed from the SQLite CLI</p>
<pre><code>SELECT jsonfield.value
FROM dataset, json_each(dataset.samples) as jsonfield
WHERE json_extract(jsonfield.value, '$.instruction') == "intrus2"
</code></pre>
<p>... | <python><sqlite><sqlalchemy><json-extract><json-each> | 2023-04-17 16:46:07 | 0 | 5,809 | LeMoussel |
76,037,279 | 468,455 | Python: getting an needs bytes not str on a Requests put | <p>We use Interact as our intranet vendor. I am trying to use their API to update the review date on some of the pages. Each session requires the user to get a token and then use that token for auth on other commands. That works fine, I can get the token and read stuff through the API. But when I try to use PUT to upda... | <python><request><put> | 2023-04-17 16:24:51 | 0 | 6,396 | PruitIgoe |
76,037,162 | 10,994,166 | Pyspark String Type to Array column | <p>I have a spark df column like this:</p>
<pre><code>["100075010", "100075010", "100075010"]
</code></pre>
<p>It's StringType.</p>
<p>I wanna cast this column datatype to Arraytype.</p>
| <python><apache-spark><pyspark><apache-spark-sql> | 2023-04-17 16:11:26 | 1 | 923 | Chris_007 |
76,036,961 | 6,672,237 | Function to add quarters represented as strings in Polars | <p>The main idea is to take string values that represent year+quarter concatenation in format <code>2020Q4</code>, <code>1999Q1</code>...ect and add/subtract an arbitrary number of quarters to/from them. These string values live in a 'polars' DataFrame in a column called 'quarter'. I want to create another column 'quar... | <python><python-polars> | 2023-04-17 15:47:36 | 1 | 562 | kuatroka |
76,036,878 | 3,788 | Formatting for separate rows per column using Pandas pivot? | <p>Consider the following data:</p>
<pre class="lang-py prettyprint-override"><code>
data = [
{
"Account": "Cash",
"amount": 10,
"direction": "debit",
},
{
"Account": "Cash",
"amount": 10,... | <python><pandas> | 2023-04-17 15:37:09 | 1 | 19,469 | poundifdef |
76,036,699 | 18,018,869 | broadcast arrays to same shape, then get the minimum along one axis | <p>I have 3 numpy arrays with different shapes (one not even an array but a scalar) or dimensions.</p>
<pre class="lang-py prettyprint-override"><code>arr1.shape
# (3, 3, 11)
arr2 # this is the scalar
# 1
arr3.shape
# (3, 11)
</code></pre>
<p>I want to compute the minimum along a specific axis.</p>
<p>I tried like <a ... | <python><numpy><numpy-ndarray><array-broadcasting> | 2023-04-17 15:18:10 | 1 | 1,976 | Tarquinius |
76,036,574 | 5,743,692 | Why does the literal string """"""" (seven quotes) give an error? | <p>Processing client's input we often use the <code>strip()</code> method. If we want to remove starting-ending symbols from some specific set we just place all it in the parameter.</p>
<p>The code:</p>
<pre><code>".yes' ".strip(". '")
</code></pre>
<p>obviously gives <code>'yes'</code> string as a... | <python><string><literals> | 2023-04-17 15:03:56 | 2 | 451 | Vasyl Kolomiets |
76,036,558 | 11,135,962 | Convert a string of list to a proper list | <p>I have the following:</p>
<pre><code>a = """\"[""123456789"",""987654321""]\""""
</code></pre>
<p>I am trying to convert that to a list of strings. I've tried the following:</p>
<pre><code>lst = ast.literal_eval(a)
</code></pre>
<p>but t... | <python><string> | 2023-04-17 15:01:43 | 1 | 3,620 | some_programmer |
76,036,476 | 12,760,550 | Save dataframe in loop according to unide values in column and password protect it | <p>I am testing the following code but, although generating the files I need (1 file per unique Business Region - which is the index column of the dataframe), it does not password protect it. Any idea?</p>
<pre><code>import os
import pandas as pd
import numpy as np
from openpyxl.workbook.protection import WorkbookProt... | <python><pandas><group-by><openpyxl><export-to-excel> | 2023-04-17 14:54:49 | 1 | 619 | Paulo Cortez |
76,036,392 | 1,833,326 | Different result in each run (pyspark) | <p>I have a data frame as a result of multiple joins. And I want to investigate for duplicates. But each time when I investigate it the data frame looks different. In particular, the following command leads to different <code>IDs</code> but the number of results stays constant.</p>
<pre><code>from pyspark.sql import Sp... | <python><apache-spark><pyspark><apache-spark-sql><databricks> | 2023-04-17 14:44:37 | 1 | 1,018 | Lazloo Xp |
76,036,228 | 327,572 | How do you implement exec_module for a custom Python module loader? | <p>I want to implement a custom Python module loader, as mentioned <a href="https://docs.python.org/3/reference/import.html" rel="nofollow noreferrer">here</a>. The process seems pretty straightforward, except I don't how to eventually delegate to the default loading process, which I think I want do when I implement <c... | <python><python-import><python-importlib> | 2023-04-17 14:28:09 | 1 | 16,719 | Rob N |
76,036,172 | 1,028,270 | How do I execute a custom filter that returns no output without assigning to a variable? | <p>I have a custom filter that updates a global variable in my code and does some other stuff when called. It returns no output.</p>
<p>I just want to call it inside a template without assigning the output to a variable.</p>
<p>Doing this works but I want to remove the unnecessary variable assignment:</p>
<pre><code>{%... | <python><python-3.x><jinja2> | 2023-04-17 14:21:58 | 1 | 32,280 | red888 |
76,036,074 | 5,409,315 | Cannot debug test case in VS Code: Found duplicate in "env": PATH | <p>I am using VS Code for developing in Python. I have been able to debug single test cases from the test module, which is very practical. Since recently, it no longer works. After a short waiting time, a dialog pops up: "Invalid message: Found duplicate in "env": PATH." with the buttons "Open ... | <python><unit-testing><visual-studio-code><debugging> | 2023-04-17 14:09:44 | 4 | 604 | Jann Poppinga |
76,035,887 | 5,597,037 | Selenium Firefox in headless running from a Celery task - Webdriver unexpectedly closes | <p>Running Selenium from a Flask app / with Celery task in headless mode. I get the error message: <code>selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127</code> Here is the code:</p>
<pre><code>from selenium.webdriver.firefox.service import Service
import sys, os
from ... | <python><selenium-webdriver><celery> | 2023-04-17 13:50:15 | 1 | 1,951 | Mike C. |
76,035,847 | 3,802,473 | Polars / Python Limits Number of Printed Table Output Rows | <p>Does anyone know why polars (or maybe my pycharm setup or python debugger) limits the number of rows in the output? This drives me nuts.</p>
<p>Here is the polars code i am running but I do suspect its not polars specific as there isnt much out there on google (and chatgpt said its info is too old haha).</p>
<pre><c... | <python><debugging><python-polars><truncated> | 2023-04-17 13:46:32 | 2 | 725 | theStud54 |
76,035,817 | 6,237,395 | How do you write to azure with Pandas | <p>You'd think this would be the same as on-prem, but it doesn't appear to be.</p>
<p>Writing works fine like so (lifted from <a href="https://learn.microsoft.com/en-us/sql/machine-learning/data-exploration/python-dataframe-pandas?view=sql-server-ver16" rel="nofollow noreferrer">microsoft's page</a>):</p>
<pre><code>im... | <python><pandas><azure> | 2023-04-17 13:42:47 | 1 | 386 | James |
76,035,783 | 891,441 | Make all fields with nested pydantic models optional recursively | <p>I have a pydantic model with many fields that are also pydantic models.
I would like to make recursively all fields optional.</p>
<p>For example:</p>
<pre class="lang-py prettyprint-override"><code>class MyModelE(BaseModel):
f: float
class MyModelA(BaseModel):
d: str
e: MyModelE
class MyModel(BaseModel):
... | <python><pydantic> | 2023-04-17 13:38:08 | 2 | 2,435 | morfys |
76,035,572 | 9,978,422 | How to ignore fragment of f-string in python assert | <p>Is it possible to ignore one fragment of f-string in python assertion, eg.</p>
<pre><code>assert results.to_dict() == {
"comment": f"Retrying in 3600 seconds (1/5)",
}
</code></pre>
<p>How to make that any of tries 1-5 was assert as true in this line?
Maybe some regex?</p>
<pr... | <python><assert><f-string> | 2023-04-17 13:14:14 | 1 | 322 | lukos06 |
76,035,499 | 18,806,499 | Why does my sorting algo with numpy arrayw work slower than with lists? | <p>I was trying to sort a list with sequential bitonic sort and wanted to make it faster by sorting a numpy array instead of a list, but it only became slower. What did I do wrong?</p>
<p>Here is sorting algo:</p>
<pre><code>from datetime import datetime
import numpy as np
def compAndSwap(a, i, j, dire):
if (dire... | <python><algorithm><numpy><sorting> | 2023-04-17 13:07:34 | 1 | 305 | Diana |
76,035,476 | 9,244,276 | How to stream local video using Django | <p>I’m using <a href="https://github.com/hadronepoch/python-ffmpeg-video-streaming" rel="nofollow noreferrer">python-ffmpeg-video-streaming</a> in my Django project. I can able to generate mpd and m3u8 files successfully, but I didn’t know how to serve these file using Django views.</p>
<p>I tried this approach, but th... | <python><django><video-streaming> | 2023-04-17 13:05:28 | 1 | 1,308 | Sandeep Prasad Kushwaha |
76,035,215 | 3,116,231 | retrieve the object_id of the Azure service principal | <p>How can I retrieve the object_id of an Azure service principal programatically using the Python APIs?</p>
<p><a href="https://i.sstatic.net/fNcT0.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/fNcT0.jpg" alt="enter image description here" /></a></p>
| <python><azure><azure-active-directory><azure-keyvault> | 2023-04-17 12:35:31 | 1 | 1,704 | Zin Yosrim |
76,035,200 | 1,826,893 | FAISS IndexHNSW Search throws an error on Linux but works on Windows (when installing from pip) | <p>I trained a HSMW Index using faiss on Windows. I wanted to deploy this to an Azure Function App, hence I just <code>pip</code> to install <code>faiss-cpu==1.7.3</code> rather than the recommended install with <code>conda</code>.</p>
<p>The code that searches for the most similar vector is</p>
<pre><code>distances, i... | <python><azure-functions><faiss> | 2023-04-17 12:33:30 | 1 | 1,559 | Edgar H |
76,035,089 | 12,860,924 | How to get and generate the Labels of the augmented data? | <p>I am working on classification of images breast cancer using <code> DensetNet121</code> pretrained model. I want to apply data augmentation on the training data. I tried on the below code to augment the data using <code>Keras</code> and <code>ImageDataGenerator</code>. The data augmented but I don't know how to gel ... | <python><tensorflow><keras><tf.keras><data-augmentation> | 2023-04-17 12:18:30 | 0 | 685 | Eda |
76,034,809 | 3,387,716 | pandas.concat() second argument? | <p>I freshly installed a program through pip3 and it now fails like this:</p>
<pre class="lang-none prettyprint-override"><code>pandas.concat(dataFrameList, 0)
TypeError: concat() takes 1 positional argument, but 2 were given
</code></pre>
<p>I looked at the <code>concat()</code> function prototype in Pandas 0.9, 1.x a... | <python><pandas> | 2023-04-17 11:42:23 | 1 | 17,608 | Fravadona |
76,034,614 | 198,145 | How do I handle LabVIEW strings over COM to python | <p>I want to call LabVIEW functions from a python script and try to understand the memory handling of strings and arrays.</p>
<p>Let's say that I have a COM API created by LabVIEW with a function that look like this:</p>
<pre><code>void Foo(LStrHandle *str)
</code></pre>
<p>I want to call this from python and use the l... | <python><python-3.x><memory-management><com><labview> | 2023-04-17 11:22:45 | 0 | 6,283 | magol |
76,034,506 | 18,140,022 | How to call a PostgreSQL function that does not wait for completion? | <p>I have a data pipeline that after wrangling data it creates a new table in a PostgreSQL database and inserts data into such table. I also have a PostgreSQL function that I want to call after the process. The postgres function is pretty heavy and can take up to 10 minutes to finish. I want Python to call the postgres... | <python> | 2023-04-17 11:09:10 | 1 | 405 | user18140022 |
76,034,294 | 9,600,253 | django.db.utils.OperationalError [Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection | <p>I am using mssql server as my database in Django, hosted on Heroku. I am having trouble connecting to that database with ODBC Driver 17 for SQL Server.</p>
<pre><code>#requirements.txt
asgiref
Django==4.0
pytz
sqlparse
djangorestframework
gunicorn
python-dotenv
django-mssql-backend
whitenoise
pyodbc
</code></pre>
<... | <python><sql-server><django><heroku><pyodbc> | 2023-04-17 10:43:26 | 0 | 316 | Musab Gulfam |
76,034,280 | 614,944 | Convert windows time to timestamp | <p>I'm using the following code to convert windows time to unix timestamp,</p>
<pre><code>def convert_windows_time(windows_time):
return datetime.datetime(1601, 1, 1) + datetime.timedelta(microseconds=windows_time / 10)
</code></pre>
<p>How can I do the same in nodejs? This does not work, it results in a different ... | <python><node.js><time> | 2023-04-17 10:42:07 | 1 | 23,701 | daisy |
76,034,275 | 18,756,733 | query() and isin() combination is not working in Kaggle notebook | <p>I want to filter dataframe using .query() and .isin() functions in Kaggle notebook.</p>
<pre><code>standard_stats=standard_stats.query('`Unnamed: 0_level_0_Player`.isin(["Squad Total","Opponent Total"])==False')
</code></pre>
<p><code>Unnamed: 0_level_0_Player</code> is the name of the column and... | <python><isin> | 2023-04-17 10:41:05 | 1 | 426 | beridzeg45 |
76,033,901 | 5,560,529 | How to get a PySpark Dataframe containing al sundays between the current date and a given number of weeks | <p>Given a constant integer <code>MAX_WEEKS</code>, I want to get all Sundays between today's date and today's date + <code>MAX_WEEKS</code> weeks.</p>
<p>For example, take today's date (<code>2023-04-17</code>) at the time of writing and <code>MAX_WEEKS</code> = 5. My desired output would be a PySpark Dataframe lookin... | <python><apache-spark><pyspark> | 2023-04-17 09:59:52 | 0 | 784 | Peter |
76,033,717 | 8,016,168 | How can I calculate the multinomial probability values? | <p>I am trying to write a function that finds the multinomial expansion. In order to do that I modified the binomial probability function;</p>
<p>From:</p>
<p>f(n, k, p) = n! / (k! * (n - k)!) * p<sup>k</sup> * (1 - p)<sup>(n - k)</sup></p>
<p>To:</p>
<p>f(n, k, p) = n! / (k[0]! * k[1]! * ... * k[x]!) * p[0]<sup>k[0]</... | <python><algorithm> | 2023-04-17 09:39:47 | 4 | 1,342 | dildeolupbiten |
76,033,376 | 13,750,668 | Prefect deploy in python "no-start" option | <p>I want to deploy a prefect flow in python. So far I've been using a script like this:</p>
<pre class="lang-py prettyprint-override"><code>deployment = Deployment.build_from_flow(
flow=flow_name,
name="deployment_name",
version=1,
work_queue_name="queue_name",
schedule=CronSc... | <python><prefect> | 2023-04-17 08:58:13 | 1 | 488 | Reine Baudache |
76,033,365 | 4,908,900 | imaplib finds the full subject string but not partial - how to fix? | <p>I'm using impalib to connect to my gmail:</p>
<pre><code>import imaplib
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('bi@great_company', 'app_password')
mail.select('"[Gmail]/All Mail"', readonly=True)
</code></pre>
<p>this finds an email:</p>
<pre><code>mail.search(None, 'SUBJECT "Green Law... | <python><imap><imaplib> | 2023-04-17 08:57:18 | 1 | 3,749 | Ezer K |
76,033,173 | 10,844,937 | Do I need to lock the table? | <p>I use MySQL's default engine <code>innodb</code> and MySQL's default transaction <code>REPEATABLE READS</code>.</p>
<p>My table <code>Job</code> has two fields, <code>job_id</code> and <code>queue</code>. Here I have two tasks, the first task is to insert a record based on the max queue.</p>
<pre><code>import uuid
i... | <python><mysql> | 2023-04-17 08:34:54 | 1 | 783 | haojie |
76,033,166 | 3,059,024 | Is it possible to syncronize threads between java and Python? | <p>I have a server written in Java. It accepts http requests as commands to do work. The work takes time.</p>
<p>We use Java in the backend and Python in the front end sending the http requests and controlling the work done. In Python, there exists a<code>threading.Event</code> which allows communication between thread... | <python><java><multithreading> | 2023-04-17 08:34:08 | 2 | 7,759 | CiaranWelsh |
76,032,976 | 13,518,907 | Recover CSV-File in Jupyter that was overwritten | <p>I work with JupyterLab and have accidentally overwritten an existing CSV-File in my environment.</p>
<p>In my environment, there was a "data.csv"-file at first which I have uploaded to my environment.
Now I accidentally executed the following line in my Jupyter-Notebook:</p>
<pre><code>df.to_csv("data... | <python><csv><jupyter><jupyter-lab> | 2023-04-17 08:10:25 | 1 | 565 | Maxl Gemeinderat |
76,032,641 | 3,685,918 | Bloomberg python API (blpapi) installation error | <p>I would like to use Bloomberg desktop API for Python.
To do this I have to install package <code>blpapi</code>.</p>
<p>My Bloomberg terminal PC environment :</p>
<ol>
<li>WIN10(64bit)</li>
<li>Ananconda 4.13.0 and Python 3.9.12</li>
<li>No internet environment</li>
</ol>
<p>Due to no internet environment, I could no... | <python><bloomberg><blpapi> | 2023-04-17 07:29:42 | 0 | 427 | user3685918 |
76,032,579 | 13,803,549 | Discord.py create_text_channel overwrites dynamic options | <p>I have a slash command for people to setup a bot in their server. During setup, the bot creates a category and adds channels but I want to add overwrites to make these channels read only.</p>
<p>The slash command takes in one parameter, 'role', so the user that is setting up the bot can choose which server role will... | <python><discord.py> | 2023-04-17 07:21:21 | 1 | 526 | Ryan Thomas |
76,032,154 | 4,398,699 | Absolute import works with pytest but fails when running with python | <p>I setup my project similar to other projects (like <a href="https://github.com/numpy/numpy" rel="nofollow noreferrer">Numpy</a> and <a href="https://github.com/pandas-dev/pandas" rel="nofollow noreferrer">Pandas</a>, i.e. using the project name as a directory):</p>
<p><strong>Directory structure:</strong></p>
<pre><... | <python><python-3.x> | 2023-04-17 06:14:53 | 1 | 2,751 | q.Then |
76,032,125 | 11,163,122 | np.clip vs np.max to limit lower value | <p>Let's say I am trying to codify <code>max(0, x)</code> (the formula for <a href="https://en.wikipedia.org/wiki/Rectifier_(neural_networks)" rel="nofollow noreferrer">ReLU activation</a>) with numpy, where <code>x</code> is a numpy array.</p>
<p>I can think of two obvious implementations:</p>
<ul>
<li><code>np.clip(x... | <python><numpy><machine-learning> | 2023-04-17 06:09:07 | 1 | 2,961 | Intrastellar Explorer |
76,032,124 | 1,610,626 | Highlight row based in streamlit | <p>I can't seem to find any specific answers to my question as I'm not sure if it can be done with <code>apply</code> or <code>applymap</code>.</p>
<p>I have a parameter dataframe, lets call it <code>x</code>. I have a raw data frame, lets call it <code>y</code>.</p>
<pre><code> y = pd.DataFrame({"a": {"... | <python><pandas><styling><streamlit> | 2023-04-17 06:09:05 | 1 | 23,747 | user1234440 |
76,031,976 | 17,801,773 | How to get 3 greatest values in a nestet defaultdict in python? | <p>I have a nested defaultdict like this:</p>
<pre><code>defaultdict(<function __main__.<lambda>()>,
{'A': defaultdict(<function __main__.<lambda>()>,
{'a':2,
'b':1,
'd':2,
'f':1}
'B': defaultdict(<f... | <python><dictionary><sorting><defaultdict> | 2023-04-17 05:32:57 | 4 | 307 | Mina |
76,031,835 | 678,572 | How to subset a binary matrix to maximize “uniqueness”? | <p>I’m trying to optimize a matrix by subsetting rows and then performing a calculation on the subsetted rows. The calculation is representing each of the columns exactly once and having as few duplicates as possible.</p>
<p>To be clear, the parameters to optimize are the following:</p>
<ul>
<li>p = Number of columns ... | <python><algorithm><matrix><optimization><platypus-optimizer> | 2023-04-17 04:59:19 | 1 | 30,977 | O.rka |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.