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 β |
|---|---|---|---|---|---|---|---|---|
75,158,662 | 4,061,181 | Comparing two timezone-aware datetimes | <p>Most probably, this question is asked hundred times, but I couldn't still find the answer.
I have the following code:</p>
<pre><code>import pytz
import datetime
from pytz import timezone
tz_moscow = timezone('Europe/Moscow')
tz_yerevan = timezone('Asia/Yerevan')
dt1 = tz_yerevan.localize(datetime.datetime(2011, 7,... | <python><datetime><timezone> | 2023-01-18 11:37:19 | 1 | 4,541 | Edgar Navasardyan |
75,158,580 | 2,531,140 | python setup.py egg_info did not run successfully when building on Docker now | <p>It built fine before.</p>
<p>I did no change for when it still worked before.</p>
<p>Here are its final moments before dying.</p>
<p>As you can see, it dies on installing measurement.</p>
<p>Here is Docker code partial:</p>
<pre><code># Install Python dependencies
COPY requirements.txt /app/
WORKDIR /app
#RUN pip in... | <python><python-3.x><docker> | 2023-01-18 11:30:59 | 1 | 919 | Mark Lopez |
75,158,485 | 17,561,414 | reading files from path with wildcard does not work - Databricks JSON | <p>trying to read a JSON file from databricks with the following code</p>
<pre><code> with open('/dbfs/mnt/bronze/categories/20221006/data_10.json') as f:
d = json.load(f)
</code></pre>
<p>which works perfecyl but problem is that I would like to use the wild cards since there are multiple folders and files. Prefer... | <python><json><databricks> | 2023-01-18 11:23:06 | 1 | 735 | Greencolor |
75,158,484 | 19,716,381 | Assign values to multiple columns using DataFrame.assign() | <p>I have a list of strings stored in a pandas dataframe <code>df</code>, with column name of text (i.e. <code>df['text']</code>).
I have a function <code>f(text: str) -> (int, int, int)</code>.
Now, I want to do the following.</p>
<pre><code>df['a'], df['b'], df['c'] = df['text'].apply(f)
</code></pre>
<p>How can I... | <python><pandas><dataframe> | 2023-01-18 11:23:02 | 1 | 484 | berinaniesh |
75,158,465 | 2,304,575 | Saving large sparse arrays in hdf5 using pickle | <p>In my code I am generating a list of large sparse arrays that are in <code>csr</code> format. I want to store these arrays to file. I was initially saving them to file in this way:</p>
<pre><code>from scipy.sparse import csr_matrix
import h5py
As = [ csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]),
csr_matrix(... | <python><arrays><pickle><h5py> | 2023-01-18 11:21:42 | 2 | 692 | Betelgeuse |
75,158,382 | 4,196,709 | How to call .cpp function inside p4python script? | <p>My job: I want to create a python script that changes the content of a file automatically and then commit the change in Perforce.</p>
<p>Because the file at first is read-only. So I need to create a python script which</p>
<ol>
<li>check out the file (in order to edit it)</li>
<li>call UpdateContent.cpp to change th... | <python><c++><perforce><p4python> | 2023-01-18 11:15:24 | 1 | 648 | gnase |
75,158,376 | 4,321,525 | scipy.optimize.minimize SLSQP indirect constraints problem | <p>I am struggling with <code>minimize</code> (<code>method=SLSQL</code>) and need help. This is a simplified car battery (dis)charging problem to prop up the power grid during reduced stability (peak demand). What I expect to happen is that during such instability, the battery gets discharged as much as possible when ... | <python><linear-programming><scipy-optimize-minimize> | 2023-01-18 11:14:52 | 1 | 405 | Andreas Schuldei |
75,158,299 | 6,212,530 | Django Rest Framework SimpleRouter inclusion inserts ^ into url pattern | <p>I have DRF application with urls defined using <code>SimpleRouter</code>.</p>
<pre><code># project/app/urls.py:
from rest_framework.routers import SimpleRouter
from .viewsets import ExampleViewset, TopViewset
router = SimpleRouter()
router.register(r"example/", ExampleViewSet, basename="example&quo... | <python><django-rest-framework> | 2023-01-18 11:08:48 | 1 | 1,028 | Matija Sirk |
75,158,264 | 10,753,968 | Difference between multiprocessing and concurrent libraries? | <p>Here's what I understand:</p>
<p>The <code>multiprocessing</code> library uses multiple cores, so it's processing in parallel and not just simulating parallel processing like some libraries. To do this, it overrides the Python GIL.</p>
<p>The <code>concurrent</code> library doesn't override the Python GIL and so it ... | <python><concurrency><multiprocessing> | 2023-01-18 11:05:49 | 2 | 2,112 | half of a glazier |
75,158,238 | 19,009,577 | How to get multiprocessing.Pool().starmap() to return iterable | <p>Im trying to construct a dataframe from the inputs of a function as well as the output. Previously I was using for loops</p>
<pre><code>for i in range(x):
for j in range(y):
k = func(i, j)
(Place i, j, k into dataframe)
</code></pre>
<p>However the range was quite big so I tried to speed it up wi... | <python><multiprocessing><python-multiprocessing> | 2023-01-18 11:03:27 | 1 | 397 | TheRavenSpectre |
75,158,198 | 12,231,454 | Test validate_unique raises ValidationError Django forms | <p>I have a ModelForm called SignUpForm located in myproj.accounts.forms</p>
<p>SignUpForm overrides Django's validate_unique so that the 'email' field is excluded from 'unique' validation as required by the model's unique=True (this is dealt with later in the view). Everything works as expected.</p>
<p>I now want to t... | <python><django><django-forms><python-unittest><django-unittest> | 2023-01-18 10:59:58 | 1 | 383 | Radial |
75,158,187 | 10,437,727 | Python unittest mocking not working as expected | <p>I got this project structure:</p>
<pre><code>my_project
βββ __init__.py
βββ app.py
βββ helpers
β βββ __init__.py
βββ tests
βββ __init__.py
βββ integration
β βββ __init__.py
β βββ test_app.py
βββ unit
βββ __init__.py
βββ test_helpers.py
</code></pre>
<p>So far, unit testing ... | <python><unit-testing><integration-testing><python-unittest> | 2023-01-18 10:58:58 | 1 | 1,760 | Fares |
75,158,146 | 3,623,723 | How to convert a structured numpy array to xarray.DataArray? | <p>I have a structured numpy array, containing sampled data from several measurement series:
Each series samples <code>m</code> as a function of <code>l</code>, and differs from the other series by <code>a</code>. l is not sampled at constant values, and there is a different number of samples per series, so we can't ju... | <python><numpy><python-xarray> | 2023-01-18 10:56:06 | 0 | 3,363 | Zak |
75,158,097 | 1,421,907 | Is it possible to use Python Mixed Integer Linear programming to get all solutions in an interval? | <p>I have a linear problem to solve looking for integer numbers. I found a way to solve it using the new <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.milp.html" rel="nofollow noreferrer">milp</a> implementation in spicy. Hereafter is a demonstration code.</p>
<p>The problem is the follow... | <python><scipy><scipy-optimize><mixed-integer-programming> | 2023-01-18 10:51:59 | 1 | 9,870 | Ger |
75,158,015 | 9,212,995 | How can additional visibility options be added to the CKAN form for data records? | <p>I'm wondering if there is a straightforward way to change the CKAN dataset form. I would be interested in <strong>adding extra visibility options</strong> than <strong>public</strong> and <strong>private</strong>:
that is to say;</p>
<ol>
<li>Public</li>
<li>Private</li>
<li>Sub Project</li>
<li>Project</li>
<li>Org... | <python><jinja2><ckan> | 2023-01-18 10:45:06 | 1 | 372 | Namwanza Ronald |
75,158,000 | 997,832 | `Tensor' object has no attribute 'numpy' Error | <p>I'm trying to apply a Lambda function to convert tensor values. I need to get the tensor values in numpy array. I'm trying <code>.numpy()</code> method but it gives <code>'Tensor' object has no attribute 'numpy'</code> error. I added configurations for running the tensor functions eagerly but I'm not sure if it work... | <python><tensorflow><deep-learning> | 2023-01-18 10:44:22 | 1 | 1,395 | cuneyttyler |
75,157,892 | 12,883,297 | Create a new column which calculates the difference between last value and the first value of time column at groupby level in pandas | <p>I have a dataframe</p>
<pre><code>df = pd.DataFrame([["A","9:00 AM"],["A","11:12 AM"],["A","1:03 PM"],["B","9:00 AM"],["B","12:56 PM"],["B","1:07 PM"],
["B","1:18 ... | <python><python-3.x><pandas><dataframe><datetime> | 2023-01-18 10:35:25 | 2 | 611 | Chethan |
75,157,791 | 17,788,573 | AttributeError: 'NoneType' object has no attribute 'glfwGetCurrentContext' | <p>I'm trying a tutorial on Reinforcement learning wherein I'm currently trying to use gymnasium, mujoco, to train agents. I've installed mujoco and when I try to run the program, the sim window opens for a second and throws this error. Idk what I'm doing wrong.</p>
<pre><code>import gymnasium as gym
import stable_base... | <python><reinforcement-learning><mujoco> | 2023-01-18 10:29:00 | 2 | 311 | Vaikruta |
75,157,585 | 8,916,474 | Tox installing external libraries in tox env not from requirements.txt | <p>I use windows. My tox.ini:</p>
<pre><code>[tox]
envlist =
docs
min_version = 4
skipsdist = True
allowlist_externals = cd
passenv =
HOMEPATH
PROGRAMDATA
basepython = python3.8
[testenv:docs]
changedir = docs
deps =
-r subfolder/package_name/requirements.txt
commands =
bash -c "cd ../subfolde... | <python><tox> | 2023-01-18 10:09:50 | 2 | 504 | QbS |
75,157,501 | 9,452,512 | How to access the previous item calculated in a list comprehension? | <p>when I create a list, I use the one-liner</p>
<pre class="lang-py prettyprint-override"><code>new_list = [func(item) for item in somelist]
</code></pre>
<p>Is there a simple way to write the following <em>iteration</em> in one line?</p>
<pre class="lang-py prettyprint-override"><code>new_list = [0]
for _ in range(N)... | <python><python-3.x> | 2023-01-18 10:03:07 | 2 | 1,473 | Uwe.Schneider |
75,157,428 | 16,852,041 | redis.exceptions.DataError: Invalid input of type: 'dict'. Convert to a bytes, string, int or float first | <p>Goal: store a <code>dict()</code> or <code>{}</code> as the value for a key-value pair, to <code>set()</code> onto <strong>Redis</strong>.</p>
<p>Code</p>
<pre><code>import redis
r = redis.Redis()
value = 180
my_dict = dict(bar=value)
r.set('foo', my_dict)
</code></pre>
<pre><code>redis.exceptions.DataError: Inv... | <python><python-3.x><serialization><redis><byte> | 2023-01-18 09:58:14 | 1 | 2,045 | DanielBell99 |
75,157,367 | 11,945,144 | cross validation in pipeline python | <p>I have this pipeline:</p>
<pre><code>
pipe = Pipeline(steps=[
("fasttext", FastTextVectorTransformer()),
("umap",umap_skl(n_components=8)),
("classifier", HistGradientBoostingClassifier())])
pipe.fit(X_train, y_train)
print(f'Fbeta_score:{fbeta_score(y[test_index], pipe.predict(X[test_i... | <python><pipeline><cross-validation> | 2023-01-18 09:53:12 | 0 | 343 | Maite89 |
75,157,339 | 19,238,204 | I want to Plot Circle and its Solid Revolution (Sphere) but get Error: loop of ufunc does not support argument 0 o | <p>I have add the assumption of nonnegative for variables <code>x</code> and <code>r</code> so why I can't plot this?</p>
<p>this is my code:</p>
<pre><code># Calculate the surface area of y = sqrt(r^2 - x^2)
# revolved about the x-axis
import matplotlib.pyplot as plt
import numpy as np
import sympy as sy
x = sy.Symb... | <python><sympy> | 2023-01-18 09:50:15 | 1 | 435 | Freya the Goddess |
75,157,264 | 498,504 | incompatible input layer size error in a Cat Dog Classification CNN model | <p>I'm writing a simple CNN model to Classification Cat and Dog picture from a local directory named <code>train</code>.</p>
<p>Below are the codes that I have written so far:</p>
<pre><code>import numpy as np
import cv2 as cv
import tensorflow.keras as keras
import os
from sklearn.preprocessing import LabelEncoder
fro... | <python><tensorflow><keras> | 2023-01-18 09:45:45 | 1 | 6,614 | Ahmad Badpey |
75,157,153 | 7,800,760 | Always include set of packages when creating a new conda environment | <p>Everytime I create a new conda environment I need to:</p>
<ol>
<li>Always include black pylint pytest packages in addition to the project's specific ones</li>
<li>Always create three subdirectories: data, tests and a third with the environment's name</li>
<li>(optionally) create a corresponding new GitHub repo</li>
... | <python><conda> | 2023-01-18 09:36:27 | 0 | 1,231 | Robert Alexander |
75,157,090 | 11,279,170 | Fill NAs : Min of values in group | <p>Here is my DataFrame.</p>
<pre><code>df = pd.DataFrame ( {'CNN': ['iphone 11 63 GB TMO','iphone 11 128 GB ATT','iphone 11 other carrier','iphone 12 256 GB TMO','iphone 12 64 GB TMO','iphone 12 other carrier'],
'Family Name':['iphone 11', 'iphone 11', 'iphone 11', 'iphone 12', 'iphone 12'... | <python><pandas><fillna> | 2023-01-18 09:31:10 | 3 | 631 | DSR |
75,156,952 | 6,653,602 | Migrate django database to existing one | <p>So I am using Django with mysql database (most basic tables, like auth, user, admin and few custom models) but I need to migrate those tables with data to a existing PostgreSQL database. The issue is that there are tables created there already. Should I create additional models in the models.py file for those models... | <python><django><postgresql><django-models> | 2023-01-18 09:19:32 | 1 | 3,918 | Alex T |
75,156,877 | 3,004,698 | Access CosmosDB Data from Azure App Service by using managed identity (Failed) | <p>A FastAPI-based API written in Python has been deployed as an Azure App Service. The API needs to read and write data from CosmosDB, and I attempted to use Managed Identity for this purpose, but encountered an error, stating <code>Unrecognized credential type</code></p>
<p>These are the key steps that I took towards... | <python><terraform><azure-web-app-service><azure-cosmosdb><azure-managed-identity> | 2023-01-18 09:12:29 | 1 | 5,152 | SLN |
75,156,728 | 3,672,883 | Pyreverse dont take relationship when I type data like List[class] | <p>Hello I have the following clas</p>
<pre><code>class Page(BaseModel):
index_page:int
content:str
class Book(BaseModel):
name:str
pages: List[Page] = []
</code></pre>
<p>The problem is that when I execute pyreverse it isn't set the relationship between Book and Page</p>
<p>But if I change the class B... | <python><uml><pylint><pyreverse> | 2023-01-18 08:57:15 | 0 | 5,342 | Tlaloc-ES |
75,156,644 | 10,583,765 | Django Ninja API schema circular import error | <p>I have <code>UserSchema</code>:</p>
<pre class="lang-py prettyprint-override"><code># users/models.py
class User(AbstractUser):
...
# users/schemas.py
from typing import List
from tasks.schemas import TaskSchema
class UserSchema(ModelSchema):
tasks: List[TaskSchema] = []
class Config:
model =... | <python><django><django-ninja> | 2023-01-18 08:49:05 | 1 | 2,143 | Swix |
75,156,551 | 7,800,760 | Finding on which port a given server is running within python program | <p>I am developing a python 3.11 program which will run on a few different servers and needs to connect to the local Redis server. On each machine the latter might run on a different port, sometimes the default 6379 but not always.</p>
<p>On the commandline I can issue the following command which on both my Linux and M... | <python><linux><macos><network-programming><tcp> | 2023-01-18 08:39:23 | 1 | 1,231 | Robert Alexander |
75,156,511 | 3,826,362 | Pandas - sort_values by combining multiple columns | <p>Assume file <code>sizes.txt</code> with the following content:</p>
<pre><code>Sig Sta FP Method Size
10 10 100 array 108
10 10 100 csr-heur 130
10 10 100 list 220
10 10 15 array 108
10 10 15 csr-heur 45
10 10 15 list 50
10 10 25 array 108
10 10 25 csr-heur 62
10 10 25 list 70
10 10 50 array 108
10 10 50 csr-heur 95
... | <python><pandas><dataframe><sorting> | 2023-01-18 08:35:18 | 0 | 1,121 | JΔdrzej Dudkiewicz |
75,156,434 | 10,829,044 | Drop duplicate lists within a nested list value in a column | <p>I have a pandas dataframe with nested lists as values in a column as follows:</p>
<pre><code>sample_df = pd.DataFrame({'single_proj_name': [['jsfk'],['fhjk'],['ERRW'],['SJBAK']],
'single_item_list': [['ABC_123'],['DEF123'],['FAS324'],['HSJD123']],
'single_i... | <python><pandas><list><dataframe><group-by> | 2023-01-18 08:28:41 | 2 | 7,793 | The Great |
75,156,360 | 19,920,392 | Why Popen.communicate returns the satus of another subprocess.Popen? | <p>I have codes that starts Django server and React server at the same time.<br />
Here are the codes:<br />
<strong>back_server.py</strong></p>
<pre><code>import os
import subprocess
def run_server():
current_dir = os.getcwd()
target_dir = os.path.join(current_dir, 'marketBack/BackServer')
subprocess.Pop... | <python><reactjs><django><subprocess> | 2023-01-18 08:21:18 | 0 | 327 | gtj520 |
75,156,323 | 13,476,175 | Pickle AttributeError: Can't get attribute 'EnsembleModel' on <module '__main__' from '<input>'> | <p>I've written a custom class to represent an ensemble model, and I want to pickle it for later usage. Here is how I construct the model and save the object using pickle:</p>
<pre class="lang-py prettyprint-override"><code>import pickle
from typing import Any
class EnsembleModel:
def __init__(self, estimators: L... | <python><python-asyncio><pickle> | 2023-01-18 08:18:10 | 1 | 875 | frisko |
75,156,182 | 11,520,576 | Is there any efficient way both getting 'max' and 'argmax' with a multi-dimensional array | <p>I have an array <code>a</code> with shape (18,4096,4096).</p>
<p>And I want to do like these:</p>
<pre class="lang-py prettyprint-override"><code>max_value = np.max(a,0)
index = np.argmax(a,0)
</code></pre>
<p><code>max_value </code> and <code>index</code> are both array with shape (4096, 4096), and I think calling ... | <python><numpy> | 2023-01-18 08:03:52 | 1 | 327 | YD Zhou |
75,156,148 | 19,500,571 | Plotly Dash (Python): Data is loaded twice upon start | <p>I'm building a dashboard in Dash, where I want to visualie a dataset that I load at the start of the dashboard. As this dataset is to be used by all methods in the dashboard, I keep it in a singleton class.</p>
<p>The issue is though that the data is loaded twice when I start the dashboard ("generated" is ... | <python><plotly-dash><dashboard> | 2023-01-18 08:00:48 | 0 | 469 | TylerD |
75,155,799 | 15,781,591 | How to select dataframe in dictionary of dataframes that contains a column with specific substring | <p>I have a dictionary of dataframes <code>df_dict</code>. I then have a substring "blue". I want to identify the name of the dataframe in my dictionary of dataframes that has at least one column that has a name containing the substring "blue".</p>
<p>I am thinking of trying something like:</p>
<pre... | <python><pandas><dataframe><dictionary><substring> | 2023-01-18 07:22:26 | 1 | 641 | LostinSpatialAnalysis |
75,155,659 | 17,267,064 | How to sort list of dictionaries by value without using built in functions via Python? | <p>I wish to sort below list of dictionaries by age key into ascending order without using any built in functions.</p>
<pre><code>[{'Name': 'Alpha', 'Age': 14}, {'Name': 'Bravo', 'Age': 21}, {'Name': 'Charlie', 'Age': 12}]
</code></pre>
<p>I wish to have below output.</p>
<pre><code>[{'Name': 'Charlie', 'Age': 12}, {'N... | <python><dictionary> | 2023-01-18 07:04:08 | 0 | 346 | Mohit Aswani |
75,155,652 | 14,045,537 | Pandas replace values if value isin dictionary of key and values as list | <p>I do realize this has already been addressed here (e.g., <a href="https://stackoverflow.com/q/72185441/14045537">pandas: replace column value with keys and values in a dictionary of list values</a>, <a href="https://stackoverflow.com/q/46432315/14045537">Replace column values by dictionary keys if they are in dictio... | <python><pandas><dataframe><dictionary> | 2023-01-18 07:02:55 | 1 | 3,025 | Ailurophile |
75,155,423 | 19,106,705 | 'OMP: Error #179' when using hugging face BERT | <p>I simply tried running this code.</p>
<pre class="lang-py prettyprint-override"><code>from transformers import BertForSequenceClassification, BertTokenizer
</code></pre>
<p>with this command. For 'GPU_ID' I used my GPU UUID, which wasn't wrong.</p>
<pre><code>CUDA_VISIBLE_DEVICES='GPU_ID' python3 MNLI.py
</code></pr... | <python><pytorch><gpu><huggingface> | 2023-01-18 06:31:53 | 0 | 870 | core_not_dumped |
75,155,225 | 3,031,069 | Can SQLAlchemy express one-to-many relations via association tables? | <p>I am trying to access an existing DB with SQLAlchemy. (Thus, I cannot easily change the schema or the existing data. I am also not sure why the schema is structured the way it is.)</p>
<p>Consider the following pattern:</p>
<pre><code>association_table = Table(
"association_table",
Base.metadata,
... | <python><sql><sqlalchemy> | 2023-01-18 06:06:48 | 1 | 3,597 | choeger |
75,155,170 | 15,781,591 | How to filter for substring in list comprehension in python | <p>I have a dictionary of dataframes. I want to create a list of the names of all of the dataframes in this dictionary that have the substring "blue" in them. No dataframes in the dictionary of dataframes contain a column simply called "blue". It is some variation of "blue", including: &qu... | <python><pandas><list><substring><list-comprehension> | 2023-01-18 05:58:40 | 1 | 641 | LostinSpatialAnalysis |
75,155,155 | 10,969,548 | Configure Python interpreter for notebook in vscode to be the same as the interpreter for a conda environment | <p>From my understanding of this <a href="https://docs.anaconda.com/anaconda/user-guide/tasks/integration/python-path/" rel="nofollow noreferrer">source</a> and what a python interpreter is, if I have an environment like this:</p>
<pre><code>$ conda activate myenv
(myenv) $ python3
> import pandas as pd
>
</code... | <python><visual-studio-code><jupyter-notebook> | 2023-01-18 05:56:49 | 1 | 2,076 | financial_physician |
75,155,030 | 4,718,335 | Python checking datetime overlapping in list of dictionaries | <p>I've list of dictionary format like below</p>
<pre><code>[{'end': '19:00', 'start': '10:00'}, {'end': '23:00', 'start': '12:15'}, {'end': '12:00', 'start': '09:15'}]
</code></pre>
<p>and want to check is time interval is overlapping or not</p>
<p>What I'm planning to do:</p>
<ol>
<li>First want to sort the list of d... | <python> | 2023-01-18 05:36:21 | 3 | 1,864 | Russell |
75,154,979 | 9,303,844 | Longest consecutive 1 from consecutive colums in Pyspark dataframe | <p>Suppose I have a Py spark data frame as follows:</p>
<pre><code>b1 b2 b3 b4 b5 b6
1 1 1 0 1 1
test_df = spark.createDataFrame([
(1,1,1,0,1,1)
], ("b1", "b2","b3","b4","b5","b6"))
</code></pre>
<p>Here, the length of the longest consecutive 1... | <python><dataframe><apache-spark><pyspark> | 2023-01-18 05:24:08 | 2 | 493 | Lzz0 |
75,154,834 | 10,620,003 | Bar Plot horizontally with some setting in python | <p>I have a dataset and I want to do the bar plot horizontally in python. Here is the code which I use:</p>
<pre><code>rating = [8, 4, 5, 6,7, 8, 9, 5]
objects = ('h', 'b', 'c', 'd', 'e', 'f', 'g', 'a')
y_pos = np.arange(len(objects))
plt.barh(y_pos, rating, align='center', alpha=0.5)
plt.yticks(y_pos, objects)
#plt.... | <python><matplotlib> | 2023-01-18 04:55:33 | 1 | 730 | Sadcow |
75,154,817 | 8,522,675 | Sqlalchemy How to count rows per month using sqlalchemy select()? | <p>I have this model:</p>
<pre><code>from sqlalchemy import Table, Column, BIGINT, VARCHAR, TIMESTAMP
Table(
'person',
metadata,
Column('id', BIGINT, nullable=False, primary_key=True),
Column('name', VARCHAR(300)),
Column('user_created', TIMESTAMP),
Column('user_deleted', TIMESTAMP)
)
</code></pre>
<... | <python><sqlalchemy> | 2023-01-18 04:51:34 | 1 | 657 | RonanFelipe |
75,154,736 | 257,924 | How to properly initialize win32com.client.constants? | <p>I'm writing a simple email filter to work upon Outlook incoming messages on Windows 10, and seek to code it up in Python using the <code>win32com</code> library, under Anaconda. I also seek to avoid using magic numbers for the "Inbox" as I see in other examples, and would rather use constants that <em>shou... | <python><outlook><constants><win32com><office-automation> | 2023-01-18 04:37:37 | 1 | 2,960 | bgoodr |
75,154,539 | 4,755,954 | Auto-update a csv based with edited grid in streamlit-aggrid | <p>I am new to <code>Streamlit</code> and <code>streamlit-aggrid</code> so I am trying to figure this simple case out.</p>
<h3># Goal:</h3>
<ol>
<li>Load a table from a <code>csv</code> as <code>df</code></li>
<li>Display it in <code>streamlit</code></li>
<li>Edit some cells using <code>streamlit-aggrid</code></li>
<li... | <python><ag-grid><streamlit> | 2023-01-18 03:54:05 | 1 | 19,377 | Akshay Sehgal |
75,154,473 | 17,560,347 | How to set negative part to zero in a MatrixSymbol? | <p>I want to set negative part to zero in a MatrixSymbol.</p>
<pre class="lang-py prettyprint-override"><code>from sympy import MatrixSymbol
x = MatrixSymbol('x', 10, 10)
_ = x < 0 # raise TypeError: Invalid comparison of non-real x
# what I want to do:
x[x < 0] = 0
</code></pre>
| <python><sympy><symbolic-math> | 2023-01-18 03:38:28 | 1 | 561 | ε΄ζ
ι |
75,154,238 | 3,411,191 | FastAPI: Task was destroyed but it is pending | <p>I've been fighting asyncio + FastAPI for the last 48 hours. Any help would be appreciated. I'm registering an <code>on_gift</code> handler that parses gifts I care about and appends them to <code>gift_queue</code>. I'm then pulling them out in a while loop later in the code to send to the websocket.</p>
<p>The goal ... | <python><websocket><python-asyncio><fastapi><tornado> | 2023-01-18 02:44:49 | 0 | 1,064 | Zane Helton |
75,154,182 | 17,696,880 | Remove 2 or more consecutive non-caps words from strings stored within a list of strings using regex, and separate | <pre class="lang-py prettyprint-override"><code>import re
list_with_penson_names_in_this_input = ["MarΓa Sol", "MarΓa del Carmen Perez AgΓΌiΓ±o", "Melina Saez Sossa", "el de juego es Alex" , "Harry ddeh jsdelasd Maltus ", "Ben White ddesddsh jsdelasd Regina yΓ‘shas a... | <python><python-3.x><regex><list><regex-group> | 2023-01-18 02:32:04 | 1 | 875 | Matt095 |
75,154,134 | 9,338,509 | Getting Incorrect padding error while decoding a message in pyhon when the encoding is from base64 in java | <p>I have a service in python which will decode the messages like below:</p>
<pre><code>json.loads(base64.b64decode(myMessage['data']))
</code></pre>
<p>This is what I am trying to do in Java to encode</p>
<pre><code>JSONObject msg=new JSONObject();
msg.put("name", "myName");
msg.put("class&quo... | <python><java><encoding><base64><decoding> | 2023-01-18 02:23:09 | 0 | 553 | lakshmiravali rimmalapudi |
75,153,957 | 4,152,567 | Loading saved Keras model fails: ValueError: Inconsistent values for attr 'Tidx' DT_FLOAT vs. DT_INT32 while building NodeDef | <p>The code below generates the <strong>error</strong>:</p>
<pre><code>ValueError: Inconsistent values for attr 'Tidx' DT_FLOAT vs. DT_INT32 while building NodeDef
</code></pre>
<p>tf_op_layer_Mean_17/Mean_17' using Op<name=Mean; signature=input:T, reduction_indices:Tidx -> output:T; attr=keep_dims:bool,default=f... | <python><tensorflow><keras> | 2023-01-18 01:45:30 | 1 | 512 | Mihai.Mehe |
75,153,851 | 3,099,733 | Is it possible to automatically convert a Union type to only one type automatically with pydantic? | <p>Given the following data model:</p>
<pre class="lang-py prettyprint-override"><code>
class Demo(BaseModel):
id: Union[int, str]
files: Union[str, List[str]]
</code></pre>
<p>Is there a way to tell <code>pydantic</code> to always convert <code>id</code> to <code>str</code> type and <code>files</code> to <code>Lis... | <python><pydantic> | 2023-01-18 01:25:01 | 2 | 1,959 | link89 |
75,153,848 | 14,673,832 | IndexError while calling dunder methods | <p>I want to print the values from the dunder methods of a class <code>foo</code>. However, I got the error:</p>
<pre><code>IndexError: Replacement index 1 out of range for positional args tuple
</code></pre>
<p>The code snippet is as follows:</p>
<pre class="lang-py prettyprint-override"><code>class foo(object):
d... | <python><format><index-error> | 2023-01-18 01:24:35 | 2 | 1,074 | Reactoo |
75,153,809 | 10,549,044 | Run 3 Python Lines of Code Asynchronous without order | <p>Ok so I have a function that calls an API and waits for the response. I am using threading in order to parallelize calling requests during building the DataFrame. The same function gets called later many times but only with 1 item. So iterator is actually a list of just 1 element, hence no threading happens.</p>
<p>... | <python><asynchronous> | 2023-01-18 01:14:52 | 1 | 410 | ma7555 |
75,153,745 | 1,961,582 | Is it possible to filter a pandas dataframe with an IntervalIndex or something similar? | <p>I have a pandas dataframe that has a DatetimeIndex. I want to filter this dataframe in 15 day chunks at a time. To do this manually I can do something like:</p>
<pre><code>start, end = pd.Timestamp('2022-07-01'), pd.Timestamp('2022-07-16')
filt_df = df[start: end]
</code></pre>
<p>However, I want to be able to do th... | <python><pandas><dataframe> | 2023-01-18 00:57:24 | 2 | 1,163 | gammapoint |
75,153,726 | 3,750,694 | How to convert bounding box with relative coordinates of object resulting from running yolov5 into absolute coordinates | <p>I have run the yolov5 model to predict trees in imagery with a geocoordinate. I got the bounding box objects with relative coordinates after running the model. I would like to have these bounding boxes with the absolute coordinate system as the imagery (NZTM 2000). Please help me to do this. Below are my bounding bo... | <python><pandas><bounding-box><coordinate-systems><yolov5> | 2023-01-18 00:55:16 | 1 | 703 | user30985 |
75,153,711 | 386,861 | How to fine tune formatting in Pandas | <p>Just learning some new pandas techniques and working on trying to fine tune the outputs.</p>
<p>Here's my code.</p>
<p>import pandas as pd
import numpy as np</p>
<pre><code>dogs = np.random.choice(['labrador', 'poodle', 'pug', 'beagle', 'dachshund'], size=50_000)
smell = np.random.randint(1,100, size=50_000)
df = pd... | <python><pandas> | 2023-01-18 00:52:26 | 1 | 7,882 | elksie5000 |
75,153,626 | 2,706,344 | How to find a single NaN row in my DataFrame | <p>I have a DataFrame with a 259399 rows and one column. It is called <code>hfreq</code>. In one single row I have a NaN value and I want to find it. I thought this is easy and tried <code>hfreq[hfreq.isnull()]</code>. But as you can see it doesn't help:</p>
<p><a href="https://i.sstatic.net/KyEt8.png" rel="nofollow no... | <python><pandas> | 2023-01-18 00:34:35 | 1 | 4,346 | principal-ideal-domain |
75,153,610 | 998,070 | Drawing an ellipse at an angle between two points in Python | <p>I'm trying to draw an ellipse between two points. So far, I have it mostly working:</p>
<p><a href="https://i.sstatic.net/b2FJ7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/b2FJ7.png" alt="Arc Angle" /></a></p>
<p>The issue comes with setting the ellipse height (<code>ellipse_h</code> below).</p>
<... | <python><numpy><geometry><linear-algebra><trigonometry> | 2023-01-18 00:31:29 | 1 | 424 | Dr. Pontchartrain |
75,153,525 | 7,766,024 | If MySQL is case-sensitive on Linux, why am I getting a duplicate entry error? | <p>I was using MLflow to log some parameters for my ML experiment and kept experiencing a <code>BAD_REQUEST</code> error. The specific traceback is:</p>
<pre><code>mlflow.exceptions.RestException: BAD_REQUEST: (pymysql.err.IntegrityError) (1062, "Duplicate entry 'hidden_Size-417080a853934d5d8a7cf5a27' for key 'par... | <python><mysql> | 2023-01-18 00:15:16 | 1 | 3,460 | Sean |
75,153,425 | 7,984,318 | python pandas convert for loop in one line code | <p>I have a Dataframe df,you can have it by running:</p>
<pre><code>import pandas as pd
data = [10,20,30,40,50,60]
df = pd.DataFrame(data, columns=['Numbers'])
df
</code></pre>
<p>now I want to check if df's columns are in an existing list,if not then create a new column and set the column value as 0,column na... | <python><pandas><dataframe> | 2023-01-17 23:56:33 | 3 | 4,094 | William |
75,153,423 | 8,406,398 | Jupyter notebook gui missing Java kernel | <p>I'm using below docker to use <code>IJava</code> kernel to my jupyter notebook.</p>
<pre><code>FROM ubuntu:18.04
ARG NB_USER="some-user"
ARG NB_UID="1000"
ARG NB_GID="100"
RUN apt-get update || true && \
apt-get install -y sudo && \
useradd -m -s /bin/bash -N -... | <python><docker><jupyter-notebook> | 2023-01-17 23:56:27 | 1 | 2,125 | change198 |
75,153,395 | 17,487,457 | matplotlib: common legend to a column in a subplots | <p>Suppose the below code is used to create my plot:</p>
<pre class="lang-py prettyprint-override"><code>x = np.linspace(0, 2 * np.pi, 400)
y = np.sin(x ** 2)
fig, axs = plt.subplots(2, 2)
axs[0, 0].plot(x, y)
axs[0, 0].set_title('Axis [0, 0]')
axs[0, 1].plot(x, y, 'tab:orange')
axs[0, 1].set_title('Axis [0, 1]')
axs[... | <python><matplotlib><legend><subplot> | 2023-01-17 23:52:28 | 1 | 305 | Amina Umar |
75,153,310 | 3,466,818 | Why can't ArUco3Detection find these tags? | <p>I created a custom 4x4 dictionary, and put four of them on a circuit board into the silkscreen.</p>
<p><a href="https://i.sstatic.net/WEnql.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/WEnql.jpg" alt="enter image description here" /></a></p>
<pre><code>myDict = cv2.aruco.custom_dictionary(4, 4, 133... | <python><opencv><computer-vision><detection><aruco> | 2023-01-17 23:37:36 | 0 | 706 | Helpful |
75,153,191 | 238,012 | PIL Open image, causing DecompressionBombError, with lower resolution | <p>I have a <code>problem_page</code> such that</p>
<pre class="lang-py prettyprint-override"><code>from PIL import Image
problem_page = "/home/rajiv/tmp/kd/pss-images/f1-577.jpg"
img = Image.open(problem_page)
</code></pre>
<p>results in</p>
<pre><code>PIL.Image.DecompressionBombError: Image size (37039074... | <python><python-imaging-library> | 2023-01-17 23:15:50 | 0 | 6,344 | RAbraham |
75,153,001 | 9,878,135 | SQLAlchemy what's the difference between creating an type instance and setting default values | <p>I am learning SQLAlchemy and found different usages of defining types and how to set default values. What are the differences between them?</p>
<p>Example 1</p>
<pre class="lang-py prettyprint-override"><code>class User(Base):
__tablename__ = "user"
age = sa.Column(
sa.Integer,
def... | <python><sqlalchemy><fastapi> | 2023-01-17 22:46:48 | 1 | 1,328 | Myzel394 |
75,152,807 | 12,116,507 | how to convert a string into an array of variables | <p>how can i take a string like this</p>
<pre><code>string = "image1 [{'box': [35, 0, 112, 36], 'score': 0.8626706004142761, 'label': 'FACE_F'}, {'box': [71, 80, 149, 149], 'score': 0.8010843992233276, 'label': 'FACE_F'}, {'box': [0, 81, 80, 149], 'score': 0.7892318964004517, 'label': 'FACE_F'}]"
</code></pre... | <python><arrays> | 2023-01-17 22:19:59 | 1 | 361 | dam1ne |
75,152,773 | 1,611,396 | Vertical scrollbar in FLET app, does not appear | <p>I am building a FLET app, but sometimes I have a datatable which is too large for the frame it is in. For the row I have a scrollbar appearing, but for the column I just don't seem to get it working.</p>
<p>In this code a scrollbar simply does not appear.</p>
<pre><code>import pandas as pd
pd.options.display.max_col... | <python><flet> | 2023-01-17 22:14:50 | 1 | 362 | mtjiran |
75,152,736 | 5,924,264 | Converting column of dataframe based on scaling factor from another dataframe | <p>I have a dataframe that has a column <code>length</code> (numeric) and another column units (string). For example,</p>
<pre><code>df2convert =
length units
1.0 "m" # meters
1.4 "in" # inches
0.5 "km" # kilometers
....
</code></pre>
<p>I have another ... | <python><pandas><dataframe> | 2023-01-17 22:11:28 | 2 | 2,502 | roulette01 |
75,152,695 | 12,436,050 | Filter rows from Pandas dataframe based on max value of a column | <p>I have a pandas dataframe with following columns</p>
<pre><code>col1 col2 col3
x 12 abc
x 7 abc
x 5 abc
x 3
y 10 abc
y 9 abc
</code></pre>
<p>I would like to find all rows in a pandas DataFrame which have the max value for col2 column, after grouping by 'c... | <python><pandas> | 2023-01-17 22:05:27 | 2 | 1,495 | rshar |
75,152,653 | 1,563,347 | Can a python pickle object be checked for malicious code before unpickling? | <p>Is there any way to test a pickle file to see if it loads a function or class during unpickling?</p>
<p>This gives a good summary of how to stop loading of selected functions:
<a href="https://docs.python.org/3/library/pickle.html#restricting-globals" rel="nofollow noreferrer">https://docs.python.org/3/library/pickl... | <python><pickle> | 2023-01-17 22:00:07 | 2 | 601 | wgw |
75,152,539 | 278,403 | Substitute compound expression in SymPy | <p>In sympy how can I make a substitution of a compound expression for a single variable as in the following example that only works for one of the instances of the common factor?</p>
<pre class="lang-py prettyprint-override"><code>from sympy import *
x, y, z = symbols('x y z')
eq = Eq(2*(x+y) + 3*(x+y)**2, 0)
print(e... | <python><sympy> | 2023-01-17 21:44:11 | 2 | 2,219 | glennr |
75,152,437 | 1,003,190 | PyTorch: bitwise OR all elements below a certain dimension | <p>New to pytorch and tensors in general, I could use some guidance :) I'll do my best to write a correct question, but I may use terms incorrectly here and there. Feel free to correct all of this :)</p>
<p>Say I have a tensor of shape (n, 3, 3). Essentially, n matrices of 3x3. Each of these matrices contains either 0 ... | <python><machine-learning><pytorch><tensor> | 2023-01-17 21:32:34 | 1 | 3,925 | aspyct |
75,152,397 | 1,142,502 | Python-docx delete table code not working as expected | <p>I am trying to do the following tasks:</p>
<ul>
<li>Open a DOCX file using <code>python-docx</code> library</li>
<li>Count the # of tables in the DOCX: <code>table_count = len(document.tables)</code></li>
<li>The function <code>read_docx_table()</code> extracts the table, creates a dataframe.</li>
</ul>
<p>My object... | <python><pandas><python-docx> | 2023-01-17 21:27:19 | 1 | 427 | aki2all |
75,152,324 | 8,588,743 | OpenCV's GrabCut produces unsatisfactory segmentation | <p>I have the following image</p>
<p><a href="https://i.sstatic.net/pa6tL.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pa6tL.png" alt="enter image description here" /></a></p>
<p>I want to identify the main object in this image, which is the blue couch, and remove the background (preferably turn it in... | <python><opencv><computer-vision><image-segmentation><semantic-segmentation> | 2023-01-17 21:19:31 | 0 | 903 | Parseval |
75,152,092 | 14,551,577 | stale element reference: element is not attached to the page document: tree recursion in python selenium | <p>I am trying to download web pages using python selenium.<br />
There is a tree view on the left side and the content on the right side.</p>
<p>This is HTML of treeview. Of course, all sub menus are closed at first.</p>
<pre><code><ul>
<li>
<a href="#" onclick="openSubMenu()"&... | <python><selenium><web-scraping><recursion><treeview> | 2023-01-17 20:52:56 | 1 | 644 | bcExpt1123 |
75,152,070 | 10,791,330 | Year transition on a 4-4-5 calendar outputs incorrect year on yyyy-mm and quarter | <p>I created a 4-4-5 calendar by repurposing some code here:
<a href="https://stackoverflow.com/questions/67017473/how-to-create-a-4-4-5-fiscal-calendar-using-python">How to create a 4-4-5 fiscal calendar using python?</a></p>
<pre><code>import pandas as pd
import datetime as dt
def create_445_calender(start_date: st... | <python><python-3.x><pandas><date> | 2023-01-17 20:50:18 | 1 | 758 | Jacky |
75,151,973 | 5,865,393 | Latin-9 exported CSV file Flask | <p>I am trying to export data from the database to a CSV file. The export is done perfectly, however, I have some Arabic text in the database where when exporting the data, I get Latin-9 characters. As below. (<em>I am on Windows</em>)</p>
<p><a href="https://i.sstatic.net/KWOxZ.png" rel="nofollow noreferrer"><img src=... | <python><csv><flask> | 2023-01-17 20:40:45 | 1 | 2,284 | Tes3awy |
75,151,887 | 569,976 | matcher.knnMatch() error: unsupported format or combination of formats | <p>I was trying to simplify <a href="https://github.com/opencv/opencv/blob/4.x/samples/python/find_obj.py" rel="nofollow noreferrer">https://github.com/opencv/opencv/blob/4.x/samples/python/find_obj.py</a> and make it use <code>warpPerspective()</code> and am now getting an error.</p>
<p>Before I share the error here's... | <python><opencv> | 2023-01-17 20:29:54 | 0 | 16,931 | neubert |
75,151,388 | 8,372,455 | add numpy array to pandas df | <p>Im experimenting with time series predictions something like this:</p>
<pre><code>import pandas as pd
from statsmodels.tsa.statespace.sarimax import SARIMAX
model = SARIMAX(data.values,
order=order,
seasonal_order=seasonal_order)
result = model.fit()
train = data.sample(frac=0.8,... | <python><pandas><statsmodels> | 2023-01-17 19:30:14 | 1 | 3,564 | bbartling |
75,151,180 | 12,244,355 | Python: How to explode two columns and set prefix | <p>I have a DataFrame as follows:</p>
<pre><code>time asks bids
2022-01-01 [{'price':'0.99', 'size':'32213'}, {'price':'0.98', 'size':'23483'}] [{'price':'1.0', 'size':'23142'}, {'price':'0.99', 'size':'6436'}]
2022-01-02 [{'price':'0.99'... | <python><pandas><dataframe><prefix><pandas-explode> | 2023-01-17 19:10:23 | 3 | 785 | MathMan 99 |
75,151,016 | 19,797,660 | How to rewrite my Pinescript code to Python | <p>I am trying to rewrite this code to Python:</p>
<pre><code>src = input.source(close, "Source")
volStop(src) =>
var max = src
var min = src
max := math.max(max, src)
min := math.min(min, src)
[max, min]
[max, min] = volStop(src)
plot(max, "Max", styl... | <python><pandas><pine-script> | 2023-01-17 18:53:29 | 1 | 329 | Jakub Szurlej |
75,150,865 | 7,422,352 | Getting "(InvalidToken) when calling the ListObjectsV2 operation" when MLFlow is trying to access the artefacts stored on S3 | <p>I am trying to start the MLFlow server on my local machine inside a python virtual environment using the following command:</p>
<pre><code>mlflow server --backend-store-uri postgresql://mlflow_user:mlflow@localhost/mlflow --artifacts-destination S3://<S3 bucket name>/mlflow/ --serve-artifacts -h 0.0.0.0 -p 8... | <python><amazon-s3><mlflow><model-management> | 2023-01-17 18:39:42 | 1 | 5,381 | Deepak Tatyaji Ahire |
75,150,849 | 17,473,587 | Checking value is in a list of dictionary values in Jinja | <p>I have a list of tables coming from a SQLite database:</p>
<pre class="lang-py prettyprint-override"><code>tbls_name = db_admin.execute(
"""SELECT name FROM sqlite_master WHERE type='table';"""
)
</code></pre>
<p>And need to check if <code>table_name</code> is in the resulting list ... | <python><jinja2> | 2023-01-17 18:38:36 | 1 | 360 | parmer_110 |
75,150,811 | 12,027,869 | Python: Conditional Row Values From a New Column Using dictionary, function, and lambda | <p>I have a dataframe:</p>
<pre><code>id
id1
id2
id3
id8
id9
</code></pre>
<p>I want to add a new column <code>new</code> with conditional row values as follows:</p>
<p>If a row from <code>id</code> == <code>id1</code>, then the new row is <code>id1 is cat 1</code></p>
<p>If a row from <code>id</code> == <code>id2</cod... | <python><pandas><dataframe><dictionary> | 2023-01-17 18:35:07 | 2 | 737 | shsh |
75,150,658 | 3,247,006 | How to display an uploaded image in "Change" page in Django Admin? | <p>I'm trying to display an uploaded image in <strong>"Change" page</strong> in Django Admin but I cannot do it as shown below:</p>
<p><a href="https://i.sstatic.net/w44zr.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/w44zr.png" alt="enter image description here" /></a></p>
<p>This is my code... | <python><django><image><django-models><django-admin> | 2023-01-17 18:21:34 | 1 | 42,516 | Super Kai - Kazuya Ito |
75,150,647 | 607,407 | Cannot change enablement of isort extension because of its extension kind | <p>I have disabled multiple extensions because I had some trouble with clangd and wasn't sure what is causing it.</p>
<p>I now wanted to re-enable the Python and Pylance extensions, but I am getting this error:</p>
<pre><code>Cannot change enablement of isort extension because of its extension kind
</code></pre>
<p>I d... | <python><visual-studio-code><pylance> | 2023-01-17 18:20:13 | 0 | 53,877 | TomΓ‘Ε‘ Zato |
75,150,609 | 12,942,095 | Is there a standard way to implement optional keyword arguments in python classes? | <p>So I'm writing a class for the purpose of doing data analysis on a signal that I am measuring. There is many ways that I can process the signal and other optional metadata that can be associated with each trial that I measure the signal. I guess my questions boils down to the best way in which I can handle multiple ... | <python><python-3.x><oop><keyword-argument> | 2023-01-17 18:16:46 | 1 | 367 | rsenne |
75,150,535 | 7,668,467 | Polars Create Column with String Formatting | <p>I have a polars dataframe:</p>
<pre><code>df = pl.DataFrame({'schema_name': ['test_schema', 'test_schema_2'],
'table_name': ['test_table', 'test_table_2'],
'column_name': ['test_column, test_column_2','test_column']})
</code></pre>
<div class="s-table-container"><table ... | <python><python-polars> | 2023-01-17 18:09:52 | 1 | 2,434 | OverflowingTheGlass |
75,150,515 | 10,480,181 | How to create click Command using API? | <p>I am trying to create a python click Command using the API instead of decorators. This is because I am trying to create commands dynamically from a <code>yaml</code> file.</p>
<p><strong>parsed yaml file</strong>:</p>
<pre><code>{'adhoc': {'args': ['abcd',
{'analytic-type': {'type': 'click.Choice... | <python><python-click> | 2023-01-17 18:08:02 | 1 | 883 | Vandit Goel |
75,150,460 | 2,224,218 | What is the best way of Importing a module to work on both Python 2 and Python 3? | <p>I have two test launchers , one with python 2 env and another with python 3 env.</p>
<p>I use <code>from itertools import izip_longest</code> which worked fine in python2 env. But the same module is missing in python3 env. Reason is <code>izip_longest</code> was renamed to <code>zip_longest</code> in Python 3.</p>
<... | <python><python-3.x><python-2.7> | 2023-01-17 18:02:54 | 1 | 588 | Subhash |
75,150,439 | 3,156,300 | ImageMagick auto converting colored RGB image to grayscale? | <p>How can i prevent imagemagick from converting my RGB channel images into a solid grayscale image? For some unknown buggy reason it's converting the final PSD image to a grayscale when it should remain as RGB.</p>
<p>It all breaks when i change the gradient of my background solid to be <code>'gradient:#f2f2f2-#f2f2f2... | <python><imagemagick> | 2023-01-17 18:00:30 | 0 | 6,178 | JokerMartini |
75,150,428 | 392,041 | apache beam to mongo | <p>I am trying to export the result of a pipeline to mongodb, the problem i have is that my to_mongo function receives an array ["122","sam"]. How can i convert this to an object to convert easily to a document for mongo</p>
<pre><code>import apache_beam as beam
def to_mongo(item):
""... | <python><mongodb><apache-beam> | 2023-01-17 17:59:26 | 0 | 562 | Josh Fradley |
75,150,334 | 12,725,674 | FileNotFoundError when writing txt file | <p>I am using the following code to write list items to a .txt. I get a FileNotFoundError error at a specific file and cannot figure what causes the issue.</p>
<pre><code>if os.path.isdir(f'C:/Users/Info/Desktop/Dissertation/Impression Management/Analyse/10 CEO Transcripts/Interviews WORK/{deal_no}/Earnings Calls Texts... | <python> | 2023-01-17 17:51:24 | 0 | 367 | xxgaryxx |
75,150,287 | 13,174,189 | How to save indices, created with nmslib? | <p>I am using nmslib with hnsw method for vector similarity search. I have built index class for index creation:</p>
<pre><code>class NMSLIBIndex():
def __init__(self, vectors, labels):
self.dimention = vectors.shape[1]
self.vectors = vectors.astype('float32')
self.labels = labelsdef build(s... | <python><python-3.x><function><nmslib> | 2023-01-17 17:47:23 | 1 | 1,199 | french_fries |
75,150,281 | 8,461,786 | Why does __init__ of Exception require positional (not keyword) arguments in order to stringify exception correctly? | <p>Can someone clarify the role of <code>super().__init__(a, b, c)</code> in making the second assertion pass? It will fail without it (empty string is returned from <code>str</code>).</p>
<p>Per my understanding <code>Exception</code> is a built-in type that takes no keyword arguments.
But what exactly is happening in... | <python> | 2023-01-17 17:47:05 | 1 | 3,843 | barciewicz |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.