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,097,347
514,149
No preview images for dataset in ClearML web UI
<p>After creating a new dataset via CLI for a bunch of images, I closed that dataset and thus uploaded it to our own, newly installed ClearML server. Now in the web UI the new dataset has been created and can be opened, the images are being listed. However, none of the images within that dataset is shown in any of the ...
<python><clearml>
2023-01-12 13:51:21
1
10,479
Matthias
75,097,288
11,868,566
Trouble with attachments in outlook using SMTPlib from python
<p>I am writing an email system for my application. Just a simple email with an attachment (pdf file) that needs to be sent upon completing a step.</p> <p>On every client that I can test (Geary on linux, Outlook on mobile, Outlook on web, our own email system using roundcube) my attachments comes through perfectly and ...
<python><email><outlook><email-attachments><smtplib>
2023-01-12 13:47:08
1
456
Yorbjörn
75,097,271
3,337,597
Python unittest startTestRun to execute setup only once before all tests
<p>I have several test files in different directories.</p> <pre><code>\tests \subtestdir1 -__init__.py -test1.py \subtestdir2 -__init__.py -test2.py -__init__.py -test3.py </code></pre> <p>I need to do some setups only once before all tests in all test files.</p> <p>Accor...
<python><python-3.x><unit-testing><python-unittest>
2023-01-12 13:46:13
2
805
Reyhaneh Sharifzadeh
75,097,183
14,790,056
Why is Jupyter suddenly showing dataframe as text-based?
<p>I've used jupyter notebook for a while now and if I do <code>df.head()</code> it always returns a nicely formatted table format. now I called the data and I get this!?? why? and how do I fix it?</p> <pre><code>import pandas as pd df = pd.read_csv(&quot;df.csv&quot;) df.head() </code></pre> <pre><code> Unnamed: 0...
<python><dataframe><jupyter-notebook>
2023-01-12 13:39:59
0
654
Olive
75,097,042
10,357,604
Why is the module 'ultralytics' not found even after pip installing it in the Python conda environment?
<p>In a conda environment with Python 3.8.15 I did <code>pip install ultralytics</code></p> <blockquote> <p>successfully installed ...,ultralytics-8.0.4</p> </blockquote> <p>But when running <code>from ultralytics import YOLO</code> , it says</p> <blockquote> <p>ModuleNotFoundError: No module named 'ultralytics'</p> </...
<python><pip><conda><yolo><modulenotfounderror>
2023-01-12 13:30:11
8
1,355
thestruggleisreal
75,096,739
11,809,811
copy an PIL image to the macOS clipboard with Python
<p>I am trying to copy a image created in PIL to the macOS clipboard.</p> <p>I found 2 ways:</p> <ol> <li><p>Using Pasteboard (pypi.org/project/pasteboard) but that one does not seem to work with Python 3.10 (I get a wheels error when trying to install it).</p> </li> <li><p>The other way is from here (<a href="https://...
<python><macos><python-imaging-library>
2023-01-12 13:02:47
1
830
Another_coder
75,096,711
3,717,987
torch.einsum to matmul conversion
<p>I have the following line:</p> <pre><code>torch.einsum(&quot;bfts,bhfs-&gt;bhts&quot;, decay_kernel, decay_q) </code></pre> <p>I have a codebase where I need to convert these einsums to primitive methods like <code>reshape</code>, <code>matmul</code>, <code>multiplication</code>, <code>sum</code>, and so on. Is it e...
<python><torch>
2023-01-12 13:00:52
1
419
majstor
75,096,556
18,089,995
In Django how to convert a single page pdf from html template?
<p>I am using <code>puppeteer_pdf</code> package to convert an HTML template into a pdf, but when my content increases, it creates another page in the pdf. I want the whole pdf as a single page.</p> <p>My main goal is the make a jpg image from that pdf and send the image to the client. If there is another way to make a...
<python><django><pdf>
2023-01-12 12:47:54
1
595
Manoj Kamble
75,096,530
14,790,056
How to disply output as a table in jupyter notebook
<p>Usually, when i do <code>df.head()</code> on jupyter notebote, it gives me a nice table format, but suddenly it is giving me the following.</p> <p>I am sure what changed? can you help with displaying output as a table on jupyter notebook?</p> <p><a href="https://i.sstatic.net/wHhOZ.png" rel="nofollow noreferrer"><im...
<python><dataframe><jupyter-notebook>
2023-01-12 12:46:01
0
654
Olive
75,096,511
3,368,667
Getting rid of special characters and unicode in byte object converted to string in Python
<p>I'm having difficulty getting ride of special characters and unicode in Pandas dataframe.</p> <p>Here is an example of one of the byte objects:</p> <pre><code>b&quot;Asana Check out your two-week recap. \n \xe2\x80\x8c \xe2\x80\x8c \xe2\x80\x8c \xe2\x80\x8c \xe2\x80\x8c \xe2\x80\x8c \xe2\x80\x8c \xe2\x80\x8c \xe2\x8...
<python><pandas><regex>
2023-01-12 12:44:16
1
1,077
tom
75,096,400
10,570,372
What is the point of using `MISSING` in hydra or pydantic?
<p>I am creating a configuration management system in python and are exploring options between hydra/pydantic/both. I get a little confused over when to use <code>MISSING</code> versus just leaving it blank/optional. I will use an example of <a href="https://omegaconf.readthedocs.io/en/2.1_branch/structured_config.html...
<python><config><pydantic><fb-hydra><omegaconf>
2023-01-12 12:34:00
1
1,043
ilovewt
75,096,386
8,081,835
Keras TimeDistributed input_shape mismatch
<p>I'm trying to build a model with the TimeDistributed Dense layer, but I still get this error.</p> <pre><code>ValueError: `TimeDistributed` Layer should be passed an `input_shape` with at least 3 dimensions, received: (None, 16) </code></pre> <p>Am I missing something? The data has a format like the one provided in t...
<python><tensorflow><keras>
2023-01-12 12:32:48
1
771
Mateusz Dorobek
75,096,369
14,594,208
How to count the occurrences of a column's value in a column of lists?
<p>Consider the following dataframe:</p> <pre><code> column_of_lists scalar_col 0 [100, 200, 300] 100 1 [100, 200, 200] 200 2 [300, 500] 300 3 [100, 100] 200 </code></pre> <p>The desired output would be a Series, representing how many times the scalar value of <code>scalar...
<python><pandas><series>
2023-01-12 12:30:37
3
1,066
theodosis
75,096,366
6,694,814
Python folium Clickformarker - 2 functions don't collaborate with each other
<p>I would like to use the folium.CLickFormarker macro more than once in my map. Unfortunately it doesn't work, as my function takes only the first one.</p> <pre><code>fs=folium.FeatureGroup(name=&quot;Surveyors&quot;) df = pd.read_csv(&quot;survey.csv&quot;) class Circle(folium.ClickForMarker): _template = Template(...
<python><folium>
2023-01-12 12:30:11
1
1,556
Geographos
75,096,336
1,436,800
How to fix Assertion error 400 in the following problem?
<p>I am working on Django project. I am writing a test case for the following model:</p> <pre><code>class Meeting(models.Model): team = models.OneToOneField(&quot;Team&quot;, on_delete=models.CASCADE) created_at = models.DateTimeField() def __str__(self) -&gt; str: return self.team.name </code></pr...
<python><django><django-rest-framework><django-testing><django-tests>
2023-01-12 12:28:03
1
315
Waleed Farrukh
75,096,188
6,368,217
TypeError when creating a marshmallow schema from dataclass inherited from generic class
<p>I'm trying to create a marshmallow schema from dataclass which is inherited from generic type:</p> <p><code>users_schema = marshmallow_dataclass.class_schema(Users)()</code></p> <p>This is my code:</p> <pre><code>from dataclasses import dataclass from typing import Generic, List, TypeVar T = TypeVar(&quot;T&quot;)...
<python><generics><python-typing><python-dataclasses><marshmallow-dataclass>
2023-01-12 12:15:55
0
991
Alexander Shpindler
75,096,055
6,386,155
Comparison circle plot in Python/Pandas
<p>Is there a way to create a comparison circle plot in python on Pandas dataframe, something similar to this <a href="https://docs.tibco.com/pub/spotfire/7.0.1/doc/html/box/box_what_are_comparison_circles.htm" rel="nofollow noreferrer">https://docs.tibco.com/pub/spotfire/7.0.1/doc/html/box/box_what_are_comparison_circ...
<python><pandas><dataframe><plot><comparison>
2023-01-12 12:02:55
0
885
user6386155
75,096,031
15,376,262
Convert scraped HTML table to pandas dataframe
<p>I would like to scrape a webpage containing data regarding all trains that have arrived and departed from Amsterdam Central station on a specific date, and convert it into a pandas dataframe.</p> <p>I know I can scrape the webpage and convert it into a pandas dataframe like so (see below), but this doesn't give me t...
<python><html><pandas><python-requests>
2023-01-12 12:00:46
1
479
sampeterson
75,096,011
2,732,991
Python logging file config with variable directory
<p>I'm using Python logging and loading it with <code>logging.config.fileConfig(config_file)</code>, from e.g. <code>logging.cfg</code>. It contains a <code>TimedRotatingFileHandler</code>. It works great. For a long time it has been using (simplied):</p> <pre><code>[handler_file] class=handlers.TimedRotatingFileHandle...
<python><logging><configparser>
2023-01-12 11:59:26
1
20,596
Halvor Holsten Strand
75,095,999
7,497,912
How to connect to a Lotus-Notes database with Python?
<p>I have to extract data from a Notes database automatically for a data pipeline validation. With HCL Notes I was able to connect to the database, so I know the access works. I have the following information to access the database: host (I got both hostname and ip address), domino server name, database name (.nsf file...
<python><lotus-notes><hcl-notes>
2023-01-12 11:58:24
2
417
Looz
75,095,986
4,832,010
Building a DataFrame recursively in Python with pd.concat
<pre><code>def recursive_df (n): if n==1: return pd.DataFrame({&quot;A&quot;:[1],&quot;B&quot;:[1]}) if n&gt;=2: return pd.concat(recursive_df(n-1),{&quot;A&quot;:[n],&quot;B&quot;:[n*n]} ) </code></pre> <p>this is not working, and i can't see a reason &quot;why&quot; and what i should do about ...
<python><pandas><recursion>
2023-01-12 11:57:00
1
1,937
Fagui Curtain
75,095,937
9,182,743
Convert String "YYYY-MM-DD hh:mm:ss Etc/GMT" to timestamp in UTC pandas
<p>I have a pandas column of datetime-like string values like this exampe:</p> <pre class="lang-py prettyprint-override"><code>exammple_value = &quot;2022-06-24 16:57:33 Etc/GMT&quot; </code></pre> <p>Expected output</p> <pre><code>Timestamp('2022-06-24 16:57:33+0000', tz='UTC') </code></pre> <p>Etc/GMT is the timezone...
<python><pandas><datetime><timestamp><utc>
2023-01-12 11:52:56
1
1,168
Leo
75,095,842
16,844,801
How to scrape multiple pages for the same item using scrapy
<p>I want to scrape multiple pages for the same item. But every time I yield, it returns an increment of the list of items instead of all the sub-items in the same item's list.</p> <pre><code>class GdSpider(scrapy.Spider): name = 'pcs' start_urls = [...] def parse(self, response): PC= dict() ...
<python><scrapy>
2023-01-12 11:44:35
1
434
Baraa Zaid
75,095,711
15,255,487
Error code 304 in flask python with GET method
<p>I'm new to python and I faced an error which I totally don't understand why occures. In the Insomnia client REST API I'm creating item with POST method, and it works well, below it the code</p> <pre><code>@app.post('/item') def create_item(): item_data = request.get_json() if ( &quot;price&quot; not ...
<python><flask>
2023-01-12 11:32:59
1
912
marcinb1986
75,095,700
9,778,828
Keras doesn't find GPU, how to change that?
<p>I am trying to build a simple NN with keras. I have 2 GPUs on my machine:</p> <p><a href="https://i.sstatic.net/ISGkS.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ISGkS.png" alt="enter image description here" /></a></p> <p>But Keras doesn't seem to recognize any of them:</p> <pre><code>print(&quot;...
<python><tensorflow><machine-learning><keras><gpu>
2023-01-12 11:32:03
0
505
AlonBA
75,095,651
10,811,647
How to unpack values from a list stored inside another list
<p>I have a list containing some elements, a lit and some other elements like so <code>[a, b, [c, d, e], f, g]</code> and I would like to get <code>[a, b, c, d, e, f, g]</code>. I tried using itertools which I'm not familiar with, but I was unsucessfull:</p> <pre><code>from itertools import chain a = 1 b = 2 c = [3, 4...
<python><list><unpack>
2023-01-12 11:28:30
2
397
The Governor
75,095,632
7,720,738
Is the __eq__ method defined as part of a Protocol?
<p>Consider the following ADT:</p> <pre><code>T = TypeVar(&quot;T&quot;) @dataclass(frozen=True) class Branch(Generic[T]): value: T left: Tree[T] right: Tree[T] Tree = Branch[T] | None </code></pre> <p>Note the requirement for <code>from __future__ import annotations</code> since <code>Tree</code> is use...
<python><protocols>
2023-01-12 11:27:08
1
804
James Burton
75,095,594
2,927,489
Modeling a One to One Relation with Optional Tables in SQLAlchemy
<p><strong>Context:</strong> I have a table with a lot of columns. I would like to break this data up because it will be used by people from a frontend like Metabase. The data is for people who will be doing simple queries that the frontend guides them through, so it won't be queried with raw SQL and I'm not worried ab...
<python><sqlalchemy>
2023-01-12 11:24:16
1
324
TYPKRFT
75,095,439
11,743,318
Why doesn't figwidth parameter work with pyplot.subplots() call?
<p>I'm trying to create a subplot figure in matplotlib, specifying only the width (using <code>figwidth(float)</code> rather than <code>figsize(float, float)</code>), assuming that the height will have some default value. When calling <code>pyplot.subplots()</code>, the <code>**fig_kw</code> parameter is <a href="https...
<python><matplotlib><figure>
2023-01-12 11:11:41
2
1,377
compuphys
75,095,429
3,414,559
Selenium: Python Webdriver to get elements from popup iframe does not find the elements
<p>In the case of the URL</p> <p><a href="https://console.us-ashburn-1.oraclecloud.com/" rel="nofollow noreferrer">https://console.us-ashburn-1.oraclecloud.com/</a></p> <p>where it pops up to accept cookies, I try to click the button element to allow/deny cookies</p> <pre><code>//div[@class=&quot;pdynamicbutton&quot;]/...
<python><selenium><selenium-chromedriver><webdriver>
2023-01-12 11:11:00
2
847
Ray
75,095,401
7,720,535
Vectorizing the aggregation operation on different columns of a Pandas dataframe
<p>I have a Pandas dataframe, mostly containing boolean columns. A small example is:</p> <pre><code>import pandas as pd df = pd.DataFrame({&quot;A&quot;: [1, 2, 3, 1, 2, 3], &quot;B&quot;: ['a', 'b', 'c', 'a', 'b', 'c'], &quot;f1&quot;: [True, True, True, True, True, False], ...
<python><pandas><group-by>
2023-01-12 11:08:28
1
485
Esi
75,095,378
3,021,252
Adding a market to a line chart Plotly python
<p>I'm trying to add a point to the last observation on a time series chart with plotly. It is not very different from the example here <a href="https://stackoverflow.com/a/72539011/3021252">https://stackoverflow.com/a/72539011/3021252</a> for instance. Except it is the last observation. Unfortunately following such pa...
<python><plotly>
2023-01-12 11:07:17
0
1,099
kismsu
75,095,331
4,432,671
NumPy: grid to full coordinate set
<p>How do I go from a shape (either <code>np.mgrid</code> or <code>np.indices</code>) to actual coordinate vectors if I don't know the number of axes up front? If you know APL, this is its <a href="https://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Index%20Generator.htm" rel="nofollow noreferrer">i...
<python><numpy>
2023-01-12 11:03:52
1
3,737
xpqz
75,095,250
10,924,836
Map with sub regions in Python (Choropleth)
<p>I am trying to plot a Choropleth map with subregions in Python for Armenia. Below you can see my data.</p> <pre><code>import numpy as np import pandas as pd import geopandas as gpd import matplotlib.pyplot as plt data_arm = { 'subregion': ['Aragatsotn','Ararat','Armavir','Gegharkunik','Kotayk','Lori','Shir...
<python><geopandas><choropleth>
2023-01-12 10:57:48
1
2,538
silent_hunter
75,095,249
12,083,557
How do I correctly code an abstract class and its subclasses to have getter/setter behavior?
<p>In Python (3.11) I have this abstract class:</p> <pre><code>from abc import ABCMeta, abstractmethod from copy import deepcopy class BookPrototype(metaclass=ABCMeta): @property def title(self): pass @title.setter @abstractmethod def title(self, val): pass @abstractmethod ...
<python><abstract-class>
2023-01-12 10:57:48
1
337
Life after Guest
75,095,240
6,409,572
Why does my pip access two site-packages?
<p>I have a bit of confusion with <code>pip</code> and multiple <code>python</code> installations. When running <code>python -m pip install pb_tool</code> I get console output:</p> <pre><code>Requirement already satisfied: pb_tool in c:\osgeo4w\apps\python39\lib\site-packages (3.1.0) Requirement already satisfied: colo...
<python><windows><pip><path><pythonpath>
2023-01-12 10:57:25
1
3,178
Honeybear
75,095,222
5,057,022
Stfrtime with 'D' inside String
<p>How can you deal with a random string inside a datetime string when parsing using pandas?</p> <p>I have some timestamps of the form</p> <p><a href="https://i.sstatic.net/ItPBT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ItPBT.png" alt="enter image description here" /></a></p> <p>Which I try to mat...
<python><pandas><string>
2023-01-12 10:56:29
2
383
jolene
75,095,132
20,589,275
How to make the list into table Django?
<p>I have got an a list:</p> <pre><code>[{'name': 'WEB-Разработчик/программист (SEO-правки)', 'description': 'Hastra Agency ищет разработчика с опытом работы с связи с ростом отдела SEO-продвижения. Требуемый о...', 'key_skills': ['HTML', 'CSS', 'MySQL', 'PHP', 'SEO'], 'employer': 'Hastra Agency', 'salary': 'None - 600...
<python><django><pandas>
2023-01-12 10:49:07
0
650
Proger228
75,095,037
1,128,648
How to select some key values from a dictionary and assign to another dictionary in python
<p>I have a variable which stores below dictionary</p> <pre><code>initial_ltp = {'s': 'ok', 'd': [{'n': 'MCX:CRUDEOIL23JANFUT', 's': 'ok', 'v': {'ch': 47.0, 'chp': 0.74, 'lp': 6377.0, 'spread': 2.0, 'ask': 6379.0, 'bid': 6377.0, 'open_price': 6330.0, 'high_price': 6393.0, 'low_pri...
<python><python-3.x>
2023-01-12 10:41:39
4
1,746
acr
75,094,994
11,274,362
Put Header, Footer and page number for pdf with pdfpages matplotlib
<p>I created <code>PDF</code> file of figures with <code>pdfpages</code> in <code>matplotlib</code>.</p> <p>Now I want to add headers (contains text and line), footer (contains text and line) and page number. <strong>How can I do that?</strong></p>
<python><matplotlib><pdfpages>
2023-01-12 10:38:00
1
977
rahnama7m
75,094,971
5,224,236
Docker: cannot import name 'BlobServiceClient' from 'azure.storage.blob
<p>I have this code running fine on my personal computer</p> <pre><code>from azure.storage.blob import BlobServiceClient blob_client = BlobClient.from_blob_url(file_sas) </code></pre> <p>This is my local envir:</p> <pre><code>python --version Python 3.10.4 $ pip show azure.storage.blob Name: azure-storage-blob Version...
<python><azure><docker>
2023-01-12 10:36:30
1
6,028
gaut
75,094,831
14,269,252
Merge of two data frames with some similar features in python
<p>I am new to Python. I want to merge two DataFrames, I used merge and it get too large with duplicates. I created a sample code for what I did. is there any better performance? I really appreciate your idea.</p> <pre><code>import pandas as pd data = [['t', 10, 5], ['n', 15, 5], ['j', 14, 66],['t', 10, 8], ['n', 15, 5...
<python><pandas><dataframe>
2023-01-12 10:27:03
1
450
user14269252
75,094,780
17,220,672
mypy does not infer generic type T with Optional[Any]
<p>I have a problem with mypy and generic T parameter. I am using sqlalchemy sessions <strong>get()</strong> method to retrieve something from the database (the code works). I am injecting (self.model=model) one of my SqlalchemyORM models that I have defined somewhere else.</p> <p>Mypy is giving me this message:</p> <p...
<python><sqlalchemy><mypy>
2023-01-12 10:23:02
1
419
mehekek
75,094,645
2,743,307
pythonic way to fill an array with geometric cumulative function
<p>I need to fill an array with the position of the boundary of <code>n_cells</code> (starting from 0 up to <code>n_cells+1</code>) with the size of the cell in geometric progression (with parameter <code>c</code>) and the total size will be thick (thus <code>x[0]=0</code> and <code>x[n_cells]=thick</code>)</p> <p>I ha...
<python><numpy><numpy-ndarray>
2023-01-12 10:10:52
2
3,783
bibi
75,094,568
1,436,800
How to make Nested Models in django
<p>I am new to django. My task is to make a feature on shared documents in backend. Documents can have folders, like google docs.We will have list of documents within list of folders.</p> <p>I created following model classes:</p> <pre><code>class Folder(models.Model): name = models.CharField(max_length=128, unique=...
<python><django><django-models><django-rest-framework><django-serializer>
2023-01-12 10:05:37
1
315
Waleed Farrukh
75,094,229
14,649,447
Is there a way to rotate a dash-leaflet dl.Rectangle() through a callback?
<p>I'm building an python dash-leaflet app where the user can click on a map to place a rectangle through a callback, and I would like to add a second callback (bond to a slider) to rotate it around its center according to North (eg. rotate it by 20° to the East).</p> <p>To place the rectangle in a callback I use:</p> ...
<python><rotation><plotly-dash><dash-leaflet>
2023-01-12 09:38:05
1
376
Mat.B
75,093,820
20,589,275
How to parse data into .csv?
<p>I have got an a list:</p> <pre><code>[{'name': 'WEB-Разработчик/программист (SEO-правки)', 'description': 'Hastra Agency ищет разработчика с опытом работы с связи с ростом отдела SEO-продвижения. Требуемый о...', 'key_skills': ['HTML', 'CSS', 'MySQL', 'PHP', 'SEO'], 'employer': 'Hastra Agency', 'salary': 'None - 600...
<python><pandas>
2023-01-12 09:05:24
1
650
Proger228
75,093,819
10,319,707
Common Lisp equivalent of Python's itertools.starmap?
<p>Python's Itertools has what is called <code>starmap</code>. Given a collection of collections and a function, it applies the function to each collection strictly inside the collection, using the elements of said internal collection as arguments to the function. For example,</p> <pre><code>from itertools import starm...
<python><common-lisp><python-itertools><starmap>
2023-01-12 09:05:22
3
1,746
J. Mini
75,093,724
6,409,572
How can I find out the path of the Python that the py Launcher uses?
<p>I have multiple Python installations and when working on different projects, these can cause some confusion. I just recently found out, that under Windows there also is a py Launcher installed and updated alongside each installation of Python. That is useful tool, but I think this py launcher is messing up some thin...
<python><windows><cmd>
2023-01-12 08:57:15
1
3,178
Honeybear
75,093,715
455,998
How to alter the response output of a list based on a query parameter in FastAPI?
<p>I'm trying to alter the content of a list view on FastAPI, depending on a query parameter. As the format is defined by a pydantic model, how can I customize it (or use an alternative model from within the view)?</p> <p>Here's my view:</p> <pre class="lang-py prettyprint-override"><code>from fastapi_pagination import...
<python><fastapi><crud><pydantic>
2023-01-12 08:56:13
1
347
koleror
75,093,702
17,839,669
How to apply annotation to each item of QuerySet with Django ORM
<p>There are a lot questions similar to this one but none of them worked for me.</p> <p>Let's assume that I have the following models:</p> <pre><code>class Cafe(models.Model): name = models.CharField(max_length=150) def __str__(self): return self.name class Food(models.Model): class SoldStatus(mo...
<python><django><django-models><django-orm><django-postgresql>
2023-01-12 08:55:30
2
359
Jasur
75,093,685
19,336,534
Connect to IRC server with python
<p>i am trying to connect to anonops irc server and subsequently #anonops channel using python. What i have done so far :</p> <pre><code>import sys import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) HOST = 'irc.anonops.com' #irc server PORT = 6697 #port NICK = 'testingbot' print('soc created |', s)...
<python><python-3.x><sockets><irc>
2023-01-12 08:54:18
2
551
Los
75,093,675
219,976
Django Rest Framework adding import in settings.py causes 403 error
<p>I have a Django Rest Framework application with custom render and parse classes, set in settings.py:</p> <pre><code>REST_FRAMEWORK = { &quot;DEFAULT_RENDERER_CLASSES&quot;: ( &quot;djangorestframework_camel_case.render.CamelCaseJSONRenderer&quot;, &quot;djangorestframework_camel_case.render.Camel...
<python><django><django-rest-framework>
2023-01-12 08:53:26
0
6,657
StuffHappens
75,093,503
12,575,557
Are Python 3.11 objects as light as slots?
<p>After <a href="https://github.com/python/cpython/issues/89503" rel="nofollow noreferrer">Mark Shannon's optimisation of Python objects</a>, is a plain object different from an object with slots? I understand that after this optimisation in a normal use case, objects <a href="https://github.com/faster-cpython/ideas/i...
<python><python-internals><slots><python-3.11>
2023-01-12 08:38:30
1
950
Jorge Luis
75,093,455
859,227
Reset index of grouped data frames
<p>I would like to reset the index of grouped data frames and based on the examples, I have written:</p> <pre><code>for name, df_group in df.groupby('BL', as_index=False): print(df_group) </code></pre> <p>But the output shows that index has not been reset.</p> <pre><code> Num BL Home Requester ...
<python><pandas>
2023-01-12 08:33:48
3
25,175
mahmood
75,093,113
9,861,647
Pandas replace in Data frame values which are contains in specific range
<p>I have this Pandas Data Frame</p> <pre><code>Months 2022-10 2022-11 2022-12 2023-01 … 2023-01 10 N/A 12 13 … 2022-12 2 14 14 N/A … 2022-11 N/A 11 N/A N/A … 2022-10 12 N/A N/A N/A … … … … … … </code></pre> <...
<python><pandas>
2023-01-12 07:56:47
2
1,065
Simon GIS
75,093,076
10,062,025
Why requests is getting same data and returning errors from different urls in python?
<p>I have a list of data to scrape here <a href="https://docs.google.com/spreadsheets/d/1KMYsjN2ggklFMQ5HPKMbdkVqc04MdjhYGLvku1Js0cc/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1KMYsjN2ggklFMQ5HPKMbdkVqc04MdjhYGLvku1Js0cc/edit?usp=sharing</a> So the scraper runs but there are two ...
<python><python-requests>
2023-01-12 07:52:48
1
333
Hal
75,092,778
13,359,498
How to solve `NameError: name 'compression' is not defined`?
<p>I am trying to implement DenseNet model and I am using image dataset with 4 classes.</p> <p>Code snippets:</p> <p>For building model:</p> <pre><code>def denseblock(input, num_filter = 12, dropout_rate = 0.2): global compression temp = input for _ in range(l): BatchNorm = BatchNormalization()(temp) relu = Ac...
<python><tensorflow><keras><conv-neural-network><densenet>
2023-01-12 07:19:52
1
578
Rezuana Haque
75,092,525
19,950,360
how to create table number columns use python to bigquery load_table_from_dataframe
<p>i want to bigquery table from python.bigquery dataframe have number columns like '333115' when i user load_table_from_dataframe(df, table_path)</p> <p>error occur</p> <pre><code>400 POST https://bigquery.googleapis.com/upload/bigquery/v2/projects/paprika-cada/jobs?uploadType=multipart: Invalid field name &quot;`3117...
<python><dataframe><google-cloud-platform><google-bigquery>
2023-01-12 06:47:35
1
315
lima
75,092,339
11,634,498
Generating ImportError: `load_model` requires h5py in jupyter notebook
<p>I am running the following github code for Age and Gender Detection on jupyter notebook (anaconda navigator) <a href="https://github.com/kaushikjadhav01/Deep-Surveillance-Monitor-Facial-Emotion-Age-Gender-Recognition-System" rel="nofollow noreferrer">https://github.com/kaushikjadhav01/Deep-Surveillance-Monitor-Facia...
<python><jupyter-notebook><tf.keras>
2023-01-12 06:24:26
1
644
Krupali Mistry
75,092,144
1,323,992
How to print SQLAlchemy update query?
<p>According to <a href="https://docs.sqlalchemy.org/en/14/faq/sqlexpressions.html#how-do-i-render-sql-expressions-as-strings-possibly-with-bound-parameters-inlined" rel="nofollow noreferrer">docs</a> printing queries is as simple as print(query).</p> <p>But according to <code>update</code> function description, it ret...
<python><debugging><sqlalchemy>
2023-01-12 05:56:45
0
846
yevt
75,092,119
7,679,045
Can't capture using set-literal, set(), or empty dict-literal (PEP-634, PEP-636)
<p>I work at a Python shop, and I've got the green-light to start using 3.10 (we're so cutting-edge). SMP was a little disappointing at first, as I was anticipating Rust-style matching, but it's still pretty dang awesome.</p> <p>...It has some quirks... I can match empty lists as expected, but I can't match empty dict ...
<python><pattern-matching><python-3.10><structural-pattern-matching>
2023-01-12 05:52:59
0
795
Sam Hughes
75,092,052
11,264,031
enable_auto_commit=False, but still offsets are committed automatically
<p>I'm using <code>kafka-python==2.0.2</code>, and have disabled <code>auto_commit</code> but still if I don't commit through code, offsets are automatically getting committed</p> <p>In the below code even if I comment out <code>self.consumer.commit_async(callback= ....</code>, offsets are still getting committed</p> <...
<python><apache-kafka><kafka-consumer-api><kafka-python>
2023-01-12 05:41:13
1
426
Swastik
75,091,827
10,062,025
Scrape website using httpx and requests returns a timeout
<p>I am trying to scrape this website <a href="https://www.blibli.com/p/facial-tissue-tisu-wajah-250-s-paseo/is--LO1-70001-00049-00003?seller_id=LO1-70001&amp;sku_id=LO1-70001-00049-00001&amp;sclid=7zuGEaS4hh5SowAA6tnfd5i2wKjR6e3p&amp;sid=c5746ccfbb298d3b&amp;pid=LO1-70001-00049-00001&amp;pickupPointCode=PP-3227395" re...
<python><python-requests-html><httpx>
2023-01-12 05:05:16
1
333
Hal
75,091,649
13,497,264
Can't install python extension on visual studio: XHR failed,XHR failed,
<p>this is the error code where the plugin can't be installed</p> <pre><code>2023-01-12 11:26:54.575 [error] XHR failed,XHR failed,XHR failed: Error: XHR failed,XHR failed,XHR failed at vscode-file://vscode-app/c:/Users/names/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/sh...
<python><visual-studio><proxy><dns>
2023-01-12 04:33:27
1
357
1988
75,091,633
15,974,438
Get resource icon from exe generated from pyinstaller
<p>I'm generating an .exe using pyinstaller, but I'm not able to include an file without resources.</p> <p>command line:</p> <p><code>pyinstaller --onefile --icon=./resources/image/icon.ico --add-data=&quot;./resources/data.txt;data&quot; ./src/MainGui.py</code></p> <p>When I try to open the file <code>./data/data.txt<...
<python><resources><pyinstaller>
2023-01-12 04:30:34
0
420
Arcaniaco
75,091,547
4,152,567
Keras model training on GPU stops/hangs at first epoch
<p>In the <a href="https://github.com/matterport/Mask_RCNN" rel="nofollow noreferrer">Mask RCNN</a> model I replaced the Lambda layer below by a custom layer. While the model compiles it does not train on GPU. It seems to stop at Epoch 1 right before allocating Workers. I am not certain what I am doing wrong. The lambd...
<python><tensorflow><keras>
2023-01-12 04:19:47
1
512
Mihai.Mehe
75,091,443
7,077,532
Python: How to Slice & Index Chunks of a List into a New List
<p>Let's say I have the following list:</p> <pre><code>nums = [10,2,3,4, 8, 3] </code></pre> <p>I want to slice and index nums so that I create a new list from only some elements of the original list. For example #1:</p> <pre><code>nums_1 = [10, 3, 4, 8, 3] </code></pre> <p>Or Example 2:</p> <pre><code>nums_2 = [10, 3...
<python><arrays><list><indexing><slice>
2023-01-12 04:01:01
0
5,244
PineNuts0
75,091,418
9,983,652
Filter a dataframe with datetime index using another dataframe with date index
<p>I have two dataframes, one dataframe has index with date and time, the other dataframe's index only has date. Now I'd like to filter rows of first dataframe if its date is within 2nd dataframe's index.</p> <p>I can do it but very complicated to use two for loop to check each item. Is there a simple way?</p> <p>Here...
<python><pandas><dataframe><indexing><datetimeindex>
2023-01-12 03:57:38
1
4,338
roudan
75,091,364
1,128,648
Google spreadsheet api batchupdate using python
<p>I am trying to update multiple cell values using batchupdate. But giving me below error</p> <p><strong>My code:</strong></p> <pre><code>import gspread gc = gspread.service_account(filename='gdrive_cred.json') sh = gc.open('SmartStraddle').sheet1 stock_name = &quot;NIFTY50&quot; stock_price = 15000 batch_update_va...
<python><python-3.x><google-sheets><google-sheets-api><gspread>
2023-01-12 03:47:25
1
1,746
acr
75,091,265
344,669
Python setuptools_scm get version from git tags
<p>I am using project.toml file to package my module, I want to extract the version from git tag using <code>setuptools_scm</code> module.</p> <p>When I run <code>python setup.p y --version</code> command it gives this output <code>0.0.1.post1.dev0</code>. How will I get only <code>0.0.1</code> value and omit the <code...
<python><setuptools><setup.py><python-packaging><setuptools-scm>
2023-01-12 03:28:44
1
19,251
sfgroups
75,091,163
14,673,832
How to solve lambda() takes 1 positional argument but 2 were given
<p>I have the following code snippet but it is giving me the type error above. What I basically wanted to do is add two to every element and reduct it to a single sum, but it didnt work. How can we achieve this??</p> <pre><code>import functools list1 = [1,2,3,4] result = functools.reduce(lambda x:x+2, list1) print(resu...
<python><lambda><typeerror>
2023-01-12 03:06:14
2
1,074
Reactoo
75,091,078
3,495,236
how to write a python worker that stays in memory processing jobs until the master thread kills it
<p>I have a worker node that reads data off of a queue to process images. The job loads from a redis queue and then a new thread is spun up to process the job. The jobs must process sequentially, I can't use parallization. I need to use threads because for some reason memory is not fully released with the GPU, so this...
<python><python-3.x><multithreading>
2023-01-12 02:50:11
1
590
jas
75,091,028
134,044
How and why to supply scalar scope to FastAPI oAuth2 scopes dict?
<p>I am using FastAPI with Python 3.9. I haven't been able to get the available oAuth2 dependencies to work with our particular Azure token authentication, and my initial attempt at using <code>fastapi-azure-auth</code> didn't seem to match either.</p> <p>I am therefore currently sub-classing <code>fastapi.security.bas...
<python><oauth-2.0><fastapi><openapi>
2023-01-12 02:40:01
1
4,109
NeilG
75,090,901
4,996,021
Find value of column based on another column condition (max) in polars for many columns
<p>If I have this dataframe:</p> <pre><code>pl.DataFrame(dict(x=[0, 1, 2, 3], y=[5, 2, 3, 3],z=[4,7,8,2])) shape: (4, 3) ┌─────┬─────┬─────┐ │ x ┆ y ┆ z │ │ --- ┆ --- ┆ --- │ │ i64 ┆ i64 ┆ i64 │ ╞═════╪═════╪═════╡ │ 0 ┆ 5 ┆ 4 │ │ 1 ┆ 2 ┆ 7 │ │ 2 ┆ 3 ┆ 8 │ │ 3 ┆ 3 ┆ 2 │ └─────┴─────┴─────┘...
<python><python-polars>
2023-01-12 02:16:42
1
610
pwb2103
75,090,896
5,901,318
django changeform_view extra_context
<p>I'm trying to learn on model admin template customization.</p> <p>I need that custom template can read some data stored/passed in 'extra_context'</p> <p>admin.py</p> <pre class="lang-py prettyprint-override"><code>from django.contrib import admin from .models import MailTemplate # Register your models here. class M...
<python><django>
2023-01-12 02:15:28
1
615
Bino Oetomo
75,090,788
1,336,134
Last 4 digits are getting converted to 0 while writing to excel using Panda and ExcelWriter
<p>I am using xlsxwriter with Panda to write an excel. Doing so 19-character long value is getting changed from <strong>9223781998151429879</strong> to <strong>9223781998151420000</strong>. Excel <a href="https://learn.microsoft.com/en-us/office/troubleshoot/excel/long-numbers-incorrectly-in-excel" rel="nofollow norefe...
<python><excel><pandas><dataframe><xlsxwriter>
2023-01-12 01:53:49
1
1,165
sandy
75,090,782
2,463,570
Subprocess Popen to call a tasks file python which cannot able to load models in Django
<p>I have Django app ..we have several tasks file(stored into tasks folder). And we want to call those tasks file from views.py</p> <p>Now when we call</p> <pre><code>p = Popen(&quot;python&quot;,&quot;./tasks/task1.py&quot;, &quot;jobid&quot;, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True) output_filename, err = p....
<python><django>
2023-01-12 01:51:17
0
12,390
Rajarshi Das
75,090,778
1,653,413
Making a logging.Handler with async emit
<p>I have a Python log handler that writes using asyncio (it's too much work to write to this particular service any other way). I also want to be able to log messages from background threads, since a few bits of code do that. So my code looks basically like this (minimal version):</p> <pre><code>class AsyncEmitLogHand...
<python><logging><python-asyncio>
2023-01-12 01:50:42
2
449
Russell Owen
75,090,691
9,989,761
How to suppress PyTorch Lightning Logging Output in DARTs
<p>I am using the python <a href="https://unit8co.github.io/darts/" rel="nofollow noreferrer">DARTs</a> package, and would like to run the prediction method without generating output logs. I appear unable to do so; all of the suggestions I've seen do not work, even when I attempt to apply them to DARTs source code.</p>...
<python><pytorch-lightning><u8darts><pytorch-forecasting>
2023-01-12 01:32:45
1
364
Josh Purtell
75,090,690
11,182,916
Best way to find a point near all four points known coordinates
<p>I have the coordinates of four points. Can anyone help me find the coordinates of one point that satisfies the condition: the distances from the finding point to four input points are in the range of 1.9 and 2.5?</p> <pre><code>import numpy as np dist_min = 1.9 dist_max = 2.5 # this show no points satisfied input_p...
<python>
2023-01-12 01:32:36
2
405
Binh Thien
75,090,629
12,980,888
How pandas process boolean statements inside a pandas frame object
<p>Wondering how Pandas process the following statement internally please.</p> <pre><code>import pandas as pd test = pd.DataFrame({'classNumber': [2, 4], 'center x': [2, 0], 'center y': [4, 4]}) </code></pre> <p>The output of <code>test</code>:</p> <p><a href="https://i.sstatic.net/SbTMB.png" rel="nofollow noreferrer">...
<python><pandas>
2023-01-12 01:20:35
1
519
Avv
75,090,614
1,870,832
Python dataprep package seems to break pip-compile due to conflicting dependencies
<p>I used the dataprep package in a jupyter notebook, installing via <code>!pip install dataprep</code> recently and it installed smoothly.</p> <p>Now I'm tidying up some of that work and am using a venv, but <code>pip-compile</code> keeps crashing and I seem to have isolated dataprep as the cause. A minimal reproducib...
<python><pip><dataprep>
2023-01-12 01:17:21
0
9,136
Max Power
75,090,518
1,330,974
Mocking os.path.exists and os.makedirs returning AssertionError
<p>I have a function like below.</p> <pre><code># in retrieve_data.py import os def create_output_csv_file_path_and_name(output_folder='outputs') -&gt; str: &quot;&quot;&quot; Creates an output folder in the project root if it doesn't already exist. Then returns the path and name of the output CSV file, w...
<python><python-3.x><python-unittest><python-mock>
2023-01-12 00:58:37
1
2,626
user1330974
75,090,510
6,810,602
Understand shap values for binary classification
<p>I have trained my imbalanced dataset (binary classification) using CatboostClassifer. Now, I am trying to interpret the model using the SHAP library. Below is the code to fit the model and calculate shap values:</p> <pre><code>weights = y.value_counts()[0] / y.value_counts()[1] catboost_clf = CatBoostClassifier(loss...
<python><binary><shap><catboost><imbalanced-data>
2023-01-12 00:55:58
1
371
Dhvani Shah
75,090,483
19,123,103
Randomly select argmax of non-unique maximum
<p>Given a 2D numpy array, I want to construct an array out of the column indices of the maximum value of each row. So far, <code>arr.argmax(1)</code> works well. However, for my specific case, for some rows, 2 or more columns may contain the maximum value. In that case, I want to select a column index randomly (not th...
<python><arrays><numpy><random>
2023-01-12 00:49:54
2
25,331
cottontail
75,090,480
875,295
Potential bug in heapq.heappush?
<p>I'm trying to understand if the following snippet doesn't exhibit a bug in heapq.heappush :</p> <pre><code>import heapq x = [] heapq.heappush(x, 1) print(x) try: heapq.heappush(x, &quot;a&quot;) except: pass print(x) # [1, 'a'] </code></pre> <p>Here, I'm trying to build a heap with non-comparable items. As...
<python>
2023-01-12 00:49:28
1
8,114
lezebulon
75,090,432
5,212,614
Can we rotate the x-axis and y-axis in a Seaborn Pairplot?
<p>I'm trying to rotate the x-axis and y-axis in a Seaborn Pairplot. SO far all I can rotate is the tick-params. I really want to rotate the x-axis and y-axis 45 degrees. Can we do that???</p> <pre><code>import seaborn as sns import matplotlib.pyplot as plt penguins = sns.load_dataset(&quot;penguins&quot;) g=sns.pairpl...
<python><python-3.x><seaborn>
2023-01-12 00:39:29
1
20,492
ASH
75,090,429
12,224,591
Best Way to Fill 3D Scatter Points? (MatPlotLib, Py 3.10)
<p>I have the following <code>Python 3.10</code> script to generate a simple 3D Scatter Plot with <code>MatPlotLib</code>, according to the <a href="https://matplotlib.org/stable/gallery/mplot3d/scatter3d.html" rel="nofollow noreferrer">MatPlotLib 3D Scatter tutorial</a>:</p> <pre><code>import matplotlib.pyplot as plt ...
<python><matplotlib>
2023-01-12 00:39:07
1
705
Runsva
75,090,410
5,041,471
Defining an aggregation function with groupby in pandas
<p>I would like to collapse my dataset using <code>groupby</code> and <code>agg</code>, however after collapsing, I want the new column to show a string value only for the grouped rows. For example, the initial data is:</p> <pre><code>df = pd.DataFrame([[&quot;a&quot;,1],[&quot;a&quot;,2],[&quot;b&quot;,2]], columns=['...
<python><pandas><dataframe><group-by><aggregation>
2023-01-12 00:35:55
2
471
Hossein
75,090,351
7,991,581
Python requests lib mix up headers in multi threaded context
<p>I'm managing several user accounts on a website with an API and I'm regularly retrieving some information for every user.</p> <p>To regularly get those information I'm using a python script which loads user data from a database and then uses the API connector to make the request.</p> <p>The endpoints I'm using to do...
<python><multithreading><python-requests>
2023-01-12 00:22:36
1
924
Arkaik
75,090,112
8,569,490
Unable to create a conda environment based on yaml file due dependencies issue (protobuf issue)
<p>hope you're doing well. Wanted to know if you could help me out with the following issue.</p> <p>I am trying to recreate a conda environment (old) in my local macbook M2 with some issues.</p> <p>Here is the <code>environment.yaml</code> for the mac.</p> <pre><code>name: airflow36 channels: - anaconda - conda-forge -...
<python><anaconda><conda><python-3.6><miniconda>
2023-01-11 23:35:28
0
395
nariver1
75,090,088
12,011,020
Kedro (Python) DeprecationWarning: `np.bool8`
<p>When I try to create a new kedro project or run an existing one, I get the following deprecation warning (see also screenshot below). As far as I understand the warning is neglebile, however, as I am trying to setup a clean project, I would like to resolve this warning. From the warning I get that it stems from the ...
<python><plotly><dependencies><kedro>
2023-01-11 23:31:21
1
491
SysRIP
75,090,084
11,462,274
Using find_all in BeautifulSoup when the filter is based on two distinct elements
<p>Currently I do it this way to pass only when there is a <code>tf-match-analyst-verdict</code> element inside the <code>div</code> which in turn should contain a <code>class</code> called <code>match-header</code>:</p> <pre class="lang-python prettyprint-override"><code>matches = soup.find_all('div', attrs={&quot;cla...
<python><beautifulsoup>
2023-01-11 23:30:47
1
2,222
Digital Farmer
75,090,010
19,009,577
Is there a way for pandas rolling.apply to enter a dataframe into the function
<p>I have code as below:</p> <pre><code>def fn(x): ... df.rolling(length).apply(lambda x: fn(x)) </code></pre> <p>I want the function to take a subset of the dataframe as input. Is this possible?</p>
<python><pandas><rolling-computation>
2023-01-11 23:17:41
2
397
TheRavenSpectre
75,089,903
3,713,236
`bootstrap_distribution` attribute in scipy.stats.bootstrap() gone?
<p>Here is the documentation of <code>scipy.stats.bootstrap()</code>, showing that <code>bootstrap_distribution</code> is an attribute that should be included in the return object:</p> <p><a href="https://i.sstatic.net/XBv85.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/XBv85.png" alt="enter image desc...
<python><scipy><bootstrapping>
2023-01-11 23:01:01
1
9,075
Katsu
75,089,656
2,862,387
Get Request to Azure DevOps with Personal Access Token (PAT) using Python
<p>I'm trying to make a get request to Azure DevOps.</p> <p>I have the URL and the Personal_Access_Token. The URL was created following these intructions <a href="https://learn.microsoft.com/en-us/rest/api/azure/devops/git/items/get?view=azure-devops-rest-6.1&amp;tabs=HTTP#definitions" rel="noreferrer">https://learn.mi...
<python><azure><azure-devops><python-requests><http-headers>
2023-01-11 22:26:15
3
936
d2907
75,089,614
1,974,918
Applying methods conditionally across columns in a pivot table
<p>Really enjoying chaining in polars. Almost feels like dplyr in R. Question: Is there a way to apply <code>fill_null</code> conditionally across columns in the table (i.e., replace with 0 for numerics and &quot;0%&quot; for str in the example below)? Like the old <code>mutate_if</code> in R-dplyr.</p> <pre class="lan...
<python><python-polars>
2023-01-11 22:19:59
0
5,289
Vincent
75,089,569
4,281,353
pandas read_json dtype=pd.CategoricalDtype does not work but dtype='category' does
<p>Is this a known issue that specifying <a href="https://pandas.pydata.org/docs/reference/api/pandas.CategoricalDtype.html" rel="nofollow noreferrer">CategoricalDtype</a> dtype at read_json does not convert the column dtype, or is there a mistake in the code?</p> <pre><code>import pandas as pd df = pd.read_json( ...
<python><pandas><dataframe><dtype>
2023-01-11 22:14:13
1
22,964
mon
75,089,555
7,720,535
Faster way to apply lambda function to Pandas groupby
<p>I have Pandas dataframe which is a (large number of times) repetition of a smaller dataframe, but only one column is not repeated. I want to apply a function that works on this non-repeated column and one of the repeating columns. But the whole procedure is slow and I need an alternative way that works faster. Here ...
<python><pandas><group-by>
2023-01-11 22:12:33
1
485
Esi