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 ⌀ |
|---|---|---|---|---|---|---|---|---|
74,844,191 | 9,373,756 | Why polars date time subseting is slow? | <p>I'm looking for a faster way to subset a polars dataframe using datetime. I tried 2 different ways and I believe there is a faster way since I also tried with pandas and it was faster:</p>
<pre><code>datetime.datetime(2009, 8, 3, 0, 0)
datetime.datetime(2009, 11, 3, 0, 0)
# - 1st
%%timeit
df_window = df_stock.filt... | <python><pandas><dataframe><python-polars> | 2022-12-18 20:31:34 | 1 | 725 | Artur |
74,844,113 | 11,809,811 | hidden titlebar makes app not show up in task switcher? | <p>I have a simple tkinter app and I want to hide the titlebar. I am doing that via:</p>
<pre><code>root.overrideredirect(True)
</code></pre>
<p>and that works fine. However, the resulting window has no icon in the taskbar and when switching the windows using Alt + Tab the window does not appear. I created an exe file ... | <python><tkinter> | 2022-12-18 20:17:41 | 1 | 830 | Another_coder |
74,844,103 | 20,800,676 | Project Euler #79: Using the Python standard library only, can a function be defined to sort the Passcode digits order from the given set? | <p>The problem in matter can be found here: <a href="https://projecteuler.net/problem=79" rel="nofollow noreferrer">Problem #79</a></p>
<p>"A common security method used for online banking is to ask the user for three random characters from a passcode. For example, if the passcode was 531278, they may ask for the ... | <python><python-3.x> | 2022-12-18 20:14:53 | 2 | 541 | Sigmatest |
74,844,094 | 11,653,374 | Projection onto unit simplex using gradient decent in Pytorch | <p>In Professor Boyd <a href="https://see.stanford.edu/materials/lsocoee364b/hw4sol.pdf" rel="nofollow noreferrer">homework solution</a> for projection onto the unit simplex, he winds up with the following equation:</p>
<pre><code>g_of_nu = (1/2)*torch.norm(-relu(-(x-nu)))**2 + nu*(torch.sum(x) -1) - x.size()[0]*nu**2 ... | <python><pytorch><gradient-descent> | 2022-12-18 20:12:43 | 1 | 728 | Saeed |
74,843,820 | 10,797,718 | Compute Aspect Ratio of a Rectangle in Perspective | <p>A popular question but for which I can't find a <strong>definitive answer</strong>. <em>Math wizards we need you!</em></p>
<h2>The Problem is the following</h2>
<p>We have a <strong>unmodified photograph</strong> (not cropped) of a <strong>rectangular object</strong> taken from some angle. We don't know the real siz... | <python><computer-vision><geometry><computational-geometry> | 2022-12-18 19:26:35 | 1 | 1,519 | Ben Souchet |
74,843,802 | 11,564,487 | Code wrapping in Quarto pdf output documents | <p>Suppose we have the following <code>qmd</code> document:</p>
<pre><code>---
title: "Untitled"
format: pdf
---
```{python}
#| eval: false
print('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam dapibus feugiat nibh, sed gravida ipsum rutrum nec. Donec tincidunt arcu scelerisque enim tempor ... | <python><latex><quarto> | 2022-12-18 19:23:30 | 1 | 27,045 | PaulS |
74,843,770 | 12,113,684 | Keras sequential model from functional API | <p>I have a Keras model using functional API and it looks:</p>
<pre><code>nn = keras.layers.Conv1D(300,19,strides=1,activation='relu')(inputs)
nn = keras.layers.Conv1D(300,19,strides=1,activation='relu')(nn)
nn = keras.layers.MaxPool1D(pool_size=3)(nn)
nn = keras.layers.Flatten()(nn)
nn = keras.layers.Dense(596,act... | <python><tensorflow><keras><deep-learning> | 2022-12-18 19:17:38 | 1 | 845 | John |
74,843,703 | 9,138,097 | How to download and save the .csv from the url and use it to process in next function using python | <p>I'm trying to download and process the .csv files and stuck on one thing, below function to process the .csv works perfect.</p>
<pre><code>def insertTimeStampcsv():
rows = []
with open(r'output.csv', 'w', newline='') as out_file:
timestamp = datetime.now()
df = pd.read_csv(getCsv())
... | <python><python-3.x><pandas><csv> | 2022-12-18 19:07:01 | 1 | 811 | Aziz Zoaib |
74,843,655 | 15,649,230 | MVC who should pass parent view to the child in GUI? | <p>I am trying to implement an application where i need the GUI framework to be easily swappable, so i decided to use a model-view-controller approach, and to keep the controller unchanged when swapping the view component, i decided to make the view responsible for contacting whatever GUI framework is used (tkinter,QT,... | <python><qt><user-interface><model-view-controller> | 2022-12-18 19:00:55 | 0 | 23,158 | Ahmed AEK |
74,843,475 | 12,883,297 | Create 2 new time columns in a dataframe which are cumulative sum of min columns in pandas | <p>I have a dataframe</p>
<pre><code>df = pd.DataFrame([["X","0 min","30 mins"],["X","1 hour 1 min","20 mins"],["X","1 min","30 mins"],["X","41 mins","28 mins"],
["Y",&quo... | <python><python-3.x><pandas><dataframe><datetime> | 2022-12-18 18:20:44 | 1 | 611 | Chethan |
74,843,377 | 5,032,387 | Getting spot gold price without API | <p>Apparently it was possible to query spot gold data using Pandas Datareader, but when I run the query mentioned in the <a href="https://github.com/pydata/pandas-datareader/issues/842" rel="nofollow noreferrer">issue</a>, I get an error. Alternative methods welcome.</p>
<pre><code>import pandas as pd
from pandas_data... | <python><pandas-datareader> | 2022-12-18 18:05:36 | 0 | 3,080 | matsuo_basho |
74,843,359 | 16,395,449 | How to add a top title above the header line | <p>I need to add a TITLE just above header using Pandas script.</p>
<pre><code>Sl_No Departure Arrival
1 UK India
2 US India
3 France India
4 New York Singapore
5 Tokyo Singapore
</code></pre>
<p>I tried the below script but I'm not sure what cha... | <python><python-3.x><pandas><dataframe> | 2022-12-18 18:02:00 | 0 | 369 | Jenifer |
74,843,260 | 7,800,760 | Stanford's Stanza NLP: find all words ids for a given span | <p>I am using a Stanza pipeline that extracts both words and named entities.</p>
<p>The sentence.entities gives me a list of recognized named entities with their start and end characters. Here is an example:</p>
<pre><code>{
"text": "Dante Alighieri",
"type": "PER",
"s... | <python><nlp><stanford-nlp> | 2022-12-18 17:37:20 | 1 | 1,231 | Robert Alexander |
74,843,000 | 4,826,074 | Calling Python code from C++ gives unexpected number of references | <p>I am running the C++ code below and it works fine if I comment out the <code>Py_XDECREF</code> lines. I suppose, however, that it causes memory leaks in such a case. When the <code>Py_XDECREF</code> lines are commented in, the code execution behaves unexpected. First of all, I don't understand the number of referenc... | <python><c++><cpython> | 2022-12-18 16:49:59 | 1 | 380 | Johan hvn |
74,842,944 | 10,914,089 | Capture the output of setup.py build_ext on stdout | <p>In my current project, I'm extensively using Cython. I have many separated setup.py files to build Cython code (*.pyx) with no issues at all, (python 3.8 and gcc 8.3) with the command:</p>
<pre><code>python setup.py build_ext --inplace
</code></pre>
<p>Here is a straightforward example:</p>
<pre><code># ==========... | <python><cython><setup.py> | 2022-12-18 16:36:48 | 1 | 457 | JackColo_Ben4 |
74,842,630 | 17,908,075 | How can i send messages or files to discord without client triggers? | <p>i want the send files to my discord channel.</p>
<p>But i want the send this file depend of some conditions and this conditions is <strong>not related with discord messages</strong>.</p>
<pre><code>def run_discord_bot():
TOKEN = '111111111111111111111'
intents = discord.Intents.default()
intents.message_... | <python><discord><discord.py> | 2022-12-18 15:42:09 | 1 | 360 | Selman |
74,842,570 | 2,230,585 | Change the font size of matplotlib.pyplot Axis after its been set | <p>How to change the font size of the X-Axis or Y-Axis on a matplotlib.pyplot plot in Python.</p>
<p>I'm want to change the fon size of the text that has already set and I don't want to re-enter the text. Is it possible to get the axis object and set its font size ?</p>
| <python><matplotlib><plot> | 2022-12-18 15:28:12 | 1 | 345 | KaO |
74,842,206 | 3,247,006 | Are there any other cases which "select_for_update()" doesn't work but works with "print(qs)" in Django? | <p>I have <strong><code>Person</code> model</strong> as shown below:</p>
<pre class="lang-py prettyprint-override"><code># "store/models.py"
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=30)
</code></pre>
<h2><<strong>CASE 1</strong>></h2>
<p>Then, whe... | <python><sql><python-3.x><django><select-for-update> | 2022-12-18 14:37:35 | 1 | 42,516 | Super Kai - Kazuya Ito |
74,841,979 | 17,889,840 | How to remove a word from str in list in dictionary | <p>I want to remove all <code><start></code> and <code><end></code> from a dictionary as:</p>
<pre class="lang-py prettyprint-override"><code>my_dict = {1:['<start> the woman is slicing onions <end>',
'<start> a woman slices a piece of onion with a knife <end>',
'<st... | <python><dictionary> | 2022-12-18 14:06:45 | 2 | 472 | A_B_Y |
74,841,827 | 12,887,070 | Python - How to trim black boarder from video (top, bottom, sides) | <p>If I have a <code>.mp4</code> video file with black boarders on the top, bottom, and/or sides, How can I trim these boarders off with python?</p>
<p>I do not want to replace the boarders with anything, I just want to trim the video.</p>
<p>For example, if I run <code>magically_trim_black_boarders_from_vid(in_vid)</c... | <python><ffmpeg><moviepy> | 2022-12-18 13:43:43 | 1 | 489 | perry_the_python |
74,841,806 | 544,542 | Python Flask how to get values for items such as DN for LDAP authentication | <p>I am using <a href="https://flask-ldap3-login.readthedocs.io/en/latest/quick_start.html#basic-application" rel="nofollow noreferrer">https://flask-ldap3-login.readthedocs.io/en/latest/quick_start.html#basic-application</a> which comes with a sample script that contains the following</p>
<pre><code># Hostname of your... | <python><ldap> | 2022-12-18 13:41:00 | 1 | 3,797 | pee2pee |
74,841,782 | 11,274,362 | Problem when download Python package and then install from .whl files | <p>I want to download Python package <code>pipy.org</code> and move them to another machine and finally install that packages with downloaded <code>.whl</code> files in that machine
This is <code>requirements.txt</code> file:</p>
<pre><code>amqp==5.1.1
anytree==2.8.0
asgiref==3.5.2
async-timeout==4.0.2
attrs==22.1.0
au... | <python><django><pip> | 2022-12-18 13:38:33 | 2 | 977 | rahnama7m |
74,841,444 | 4,865,723 | Use os.execvp() to call Python script (with Tkinter based GUI) via pkexec and setting environment variables before | <p>This is a follow-up question of <a href="https://stackoverflow.com/q/74840452/4865723">Use tkinter based PySimpleGUI as root user via pkexec</a>.</p>
<p>I have a Python GUI application. It should be able to run as user and as root. For the latter I know I have to set <code>$DISPLAY</code> and <code>$XAUTHORITY</code... | <python><environment-variables><polkit> | 2022-12-18 12:47:03 | 1 | 12,450 | buhtz |
74,841,344 | 19,797,660 | In Pandas dataframe, how to add metadata to a column? | <p>I am creating my own module for calculation of price indicators, and I would like to add metadata to a column of a dataframe, so each column will have unique metadata.</p>
<p>It is important for me since I have multiple functions and I can recalculate output of one function using another function, also I use some fu... | <python><pandas><dataframe> | 2022-12-18 12:33:30 | 0 | 329 | Jakub Szurlej |
74,841,340 | 490,648 | No method to rename Pandas index names (not labels) inline? | <p>I have a dataframe <code>bmi</code>. I can summarize it like this:</p>
<p><a href="https://i.sstatic.net/V9Vo9.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/V9Vo9.png" alt="enter image description here" /></a></p>
<p>Now I want to summarize the dataframe based on <code>Age</code> values measured in ... | <python><pandas> | 2022-12-18 12:32:42 | 1 | 494 | farhanhubble |
74,840,937 | 16,682,019 | RegEx works in regexr but not in Python re | <p>I have this regex: <code>If you don't want these messages, please [a-zA-Z0-9öäüÖÄÜ<>\n\-=#;&?_ "/:.@]+settings<\/a></code>. It works on <a href="https://regexr.com/" rel="nofollow noreferrer">regexr</a> but not when I am using the <code>re</code>
library in Python:</p>
<pre><code>data = "&l... | <python><regex><python-re> | 2022-12-18 11:29:53 | 1 | 1,900 | Julius Babies |
74,840,911 | 10,563,068 | How to split a dataframe into multiple dataframe in pandas dynamically based on the column count? | <p>I am still a newbie in pandas. I have an excel file which contains more than 700 columns with 600 rows. I am trying to split it into multiple dataframes so I can insert it into sql table. The reason why I am trying to split is because I am getting an error saying The statement has been terminated. (3621); [42000] [M... | <python><sql><pandas><dataframe><dynamic> | 2022-12-18 11:24:38 | 1 | 453 | Sriram |
74,840,864 | 7,713,770 | How to show content with zip in view with django? | <p>I hava a django applicaiton. And I try to show the content values from the backend in the template. There is a method: <code>show_extracted_data_from_file </code> where I combine three methods:</p>
<pre><code>
class FilterText:
def total_cost_fruit(self):
return [3588.20, 5018.75, 3488.16, 444]
def... | <python><html><django> | 2022-12-18 11:13:39 | 1 | 3,991 | mightycode Newton |
74,840,859 | 17,945,841 | Rotate the xlabels with seaborn | <p>I've made a boxplot, but as you see the xlabels are too long so I need to rotate them a little bit:</p>
<p><a href="https://i.sstatic.net/wk7jw.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wk7jw.png" alt="enter image description here" /></a></p>
<p>I've found several topics for this, here on stack,... | <python><seaborn><boxplot> | 2022-12-18 11:12:01 | 1 | 1,352 | Programming Noob |
74,840,717 | 14,862,885 | Difference between today,week start | <p>How to get the difference between <code>datetime.datetime.utcnow()</code>, and the start of week?</p>
<p>I want start of week of<br />
<code>"date=17,month=12,year=2022,hour=x,minute=y,second=z"</code> to be:
<code>"date=12,month=12,year=2022,hour=0,minute=0,second=0"</code>, where <em>x,y,z are ... | <python><datetime><dayofweek><weekday> | 2022-12-18 10:44:19 | 1 | 3,266 | redoc |
74,840,642 | 19,251,893 | How to use xmltodict.parse with non-printable data | <p>I tried to convert xml to dict with Python</p>
<pre><code>import xmltodict
xmltodict.parse('<a>as\x08</a>')
</code></pre>
<p>But I got an exception</p>
<pre><code>ExpatError Traceback (most recent call last)
<ipython-input-8-XXXXXX> in <module>
----> 1 xmltod... | <python><python-3.x><dictionary><xmltodict> | 2022-12-18 10:31:10 | 0 | 345 | python3.789 |
74,840,608 | 5,836,951 | When using TensorFLow / Keras, what is the most efficient way to get some metadata inside a custom cost function? | <p>In my dataset, I have a binary Target column, some Features columns, and a Date column. I want to write a custom cost function that would first compute a cost-by-date quantity, then add all the costs up. But to do this, I would need to know inside the cost function the corresponding date for each data point in <code... | <python><tensorflow><keras> | 2022-12-18 10:26:35 | 1 | 487 | Gabi |
74,840,591 | 17,176,270 | Mock object with pyTest | <p>I have a function I need to test:</p>
<pre><code>def get_user_by_username(db, username: str) -> Waiter:
"""Get user object based on given username."""
user = db.query(Waiter).filter(Waiter.username == username).first()
return user
</code></pre>
<p>Here I try to mock DB ca... | <python><unit-testing><mocking><pytest> | 2022-12-18 10:24:17 | 1 | 780 | Vitalii Mytenko |
74,840,576 | 5,404,647 | Cannot import name 'structures' from partially initialized module 'music' | <p>I'm trying to use the package <code>music</code>, and I installed it using <code>pip3 install music</code>.
It installed the dependencies correctly, but now with a sample code like the following</p>
<pre><code>from music import *
# create a clarinet
clarinet = Clarinet()
# create a song
song = Song()
# add notes ... | <python><python-3.x> | 2022-12-18 10:22:37 | 1 | 622 | Norhther |
74,840,452 | 4,865,723 | Use tkinter based PySimpleGUI as root user via pkexec | <p>I want to show a GUI Window (<code>PySimpleGUI</code> which is based on <code>tkinter</code>) as root user.
I'm using <code>pkexec</code> for that. Using GNU/Linux Debian stable.</p>
<p>But I got the error</p>
<pre><code>no display name and no $DISPLAY environment variable
</code></pre>
<p>I understand that a bit. B... | <python><tkinter><pysimplegui><polkit> | 2022-12-18 10:00:06 | 0 | 12,450 | buhtz |
74,840,385 | 9,079,461 | How to trigger scala/python code when value in BQ table changes | <p>We wanted to run (poll) scala/python code in GCP VM continuously which will run ETL program only when there is change in value in BQ table.
i.e. we'll add which ETL to run in BQ table and based on that ETL program will run via GCP VM.</p>
<p>If there are multiple values in BQ table, it should run multiple ETL progra... | <python><scala><google-cloud-platform> | 2022-12-18 09:46:46 | 1 | 887 | Khilesh Chauhan |
74,840,293 | 4,451,521 | How to find the place where a int conversion is failing in a dataframe? | <p>I have a dataframe with a column "<code>next</code> which is a string of numbers separated by ;</p>
<p>When I do</p>
<pre><code>thedataframe.next.str.split(;).explode().astype(int)
</code></pre>
<p>It usually works but sometimes it fails with the error</p>
<pre><code>ValueError: invalid literal for int() with b... | <python><pandas> | 2022-12-18 09:27:22 | 1 | 10,576 | KansaiRobot |
74,840,258 | 1,525,936 | Django DRF - nested serializer (level>2) does not show up in the response | <p>We have the follwing structure <code>(library->books->pages)</code></p>
<p>the first serializer</p>
<pre><code> class Library(serializers.ModelSerializer):
books = BookSerializer(many=True)
class Meta:
model = Library
fields = '__all__'
@transaction.atomic... | <python><django><django-rest-framework> | 2022-12-18 09:21:39 | 1 | 1,323 | Paramore |
74,840,221 | 6,699,103 | AttributeError: 'Flask' object has no attribute 'get | <p>I'm getting the following error while running the below code</p>
<p>File "D:\Inteliji Projects\Python Flask\whatsgrouprestapi\src\app.py", line 13, in create_app
@app.get("/")
AttributeError: 'Flask' object has no attribute 'get</p>
<pre><code>from flask import Flask
def create_app(test_config=N... | <python><rest><flask> | 2022-12-18 09:15:04 | 1 | 494 | Mohan K |
74,840,212 | 18,125,194 | chi squared hypothesis test with several binary variables | <p>I have a data about plants grown in a nursery. I have a variable for plant health and several factors.</p>
<p>I wanted to test if any of the factors influenced plant health, so I thought the best method would be to use a chi squared test.</p>
<p>My method is below, but I get stuck after the cross tab</p>
<pre><code>... | <python><scipy><chi-squared> | 2022-12-18 09:13:13 | 1 | 395 | Rebecca James |
74,840,179 | 11,883,900 | Plotly line graph to follow ordered time series on X-axis | <p>I have a dataframe that looks like this :</p>
<pre><code>country = ['Cambodia',
'Cambodia',
'Cambodia',
'Cambodia',
'Cambodia',
'Lao PDR',
'Lao PDR',
'Lao PDR',
'Lao PDR']
month_year = ['2020-Aug',
'2020-Dec',
'2020-May',
'2020-Oct',
'2021-Mar',
'2020-Jul',
'2021-Mar',
'2021-May',
'2021-Nov']
count... | <python><pandas><plotly> | 2022-12-18 09:05:42 | 1 | 1,098 | LivingstoneM |
74,840,161 | 12,883,297 | Get the dictionary from elements in the list of a column where key-value pair are number of elements and element value in pandas | <p>I have a dataframe</p>
<pre><code>df = pd.DataFrame([["X",["A","B","C","D"]],["Y",["E","F","G"]],["Z",["H","I","J","K","L"]]],columns=["type","id"]... | <python><python-3.x><pandas><dataframe> | 2022-12-18 09:00:55 | 1 | 611 | Chethan |
74,840,109 | 1,231,714 | Python3 not recognized in bash scripts | <p>I removed Python 2.7 from my system and some of my old bash scripts stopped working. The problem was that it was not finding python3. I aliased python to point to python3 in .bashrc and everything works fine at the commandline, but in the bash script I still get the same error "python: command not found".<... | <python><bash><raspberry-pi> | 2022-12-18 08:49:42 | 1 | 1,390 | SEU |
74,839,927 | 386,861 | How to get selenium working in VSCode python | <p>Trying to work through tutorial that works in Python using Selenium.</p>
<p>Tried this:</p>
<pre><code>import selenium
</code></pre>
<p>Didn't work. Tried to install again:</p>
<pre><code>pip install selenium
Requirement already satisfied: selenium in ./opt/anaconda3/lib/python3.9/site-packages (4.7.2)
Requirement a... | <python><selenium> | 2022-12-18 08:10:14 | 1 | 7,882 | elksie5000 |
74,839,916 | 2,853,908 | Python OHLC convert weekly to biweekly | <p>I have weekly data from Yahoo Finance</p>
<pre><code> Open High Low Close Adj Close Volume
Date
1999-12-27 0.901228 0.918527 0.888393 0.917969 0.782493 1.638112e+08
2000-01-0... | <python><dataframe><yahoo-finance><ohlc> | 2022-12-18 08:06:59 | 1 | 479 | Ashish |
74,839,883 | 11,274,362 | How to return empty queryset from django_filters.FilterSet in API view if querystring hasn't any valid key | <p>I use <code>django-filter</code> package with <code>djangorestframework</code> package for filter objects that return from API view. There are my files:</p>
<pre><code># models.py
class Symbol(models.Model):
title = models.CharField(max_length=30, verbose_name='title')
# serializers.py
class SymbolSerializ... | <python><django><django-rest-framework><django-filter> | 2022-12-18 08:00:55 | 1 | 977 | rahnama7m |
74,839,830 | 17,550,177 | HeidiSQL is not showing any data even when table size is more than 0B | <p>I have Postgresql Database in production and i'm trying to insert data from my localhost using <code>psycopg2</code> library. i'm seeing my database through HeidiSQL. But after i finished inserting the data, my HeidiSQL shows that table size increased but when i try to see the data, it shows 0 rows. I have tried to ... | <python><django><postgresql><heidisql> | 2022-12-18 07:47:32 | 0 | 756 | Michael Halim |
74,839,707 | 501,333 | What is the cause of the Sphinx warning "Block quote ends without a blank line; unexpected unindent" in a one line docstring | <p>When I build my Sphinx HTML documentation, I get a warning.</p>
<blockquote>
<p>checkdmarc.py:docstring of checkdmarc.BIMIRecordInWrongLocation:1: WARNING: Block quote ends without a blank line; unexpected unindent.</p>
</blockquote>
<p><code>BIMIRecordInWrongLocation</code> is a simple <code>Exception</code> class ... | <python><python-sphinx><docstring><myst> | 2022-12-18 07:19:03 | 1 | 5,152 | Sean W. |
74,839,586 | 1,779,091 | Is there any purpose of using loc or iloc when filtering the dataframe? | <p>Taking into account the following:</p>
<pre><code>df[df.B == 9]
</code></pre>
<p>vs</p>
<pre><code>df.loc[df.B == 9]
</code></pre>
<p>I understand that 1st is syntactic sugar for the 2nd.</p>
<p>Generally we use loc or iloc when we need to work with label or index respectively.</p>
<p>However, as shown in the above ... | <python><pandas> | 2022-12-18 06:46:48 | 0 | 9,866 | variable |
74,839,415 | 3,761,310 | hybrid_property.expression to return date from column or today's date | <p>I have a SQLAlchemy model in my Flask app that looks something like this:</p>
<pre><code>class MyModel(db.model):
_date_start = db.Column(db.Date, nullable=False, default=date.today)
_date_end = db.Column(db.Date, nullable=True, default=None)
@hybrid_property
def date_start(self) -> date:
... | <python><sqlalchemy> | 2022-12-18 06:06:12 | 1 | 718 | DukeSilver |
74,839,413 | 8,417,363 | Add column from single dimension list pyspark efficiently | <p>I'm doing ensemble learning and I want to put the ensembled single column matrix into the original Dataframe used to gather the data.</p>
<p>The <code>df</code> looks like this, with repeating UserId every six rows.</p>
<pre><code>+------+-------+----------+----------+----------+----------+----------+----------+
|Us... | <python><dataframe><pyspark><jupyter-notebook> | 2022-12-18 06:05:25 | 1 | 3,186 | Jimenemex |
74,839,142 | 8,070,090 | google sheet API Request had insufficient authentication scopes | <p>I'm trying to follow the Google Sheet API from its documentation here:
<a href="https://developers.google.com/sheets/api/guides/values" rel="nofollow noreferrer">https://developers.google.com/sheets/api/guides/values</a></p>
<p>I'm trying to run the snippets of the codes mentioned there, for example, Python code on ... | <python><ubuntu><google-sheets-api> | 2022-12-18 04:33:18 | 2 | 3,109 | Tri |
74,839,133 | 19,939,086 | A more efficient solution for balanced split of an array with additional conditions | <p>I appreciate your help in advance. This is a practice question from Meta's interview preparation website. I have solved it, but I wonder if any optimization can be done.</p>
<h4>Question:</h4>
<p>Is there a way to solve the following problem with a time complexity of O(n)?</p>
<h4>Problem Description:</h4>
<blockquo... | <python><algorithm><sorting><optimization><time-complexity> | 2022-12-18 04:30:09 | 1 | 938 | KORIN |
74,838,922 | 2,989,330 | python3-config --ldflags doesn't include -lpython3.x | <h1>Problem statement</h1>
<p>When trying to build a sample Cython application with g++, I get the linker error <code>undefined reference to 'Py_Finalize'</code>. The Python linker arguments are provided by <code>python3-config</code>, but they appear to be incomplete. If I additionally include <code>-lpython3.x</code>... | <python><c++><python-3.x><linux><compiler-errors> | 2022-12-18 03:18:12 | 1 | 3,203 | Green 绿色 |
74,838,796 | 7,987,118 | Efficiently replace column value from a column of dict from pandas dict | <p>I would like help vectorizing my current code, any help or comments are appreiciated
I have a df with a weird column that is derived from an availability checker function like this:</p>
<pre><code>original_df = pd.DataFrame({
'a':['a1', 'a2', 'a3', 'a4'],
'b':['b1', 'b20', 'b98', 'b4'],
'c':[{'a':'not_av... | <python><python-3.x><pandas><performance><vectorization> | 2022-12-18 02:35:34 | 2 | 363 | Harsha |
74,838,582 | 15,542,245 | "NoneType" error message for variables of class string type | <p>I understand that re.search returns a match object <a href="https://docs.python.org/3/library/re.html" rel="nofollow noreferrer">re.search(pattern, string, flags=0)</a>
I am testing the success of the match & then retrieving the string.</p>
<pre><code># matchTest.py --- testing match object returns
import re
#... | <python><regex><typeerror> | 2022-12-18 01:30:34 | 1 | 903 | Dave |
74,838,554 | 5,410,188 | requests.exceptions.JSONDecodeError: Extra data: line 1 column 5 (char 4) | <p>newb to python and requests here. I'm working with an API trying to get a JSON response but am only able to get the text version of it. My line of <code>resp_random_1_100_int.json()</code> returns the error:</p>
<p><code>*** requests.exceptions.JSONDecodeError: Extra data: line 1 column 4 (char 3) resp_random_1_100_... | <python><json><python-requests><insomnia> | 2022-12-18 01:20:43 | 1 | 1,542 | Cflux |
74,838,498 | 1,914,781 | plotly - show x-axis with arrow head | <p>How to draw a x-axis with arrow head at the right side? example:</p>
<pre><code>import re
import numpy as np
import plotly.express as px
def save_fig(fig,pngname):
fig.write_image(pngname,format="png", width=800, height=300, scale=1)
print("[[%s]]"%pngname)
#plt.show()
return
de... | <python><plotly> | 2022-12-18 01:01:52 | 1 | 9,011 | lucky1928 |
74,838,389 | 12,990,109 | Import output of kubectl get pods -o json in to pandas dataframe | <p>I'd like to import the output of:</p>
<pre><code>kubectl get pods -o json
</code></pre>
<p>into a python pandas dataframe. This should contain also all containers and there resource request and limits.</p>
<p>My code starts as follows:</p>
<pre><code>import json
import numpy as np
import pandas as pd
import os
pods_... | <python><json><pandas><kubernetes> | 2022-12-18 00:28:06 | 2 | 453 | Jeromba6 |
74,838,294 | 13,983,136 | Update a model with test data to make new forecasts after training it on training data | <p>I would like to understand if the procedure I'm following is standard or if I'm making some mistake.
I have a time series of 48 values (one value per month from 2018 to 2021), stored in the data frame <code>df</code>:</p>
<pre><code> Amount
2018-01 125.6
... ...
2020-12 145.2
2... | <python><time-series><forecasting><arima><pmdarima> | 2022-12-18 00:00:41 | 0 | 787 | LJG |
74,838,138 | 2,665,591 | Python function with two overloads calls another one with the same overloads - explain to mypy | <p>How do we explain to mypy that this code is ok?</p>
<pre><code>from typing import overload, Union
@overload
def foo(x: float, y: str):
...
@overload
def foo(x: list, y: tuple):
...
def foo(x: Union[float, list], y: Union[str, tuple]):
bar(x, y) # type error!
@overload
def bar(x: float, y: str):
... | <python><mypy> | 2022-12-17 23:20:29 | 1 | 3,462 | DanielSank |
74,838,124 | 3,684,575 | How to convert screen x,y (cartesian coordinates) to 3D world space crosshair movement angles (screenToWorld)? | <p>Recently I've been playing around with computer vision and neural networks.<br>
And came across experimental object detection within a 3D application.<br>
But, surprisingly to me - I've faced an issue of converting one coordinates system to another <em>(AFAIK cartesian to polar/sphere)</em>.</p>
<p><strong>Let me ex... | <python><math><3d><camera><trigonometry> | 2022-12-17 23:17:08 | 1 | 1,912 | Abraham Tugalov |
74,838,064 | 3,611,472 | SSL pickle error when running multiprocess inside class's method and websocket | <p>I am creating a phyton object that establishes a websocket connection.
Depending the message that I receive, I would like to run a class's method on a child-process using <code>multiprocessing</code>. However, I get the error <code>cannot pickle 'SSLSocket' object</code>. Why does it happen?</p>
<p>The following cod... | <python><python-3.x><websocket><multiprocessing><python-multiprocessing> | 2022-12-17 23:04:08 | 1 | 443 | apt45 |
74,838,036 | 11,573,910 | Dataframe with Array Column to New Dataframe | <p>Actually i have an <code>feather</code> file that im loading to an Dataframe.</p>
<p>And this Dataframe have a column with <code>languages </code> in each row. Like the abone one:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>student_id</th>
<th>name</th>
<th>created_at</th>
<th>langua... | <python><pandas><dataframe><feather> | 2022-12-17 22:58:54 | 1 | 331 | Hudson Medeiros |
74,838,017 | 3,215,940 | Apply rolling custom function with pandas | <p>There are a few similar questions in this site, but I couldn't find out a solution to my particular question.</p>
<p>I have a dataframe that I want to process with a custom function (the real function has a bit more pre-procesing, but the gist is contained in the toy example <code>fun</code>).</p>
<pre><code>import ... | <python><pandas> | 2022-12-17 22:54:23 | 4 | 4,270 | Matias Andina |
74,837,978 | 19,111,974 | SyntaxError: invalid non-printable character U+00A0 in python | <p>I'm getting the error:</p>
<p><code>SyntaxError: invalid non-printable character U+00A0</code></p>
<p>When I'm running the code below:</p>
<pre><code># coding=utf-8
from PIL import Image
img = Image.open("img.png")
</code></pre>
<p>I have tried to load different images with different formats (png, jpg, j... | <python><syntax-error><indentation> | 2022-12-17 22:45:14 | 1 | 571 | cris.sol |
74,837,661 | 13,062,745 | Pandas how to plot multiple 0/1 distributions in to one figure | <p>I have a dataset that looks like this:</p>
<pre><code>label colA colB colC
0 1 0 0
0 0 1 0
1 0 0 1
1 1 0 1
</code></pre>
<p>Each row will be either label 0 or 1, and only one of colA, colB and colC will be 1, other will be 0. <br>
I want to plot one figure that looks s... | <python><pandas><matplotlib> | 2022-12-17 21:44:42 | 2 | 742 | zxcisnoias |
74,837,591 | 386,861 | No module called found - why? | <p>Still trying to get to grips with VSCode.</p>
<p>Trying to work through this: <a href="https://www.youtube.com/watch?v=7aIb6iQZkDw" rel="nofollow noreferrer">https://www.youtube.com/watch?v=7aIb6iQZkDw</a></p>
<p>I've run the first line of code:</p>
<p>from selenium import webdriver</p>
<p>The reply is:</p>
<pre><co... | <python><visual-studio-code> | 2022-12-17 21:30:55 | 1 | 7,882 | elksie5000 |
74,837,586 | 6,346,514 | Loop through .zip files and print length of excels inside zip | <p>I am having trouble looping through my .zip files (5 of them) in my directory , which have multiple sheets in them.</p>
<ol>
<li>I want to count the records in each .zip file (appending record count of each sheet)</li>
</ol>
<p>right now im just getting the first row of my below output. I do think i have an issue at... | <python><pandas> | 2022-12-17 21:28:47 | 1 | 577 | Jonnyboi |
74,837,553 | 1,123,336 | How to fix a Mac base conda environment when sqlite3 is broken | <p>I recently updated the Python version of my base conda environment from 3.8 to 3.9, using <code>mamba update python=3.9</code>, but I can no longer run IPython, because the sqlite3 package appears to be broken.</p>
<pre><code>python
Python 3.9.15 | packaged by conda-forge | (main, Nov 22 2022, 08:55:37)
[Clang 14.0... | <python><sqlite><conda> | 2022-12-17 21:19:53 | 2 | 582 | Ray Osborn |
74,837,544 | 86,924 | Exclude packages included in Lambda layers from being packaged with AWS Lambda function | <p>A number of the dependencies for my Python AWS Lambda function are in Lambda layers, so they do not have to be in the deployment package for the lambda. I'm using pipenv to manage my dependencies.</p>
<p>To test locally I need the dependencies that are in the layers to be in my Pipfile, but then they also end up in... | <python><aws-lambda><pipenv> | 2022-12-17 21:19:02 | 1 | 7,162 | Dan Hook |
74,837,332 | 14,190,526 | Why is an autospecced mock of Enum not iterable (has no __iter__ method)? | <p>Why is an autospecced mock of <code>Enum</code> not iterable (has no <code>__iter__</code> method)?</p>
<pre class="lang-py prettyprint-override"><code>from unittest.mock import create_autospec
from enum import IntEnum
class IE(IntEnum):
Q = 1
W = 2
m = create_autospec(spec=IE, instance=False)
print(has... | <python><mocking><python-unittest><python-unittest.mock> | 2022-12-17 20:38:16 | 1 | 1,100 | salius |
74,837,241 | 4,864,195 | use openAI CLIP with torch tensor or numpy array as input | <p>How to use a pytorch tensor or an openCV iamge correctly as input for for OpenAi CLIP?</p>
<p>I tried the following but this didn't work so far :</p>
<pre><code>device = "cuda" if torch.cuda.is_available() else "cpu"
clip_model, clip_preprocess = clip.load("ViT-B/32", device=device)
cli... | <python><pytorch><openai-clip> | 2022-12-17 20:21:38 | 3 | 333 | werber bang |
74,837,095 | 5,881,882 | Torch: tensor to numpy - cycling problem .cpu() to .detach().numpy() | <p>I got a problem with converting a torch tensor to numpy array.</p>
<pre><code> avg_rewards = th.mean(rewards, dim=[0,1,3])
avg_targets = th.mean(th.mean(targets.reshape(rewards.shape), dim=[0, 1, 3]))
avg_score = th.max(avg_rewards, avg_targets)
avg_q = th.mean(q, dim=[0, 1, 3])
griefers = avg_sc... | <python><numpy><tensor><torch> | 2022-12-17 19:58:16 | 1 | 388 | Alex |
74,836,987 | 4,358,113 | How can I extract all sections of a Wikipedia page in plain text? | <p>I have the following code in python, which extracts only the introduction of the article on "Artificial Intelligence", while instead I would like to extract all sub-sections (History, Goals ...)</p>
<pre><code>import requests
def get_wikipedia_page(page_title):
endpoint = "https://en.wikipedia.org/... | <python><wikipedia-api> | 2022-12-17 19:41:27 | 1 | 507 | blindeyes |
74,836,912 | 20,026,039 | Selecting an element with multiple classes in python lxml using xpath | <p>I was trying to scrape a website using python request and lxml. I could easily select the elements with single class using <code>html.xpath()</code> but I can't figure out how to select the elements with multiple class.</p>
<p>I used some code like this to select the elements in page with class "title":</p... | <python><html><python-3.x><xpath><lxml> | 2022-12-17 19:29:23 | 2 | 464 | Ajay Pun Magar |
74,836,900 | 11,652,655 | ValueError: [E966] `nlp.add_pipe` when changing the sentence segmentaion rule of spaCy model | <p>I am using Python 3.9.7 and the <code>spaCy</code> library and want to change the way the model segments a given sentence. Here is a sentence and the segmentation rule I created as an example:</p>
<pre class="lang-py prettyprint-override"><code>import spacy
nlp=spacy.load('en_core_web_sm')
doc2=nlp(u'"Manageme... | <python><nlp><spacy> | 2022-12-17 19:27:39 | 1 | 1,285 | Seydou GORO |
74,836,886 | 5,075,518 | Deserialize JSON string to a class instance automatically in Python | <p>Assume I have several classes:</p>
<pre><code>class Assignee:
gid: str
name: str
class Task:
gid: str
name: str
created_at: datetime
assignee: Assignee
</code></pre>
<p>and I receive a JSON, that I want to translate into my Task class instance:</p>
<pre><code>{
"gid": "#1... | <python><json> | 2022-12-17 19:25:49 | 3 | 466 | Alex Sham |
74,836,777 | 4,061,068 | Matplotlib in huggingfaces space cases Permission Denied Error | <p>I am trying to setup huggingface spaces. Here is my dockerfile</p>
<pre><code>FROM python:3.9
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --prefer-binary -r /code/requirements.txt
RUN pip install --user matplotlib
COPY . .
CMD ["uvicorn", "app.main:a... | <python><docker><matplotlib><huggingface> | 2022-12-17 19:13:15 | 1 | 1,067 | Andrius Solopovas |
74,836,772 | 7,318,120 | can seaborn normalise data such that y-axis is clear | <p>I plot time series of data where the y values of the data are orders of magnitude different.</p>
<p>I am using <code>seaborn.lmplot</code> and was expecting to find a <code>normalise</code> keyword, but have been unable to.</p>
<p>I tried to use a log scale, but this failed (see diagram).</p>
<p>This is my best atte... | <python><matplotlib><graph><seaborn> | 2022-12-17 19:12:29 | 1 | 6,075 | darren |
74,836,446 | 7,800,760 | Networkx: merge list of nodes into a new one conserving edges | <p>I am aware of the nx.contracted_nodes function but it only takes two nodes to merge.</p>
<p>Is there a simple, concise way of passing a list of nodes, and merge all those nodes into a new one? Here is an example:</p>
<pre><code>import networkx as nx
G = nx.DiGraph()
G.add_edges_from([
('A','B'),
('B','C'),
... | <python><networkx> | 2022-12-17 18:22:06 | 2 | 1,231 | Robert Alexander |
74,836,347 | 494,134 | sqlalchemy session with autocommit=True does not commit | <p>I'm trying to use a session with autocommit=true to create a row in a table, and it does not seem to be working. The row is not saved to the table.</p>
<pre><code>import os
import sqlalchemy
from sqlalchemy import Table
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker... | <python><sqlalchemy><commit> | 2022-12-17 18:07:56 | 1 | 33,765 | John Gordon |
74,836,331 | 10,088,866 | SqlAlchemy + Postgres - query with @> ANY(ARRAY['["...]']::jsonb[]) | <p>I have a postgres table represented in the sql alchemy like</p>
<pre><code>from sqlalchemy import Column
from sqlalchemy.dialects.postgresql import UUID, JSONB
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class ListingDatabaseDocument(Base):
__tablename__ = 'listing'
uu... | <python><postgresql><sqlalchemy> | 2022-12-17 18:05:05 | 1 | 2,164 | Clyde Barrow |
74,836,262 | 19,797,660 | What to use instead of if-elif inside a function to choose between multiple functions? | <p>I am trying to create my own module that will calculate indicators, and I am implementing a function like this:</p>
<pre><code>def average_day_range(price_df: PandasDataFrame, n: int=14, calculation_tool: int=0):
'''
0 - SMA, 1 - EMA, 2 - WMA, 3 - EWMA, 4 - VWMA, 5 - ALMA, 6 - LSMA, 7 - HULL MA
:param p... | <python> | 2022-12-17 17:54:49 | 2 | 329 | Jakub Szurlej |
74,836,250 | 7,032,878 | From normalized Pandas DataFrame to list of nested dicts | <p>Supposing I have obtained a normalized DataFrame starting from a list of nested dicts:</p>
<pre><code>sample_list_of_dicts = [
{ 'group1': { 'item1': 'value1', 'item2': 'value2' } },
{ 'group1': { 'item1': 'value3', 'item2': 'value4' } }
]
df = pd.json_normalize(sample_list_of_dicts)
</code></pre>
<p>Is the... | <python><pandas> | 2022-12-17 17:52:59 | 3 | 627 | espogian |
74,836,227 | 511,542 | When loading Keras checkpoint the validation loss increases on first evaluation | <p>I'm having an issue with model saving and loading (fine-tuning).</p>
<p>After I load the model that was saved at val_loss 0.8, on first epoch it will be evaluated to 0.85 or so, even if the model never climbed more than 0.82 for example on previous training (just went flat).
The ModelCheckpoint then will save it at ... | <python><tensorflow><machine-learning><keras> | 2022-12-17 17:50:44 | 0 | 1,002 | Spider |
74,836,151 | 12,228,795 | nothing provides __cuda needed by tensorflow-2.10.0-cuda112py310he87a039_0 | <p>I'm using mambaforge on WSL2 Ubuntu 22.04 with <code>systemd</code> enabled. I'm trying to install TensorFlow 2.10 with CUDA enabled, by using the command:</p>
<pre><code>mamba install tensorflow
</code></pre>
<p>And the command <code>nvidia-smi -q</code> from WSL2 gives:</p>
<pre><code>==============NVSMI LOG======... | <python><tensorflow><conda><mamba><mambaforge> | 2022-12-17 17:40:52 | 1 | 420 | Otávio Augusto Silva |
74,835,980 | 4,508,737 | Yahoo Finance encrypt context Python fetch | <p>Using python script to find quotes data but yahoo recently encrypted it, now it is not clear text quotes but it shows no encrypt when web browser.</p>
<pre><code>def _get_headers():
return {"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"... | <python><python-3.x><yahoo-finance> | 2022-12-17 17:15:15 | 2 | 767 | Colin Zhong |
74,835,912 | 309,812 | ValueError: cannot join with no overlapping index names on the same dataframe | <p>I am encountering a strange problem with a pandas dataframe where in, where() fails complaining that it cannot join on the overlapping index names.</p>
<p>To reproduce this problem try below:</p>
<pre class="lang-py prettyprint-override"><code>import yfinance as yf
from datetime import datetime
startdate=datetime(20... | <python><pandas><dataframe><valueerror> | 2022-12-17 17:03:41 | 4 | 736 | Nikhil Mulley |
74,835,752 | 3,728,901 | How to use GPU with TensorFlow? | <p>My PC</p>
<p><a href="https://i.sstatic.net/yIFDJ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/yIFDJ.png" alt="enter image description here" /></a></p>
<pre class="lang-py prettyprint-override"><code>Microsoft Windows [Version 10.0.22621.963]
(c) Microsoft Corporation. All rights reserved.
C:\User... | <python><tensorflow><machine-learning><keras><nvidia> | 2022-12-17 16:39:29 | 2 | 53,313 | Vy Do |
74,835,691 | 54,606 | How to determine why a query acquire a lock in postgresql | <p>I've got some weird issue with Odoo and postgresql. It happens when I try to install the forum module on odoo 15. It's not that relevant and I'm not sure it's repeatable but if you can reproduce the bug that would be how.</p>
<p>Using the answers from this question: <a href="https://stackoverflow.com/questions/26489... | <python><postgresql><odoo><deadlock> | 2022-12-17 16:31:32 | 0 | 13,710 | Loïc Faure-Lacroix |
74,835,522 | 5,889,169 | Django models - how to properly calculate multiple values with various conditions | <p>I want to calculate multiple values in a single query on my model. Each metric should have a different filter (or no filters at all). I'm using Django==2.2.3 and a <a href="https://www.djongomapper.com/" rel="nofollow noreferrer">Djongo</a> model.</p>
<p>MyModel columns:</p>
<pre><code>user_id = models.IntegerField... | <python><django><filter><orm><model> | 2022-12-17 16:07:39 | 0 | 781 | shayms8 |
74,835,369 | 7,984,318 | Postgresql remove rows by duplicated column value | <p>I'm using python pandas with Postgresql,and I have a table named stock:</p>
<pre><code> open high low close volume datetime
383.97 384.22 383.66 384.08 1298649 2022-12-16 14:25:00
383.59 384.065 383.45 383.98 991327 2022-12-16 14:20:00
383.59 384.065 383.45 383.9... | <python><sql><pandas><postgresql> | 2022-12-17 15:44:53 | 1 | 4,094 | William |
74,835,240 | 4,907,339 | Comparing time of day on day of week to time of day on day of week | <p>Is there a straightforward way to test whether <code>now</code> is between Friday, 5pm and Sunday, 5pm, of the same week?</p>
<p>This attempt returns <code>False</code> because it does not compare <code>now.time()</code> relative to either <code>now.isoweekday() >= 5</code> or <code>now.isoweekday() <= 7</code... | <python><datetime><date-comparison> | 2022-12-17 15:21:55 | 3 | 492 | Jason |
74,835,108 | 9,220,463 | Graph analysis and optimisation. Transform a UCG in a UAG while maximising total edge weights | <p>I want to transform a UCG (undirected cyclic graph) into a UAG (Undirected acyclic graph)</p>
<p>To do so I'm looking for an algorithm that can help me prune the edges.</p>
<p>Let's take as example the following graph:</p>
<pre><code>import pandas as pd
import igraph as ig
import matplotlib.pyplot as plt
fig, ax = ... | <python><optimization><graph><igraph><mathematical-optimization> | 2022-12-17 15:00:19 | 1 | 621 | riccardo nizzolo |
74,834,890 | 15,852,600 | How to detect the language used in a column and put it in a new column? | <p>I have the following <code>df</code>:</p>
<pre><code>df = pd.DataFrame({
'user': ['Id159', 'Id758', 'Id146', 'Id477', 'Id212', 'Id999'],
'comment' : ["I inboxed you", '123', 123, 'je suis fatigué', "j'aime", 'ما نوع الجهاز بالضبط']
})
</code></pre>
<p>It has the following display:</p>
<... | <python><pandas><dataframe><language-detection> | 2022-12-17 14:29:44 | 3 | 921 | Khaled DELLAL |
74,834,753 | 1,088,305 | Is there a way to perform lazy operations in Polars on multiple frames at the same time? | <p>Lazy more and query optimization in Polars is a great tool for saving on memory allocations and CPU usage for a single data frame. I wonder if there is a way to do this for multiple lazy frames as:</p>
<pre><code>lpdf1 = pdf1.lazy()
lpdf2 = pdf2.lazy()
result_lpdf = -lpdf1/lpdf2
result_pdf = result_lpdf.collect()
<... | <python><dataframe><hpc><python-polars><rust-polars> | 2022-12-17 14:08:34 | 1 | 1,186 | Mark Horvath |
74,834,635 | 5,281,811 | Efficient way to check if list of strings are in list of lists and get indexes | <p>I have two lists who are generated, one is a simple list of words, and another a list of lists of words. What would be the fastest way to check if elements in the list are in the list of lists and get the indexes?</p>
<p>E.g.</p>
<pre><code>lists=[["apple","car"],["street","beer&qu... | <python><list> | 2022-12-17 13:50:04 | 4 | 373 | Laz22434 |
74,834,564 | 17,696,880 | How to add an if conditional inside a lambda function to determine what string concatenate to another string? | <pre class="lang-py prettyprint-override"><code>def weeks_to_days(input_text, nro_days_in_a_week = 7):
input_text = re.sub(
r"(\d+)[\s|]*(?:semanas|semana)",
lambda m: str(int(m[1]) * nro_days_in_a_week) + " dias ",
input_text)
return input_te... | <python><regex><string><if-statement><lambda> | 2022-12-17 13:40:34 | 1 | 875 | Matt095 |
74,834,362 | 16,009,435 | Know when upload to s3 bucket is complete | <p>I am using boto3 to upload an image to my s3 bucket and the below proccess works fine. What I want is, how can I know when the upload process is complete. Maybe print 'upload complete' when done. How can I achieve this? Thanks in advance.</p>
<pre><code>import boto3
s3 = boto3.resource('s3')
file = open(imagePath, ... | <python><amazon-web-services><amazon-s3><boto3> | 2022-12-17 13:12:59 | 1 | 1,387 | seriously |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.