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,382,158 | 10,065,556 | sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DatatypeMismatch) column is of type bit but expression is of type integer | <p>I'm trying to insert a BIT value in my postgres column called <code>isFile</code>. The following error is raised when passing IsFile=1</p>
<pre><code>sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DatatypeMismatch) column "IsFile" is of type bit but expression is of type integer
</code></pre>
<p>For som... | <python><postgresql><sqlalchemy><psycopg2> | 2023-02-08 06:39:13 | 0 | 994 | ScriptKiddieOnAComputer |
75,382,057 | 4,796,963 | A random string of ascii_letters + digits, but only starts with a letter | <p>I'm using the following simple code to generate a random string of length 10</p>
<pre><code>from string import ascii_letters, digits
''.join(choice(ascii_letters + digits) for i in range(10))
</code></pre>
<p>The problem is that sometimes the first character of the string is a digit. I don't want that. I want the fi... | <python><python-3.x><string><random> | 2023-02-08 06:26:26 | 4 | 1,297 | AhmedWas |
75,382,000 | 15,781,591 | How to insert string into plotting function in python | <p>I have the following code that creates a histogram from my data using seaborn in python:</p>
<pre><code>ax=sns.histplot(data=data, y=value, x=category)
ax.figure.set_size_inches(7,len(10))
plt.title('Title'.format(field))
plt.show()
</code></pre>
<p>Now I want to work on creating ... | <python><matplotlib><seaborn> | 2023-02-08 06:18:28 | 1 | 641 | LostinSpatialAnalysis |
75,381,941 | 19,238,204 | How to Generate Random Year in Python with format YYYY? | <p>I have this code to generate fake name, age, address, I want to know what is the line to generate fake year in YYYY format?</p>
<pre><code>def create_fake_users(n):
"""Generate fake users."""
faker = Faker()
for i in range(n):
user = User(name=faker.name(),
... | <python><python-3.x> | 2023-02-08 06:09:36 | 2 | 435 | Freya the Goddess |
75,381,861 | 3,386,779 | turnoff screenshot in robot framework | <p>I have created application in robot framework and want to disable screenshot.</p>
<p>Selenium2Library tried run_on_failure=Capture Page Screenshot but taking screenshot for success case .</p>
<p>I need to stop taking screenshot for both success and failure case</p>
| <python><robotframework> | 2023-02-08 05:57:03 | 1 | 7,263 | user3386779 |
75,381,833 | 3,169,868 | Pandas extract phrases in string that occur in a list | <p>I have a data frame with a column <code>text</code> which has strings as shown below</p>
<pre><code>text
my name is abc
xyz is a fruit
abc likes per
</code></pre>
<p>I also have a list of phrases as shown below</p>
<pre><code>['abc', 'fruit', 'likes per']
</code></pre>
<p>I want to add a column <code>terms</code> to... | <python><pandas><list><apply> | 2023-02-08 05:53:43 | 2 | 1,432 | S_S |
75,381,812 | 9,768,643 | filter a pandas df with multiple check of different column equal | <pre><code>,unique_system_identifier,call_sign,date1,date2,date3,date4
0,3929436,WQZL268,14-06-2023,,14-06-2023,
1,3929436,WQZL268,,,,
2,3929437,WQZL269,14-06-2023,,14-06-2023,
3,3929437,WQZL269,,,,
4,3929438,WQZL270,14-06-2023,,14-06-2023,
5,3929438,WQZL270,,,,
6,3929439,WQZL271,14-06-2023,,14-06-2023,
7,3929439,WQZL2... | <python><pandas> | 2023-02-08 05:50:59 | 1 | 836 | abhi krishnan |
75,381,775 | 19,321,677 | How to randomly sample a value within a given segment? | <p>I want to create a new column "sample_group_B" which randomly samples a purchase price value from group B within the same segment of group A. How do I do this in pandas?</p>
<pre><code>segment | purchase price | group
High | 100 | A
High | 105 | A
High | 103 | B
Hi... | <python><pandas> | 2023-02-08 05:44:59 | 2 | 365 | titutubs |
75,381,758 | 6,928,142 | How to update arguments of an already started apscheduler job? | <p>I have a function called 'run' that runs for several hours and receive an argument 'param', as shown in the code below. How can I change param while the job is running?</p>
<pre><code>sched1 = BackgroundScheduler()
sched1.add_job(run, 'interval', hours = 5, args=[param])
sched1.start()
</code></pre>
<p>Regards</p>
| <python><apscheduler> | 2023-02-08 05:43:09 | 1 | 355 | SergioABP |
75,381,750 | 7,052,826 | Different user running same Python version can't import package | <p>I have an Ubuntu (18.04.6 LT)) server with multiple users. On my default user, I can do the following:</p>
<pre><code>defaultUser@server:~$ python
Python 2.7.17 (default, Mar 18 2022, 13:21:42)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more inf... | <python> | 2023-02-08 05:42:17 | 0 | 4,155 | Mitchell van Zuylen |
75,381,665 | 9,357,484 | Precision, recall, F1 score all have zero value for the minority class in the classification report | <p>I got a warning while using SVM and MLP classifiers from SkLearn package:</p>
<blockquote>
<p>C:\Users\cse_s\anaconda3\lib\site-packages\sklearn\metrics_classification.py:1327: UndefinedMetricWarning: Precision and F-score are ill-defined and being set to 0.0 in labels with no predicted samples. Use <code>zero_divis... | <python><scikit-learn><svm><mlp> | 2023-02-08 05:25:29 | 1 | 3,446 | Encipher |
75,381,655 | 1,639,926 | Looking for python packages that can calculate nodes/region/edges while respecting X,Y coordinates of nodes | <p>I have a list of cities (nodes) plotted in a 2D plane each given by an X,Y coordinate.
I now want to add roads (edges) to it, but the roads cannot intersect. I want to create the most number of roads possible. By count, not by total length.</p>
<p>In more general graph theory parlance, I think I want the maximum n... | <python><graph-theory> | 2023-02-08 05:23:42 | 0 | 862 | user1639926 |
75,381,553 | 1,344,579 | Pelican *_SAVE_AS settings set to "" are still generating pages | <p>According to the documentation for Pelican 4.8.0, I should be able to prevent the creation of certain pages by setting their value to an empty string.</p>
<p>I am the only author of my blog, and have set up a simple about me page, with more detail than the author page provides. Within the <a href="https://docs.getpe... | <python><pelican> | 2023-02-08 05:04:27 | 1 | 3,473 | NewGuy |
75,381,464 | 1,828,539 | Plot multiple multi-plot panels with seaborn | <p>I'm trying to plot three panels of 3 plots in a single figure, but all I get is an empty grid and the invidiual 3-plot panels. What am I doing wrong?</p>
<pre><code>def plot_qc_metrics(adata, key):
pg.qc_metrics(adata, min_genes=100, mito_prefix='MT-')
pg.filter_data(adata)
fig, ax = plt.subplots(... | <python><matplotlib><seaborn> | 2023-02-08 04:44:27 | 0 | 2,376 | Carmen Sandoval |
75,381,444 | 4,112,504 | solve deflection curve using scipy.solve_ivp error: 'Required step size is less than spacing between numbers.' | <p>I encountered a failure on solving deflection curve using scipy.solve_ivp when I used a big length for the beam(pipe). The following is my script.</p>
<pre><code># -*- coding: utf-8 -*-
#
# Calculate deflection curve under gravity
#
import numpy as np
from scipy.integrate import solve_ivp
import matplotlib.pyplot ... | <python><scipy><ode><runge-kutta> | 2023-02-08 04:40:01 | 0 | 340 | Jilong Yin |
75,381,432 | 17,610,082 | MYSQL Database Copy Using Python/Django | <p>I need to create a copy of the database in my MySQL Server using Django Application</p>
<p>After a little research, i found mysqldump as the better approach</p>
<pre class="lang-py prettyprint-override"><code>backup_file_path = f"/tmp/{src_database_name}_backup.sql"
backup_db_command = f"mysqldump -h... | <python><mysql><sql><django><database> | 2023-02-08 04:37:42 | 1 | 1,253 | DilLip_Chowdary |
75,381,387 | 5,254,055 | Appending to lists within loops in Python3 (again) | <p>I'm having difficulty adding to a list iteratively.</p>
<p>Here's a MWE:</p>
<pre><code># Given a nested list of values, or sets
sets = [[1, 2, 3], [1, 2, 4], [1, 2, 5]]
# add a value to each sublist giving the number of that set in the list.
n_sets = len(sets)
for s in range(n_sets):
(sets[s]).insert(0, s)... | <python><python-3.x><append><nested-lists> | 2023-02-08 04:28:02 | 1 | 567 | zazizoma |
75,381,362 | 4,414,359 | Uploading Google API python library to Lambda | <p>I have a Jupyter notebook that i've built a script in for extracting data from a Google Sheet using these two imports:</p>
<pre><code>from googleapiclient.discovery import build
from google.oauth import service_account
</code></pre>
<p>I'm trying to copy it to AWS Lambda and I'm having trouble uploading these three ... | <python><amazon-web-services><aws-lambda><google-api> | 2023-02-08 04:23:34 | 1 | 1,727 | Raksha |
75,381,208 | 4,183,877 | Serve TailwindCSS with django_plotly_dash | <p>I have a Dash app in Django being served via <a href="https://github.com/GibbsConsulting/django-plotly-dash" rel="nofollow noreferrer"><code>django-plotly-dash</code></a> and I'm using Tailwind for the styling across the site. Tailwind seems to be working everywhere except for the Dash app, where it is kind of worki... | <python><css><django><tailwind-css><plotly-dash> | 2023-02-08 03:50:52 | 1 | 1,305 | hubbs5 |
75,381,130 | 7,267,480 | very slow work with dataframe, how to avoid | <p>I have an issue with the part of code which seems to work slowly.</p>
<p>I suppose it's because of iterating through a dataframe.
Here is the code:</p>
<pre><code># creating a dataframe for ALL data
df_all = pd.DataFrame()
for idx, x in enumerate(all_data[0]):
peak_indx_E = ...
...
# TODO: spe... | <python><pandas><performance> | 2023-02-08 03:31:54 | 1 | 496 | twistfire |
75,381,109 | 998,070 | Generate a new set of points along a line | <p>I have a Python project where I need to redraw a line many times with the points in random places but keeping the line's shape and point count roughly the same. The final output will be using polygonal points and <strong>not</strong> Bezier paths (though I wouldn't be opposed to using Bezier as an intermediary step)... | <python><matplotlib><graphics><geometry> | 2023-02-08 03:24:45 | 1 | 424 | Dr. Pontchartrain |
75,381,105 | 1,828,539 | Why do these plots with same parameters look so different? logging in matplotlib vs seaborn | <p>With seaborn.histplot:</p>
<pre><code>import seaborn as sns
plot = sns.histplot(data = adata.obs, x = 'n_counts', bins=50, log_scale=True)
plot.set_xlim(1, 100000)
</code></pre>
<p><a href="https://i.sstatic.net/42Om0.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/42Om0.png" alt="enter image descri... | <python><matplotlib><seaborn> | 2023-02-08 03:23:48 | 2 | 2,376 | Carmen Sandoval |
75,380,950 | 1,106,951 | Convert complex comma-separated string into Python dictionary | <p>I am getting following string format from csv file in Pandas</p>
<blockquote>
<p>"title = matrix, genre = action, year = 2000, rate = 8"</p>
</blockquote>
<p>How can I change the string value into a python dictionary like this:</p>
<pre><code>movie = "title = matrix, genre = action, year = 2000, rate ... | <python> | 2023-02-08 02:47:27 | 3 | 6,336 | Behseini |
75,380,909 | 7,590,993 | Raspberry pi wiringPi c not able to send serial data | <p>I have a working python file for my RaspberryPi which send serial communication</p>
<pre><code>import serial # pyserial
from time import sleep
ser = serial.Serial('/dev/ttyAMA0', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_TWO)
on_packet = bytearray()
on_packet.append(0x00)
on_pac... | <python><c><raspberry-pi><serial-port> | 2023-02-08 02:39:33 | 0 | 3,672 | Hariom Singh |
75,380,890 | 1,332,521 | Python: Parse dita map file and contents and output all href values | <p>I'm a newbie Python programmer, and I was looking for a script or snippet to help. I have to parse a dita map/xml file and for every xml file, output that filename, open that file and search for referenced <code>.dita</code>, <code>.ditamap</code>, or <code>.xml</code> file, output their filename, and recurse into t... | <python><xml><dita> | 2023-02-08 02:35:13 | 2 | 329 | Russ Urquhart |
75,380,812 | 10,210,261 | Discovering Bluetooth devices in Python with M1 MacBook | <p>Is there any way to discover nearby Bluetooth devices using Python on macOS running on the newer Apple Silicon?</p>
<p>I tried <code>Pybluez</code>, but <code>lightblue</code>, one of its dependencies, doesn't seem to be supported.</p>
| <python><bluetooth><apple-m1><pybluez> | 2023-02-08 02:20:25 | 1 | 311 | Sam Lerman |
75,380,805 | 766,704 | Regex for finding numbers with or without a comma - but no other trailing symbols | <p>I need a regex that will parse a string and give me all of the numbers in it EXCEPT for things like percentage or currency.</p>
<p>So for example:</p>
<pre><code>Mario is 1,400 - which is 16% older than Luigi --> 1,400
Mario is 1400 - which is 500 years older than peach ---> 1400 500
Peach is 20% older than Lu... | <python><regex><excel-formula> | 2023-02-08 02:19:02 | 5 | 353 | Ortal |
75,380,736 | 3,136,710 | Python guessing game exercise - confused about the description and the math | <p>My questions are on the bottom.</p>
<p>This exercise is based on a guessing game where the user (you) inputs a lower and upper bound int and then the PC picks a random number within those boundaries. Your job is to guess the number and the program tells the user if the guess is greater than, less than, or equal to t... | <python> | 2023-02-08 02:05:31 | 1 | 652 | Spellbinder2050 |
75,380,478 | 2,491,592 | For each group add a new shifted column based on the value in another column | <p>Given the dataframe below, I am trying to add a new shifted column based on yes/no value in the column start. However, my attempts are not really effective.</p>
<pre><code>id Name type start
AAA A xx yes
AAA B yy no
AAA C xx no
BBB C xx yes
B... | <python><pandas><dataframe> | 2023-02-08 01:07:44 | 2 | 315 | K3it4r0 |
75,380,343 | 6,293,211 | Import png into Excel and change its height and width | <p>I use the following code to import the <code>image.png</code> file into the excel sheet <code>image_in_excel.xlsx</code> at cell location <code>D5</code>. I also attempt to change the width and height of the imported image.</p>
<p><strong>Issue</strong>:
The image imports successfully. However, irrespective of whate... | <python><excel><image><xlsxwriter> | 2023-02-08 00:33:11 | 1 | 466 | Sinha |
75,380,282 | 5,212,614 | How can we use Feature Importance to Find the 'Worst' Features? | <p>I have some data at work that is confidential so I can't share it here, but the dataset below illustrates the point quite well. Basically, I want to run a feature importance exercise to find the top independent features (in this case, RM, LSTAT, and DIS) that have the most influence on the dependent feature (MDEV). ... | <python><python-3.x><machine-learning><data-science><feature-selection> | 2023-02-08 00:18:47 | 0 | 20,492 | ASH |
75,380,233 | 7,882,846 | Non-Linear Least Square Fitting Using Python | <p>I am trying to find the optimal parameter values based on 2 dimensional data.
<br>
I searched for other Q&A threads and one of the questions looked similar to mine and the answer seemed to be duable <a href="https://stackoverflow.com/questions/40046961/non-linear-least-squares-fitting-2-dimensional-in-python">li... | <python><curve-fitting><scipy-optimize><nonlinear-optimization> | 2023-02-08 00:09:29 | 1 | 439 | Todd |
75,380,186 | 17,487,457 | How to drop one of any two highly correlated features having low correlation with target | <p>I am working with the breast cancer dataset included in the <a href="https://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_breast_cancer.html#sklearn.datasets.load_breast_cancer" rel="nofollow noreferrer">scikit-learn's</a> package, loaded like so:</p>
<pre class="lang-py prettyprint-override"><co... | <python><machine-learning><scikit-learn><classification><feature-selection> | 2023-02-07 23:59:11 | 1 | 305 | Amina Umar |
75,380,064 | 251,276 | How do I create a Dask DataFrame partition by partition and write portions to disk while the DataFrame is still incomplete? | <p>I have python code for data analysis that iterates through hundreds of datasets, does some computation and produces a result as a pandas DataFrame, and then concatenates all the results together. I am currently working with a set of data where these results are too large to fit into memory, so I'm trying to switch f... | <python><pandas><dataframe><dask> | 2023-02-07 23:37:06 | 1 | 10,920 | Colin |
75,380,003 | 220,225 | Clean setup of pip-tools doesn't compile very basic pyproject.toml | <p>Using a completely new <code>pip-tools</code> setup always results in a <code>Backend subprocess exited</code> error.</p>
<p><code>pyproject.toml</code>:</p>
<pre class="lang-ini prettyprint-override"><code>[project]
dependencies = [
'openpyxl >= 3.0.9, < 4',
]
</code></pre>
<p>Running pip-tools in an empty ... | <python><pip-tools> | 2023-02-07 23:28:10 | 1 | 600 | Windowlicker |
75,379,948 | 19,840,632 | What is correct mapped annotation for `JSON` in SQLAlchemy 2.x version? | <p>The new version of SQLAlchemy introduced the ability to use type annotations using Mapped[Type] (<a href="https://docs.sqlalchemy.org/en/20/orm/declarative_tables.html#using-annotated-declarative-table-type-annotated-forms-for-mapped-column" rel="noreferrer">link</a>).</p>
<p>My question is, what should we use as an... | <python><json><sqlalchemy> | 2023-02-07 23:18:35 | 3 | 459 | May Flower |
75,379,889 | 18,476,381 | Python groupby/convert a triple join table to nested dictionary | <p>From a SQL stored procedure that performs a join on 3 tables I get the data below.</p>
<pre><code> data = [
{"service_order_number": "ABC", "item_id": 0, "ticket_id": 10},
{"service_order_number": "ABC", "item_id": 0, "tick... | <python><json><dictionary><nested> | 2023-02-07 23:08:11 | 1 | 609 | Masterstack8080 |
75,379,771 | 17,696,880 | How to validate if a date indicated as a string belongs to an interval of 2 dates indicated in another string? | <pre class="lang-py prettyprint-override"><code>import os, datetime
content = os.listdir("when")
print(content)
#this print...
#['2022_-_12_-_29 12pp33 am _--_ 2023_-_01_-_25 19pp13 pm.txt', '2023-02-05 00pp00 am.txt']
for i in range(len(content)):
content[i] = content[i].replace("_-_", "... | <python><python-3.x><regex><date><datetime> | 2023-02-07 22:49:07 | 2 | 875 | Matt095 |
75,379,715 | 4,931,020 | Python: creating a class instance via static method vs class method | <p>Let's say I have a class and would like to implement a method which creates an instance of that class. What I have is 2 options:</p>
<ol>
<li>static method,</li>
<li>class method.</li>
</ol>
<p>An example:</p>
<pre><code>class DummyClass:
def __init__(self, json):
self.dict = json
@staticmethod
... | <python><oop><static-methods><class-method> | 2023-02-07 22:42:18 | 1 | 739 | kaksat |
75,379,579 | 4,159,530 | "Invalid operation" error in resizeGL after window closed | <ul>
<li>Window 10 64-bit</li>
<li>Python 3.8</li>
<li>PyQt 6.3.0</li>
<li>PySide 6.3.1</li>
<li>PyOpenGL 3.1.6</li>
</ul>
<p>When I close the window, I get an "Invalid operation" error in resizeGL() on the line with the glViewport() function. This happens with PyQt6 and PySide6.</p>
<pre class="lang-py prett... | <python><pyqt><pyside><pyside6><pyqt6> | 2023-02-07 22:21:41 | 0 | 1,212 | 8Observer8 |
75,379,387 | 4,035,296 | Python tkinter canvas events not triggering on scrolled region | <p>I am making a python progrem using Tkint GUI and the canvas element. I attached a scrollbar to the canvas element so that the user can scroll to unseen regions of the canvas. I created a dotted grid that would allow the user to hover over the dots and if clicked the program draws a circle over the dot. Also as the m... | <python><tkinter><tkinter-canvas> | 2023-02-07 21:55:27 | 1 | 571 | Salvo |
75,379,195 | 1,476,285 | What workflow can I use for moving from Poetry environment from dev to prod? | <p>I've been coding small personal projects using <em>conda</em> for years. Recently I've been working on a higher volume of projects without the need for scientific packages, so I decided to switch over to standard Python. I am now using poetry as my package manager.</p>
<p>My development environment is working fine, ... | <python><virtualenv><python-poetry> | 2023-02-07 21:31:34 | 1 | 413 | pedwards |
75,379,185 | 880,874 | How can I loop through my arrays and build a list of SQL INSERT commands? | <p>I'm trying to build some SQL INSERT commands using data from arrays.</p>
<p>My problem is, I can't figure out how to iterate through all of them at the same time.</p>
<p>Here is my beginning code:</p>
<p>import os</p>
<pre><code>raceValues = [
"Human",
"Elf",
"Orc"
]
... | <python><python-3.x> | 2023-02-07 21:30:21 | 2 | 7,206 | SkyeBoniwell |
75,379,184 | 10,963,057 | plotly range slider without showing line in small | <p>I want to use Plotly to generate a line chart with a range slider. the range slider shows the displayed line again. this code is just an example. in my case, I have a lot of subplots and everything is shown twice. is it possible to show nothing or only the date in the range slider?</p>
<pre><code>import plotly.expre... | <python><plotly><visualization><rangeslider> | 2023-02-07 21:30:19 | 1 | 1,151 | Alex |
75,379,119 | 9,816,919 | How can I partition `itertools.combinations` such that I can process the results in parallel? | <p>I have a massive quantity of combinations (86 choose 10, which yields 3.5 trillion results) and I have written an algorithm which is capable of processing 500,000 combinations per second. I would not like to wait 81 days to see the final results, so naturally I am inclined to separate this into many processes to be ... | <python><math><combinations> | 2023-02-07 21:22:11 | 2 | 853 | Gaberocksall |
75,379,085 | 459,975 | Why is Pandas to_datetime is stripping nanoseconds with one format string, but not another? | <p>I am attempting to convert a timestamp with nanoseconds to a Pandas datetime object via <code>pandas.to_datetime</code>.</p>
<p>The following does what I expect:</p>
<pre><code>print(pandas.to_datetime('2023-01-02 03:04:05.012345678', format='%Y-%m-%d %H:%M:%S.%f'))
> 2023-01-02 03:04:05.012345678
</code></pre>
<... | <python><pandas><datetime> | 2023-02-07 21:16:33 | 1 | 4,601 | Chuu |
75,379,032 | 3,162,724 | Python - Azure function service bus trigger batch processing | <p>I am using Azure function service bus trigger in Python to receive messages in batch from a service bus queue. Even though this process is not well documented in Python, but I managed to enable the batch processing by following the below Github PR.</p>
<p><a href="https://github.com/Azure/azure-functions-python-libr... | <python><azure><azure-functions><azureservicebus><azure-python-sdk> | 2023-02-07 21:11:23 | 1 | 5,992 | Niladri |
75,379,028 | 528,369 | Fix mypy error (got "signedinteger[Any]", expected "int") | <p>Mypy says</p>
<pre><code>first.py:11: error: Incompatible return value type (got "signedinteger[Any]", expected "int") [return-value]
</code></pre>
<p>for the code</p>
<pre><code>import numpy as np
import numpy.typing as npt
def first_true_pos(x: npt.NDArray) -> int:
""" f... | <python><mypy> | 2023-02-07 21:10:59 | 0 | 2,605 | Fortranner |
75,379,000 | 2,654,794 | python one liner for assignment in loop | <p>In two lines I can do something like:</p>
<pre><code>for object in object_list:
object.param = 10
</code></pre>
<p>Is there any way to do this in one line?</p>
<p>something like:</p>
<pre><code>(object.param = 10) for object in object_list
</code></pre>
| <python><one-liner> | 2023-02-07 21:07:23 | 1 | 346 | pongoS |
75,378,976 | 4,784,683 | Qt - does it make sense to call QTreeView::dataChanged() from within QTreeView::currentChanged()? | <p>I have existing code that I'm modifying.</p>
<p>It derives a class, <code>MyTreeView</code>, from <code>QTreeview</code> and re-implements <code>currentChanged()</code>.</p>
<p>Does it make sense to call <code>dataChanged()</code> here? Since <code>currentChanged()</code> is only called when the selection changes, i... | <python><c++><qt> | 2023-02-07 21:05:39 | 0 | 5,180 | Bob |
75,378,968 | 7,760,910 | unable to fetch record based on a specific key in dynamo db and python | <p>I have a child class where I am trying to fetch the dynamo db data based on a specific key, I tried multiple variations of passing a value to the key but somehow I am getting an error on the response.</p>
<pre><code>class AdGroupDetailsRepository(Repository):
def __init__(self, client, table_name):
super... | <python><amazon-web-services><amazon-dynamodb> | 2023-02-07 21:05:05 | 1 | 2,177 | whatsinthename |
75,378,950 | 1,783,632 | subprocess.run gives me error "UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128)" python 3.6 | <p>I wrote a script in python3.9 and used subprocess.run to run shell scripts from inside the python, As a requirement, I needed to downgrade to <strong>python3.6</strong>, and some of the code needed to change.</p>
<p>What hasn't changed is the way I run the sub processes but for some reason, I now get an error like:<... | <python><python-3.x><python-3.6> | 2023-02-07 21:03:31 | 1 | 6,237 | Shahar Hamuzim Rajuan |
75,378,903 | 7,951,365 | Create clusters depending on scores performance | <p>I have data from students who took a test that has 2 sections : the 1st section tests their digital skill at level2, and the second section tests their digital skills at level3. I need to come up with 3 clusters of students depending on their scores to place them in 3 different skills levels (1,2 and 3) --> code ... | <python><cluster-analysis><k-means> | 2023-02-07 20:57:12 | 1 | 490 | Kathia |
75,378,747 | 10,266,106 | Moving Window Calculation Across Multiple Arrays | <p>I have several two-dimensional data arrays loaded into NumPy arrays, all of which have identical dimensions. These shared dimensions are 2606x and 1228y.</p>
<p>I am interested in computing calculations between the first two arrays (a1 & a2) across a moving window, using a window sized 2x by 2y, with the resulta... | <python><arrays><numpy><numpy-ndarray> | 2023-02-07 20:37:21 | 1 | 431 | TornadoEric |
75,378,726 | 3,919,277 | How can I set up Python virtual environment in VScode so that it views locally-installed modules? | <p>I have created a virtual environment via the command line</p>
<pre><code>python3.11 -m venv .
source ./bin/activate
python -m pip install NAME_OF_MODULE
source deactivate
</code></pre>
<p>I can see the installed modules when I run <code>pip freeze</code> (prior to deactiving). So far so good.</p>
<p>T... | <python><visual-studio-code> | 2023-02-07 20:35:01 | 1 | 421 | Nick Riches |
75,378,642 | 11,814,875 | Scrapy redirecting [302 to 200] but url isn't updating | <p>I'm trying to fetch redirected url from a url using Scrapy</p>
<p>Response status changes from 302 to 200 but still the url isn't changing.</p>
<pre class="lang-py prettyprint-override"><code>from scrapy import Spider
from scrapy.crawler import CrawlerProcess
class MySpider(Spider):
name = 'test'
start_u... | <python><python-3.x><web-scraping><scrapy> | 2023-02-07 20:25:26 | 1 | 491 | rish_hyun |
75,378,245 | 3,403,293 | GeoPandas.explore MultiPolygon not serializable | <p>I have my own dataset containing MultiPolygon definitions, and I want to plot them using GeoPandas <code>explore</code> function. I have followed the steps outlined at: <a href="https://geopandas.org/en/stable/getting_started/introduction.html" rel="nofollow noreferrer">https://geopandas.org/en/stable/getting_starte... | <python><geopandas><shapely> | 2023-02-07 19:40:51 | 1 | 320 | wikenator |
75,378,240 | 4,772,565 | How to use absolute import in source code when using requirements.txt, Python3? | <p>I have a Python project with this directory structure:</p>
<pre><code>my_project
|
|_venv/
|
|_requirements.txt
|
|_src
|
|_main.py
|
|_input_data.py
</code></pre>
<p>The file of <code>requirements.txt</code> is:</p>
<pre><code>numpy
pydantic
</code></pre>
<p>The file of <code>input_data.py</code></p>
<pre c... | <python><pip><python-import><requirements.txt> | 2023-02-07 19:40:09 | 2 | 539 | aura |
75,378,119 | 303,056 | Pulumi runtime can't find pulumi library | <p>I keep hitting this problem where the <code>pulumi</code> CLI tool runs, but whenever I try to do anything with it like <code>pulumi up</code> or <code>pulumi preview</code> it gives me this error that it can't find its own library:</p>
<pre><code> Traceback (most recent call last):
File "/home/ubuntu/... | <python><conda><pulumi><pulumi-python> | 2023-02-07 19:29:19 | 1 | 42,939 | Leopd |
75,378,061 | 528,369 | How to use mypy to ensure that a NumPy array of floats is passed as function argument? | <p>Can mypy check that a NumPy array of floats is passed as a function argument? For the code below mypy is silent when an array of integers or booleans is passed.</p>
<pre><code>import numpy as np
import numpy.typing as npt
def half(x: npt.NDArray[np.cfloat]):
return x/2
print(half(np.full(4,2.1)))
print(half(np... | <python><numpy><numpy-ndarray><mypy> | 2023-02-07 19:23:42 | 1 | 2,605 | Fortranner |
75,378,037 | 8,187,191 | expo-av recording to flask api | <p>I am trying to build an app using React-Native that will record a sound on a mobile device, using expo-av, and send it to a Flask API.</p>
<p><strong>The problem</strong> is that the data I receive from expo-av, into the API, is in an unexpected format. I would like to retrieve the signal/wave data of the sound but ... | <python><react-native><flask><expo> | 2023-02-07 19:20:42 | 1 | 1,028 | Claudio Paladini |
75,378,025 | 3,763,616 | How to complete a self join in python polars vs pandas sql? | <p>I am trying to use python polars over pandas sql for a large dataframe as I am running into memory errors. There are two where conditions that are utilized in this dataframe but can't get the syntax right.</p>
<p>Here is what the data looks like:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<... | <python><python-polars> | 2023-02-07 19:19:05 | 1 | 489 | Drthm1456 |
75,377,986 | 20,266,647 | Exception during ingestion, MLRunAccessDeniedError | <p>I got this issue during data ingest/write:</p>
<pre><code>~/.pythonlibs/jist-jupyter/lib/python3.7/site-packages/mlrun/errors.py in raise_for_status(response, message)
82 raise STATUS_ERRORS[response.status_code](
83 error_message, response=response
---> 84 ) from... | <python><mlops><feature-store><mlrun> | 2023-02-07 19:14:33 | 1 | 1,390 | JIST |
75,377,927 | 5,659,966 | Django filter on list of column values | <p>I'm using Django 3.2 and Postgres 13.</p>
<p>I have a simple model:</p>
<pre class="lang-py prettyprint-override"><code>from django.db import models
class Member(models.Model):
user = models.ForeignKey("User", on_delete=models.CASCADE)
group = models.ForeignKey("Group", on_delete=model... | <python><django><django-orm> | 2023-02-07 19:09:05 | 0 | 780 | Lotram |
75,377,863 | 14,012,215 | EOF occurred in violation of protocol (_ssl.c:2396) when connecting to odoo 15 | <p>I am running a django app that connects to an Odoo instance. Like so</p>
<pre><code>userlog = request.user
if request.method == 'GET':
# return render(request, 'inventory_updates.html')
products = models.execute_kw(db, uid, password, 'product.product', 'search_read', [[['type', 'in', ['product', 'c... | <python><ssl><odoo> | 2023-02-07 19:02:43 | 0 | 433 | apexprogramming |
75,377,514 | 5,016,440 | Plotly: changing axis range in surface subplots | <p>I have the following minimal reproducible example and can't find how to change the z-axis range for the subplots</p>
<pre><code>import plotly.graph_objects as go
from plotly.subplots import make_subplots
import numpy as np
main_fig = make_subplots(
rows= 4,
cols= 4,
specs = [[{'type': 'surface'} for k in range(4)]... | <python><plotly> | 2023-02-07 18:27:04 | 2 | 455 | nestor556 |
75,377,479 | 12,845,199 | Acessing multiple anchor elements inside text | <p>I have the following XPATH</p>
<pre><code>//a[@class='product-cardstyles__Link-sc-1uwpde0-9 bSQmwP hyperlinkstyles__Link-j02w35-0 coaZwR']
</code></pre>
<p>This xpath, finds a lot of anchor tags similar to the following HTML sample</p>
<pre><code><a href="/produto/10669/acucar-refinado-da-barra-pacote-1kg&qu... | <python><selenium><xpath><webdriverwait> | 2023-02-07 18:23:42 | 2 | 1,628 | INGl0R1AM0R1 |
75,377,374 | 105,589 | OpenAI Embeddings API: How to get an embedding and calculate cosine similarity? | <p>I have an OpenAI embedding generated from their API.</p>
<p>I see examples of putting that vector into Postgres or Sqlite and then running a query against it.</p>
<p>I'm looking for simple code in python where I can use a text string and see how close the cosine distance for that text. I believe that cosine distance... | <python><openai-api> | 2023-02-07 18:13:21 | 3 | 4,091 | xrd |
75,377,281 | 12,694,438 | Method suggestions don't work for 'nltk.corpus.wordnet` (vscode) | <p>When I write <code>nltk.corpus.wordnet.</code>, method suggestions don't show up and I can't see the signatures of the functions that I call, even though the code executes fine.</p>
<p>This happens both in notebook and in regular <code>.py</code> files.</p>
<hr />
<pre class="lang-py prettyprint-override"><code>impo... | <python><nltk><wordnet> | 2023-02-07 18:01:45 | 1 | 944 | splaytreez |
75,377,265 | 4,414,359 | How do add python libraries to AWS Lambda? | <p>I just made my first function that fetches data from an excel sheet in Google Sheets. I got an error:</p>
<p><code>"errorMessage": "Unable to import module 'lambda_function': No module named 'googleapiclient'"</code></p>
<p>so i googled how to upload python modules (<a href="https://www.youtube.c... | <python><amazon-web-services><aws-lambda><google-api> | 2023-02-07 18:00:40 | 4 | 1,727 | Raksha |
75,377,184 | 2,575,155 | how to improve the performance python script for extracting big size(3-4GB)of oracle table | <p>I'm connecting to oracle database using python script and extracting around 10 tables. one table is having 3Gb of data it took around 4 hours to extract with below code and upload it to S3. How can we improve the performance of the below python script?</p>
<p>Different file format other than csv will improve the per... | <python><python-3.x><oracle-database> | 2023-02-07 17:53:09 | 0 | 736 | marjun |
75,377,023 | 5,349,476 | Hough lines missing some lines | <p>I'm trying to detect lines in an irregular image using a relatively low <code>threshold</code> of 5. The result I get is the following:</p>
<p><a href="https://i.sstatic.net/KX0mH.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/KX0mH.png" alt="enter image description here" /></a></p>
<p>where red line... | <python><opencv><signal-processing><technical-indicator> | 2023-02-07 17:37:23 | 1 | 2,742 | John M. |
75,376,998 | 3,168,283 | Error: invalid command 'bdist_wheel' with setuptools==67.1.0 | <p>I'm getting tje following error after having upgraded <code>setuptools</code> to version 67.1.0:</p>
<pre><code>% python setup.py bdist_wheel
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error:... | <python><pypi> | 2023-02-07 17:34:21 | 0 | 683 | takachanbo |
75,376,787 | 2,755,116 | Flatten list of whatever objects | <p>I want to flatten a list whatever the values of list are:</p>
<p>Example:</p>
<pre><code>[1, 2, 1] --> [1, 2]
[[1, 2], [2, 1] --> [1, 2]
</code></pre>
<p>Now I have a code which have very cases depending of the type of the objects in the list (first example numbers, second example list).</p>
<p>Is there a uni... | <python><list><flatten> | 2023-02-07 17:13:54 | 1 | 1,607 | somenxavier |
75,376,695 | 6,775,101 | Generics, inheritance - TypeVar bound class fails mypy check | <p>hope i won't leave out anything important. My very much simplified situation is like this:</p>
<p>In my domain I have some defined data structures:</p>
<pre><code>@dataclass
class Model:
var_1: str
var_2: str
class Book(Model):
...
class Page(Model):
...
</code></pre>
<p>I want to have 2 abstractio... | <python><generics><inheritance><mypy> | 2023-02-07 17:03:57 | 1 | 716 | jiripi |
75,376,519 | 661,740 | Pytest mocker failing to find Path | <p>I am working with someone else's testing code, and they make extensive use of mocker. The problem is that I changed the underlying code so it tests for the existence of a file using Path ().is_file.</p>
<p>Now I need to mock Path ().is_file so it returns True. I tried this:</p>
<pre><code>from pathlib import Path
@... | <python><pytest><pytest-mock> | 2023-02-07 16:49:46 | 1 | 3,511 | Greg Dougherty |
75,376,379 | 1,132,408 | Inserting pandas dataframe with float values into Oracle | <p>I can insert normal values like integer, string into Oracle from pandas data frame but when I try float type values , sqlalchemy gives below errors</p>
<pre><code>sqlalchemy.exc.ArgumentError: Oracle FLOAT types use 'binary precision', which does not convert cleanly from decimal 'precision'. Please specify this typ... | <python><pandas><dataframe><sqlalchemy><cx-oracle> | 2023-02-07 16:35:44 | 2 | 335 | Justin Mathew |
75,376,266 | 1,581,090 | How to get the complete response from a telnet command using python? | <p>I am trying to use python 3.10.9 on windows to create a telnet session using <a href="https://docs.python.org/3/library/telnetlib.html" rel="nofollow noreferrer">telnetlib</a>, but I have trouble to read the complete response.</p>
<p>I create a telnet session like</p>
<pre><code>session = telnetlib.Telnet(host, port... | <python><telnet><telnetlib> | 2023-02-07 16:26:30 | 1 | 45,023 | Alex |
75,376,241 | 6,895,840 | Mutagen using forward slash as delimiter | <p>I'm using mutagen to collect information about given MP3 files. It's working but there is one problem. When a song has mutliple artists it uses a forward slash as a delimiter. So the TPE1 tag may return the following when the song is, e.g., a collaboration between AC/DC and Ministry:</p>
<pre><code>['Ministry/AC/DC'... | <python><mutagen> | 2023-02-07 16:24:06 | 1 | 1,156 | Anteino |
75,376,225 | 15,045,363 | Saving partial result of df.apply after exception | <p>How to get the partial result computed by <code>df.apply()</code> when an Exception is raised within the function?</p>
<h2>Context</h2>
<p>I have a Pandas dataframe where values are missing. To get this values I have to call a REST API for each row (which take time). To do that, I use the <code>apply()</code> functi... | <python><pandas><exception> | 2023-02-07 16:22:43 | 0 | 865 | Maxime Charrière |
75,376,167 | 9,536,103 | Equivalent function of pytesseract.image_to_data in tesserocr | <p>I am currently using <code>pytesseract.image_to_data</code> on several images but this is incredibly slow so I was thinking of moving over to <code>tesserocr</code>.</p>
<p>I can't seem to find an equivalent function though that gives me the positions of all the pieces of text on the page as well as breaking them in... | <python><image-processing><ocr><python-tesseract> | 2023-02-07 16:17:32 | 0 | 1,151 | Daniel Wyatt |
75,376,061 | 9,773,920 | Export redshift table data to csv file tabs using lambda python | <p>I have a table metric_data that has data in the below format:</p>
<p><a href="https://i.sstatic.net/1oKfu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/1oKfu.png" alt="enter image description here" /></a></p>
<p>I want to export this data into csv file in S3 with separate tabs for components. So I w... | <python><pandas><csv><aws-lambda><amazon-redshift> | 2023-02-07 16:08:50 | 1 | 1,619 | Rick |
75,376,021 | 11,436,357 | Why playwright isn't modifying request body? | <p>I need to modify the request body that is sent by the browser, i do it like this:</p>
<pre class="lang-py prettyprint-override"><code>async def handle_uri_route(route: Route):
response = await route.fetch()
response_json = await response.json()
reg_notification_uri = response_json['confirmUri']
awai... | <python><playwright><playwright-python> | 2023-02-07 16:05:10 | 0 | 976 | kshnkvn |
75,376,016 | 17,897,456 | How to compute the next minute of a time in Python? | <p>So I have a <code>datetime.datetime</code> object and I want to compute the next minute of it. What I mean by next minute is the same time but at the very beginning of the next minute. For example, the next minute of 16:38:23.997 is 16:39:00.000.</p>
<p>I can do that easily by adding 1 to the minute and setting ever... | <python><datetime> | 2023-02-07 16:04:30 | 1 | 710 | Mateo Vial |
75,375,938 | 3,654,588 | Cython: efficient memoryview of type "object" such that it can be used in nogil function | <p>I am currently using the new NUMPY_1_7 C API and Cython 0.29+. Usage of types like <code>cnp.ndarray</code> are deprecated and it is preferred to use a Cython memoryview instead.</p>
<p>However, part of my code stores a ndarray of type 'object'. E.g.</p>
<pre><code>cdef class A:
cdef cnp.ndarray buff
cdef voi... | <python><cython><cythonize> | 2023-02-07 15:58:22 | 0 | 1,302 | ajl123 |
75,375,918 | 10,270,590 | How to have multiple input and output connection for an Airflow DAG task use a global variable pandas data frame with in @task.external_python? | <h2>GOAL</h2>
<ul>
<li>I use the Docker 2.4.1 version of Airflow</li>
<li>I use my external python virtual environment for each task</li>
<li>I have a normal python integer that I want to pass on from task to task.</li>
<li>I should start form 1 graph point the "start" than it should push it's result to x, y,... | <python><airflow><directed-acyclic-graphs><airflow-2.x> | 2023-02-07 15:56:16 | 1 | 3,146 | sogu |
75,375,906 | 240,795 | Can pyinstaller make a desktop file (with an icon) for an Ubuntu python app | <p>I'm building a python app which is to pack up as a single executable and work on Windows, MacOS and Linux. Have made a lot of progress and am using a workflow on Github to build using pyinstaller for each OS. Most things are working fine.</p>
<p>Right now I am working on getting an icon onto the executable instead o... | <python><linux><pyinstaller><desktop> | 2023-02-07 15:55:00 | 2 | 2,140 | Kibi |
75,375,612 | 11,668,258 | How to convert Neo4j response into JSON | <p>Convert stream of records from NEO4j get by NEO4J python driver into JSON. simply, I want to convert the results of cypher queries in neo4j into a JSON format.
Below is output got from NEO4J</p>
<pre><code><Record n=<Node id=3099 labels=frozenset({'BusinessData'}) properties={'Description': 'sample description... | <python><json><python-3.x><neo4j><neo4j-python-driver> | 2023-02-07 15:33:27 | 1 | 916 | Tono Kuriakose |
75,375,549 | 5,235,665 | Adding Python library to Flask app requirements.txt | <p>Long time Java dev who inherited a Python (Flask) application that is in dire need of some maintenance. Instead of using env vars or system properties or <em>any</em> kind of configuration (!!!) all the connections and credentials are <strong>hardcoded</strong> right there in the source code. Yikes.</p>
<p>Trying to... | <python><macos><pip><dotenv> | 2023-02-07 15:29:24 | 2 | 845 | hotmeatballsoup |
75,375,485 | 3,025,555 | Socket IO returns 127.0.0.1 as host address, randomly, instead of the public IP Of the device | <p>Trying to get host-IP Through Python, using socket module -
Occasionally, i get address 127.0.0.1 and not the real IP Address - i.e 10.210.24.24</p>
<p>I've adjusted my code per the answer in:</p>
<p><a href="https://stackoverflow.com/questions/72331707/socket-io-returns-127-0-0-1-as-host-address-and-not-192-168-0-o... | <python><python-3.x><socket.io><dns> | 2023-02-07 15:25:16 | 0 | 1,225 | Adiel |
75,375,458 | 5,197,329 | pygame triggers "pycharm not responding" popup message, how to prevent/supress this message? | <p>I have created a small game in python using pygame. The game is a 2-player game, and has various player modes including random cpu. When I allow two cpu players to play against each other it works well, except for the problem that pycharm shows a "pycharm not responding" popup message after around 5 second... | <python><pycharm> | 2023-02-07 15:23:25 | 1 | 546 | Tue |
75,375,442 | 14,269,252 | what is version of spark and pyspark compatible with python 3.10 | <p>I built a virtual environment and I installed these version of packages. it throws an error as follows and it is because of not being compatible packages, what is the best version of spark and Pyspark which is compatible with my version of Python?</p>
<pre><code>java version: openjdk 11.0.11 2021-04-20
spark versio... | <python><apache-spark><pyspark> | 2023-02-07 15:22:12 | 1 | 450 | user14269252 |
75,375,354 | 9,944,937 | add values to each array in a 2D numpy array | <p>I'm looking for a way to efficiently add a fixed number of <code>np.nan</code> values at the beginning of each array in a numpy array of shape (3,123...):</p>
<pre><code>Original numpy array:
[[1,2,3...],
[4,5,6...],
[7,8,9...]]
New numpy array:
[[nan,nan,1,2,3...],
[nan,nan,4,5,6...],
[nan,nan,7,8,9...]]
</c... | <python><arrays><numpy> | 2023-02-07 15:15:39 | 2 | 1,101 | Fabio Magarelli |
75,375,250 | 18,221,164 | Getting a 401 response while using Requests package | <p>I am trying to access a server over my internal network under <code>https://prodserver.de/info</code>.
I have the code structure as below:</p>
<pre><code>import requests
from requests.auth import *
username = 'User'
password = 'Hello@123'
resp = requests.get('https://prodserver.de/info/', auth=HTTPBasicAuth(usernam... | <python><python-requests><http-error> | 2023-02-07 15:07:32 | 2 | 511 | RCB |
75,375,222 | 6,414 | PyCharm [Intellij] auto-import from Binary Skeletons instead of standard python library | <p>I'm trying to import Decimal from <code>decimal</code> but when I try and do this using Intellij it just says I can import from <code>_decimal</code> instead which is in the Binary Skeletons.</p>
<p>I'm using Poetry and Python 3.10, and it's almost certainly something wrong with my setup, I just can't work out what.... | <python><intellij-idea><pycharm><python-3.10> | 2023-02-07 15:05:12 | 2 | 8,037 | Henry B |
75,375,139 | 2,403,819 | Can I get the black python code format tool to recognize what directory my code is in | <p>I am trying to integrate the black python code formatting tool into my workflow. As a test I have created a directory with the following structure.</p>
<pre><code>hello
|_ pyproject.toml
|_ hello
|_main.py
</code></pre>
<p>The pyproject.toml file has the following information in it.</p>
<pre><code>[tool.poetry]... | <python><python-3.x><python-black> | 2023-02-07 14:59:13 | 1 | 1,829 | Jon |
75,375,121 | 7,194,271 | how to solve "Unresolved reference 'unpack'" in python3.7? | <p>when I check the code in <a href="https://www.kaggle.com/code/hengck23/3hr-tensorrt-nextvit-example" rel="nofollow noreferrer">kaggle 3hr-tensorrt-nextvit-example</a>, I find there is a error that I can not solve. it is called <strong>Unresolved reference</strong> '<strong>unpack</strong>'.what should I do?</p>
<pre... | <python><python-3.x><reference> | 2023-02-07 14:57:48 | 1 | 380 | Hong Cheng |
75,375,116 | 243,031 | docker python:3.9 image gives error for scripts | <p>We are using <code>python:3.9</code> image for the base, and run some command on that.</p>
<p><strong>Base Image</strong></p>
<pre><code>########################
# Base Image Section #
########################
#
# Creates an image with the common requirements for a flask app pre-installed
# Start with a smol OS
... | <python><docker><image><containers> | 2023-02-07 14:57:14 | 0 | 21,411 | NPatel |
75,375,099 | 7,192,318 | ctypes.c_int.from_address does not work in RStudio | <p>I am trying to count references to an object in Python using the RStudio. I use following function:</p>
<pre><code> ctypes.c_int.from_address(id(an_object)).value
</code></pre>
<p>This work perfectly in Pycharm and Jupyter as shown bellow:</p>
<p><a href="https://i.sstatic.net/YcbTx.png" rel="nofollow noreferrer"><i... | <python><rstudio> | 2023-02-07 14:55:13 | 1 | 625 | Masoud |
75,375,096 | 1,056,179 | Finding the date diff between all pairs of dates in an array without using two loops | <p>I have a huge array containing dates as its element:</p>
<pre><code>arr = ['01/01/2020', '15/11/2021', '05/07/2018', '01/03/2020', '10/10/2022', '07/02/2015', ....]
</code></pre>
<p>I would like to find the date difference between all pairs but using two loops has a time complexity of <strong>O(nˆ2)</strong>. I thin... | <python><algorithm> | 2023-02-07 14:54:53 | 2 | 2,059 | Amir Jalilifard |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.