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,835,908 | 21,420,742 | How to filter on dates n days from from today using Python | <p>iI am fairly new to Python and have not used datetime/timedelta too much, I am trying to look at a dataset I have from the past 90 days and I have seen how to get todays date, but have no clue how to use <code>date.today()</code> into filter.</p>
<p>You can assume the date looks like this:</p>
<pre><code> ID Da... | <python><python-3.x><dataframe><datetime><timedelta> | 2023-03-24 16:05:37 | 1 | 473 | Coding_Nubie |
75,835,720 | 1,120,622 | Python property getters and setters not working | <p>I am attempting to use property-based getters and setters in Python and am getting strange problems. Consider the following code:#!/usr/bin/env python</p>
<pre><code>class anyThing(object):
def __init__(self):
self._xyz = 'something'
@property
def XYZ(self):
return self._xyz
@XYZ.s... | <python><getter> | 2023-03-24 15:49:15 | 0 | 2,927 | Jonathan |
75,835,580 | 5,213,451 | How to configure MyPy for Polars API Extension? | <p>I'm writing data manipulation code around <code>polars</code> Series and DataFrames.
To make my life easier and the code more readable, I use the <a href="https://pola-rs.github.io/polars/py-polars/html/reference/api.html" rel="nofollow noreferrer">Polars API extensions</a>:</p>
<pre class="lang-py prettyprint-overr... | <python><mypy><python-polars> | 2023-03-24 15:35:12 | 2 | 1,000 | Thrastylon |
75,835,550 | 5,168,463 | Parsing NLTK Chart diagram | <p>I am trying to do parsing using context free grammar which is returning multiple parse trees.
I can visualize these parse trees one by one using the code below:</p>
<pre><code>grammar = nltk.CFG.fromstring("""
S -> VP NP PUN | NP VP PUN | NP PUN | VP PUN
NP -> ADP NP | NOUN | ADJ NP | ADV... | <python><nlp><treeview><nltk><text-parsing> | 2023-03-24 15:32:12 | 0 | 515 | DumbCoder |
75,835,421 | 3,734,059 | How to get start and end datetime indices of groups of consecutive values of data in pandas including repeated valus? | <p>There are many answers based on numerical indices but I am looking for a solution that works with a <a href="https://pandas.pydata.org/docs/reference/api/pandas.DatetimeIndex.html" rel="nofollow noreferrer">DateTimeIndex</a> and got really stuck here. The closest answer I found with a numerical index is <a href="htt... | <python><pandas> | 2023-03-24 15:18:25 | 1 | 6,977 | Cord Kaldemeyer |
75,835,357 | 13,039,962 | Calculate consecutive quarterly cumulative values from daily data | <p>I have this df:</p>
<pre><code> DATE PP
0 1964-01-01 1.0
1 1964-01-02 0.0
2 1964-01-03 0.0
3 1964-01-04 0.0
4 1964-01-05 0.0
... ...
21788 2023-03-18 NaN
21789 2023-03-19 NaN
21790 2023-03-20 NaN
21791 2023-03-21 NaN
21792 2023-03-22 NaN
</code></pre>
<p>I want to... | <python><pandas> | 2023-03-24 15:12:22 | 1 | 523 | Javier |
75,835,249 | 10,192,593 | Nested for loop to create summary table of mean and SD in Python | <p>I have a numpy array of shape (2,2,1000) representing income-groups, age-groups and a sample of 1000 observations for each group.</p>
<p>I am trying to use a for-loop to calculate a summary table.</p>
<p>I would like to receive a table of the following sort:</p>
<p><a href="https://i.sstatic.net/ofaCW.png" rel="nofo... | <python><numpy><numpy-ndarray> | 2023-03-24 15:02:37 | 2 | 564 | Stata_user |
75,835,248 | 1,175,081 | Mypy can't find obvious type mismatch when using namespace-packages and subfolders with the same name | <p>The problem is as simple as can be if put in one file:</p>
<pre><code>class A():
a = 1
class B():
b = 2
def test(x: A):
return x
def testit():
b = B()
test(b)
</code></pre>
<p>And mypy finds the issue here with <code>mypy test_folder --check-untyped-defs</code></p>
<p>But if those functions / classes ar... | <python><mypy> | 2023-03-24 15:02:15 | 1 | 14,967 | David Schumann |
75,835,230 | 7,240,233 | How to put elements of a pandas index as values of a dictionary? | <p>I'm struggling with an error in pandas which is driving me crazy.</p>
<p>I want to build a dictionary which extracts some data from a pandas df:</p>
<pre><code>Index_col col1
P1 F1-R1
P2 F1-R1
P3 F1-R1
P4 F1-R1
P5 F1-R2
P6 F1-R2
P7 F1-R2
P8 F1-R2
(etc... | <python><pandas> | 2023-03-24 15:00:27 | 3 | 721 | Micawber |
75,835,140 | 11,160,898 | Python load .pem public key | <p>I have an ERCA pem file and need to load it in as a public key, which is then used to decrypt some data.</p>
<pre><code>------------ BEGIN ERCA PK ---------------
/UVDIAD//wHpgHY6REqVJQqVh4LR1UrPwyPSXzlGuBbpL8+dMrQqJhPRo2O05DUyoCZoYynI
lmPMwAH3J4IGtqtlrShxhIpoD2pX2P2h14LJtYEpA+pbZuKpvh2FvdD9rnakYIjXGmF2sfap
hBkQBCTc... | <python><encryption><rsa><public-key-encryption> | 2023-03-24 14:51:33 | 2 | 305 | Oscar K |
75,835,020 | 898,042 | How to print list with comma separators without spaces? | <p>I need to print list with commas without spaces and enclosed with 2 curly brackets. My code:</p>
<pre><code>x = [1,3,6,7]
x = set(x)
print('{', *x, "}", sep=',')
</code></pre>
<p>This prints:</p>
<pre><code>{,1,3,6,7,}
</code></pre>
<p>I need it to be like this:</p>
<pre><code>{1,3,6,7}
</code></pre>
| <python> | 2023-03-24 14:40:26 | 5 | 24,573 | ERJAN |
75,834,927 | 7,376,511 | isinstance with string representing types | <pre><code>isinstance("my string", "str | int")
isinstance("my string", "list")
</code></pre>
<p>Is there a way to check the type of a variable (<code>"my string"</code> in this case) based on a valid type which is stored as a string?</p>
<p>I don't need to import the t... | <python><eval><isinstance> | 2023-03-24 14:32:13 | 3 | 797 | Some Guy |
75,834,913 | 1,621,736 | How to cache response in google app engine | <p>We have some APIs which return exact same response to all calls based on some data which we change from time to time. We have a memcached layer where we have stored the response and have to do a fetch from memcached whenever the calls are received in API. Since there is high frequency of calls to API we would have i... | <python><google-app-engine><google-cloud-platform> | 2023-03-24 14:29:55 | 1 | 797 | puneet |
75,834,891 | 737,971 | Apply a generic function to an all-to-all couple of tensors | <p>I have a question <a href="https://stackoverflow.com/questions/67741628/apply-a-function-over-all-combination-of-tensor-rows-in-pytorch">similar to this one</a>, using a <strong>generic function</strong> of the kind:</p>
<pre><code>def f(a, b):
return Something
</code></pre>
<p>This something can be a scalar, or ... | <python><pytorch> | 2023-03-24 14:28:29 | 1 | 2,499 | senseiwa |
75,834,673 | 19,980,284 | Pandas convert values with commas to new value | <p>I have a column in a pandas df that looks like this:</p>
<pre><code> specialty
0 1
1 2,5
2 2
3 6
4 missing
5 1
6 3
7 1,3,4
8 4
9 1
</code></pre>
<p>And I'd like to convert all the values with more than one value to <code>7</code>, and convert all "missing" to 6. I know for that I can do <code>df['specialt... | <python><pandas><replace> | 2023-03-24 14:07:58 | 3 | 671 | hulio_entredas |
75,834,651 | 21,420,742 | Conditionally fill a column using multiple fields using Python | <p>I have a dataset where I am looking to see if an ID has switched Jobs as well as Departments through their history and if it happened at least once then create a new column [Transition] that is all 'Yes' or 'No'. Below is the code I have and what it shows:</p>
<pre><code>df[Transition] = np.where((df['Job_Code'] != ... | <python><python-3.x><pandas><dataframe><numpy> | 2023-03-24 14:05:40 | 3 | 473 | Coding_Nubie |
75,834,409 | 17,158,703 | Array Averages for "Hour of the Date in Year" in Python | <p>I have two arrays:</p>
<ol>
<li>a 3D numpy array with shape (1, 87648, 100) and dtype float64</li>
<li>a 1D array with shape (87648,) and type pandas DatetimeIndex</li>
</ol>
<p>the values of the 3D array along the axis=1 correspond to the hourly sequence datetimes in the 1D array. Total duration is 10 years with 2 ... | <python><numpy><datetime><multidimensional-array> | 2023-03-24 13:42:47 | 1 | 823 | Dattel Klauber |
75,834,362 | 19,980,284 | Pandas convert pairs of values into new values | <p>I have a pandas column that looks like this:</p>
<pre><code> gender
0 1
1 2
2 1
3 1
4 3
5 2
6 1
7 4
8 5
9 1
</code></pre>
<p>I want all the values of 1 to stay 1, 2 or 5 to become 2, and 3 or 4 to become 3. The desired output would then be</p>
<pre><code> gender
0 1
1 2
2 1
3 1
4 3
5 2
6 1
7 3
8 2
9 1
</code></pre... | <python><pandas> | 2023-03-24 13:38:54 | 1 | 671 | hulio_entredas |
75,834,302 | 423,839 | Subscribe mechanism in telegram bot | <p>I'm trying to build a bot that basically has two threads. One thread is doing something, generating data and another thread is managing telegram bot. User can subscribe on telegram to receive updates from the first thread. This first thread calls the second one when it generates data and that data is sent out to all... | <python><telegram><telegram-bot><python-telegram-bot> | 2023-03-24 13:32:58 | 1 | 8,482 | Archeg |
75,834,182 | 6,303,377 | Safe way to update a mysql table entry with a dictionary in python (safeguarding against SQL injection) | <p>I am writing a helper function for my webapp that updates the database based on some information that is fetched from a foreign API (not user entered). I have the following code, but it was flagged as 'unsafe' by the <a href="https://bandit.readthedocs.io/en/latest/start.html" rel="nofollow noreferrer">Bandit</a> py... | <python><mysql><sql><sql-injection><mysql-connector> | 2023-03-24 13:22:46 | 1 | 1,789 | Dominique Paul |
75,834,092 | 18,018,869 | Expand and transform dataframe. Compare each row with all other rows | <p>Please compare Bob's byte array with the byte arrays of all the other people. Do this with every person.</p>
<pre class="lang-py prettyprint-override"><code>columns = ["pasta", "potatoes", "rice"]
data = [[1, 0, 1], [0, 1, 1], [1, 1, 1]]
index = ["tom", "jenny", &quo... | <python><pandas><numpy> | 2023-03-24 13:11:48 | 4 | 1,976 | Tarquinius |
75,833,973 | 7,951,901 | How do I change the value of a field using odoo migration manager? | <p>I created a migration folder with a pre-migration file in odoo to change the value of a field in odoo, but the migration seems not be triggered.</p>
<p>I created a pre migration file like this2</p>
<pre><code>import logging
from odoo import SUPERUSER_ID, api
from openupgradelib import openupgrade
logger = logging.g... | <python><odoo><odoo-15> | 2023-03-24 12:59:31 | 1 | 405 | A.Sasori |
75,833,935 | 8,699,450 | Is there any way to specify a typehinted Pytorch DataLoader? | <p>Say I have the following:</p>
<pre class="lang-py prettyprint-override"><code>class SomeClass:
def some_function(dataloader: DataLoader):
for idx, batch in enumerate(dataloader):
... do something with batch ...
</code></pre>
<p>I would like to type the dataloader such that I can show through fun... | <python><pytorch><python-typing><pytorch-dataloader> | 2023-03-24 12:55:47 | 2 | 380 | Robin van Hoorn |
75,833,861 | 305,904 | Gateway Timeout when performing REST API CALL via Python3.9 | <p>I am trying to query <a href="https://www.nseindia.com/get-quotes/equity?symbol=EQUITASBNK" rel="nofollow noreferrer">this site</a> for historical price volume data, but it seems my GET queries are timing out. How can I set up my requests to bypass this problem?</p>
<p>The way the code is set up is:</p>
<ol>
<li>The... | <python><json><python-3.x><web-scraping><python-requests> | 2023-03-24 12:49:34 | 1 | 873 | Soham |
75,833,833 | 1,284,927 | Python type hinting with Visual Studio Code & Flake8 plugin (without "missing" Annotations) | <p>I have a bigger Python project and want to introduce type hinting step-by-step (I would like to suppress the "Missing type annotation" messages for now) to give me (coming from the strongly typed world) more confidence with Python. But I'm struggling to setup Flake8 with some meaningful type hinting in VS ... | <python><visual-studio-code><python-typing><flake8> | 2023-03-24 12:46:32 | 1 | 3,075 | thomiel |
75,833,826 | 12,760,550 | Search for LOV columns in dataframe and replace with codes using other dataframe | <p>Imagine I have a dirty dataframe of employees with their ID, and Contract related information per country.</p>
<p>Some columns of this dataframe are LOV columns (depending on the country, some columns are LOV for just one country, others some or all of them) and some LOV columns are mandatory and some are not (that... | <python><pandas><dataframe><group-by><lines-of-code> | 2023-03-24 12:45:35 | 1 | 619 | Paulo Cortez |
75,833,728 | 17,487,457 | Pandas equivalent of SQL LAG() | <p>I have this <code>dataframe</code>:</p>
<pre class="lang-py prettyprint-override"><code>df = pd.DataFrame(
{'id': [10, 10, 10, 12, 12, 12, 12, 13, 13, 13],
'session_id': [1, 3, 9, 1, 3, 5, 7, 1, 3, 5],
'start_time': [5866, 6810, 8689, 8802, 8910, 9013, 9055, 9157, 9654, 9665],
'end_time': [6808, 8653, 8722, 8881,... | <python><pandas><dataframe> | 2023-03-24 12:35:17 | 2 | 305 | Amina Umar |
75,833,721 | 762,688 | Unpacking an Optional value | <p>I have an <code>Optional[str]</code> that I know <code>is not None</code> and am passing this into a method that requires a <code>str</code> argument.</p>
<p>MyPy complains that the types do not match (<code>Optional[str]</code> vs <code>str</code>). I'm trying to write a method to unpack the wrapped value in option... | <python><mypy> | 2023-03-24 12:34:39 | 1 | 759 | sean.net |
75,833,518 | 4,179,570 | Accessing child orderable attribute in page model template | <p>The <a href="https://docs.wagtail.org/en/stable/getting_started/tutorial.html#parents-and-children" rel="nofollow noreferrer">wagtail documentation</a> outlines how to iterate over an orderable property in a page template, however, if I try the same from the parent page, whilst iterating on the children, I am unable... | <python><jinja2><wagtail> | 2023-03-24 12:13:55 | 0 | 2,423 | glls |
75,833,516 | 5,506,400 | Debugging Python, stay in current stack trace (not cycle after each command) | <p>Say I am debugging some python code, for interest sake it's a Django application, that has a <code>breakpoint()</code> in it, while stepping the code, another request may come and hit the same breakpoint. Now there are multiple concurrent debugger instances. And sometimes its more than 2.</p>
<p>With after eacvh deb... | <python><pdb> | 2023-03-24 12:13:39 | 0 | 2,550 | run_the_race |
75,833,473 | 5,588,347 | Extract data from pdf in table format to excel/csv - Amazon textract | <p>Today, I'm trying to extract table from pdf files into an excel using Amazon Textract! Initially I thought this is going to be very simple because it was till I was working on it with Java sdk's. But now I'm stuck. I don't want to use lambda, I don't want to use S3 bucket to upload the files.</p>
<p><strong>What I n... | <python><java><c#><amazon-textract><pdf-parsing> | 2023-03-24 12:08:26 | 0 | 958 | StackUseR |
75,833,456 | 673,018 | Highlight dataframe having NaN (matplotlib) while writing to the PDF file(PdfPages)? | <p>I'm trying to perform two things:</p>
<ol>
<li>Highlight 'NaN' values with red color for the dataframe.</li>
<li>Add the dataframe to the PDF file.</li>
</ol>
<p>I'm able to display the <code>dataframe</code> successfully in the PDF pages, however <code>NaN</code> values are not reflected with the red color inside t... | <python><pandas><matplotlib><pdfpages> | 2023-03-24 12:06:26 | 1 | 13,094 | Mandar Pande |
75,833,328 | 1,473,517 | Why do these two different ways to sum a 2d array have such different performance? | <p>Consider the following two ways of summing all the values in a 2d numpy array.</p>
<pre><code>import numpy as np
from numba import njit
a = np.random.rand(2, 5000)
@njit(fastmath=True, cache=True)
def sum_array_slow(arr):
s = 0
for i in range(arr.shape[0]):
for j in range(arr.shape[1]):
... | <python><numpy><numba> | 2023-03-24 11:54:17 | 1 | 21,513 | Simd |
75,833,309 | 241,552 | Bazel: install python using bazel | <p>I am working on an Bazel build MVP, and one of the steps in this process is to run our build in CI. However, CI builds are run in docker containers that do not contain much. Previously I had to add gcc to the container to build python that is used by Bazel itself, but now when I try to build a python library with <c... | <python><bazel> | 2023-03-24 11:52:31 | 1 | 9,790 | Ibolit |
75,833,267 | 15,673,412 | python - count number of windows containing only 0s | <p>Let's suppose I have a list or array <code>ts</code> of length N:</p>
<pre><code>ts = [1, 6, 2, 9, 0, 0, 0, 0, 0, 3, 6, 4, 0, 0, 5, 2, 3]
</code></pre>
<p>Let's suppose <code>k=4</code>.</p>
<p>I need to find the number of times that a sequence of <code>k</code> or more consecuitve zeros are present in the array. In... | <python><arrays> | 2023-03-24 11:48:08 | 3 | 480 | Sala |
75,833,221 | 2,836,172 | Code generated from Postman does not work - body format in request is actually different | <p>I build a REST API in Flask and tested it with Postman. Now I want to get a script which i can modify myself. Therefore I generated the script for Python and well, it doesn't work.</p>
<p>In Postman I send a key-value pair under the form-data tab. It works, request parser can find the string and proceed using it.</p... | <python><postman> | 2023-03-24 11:42:23 | 0 | 1,522 | Standard |
75,833,101 | 3,393,192 | Calculation of world coordinates of camera from chessboard image | <p>I have a stationary camera and want to get the real world coordinates and rotation from my camera (relative to the pattern). I placed a checkerboard pattern in the FoV of the camera and took some images.</p>
<p>Some might say, this question already has an answer on Stackoverflow, but none of them work. So this is NO... | <python><opencv><pose-estimation><opencv-solvepnp> | 2023-03-24 11:29:38 | 0 | 497 | Sheradil |
75,833,059 | 16,030,430 | Pandas extend DataFrame with Zeros | <p>I have following DataFrame which start by an index of 1.10 and increment by 0.05:</p>
<pre><code> A B C D E
1.10 3 2 2 1 0
1.15 1 2 0 1 0
1.20 0 0 0 1 -1
1.25 1 1 3 -5 2... | <python><pandas><dataframe> | 2023-03-24 11:26:02 | 1 | 720 | Dalon |
75,832,973 | 6,110,160 | Why aliasing dataclass(frozen=True) fails mypy check? | <p>Is it possible to alias <code>dataclass(frozen=True)</code> decorator? I tried this:</p>
<pre class="lang-py prettyprint-override"><code>import dataclasses
key = dataclasses.dataclass(frozen=True)
@key
class A:
a: str
A(a="a")
</code></pre>
<p>And I get the following mypy error:</p>
<pre><code>>... | <python><mypy><python-dataclasses> | 2023-03-24 11:16:38 | 0 | 1,852 | psarka |
75,832,814 | 15,593,152 | Pandas, combination of values and check if any of the combiantions is in a list | <p>I have a <code>df1</code> with some <code>item_id</code>'s and some values for each item (called "nodes"):</p>
<pre><code>df1 = pd.DataFrame({'item_id':['1','1','1','2','2','2','3','3'],'nodes':['a','b','c','d','a','e','f','g']})
</code></pre>
<p>and a <code>df2</code> that is a list of "vectors"... | <python><pandas><dataframe><combinations> | 2023-03-24 10:59:05 | 2 | 397 | ElTitoFranki |
75,832,731 | 9,104,884 | Parallel while loop with unknown number of calls | <p>I have written a function that does some calculations, and that everytime it is called it returns a different result, since it uses a different seed for the random number generator. In general, I want to run this functions many times, in order to obtain many samples.</p>
<p>I have managed to use <code>multiprocessin... | <python><while-loop><parallel-processing><multiprocessing><python-multiprocessing> | 2023-03-24 10:50:59 | 1 | 1,523 | Tropilio |
75,832,713 | 10,229,386 | Stable Baselines 3 support for Farama Gymnasium | <p>I am building an environment in the maintained fork of <code>gym</code>: <code>Gymnasium</code> by Farama. In my <code>gym environment</code>, I state that the <code>action_space = gym.spaces.Discrete(5)</code> and the <code>observation_space = gym.spaces.MultiBinary(25)</code>. Running the environment with the agen... | <python><reinforcement-learning><openai-gym><stable-baselines> | 2023-03-24 10:49:24 | 2 | 1,103 | Lexpj |
75,832,701 | 6,160,923 | How to make a static tree view in odoo with fixed rows where first column contains some hard coded value and 2nd and 3rd column is editable | <p>How to make a static tree view in odoo with fixed number of rows where first column contains some hard coded value and 2nd column is editable. When user will go to crate new record button there will be a tree view with first column having some pre defined value and user only input in other columns and save the table... | <python><xml><odoo> | 2023-03-24 10:48:40 | 1 | 672 | Atiq Baqi |
75,832,685 | 4,997,239 | Import "dash" could not be resolved Pylance | <p>I'm using python on Mac with VSCode and have set up a virtual environment which is definitely being used by the program. Imports like <code>requests</code>, <code>pandas</code> etc are found no problem but <code>dash</code> cannot be found and <code>matplotlib</code> cannot be found. I installed the libraries using ... | <python><visual-studio-code><pylance> | 2023-03-24 10:46:39 | 1 | 12,448 | Hasen |
75,832,639 | 3,203,845 | How to split a string to an array of filtered integers? | <p>I have a <code>DF</code> column which is a long strings with comma separated values, like:</p>
<ul>
<li><code>2000,2001,2002:a,2003=b,2004,100,101,500,20</code></li>
<li><code>101,102,20</code></li>
</ul>
<p>What I want to do is to create a new <code>Array<Int></code> column out of it where:</p>
<ol>
<li>only ... | <python><amazon-web-services><apache-spark><pyspark><aws-glue> | 2023-03-24 10:41:51 | 2 | 407 | 1131 |
75,832,624 | 4,162,689 | Is there a DRY way to get n Cartesian Products in Python? | <p>According to <a href="https://stackoverflow.com/a/72490086/4162689">72489951</a>, if one wants to generate the product of a list, this function does the job.</p>
<pre><code>def generate_prods():
from itertools import product
in_list = ['a', 'b', 'c']
out_prods = list(product(in_list, in_list))
return... | <python> | 2023-03-24 10:40:43 | 1 | 972 | James Geddes |
75,832,590 | 15,637,435 | Website section not visible when using Selenium over Playwright | <h2>Problem</h2>
<p>I have a scraper that scrapes product information. One thing that I would like to scrape is the CO2 emission and the compensation price of the product. Since this information is available in a specific section I have to click on a button and therefore use a browser automation tool.</p>
<p>I have now... | <python><selenium-webdriver><web-scraping><playwright> | 2023-03-24 10:38:09 | 1 | 396 | Elodin |
75,832,557 | 1,160,393 | Initial pagerank precomputed values with networkx | <p>I'm trying to run an experiment where I have PageRank values and a directed graph built. I have a graph in the shape of a star (many surrounding nodes that point to a central node).</p>
<p>All those surrounding nodes have already a PageRank value precomputed and I want to check how the central node PageRank value is... | <python><networkx><pagerank> | 2023-03-24 10:35:43 | 1 | 876 | Ed. |
75,832,518 | 5,664,889 | Github X-RateLimit-Remaining is not zero and "limit exceeded" error is thrown | <p>I am experiencing this issue when in response headers I see X-RateLimit-Remaining is set to a value other than zero, but an exception is raised with "Max retries exceeded (Caused by ResponseError('too many 403 error responses'))"</p>
| <python><github><python-requests><github-api> | 2023-03-24 10:30:39 | 0 | 449 | qurat |
75,832,471 | 13,935,315 | How to prevent long type hints in python when using third party classes, abstract classes and factory class | <p>I am trying to create a python package which works with secret managers. Depending on which cloud the user is working (azure, gcp or aws) it should create the required secret manager of that particular cloud provider. For azure this is keyvaul and for gcp this is secret manager. To accomodate this I have created a f... | <python> | 2023-03-24 10:26:16 | 1 | 331 | Jens |
75,832,445 | 6,068,731 | Matplotlib imshow with x values log-spaced but y values lin-spaced | <h1>Task</h1>
<p>I have a grid of values <code>zs</code> relating to some <code>xs</code> values that are log-spaced, and <code>ys</code> values that are lin-spaced. I tried to make it work as follows but the plot looks weird.
The key problem is that the x-values are in the log-space and the y values are not.</p>
<p>I ... | <python><matplotlib> | 2023-03-24 10:23:38 | 0 | 728 | Physics_Student |
75,832,379 | 12,255,379 | reliable scale aware and lightweight object tracking on real life video stream | <p>I'm trying to make a python script which tracks people on live video stream. My script uses pose detector from mediapipe solutions and face-recognition module which does some dlib magic under the hood.</p>
<p>Currently I locate faces, and check for overlaps with body bbox and group them in such fashion, however face... | <python><opencv> | 2023-03-24 10:16:28 | 0 | 769 | Nikolai Savulkin |
75,832,256 | 1,818,713 | How to get output from Fiona instead of fiona.model object | <p>I'm following the examples in <a href="https://fiona.readthedocs.io/en/stable/manual.html#records" rel="nofollow noreferrer">the docs</a> but using Virginia's <a href="https://gismaps.vdem.virginia.gov/download/BaseMapData/SHP/VirginiaParcel.shp.zip" rel="nofollow noreferrer">parcel shp file</a>. Warning: it's about... | <python><shapefile><fiona> | 2023-03-24 10:03:08 | 1 | 19,938 | Dean MacGregor |
75,832,196 | 673,600 | Editing a pandas dataframe, and I simply don't know why | <p>I'm perplexed whereby I cannot seem to update a row in pandas. I have tried a) creating a copy (and deep copy), since I only need to change the copy.</p>
<pre><code>df_company = df.copy(deep=True)
df_company = df_company[df_company["Market"]==company_name]
df_company = df_company[( df_company["Date&qu... | <python><pandas> | 2023-03-24 09:56:57 | 1 | 6,026 | disruptive |
75,832,049 | 6,760,948 | timeout if the condition is not met | <p>My requirement is to monitor a kafka topic for the messages & filter or search for a keyword - <code>state</code> from the arrived messages and print, Active Brands and Non active brands(Disables & Booted) separately. This has to be done within a timeout of 15 minutes or else break out of the script saying T... | <python><python-3.x><confluent-kafka-python> | 2023-03-24 09:40:40 | 1 | 563 | voltas |
75,831,843 | 520,556 | How to fill pandas column (variable) using two conditions at once | <p>The following code works fine, but I failed to make it a single-liner. Is it possible?</p>
<pre><code>dat.loc[dat['A'] == '', 'A'] = 'no'
dat.loc[dat['A'].isnull(), 'A'] = 'no'
</code></pre>
<p>(It is strange, though, that after merging two dataframes A contains both empty strings and nulls. π€·π»)</p>
| <python><pandas> | 2023-03-24 09:16:36 | 2 | 1,598 | striatum |
75,831,723 | 2,859,206 | Pandas group events close together by date, then test if other values are equal | <p>The problem: group together events that occur close to each other in time, that also have another variable that is equal. For example, given the date of disease onset, and an address, find disease outbreaks that occur at the same location within specified timeframe of each other. Large - 300K rows - pandas dataframe... | <python><pandas><lambda> | 2023-03-24 09:03:59 | 2 | 2,490 | DrWhat |
75,831,457 | 13,217,286 | How do I filter rows of strings that contain any value from a list in Polars | <p>If you had a list of values and a Polars dataframe with a column of text. And you wanted to filter to only the rows containing items from the list, how would you write that?</p>
<pre class="lang-py prettyprint-override"><code>import polars as pl
a_list = ['a', 'b', 'c']
df = pl.DataFrame({
'col1': [
'I... | <python><regex><dataframe><contains><python-polars> | 2023-03-24 08:31:58 | 2 | 320 | Thomas |
75,831,415 | 2,730,554 | pycharm not detecting changes to code when re-running function | <p>I have just moved from using Spyder to PyCharm & so far think its great. I have one issue though. When I run a simple function it runs as expected. The problem comes when I make a small change to the function, for example add an extra column to a dataframe that will be returned by the function, it is not reflect... | <python><pycharm> | 2023-03-24 08:27:27 | 1 | 6,738 | mHelpMe |
75,831,265 | 13,994,829 | How to improve bigquery client query response time in FastAPI? | <p>I have develope an API via <code>FastAPI</code>.</p>
<p>This API will do:</p>
<blockquote>
<ol>
<li><strong>POST</strong> with <code>user_ip</code> in <code>client.py</code></li>
<li>Use <em>BigQuery API Client</em> to <code>query</code> from data table in <code>v1_router.py</code></li>
<li>If <code>user_ip</code> e... | <python><google-bigquery><fastapi> | 2023-03-24 08:09:03 | 0 | 545 | Xiang |
75,831,189 | 6,866,762 | ROS2 Topic on WSL Can not Find All Available Topics | <p>I have a ROS2 Galactic version installed in my <code>Ubuntu 20.04</code> inside <strong>WSL</strong> on my <strong>Windows 11</strong>. I have a <code>Turtlebot4</code> which is functioning without issues. My windows pc is connected to the same network as the TurtleBot4 but whenever I ran <code>ros2 topic list</code... | <python><windows-subsystem-for-linux><ros><ubuntu-20.04><ros2> | 2023-03-24 08:00:07 | 0 | 519 | tahsin314 |
75,830,683 | 6,197,439 | Right-align (pad left) index column in Pandas? | <p>Consider the following simple example:</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
df = pd.DataFrame({'text': ["foo", "bar", "baz", "qux", "quux", "corge", "grault", "garply", "waldo", "fred&qu... | <python><pandas><stdout> | 2023-03-24 06:42:22 | 1 | 5,938 | sdbbs |
75,830,645 | 2,065,083 | Parse a dynamic xml file recursively in python | <p>I am trying to read a dynamic xml file recursively. Here is my code:</p>
<pre><code>import xml.etree.ElementTree as ET
class XmlNavigator:
def __init__(self, xml=None):
self.tree = ET.ElementTree(ET.fromstring(xml))
self.root = self.tree.getroot()
def parse_xml(self, node):
... | <python><xml> | 2023-03-24 06:36:19 | 1 | 21,515 | Learner |
75,830,592 | 5,371,582 | type annotation when I know to be in a particular case | <p>I have a function that reads a JSON file and returns either a dictionary or a list, depending on the contents of the file. Here is the function:</p>
<pre><code>from typing import Union
import json
def read_json_file(filename)->Union[dict, list]:
with open(filename) as f:
return json.load(f)
</code></... | <python><python-typing> | 2023-03-24 06:26:01 | 1 | 705 | Laurent Claessens |
75,830,048 | 1,021,306 | Python - ModuleNotFoundError thrown when calling a function that imports another module in the same directory | <p>I have the following Python file structure.</p>
<pre><code>-- main.py
-- scripts/
-- __init__.py
-- helper_functions.py
-- mytest.py
</code></pre>
<p><code>mytest.py</code> has the following function.</p>
<pre><code>def test():
print("test")
</code></pre>
<p><code>helper_funct... | <python> | 2023-03-24 04:31:10 | 2 | 3,579 | alextc |
75,829,938 | 19,293,506 | TypeError: only size-1 arrays (I am trying to print most similar words) | <h1>How to return similar words?</h1>
<p>I have such Python code, this code should simply prints array of given similar word e,g, "japan"</p>
<h2>code:</h2>
<pre class="lang-py prettyprint-override"><code>import spacy
import numpy as np
# Load the larger pre-trained English model
nlp = spacy.load("en_co... | <python><numpy><nlp><spacy> | 2023-03-24 04:03:45 | 1 | 631 | kawa |
75,829,937 | 11,901,732 | Sort list by dictionary in Python | <p>I want to sort a list by a dictionary, as shown below:</p>
<p>The list:</p>
<pre><code>L = ['Jack', 'King', '9', 'King', '10']
</code></pre>
<p>The dictionary:</p>
<pre><code>D = {0:'Ace', 1:'King', 2:'Queen', 3:'Jack', 4:'10', 5:'9'}
</code></pre>
<p>I want to sort L based on keys of dictionary D, such that the out... | <python><list><dictionary><sorting> | 2023-03-24 04:02:49 | 2 | 5,315 | nilsinelabore |
75,829,747 | 12,931,358 | Setting CUDA_VISIBLE_DEVICES just has no effect even though I put it before pytorch | <p>I have tried many methods to set cuda device as 1, or 0,1 however,most of them didn't work, I followed some solution but not work...</p>
<pre><code># '''cmd:CUDA_VISIBLE_DEVICES=1, python mytest.py''' #stil shows 0
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '1' #cannot work
#export 'CUDA_VISIBLE_DEVICES'='1... | <python><pytorch><cuda> | 2023-03-24 03:21:41 | 2 | 2,077 | 4daJKong |
75,829,670 | 308,827 | Finding sets of files matching the same substring | <p>I have a set of files with the following type of name:
<code>soil_moisture_2015090T043000_sm_global.tif</code>
<code>soil_moisture_2015090T133000_sm_global.tif</code>
<code>soil_moisture_2015090T163000_sm_global.tif</code>
<code>soil_moisture_2015091T073000_sm_global.tif</code>
<code>soil_moisture_2015091T223000_sm_... | <python> | 2023-03-24 03:01:22 | 1 | 22,341 | user308827 |
75,829,412 | 1,857,373 | PCA(n_components=9) digits Value Error Shape passed values (n, 9), indices imply (n, 10) | <p><strong>Problem</strong></p>
<p>Working on digits data (0-9) and finished coding OneVsOne Classifier and OneVsRest Classifiers for Binary Classification using Multi Class Classification. Code is working on classifiers for machine leaning.</p>
<p>Now ready to add PCA dimension reduction and experiment with results to... | <python><pandas><machine-learning><scikit-learn><pca> | 2023-03-24 01:51:42 | 1 | 449 | Data Science Analytics Manager |
75,829,393 | 1,270,076 | Install brew in another folder | <p>I want to install python 3.8.6 on an M1 mac but that version has no arm compilation. Looking at this <a href="https://stackoverflow.com/questions/71862398/install-python-3-6-on-mac-m1">answer</a>, I could install x86 brew but I already have a lot of other dependencies installed with my current brew version so I don'... | <python><python-3.x><homebrew><zsh><apple-m1> | 2023-03-24 01:46:55 | 0 | 344 | JuanKB1024 |
75,829,289 | 9,926,472 | Variable length nested for loops with different function calls at each level | <p>Although some variants of this question has been asked, I could not find what I was looking for.</p>
<p>Let us say I have a variable length vector of instances of different classes: [objA, objB, objC], each of which have a method called <code>call_method()</code> that returns a particular value <code>v</code>, and a... | <python><loops><nested> | 2023-03-24 01:21:46 | 1 | 587 | OlorinIstari |
75,829,014 | 2,158,231 | Bazel error: no such package: The repository could not be resolved: Repository is not defined and referenced by | <p>I am trying to run a simple python binary with bazel using <code>bazel run projects/my-python-app/...</code>. But when I run it I get the error:</p>
<pre><code>ERROR: /private/var/tmp/_bazel_justin/84cef48b5ae183d272bc73733d19e8e1/external/python_deps_pypi__flask/BUILD.bazel:11:11: no such package '@python_deps_pypi... | <python><bazel><bazel-rules> | 2023-03-24 00:09:13 | 2 | 1,828 | jlcv |
75,829,013 | 250,161 | Python Venv in a Docker running as root | <p>I am editing the question because you did not understand the problem. And the problem still exists.</p>
<p>How do I install into a Docker container via pip3, modules that are not installed on the system. When I do that it says it is a managed environment, and does not proceed, <strong>BUT</strong> there is no debi... | <python><docker><pip><python-venv> | 2023-03-24 00:08:57 | 0 | 1,362 | Bodger |
75,828,973 | 6,683,107 | mypy: Missing type parameters for generic type "Connection" [type-arg] when type hinting pymysql.connections.Connection | <p>mypy is saying "Missing type parameters for generic type "Connection" [type-arg]" when I type hint these pymysql Connection types:</p>
<pre><code>import typing
from dataclasses import dataclass
import pymysql
from loguru import logger
@dataclass
class ConnectionDetails:
"""... | <python><mypy><pymysql> | 2023-03-24 00:00:52 | 0 | 840 | bearoplane |
75,828,902 | 6,875,778 | How do I get the index of the array for a job in a batch job that was started using a map distribution in a step function? | <p>I have a script in batch job that gets the index of the batch array using the environment variable like this:</p>
<pre><code>import os
# get index of array
int_idx_array = int(os.environ['AWS_BATCH_JOB_ARRAY_INDEX'])
print(f'Array index: {int_idx_array}')
</code></pre>
<p>This works perfectly unless I run the batch... | <python><amazon-web-services><aws-lambda><aws-step-functions><aws-batch> | 2023-03-23 23:45:52 | 1 | 1,283 | Aaron England |
75,828,899 | 11,922,765 | Python how to count the nested list of lists containing strings | <p>I have a nested lists of list. I want to know total items in the main and sublists. Then accordingly I want to choose a value for each sublist or item.</p>
<p>My code:</p>
<pre><code>y = ['ab',['bc','cd'],'ef']
print([len(y[i]) for i in range(len(y))])
alpha=0.5
plot_alpha = [alpha for i in range(len(y)) if len(y[i]... | <python><arrays><list><numpy><arraylist> | 2023-03-23 23:45:02 | 1 | 4,702 | Mainland |
75,828,787 | 6,676,101 | How do you compute a regular expression which is the intersection of two other regular expressions? | <p>Consider the following two regular expressions:</p>
<blockquote>
<ol>
<li><code>[ab][0123]</code></li>
<li><code>[bc][2345]</code></li>
</ol>
</blockquote>
<p>What function will output the intersection of the two inputs without using <code>?=</code></p>
<p>The following is not an acceptable output for our applicatio... | <python><string> | 2023-03-23 23:21:41 | 1 | 4,700 | Toothpick Anemone |
75,828,625 | 525,865 | NoneType' object is not subscriptable : bs4 task fails permanently | <p><strong>update:</strong> tried the scripts of Driftr95 .. in google-colab - and got some questions - the scripts failed - and was not succesful - queston. at the beginning of the scripts i have noticed that some lines are commendted out. why is this so. i will try to investigate more - meanwhile thanks alot..-. aw... | <python><pandas><csv><web-scraping><beautifulsoup> | 2023-03-23 22:50:49 | 2 | 1,223 | zero |
75,828,595 | 15,257,122 | How do I precompile Python code on a Mac? | <p>I am using a Mac M2 with Ventura, and the answers I can get from other webpages / ChatGPT / Bard told me I can do either:</p>
<ol>
<li>Run this as a python program, using <code>python3 do_it_foo.py</code></li>
</ol>
<pre class="lang-py prettyprint-override"><code>import py_compile
py_compile.compile('abc.py')
</code... | <python><python-3.x> | 2023-03-23 22:45:44 | 0 | 787 | Stefanie Gauss |
75,828,524 | 525,865 | itterating over a set of data - so that i fetch data from a site with beautiful-soup, panda and store it subsequently | <p>i am currently workin on a sript to be able to scrape the data from the given website using Beautiful Soup and store it in a CSV format: the site 'https://schulen.bildung-rp.de' - a governmental site that lists schools.</p>
<p><strong>update:</strong> see a result-page here.</p>
<p><a href="https://i.sstatic.net/EA... | <python><pandas><csv><beautifulsoup> | 2023-03-23 22:32:05 | 2 | 1,223 | zero |
75,828,373 | 2,256,085 | How to rotate a stacked area plot | <p>I'd like to re-orient a stacked-area plot such that the stacked areas are stacked horizontally rather than vertically (from a viewer's perspective). So here is what a typical stacked-area plot looks like:</p>
<pre><code># imports
import matplotlib.pyplot as plt
from matplotlib.transforms import Affine2D
from matplo... | <python><matplotlib> | 2023-03-23 22:05:29 | 1 | 469 | user2256085 |
75,828,370 | 21,420,742 | Conditionally Fill a column with a single value in Python | <p>I have a dataset where I am looking to see if someone has left their job title to start a new job. The way I have decided to represent this is, I have taken the column 'job' and made a new column named 'Latest_Job' which populates to all the rows of their history. I compare the two to see when or if a change has oc... | <python><python-3.x><pandas><dataframe><numpy> | 2023-03-23 22:04:10 | 2 | 473 | Coding_Nubie |
75,828,345 | 993,812 | Aggregating Columns Returns 'Column not iterable' Error | <p>I'm trying to get percentiles for some columns in a spark dataframe, but the following code returns a "Column not iterable" error.</p>
<pre><code>import pyspark.sql.functions as F
exprs = {x: F.percentile_approx(x, 0.25) for x in df.columns}
df.agg(exprs).show()
</code></pre>
<p>Any sugge... | <python><pyspark> | 2023-03-23 22:00:57 | 1 | 555 | John |
75,828,279 | 1,653,273 | Polars conversion error going from Python to Rust with pyo3 | <p>Related to the solution proposed in <a href="https://stackoverflow.com/questions/75827086/convert-pandas-dataframe-with-dictionary-objects-into-polars-dataframe-with-obje/75827315#75827315">this other question</a>.</p>
<p>This code creates a polars dataframe of python dictionaries. In Python land, everything is fine... | <python><dataframe><rust><rust-polars><pyo3> | 2023-03-23 21:51:01 | 0 | 801 | GrantS |
75,828,264 | 5,224,239 | Remove palindromic rows based on two columns | <p>I have the following data frame:</p>
<pre><code>Data_Frame <- data.frame (
A = c("a", "c", "b", "e", "g", "d", "f", "h"),
B = c("b", "d", "a", "f", "h", "c", "e"... | <python><r><pandas> | 2023-03-23 21:49:02 | 1 | 447 | RJF |
75,828,200 | 1,717,414 | pip install <.whl file> installs dist_info but doesn't actually install the package | <p>I'm trying change my package over from using <code>setup.py</code> to using <code>pyproject.toml</code> and <code>setup.cfg</code>.</p>
<p>My <code>setup.cfg</code> is roughly as follows:</p>
<pre><code>[metadata]
name = our_name
version = 0.1.1
author = me
[options]
install_requires =
networkx >= 3.0
</code... | <python><pip><setuptools><python-packaging><python-wheel> | 2023-03-23 21:37:53 | 1 | 533 | Nathan Kronenfeld |
75,828,115 | 4,042,278 | How run sklearn.preprocessing.OrdinalEncoder on several columns? | <p>this code raise error:</p>
<pre><code>import pandas as pd
from sklearn.compose import ColumnTransformer
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import OrdinalEncoder
# Define categorical columns and mapping dictionary
categorical_cols = ['color', 'shape', 'size']
mapping = {'red': 0, 'green... | <python><scikit-learn><pipeline> | 2023-03-23 21:24:07 | 2 | 1,390 | parvij |
75,828,068 | 781,938 | Does scikit-learn have a method for calculating an "all errors curve" for a binary classifier (TP, FP, TN, FN)? | <p>i'm plotting ROC curves and precision-recall curves to evaluate various classification models for a problem i'm working on. i've noticed that scikit-learn has some nice convenience functions for computing such curves:</p>
<ul>
<li><a href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_curve.h... | <python><machine-learning><scikit-learn><statistics> | 2023-03-23 21:17:27 | 1 | 6,130 | william_grisaitis |
75,828,046 | 3,605,534 | How to convert a dataset column of numbers in python numpy 2D array? | <p>I would like to ask for help. I have a dataset which has a column called pixels (I loaded with Pandas):</p>
<p><a href="https://i.sstatic.net/W3LL7.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/W3LL7.png" alt="enter image description here" /></a></p>
<p>I would like to train this image classificatio... | <python><pandas><numpy> | 2023-03-23 21:14:11 | 0 | 945 | GSandro_Strongs |
75,828,008 | 594,376 | Docs about boolean scalars in indexing of numpy array | <p>The NumPy's <a href="https://numpy.org/doc/stable/user/basics.indexing.html" rel="nofollow noreferrer">array indexing</a> documentation seems to contain no mention of array indexing Of the type <code>x[True]</code>, or <code>x[False]</code>.</p>
<p>Empirically, using <code>True</code> inserts a new dimension of size... | <python><numpy><numpy-ndarray> | 2023-03-23 21:09:13 | 1 | 5,954 | Sasha |
75,827,857 | 15,257,122 | What is the reason a Python3 loop is taking so much longer than Node.js? | <p>First of all, some readers are negating it as a valid question. But if my goal is to check, if I have an algorithm that is O(nΒ²) and <code>n</code> is 10,000 or 100,000, then what kind of minimum running time should I expect, then the loop down below is totally valid.</p>
<p>I first wrote a JavaScript test:</p>
<pre... | <javascript><python><python-3.x> | 2023-03-23 20:48:34 | 1 | 787 | Stefanie Gauss |
75,827,840 | 11,572,712 | Streamlit - AssertionError: Cannot pair 2 captions with 1 images | <p>I have the following code:</p>
<pre><code>import pm4py
import pandas as pd
import streamlit as st
import graphviz
st.set_page_config(page_title="Process Mining dashboard", page_icon=":chart_with_downwards_trend:", layout="wide")
file_path = r'path/to/file.csv'
event_log = pd.read_csv(... | <python><error-handling><streamlit> | 2023-03-23 20:46:09 | 1 | 1,508 | Tobitor |
75,827,778 | 2,510,104 | Trying to calculate total memory usage of multiprocess Python code on Linux | <p>I'm stuck with a memory usage calculation problem for a Python code I have which is using multiprocessing. The code runs on Linux.</p>
<p>Here is the gist of the problem: I have a parent process which forks off bunch of child processes. The address space of the parent process is pretty much readonly from child proce... | <python><linux><memory><multiprocessing> | 2023-03-23 20:36:53 | 0 | 541 | Amir |
75,827,769 | 15,452,168 | change iterrows() to .loc for large dataframes | <p>I have 2 data frames, df1 and df2.</p>
<p>Based on the condition in <code>df1</code> that <code>day_of_week == 7</code> we have to match 2 other column values, <code>(statWeek and statMonth)</code> if the condition matches then we have to replace <code>as_cost_perf</code> from df2 with <code>cost_eu</code> from df... | <python><pandas><dataframe><lambda><data-wrangling> | 2023-03-23 20:35:06 | 3 | 570 | sdave |
75,827,592 | 12,436,050 | PermissionError: [Errno 13] Permission denied: while writing output to a file in Python3.7 | <p>I am trying to write & append json data retrieved through the API calls to a file. 'missed_loc_id' is a dataframe of single column with identifiers. Below is the python code.</p>
<pre><code>df_loc_missed = pd.DataFrame( columns=['location_id', 'city', 'country'])
json_arr = []
url_loc_missed = "https://eur... | <python><json> | 2023-03-23 20:10:43 | 0 | 1,495 | rshar |
75,827,522 | 2,809,834 | Merging multiple pandas columns together | <p>I want to convert the following data frame:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>2020</th>
<th>2021</th>
<th>2022</th>
</tr>
</thead>
<tbody>
<tr>
<td>10</td>
<td>NaN</td>
<td>NaN</td>
</tr>
<tr>
<td>NaN</td>
<td>5</td>
<td>NaN</td>
</tr>
<tr>
<td>12</td>
<td>NaN</td>
<td>NaN<... | <python><pandas> | 2023-03-23 20:00:47 | 1 | 374 | Ossz |
75,827,508 | 9,937,874 | Better way to iterate over a list? | <p>I am using <code>fitz</code> to scrape PDFs. I use the following code to generate a list of words located in the pdf.</p>
<pre><code>import fitz
doc = fitz.open("very_important_document.pdf")
for page in doc.pages(0, 1, 1): # reads just the first page
wlist = page.get_text("words")
doc.clos... | <python><string><list><iteration> | 2023-03-23 19:59:26 | 2 | 644 | magladde |
75,827,502 | 3,788 | How to get Pydantic model types? | <p>Consider the following model:</p>
<pre class="lang-py prettyprint-override"><code>from pydantic import BaseModel
class Cirle(BaseModel):
radius: int
pi = 3.14
</code></pre>
<p>If I run the following code, I can see the fields of this model:</p>
<pre class="lang-py prettyprint-override"><code>print(Circle.__... | <python><pydantic> | 2023-03-23 19:58:56 | 2 | 19,469 | poundifdef |
75,827,415 | 11,025,049 | Is it possible to mock SimpleUploadedFile? | <p>I have a function like this:</p>
<pre class="lang-py prettyprint-override"><code>def my_func():
[...]
with open(full_path, "rb") as file:
image.image = SimpleUploadedFile(
name=image.external_url,
content=file.read(),
content_type="image/jpeg",
... | <python><django><mocking> | 2023-03-23 19:46:45 | 1 | 625 | Joey Fran |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.