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 ⌀ |
|---|---|---|---|---|---|---|---|---|
77,745,876 | 2,801,669 | What is the json_schema attribute of core_schema.json_or_python_schema used for in pydantic | <p>Assume I have an external Class <code>OriginalExternalClass</code> whose code I can not be modified. I want to use that external class as a field of another class called <code>PydanticClassWithExternalClassMember</code> which derives from pydantic <code>BaseModel</code>.</p>
<p>I want circumvent using the arbitrary ... | <python><python-3.x><pydantic-v2> | 2024-01-02 11:48:00 | 1 | 1,080 | newandlost |
77,745,851 | 2,827,181 | a col("Masse hydrique").divide(lit(100)) succeeds with Scala, but fails with Python, with a "'Column' object is not callable" error | <p>I'm converting a Zeppelin notebook written is Scala into a Jupyter one, with Python</p>
<p>This piece of code is working with Scala:</p>
<pre class="lang-scala prettyprint-override"><code>import org.apache.spark.sql.types.DateType;
val poidsCsvFile = "/home/lebihan/correctionPoids.csv";
var poids = spark.... | <python><apache-spark> | 2024-01-02 11:41:26 | 2 | 3,561 | Marc Le Bihan |
77,745,786 | 1,533,811 | can the merchants disable the shopee's Buyer Info masking functionality | <p>I am consuming the Shopee API "get_order_detail" and Im getting masked data in the shipping section of the response as shown below</p>
<pre><code>{'name': '****', 'phone': '****', 'town': '****', 'district': '****', 'city': '****',
'state': '****', 'region': '****', 'zipcode': '****', 'full_address': '***... | <python><shopee> | 2024-01-02 11:30:49 | 0 | 794 | balaji |
77,745,673 | 5,594,008 | Poetry add command removes category from lock file | <p>My current poetry.lock file looks like this (part of it)</p>
<pre><code># This file is automatically @generated by Poetry and should not be changed by hand.
[[package]]
name = "annotated-types"
version = "0.6.0"
description = "Reusable constraint types to use with typing.Annotated"
cat... | <python><python-poetry> | 2024-01-02 11:07:59 | 1 | 2,352 | Headmaster |
77,745,537 | 746,703 | pyside6-designer - libpython3.12.dylib (no such file) | <p>I want to start pyside6-designer after I installed Python 3.12.1 via pyenv, which was successful. I also installed pyside6 via pip, which also was successful.</p>
<p>Now, when I want to start the designer with <code>pyside6-designer</code>, I get this error:</p>
<pre><code>Error: dyld[28253]: terminating because ins... | <python><qt-designer><pyside6> | 2024-01-02 10:42:04 | 2 | 545 | Danzzz |
77,745,266 | 1,851,425 | Create a local settings file using poetry | <p>I have a python script that checks some files in a certain directory that uses a settings.ini file with local settings to a database and where the rootdir of the files to check is located on your environment and some git settings.</p>
<p>This file was now on the same directory as the script.
In the code I used the f... | <python><python-3.x><python-poetry> | 2024-01-02 09:49:42 | 1 | 2,139 | nightfox79 |
77,745,248 | 9,814,710 | MaxPooling operation on temporal data - select signal with the highest amplitude | <p>Is there any clean way to perform Maxpooling operation on temporal data (i.e. signal with highest amplitude will be the output).</p>
<p>For example,</p>
<pre class="lang-py prettyprint-override"><code># sample four sin signals
a = 2*tf.math.sin(tf.linspace(0, 10, 200))
b = 0.1*tf.math.sin(2*tf.linspace(0, 10, 200))
... | <python><tensorflow><conv-neural-network> | 2024-01-02 09:46:32 | 1 | 511 | Vigneswaran C |
77,744,784 | 5,572,627 | Python multiprocess pool.map takes too long for initialization | <pre><code>%%time
import pandas as pd
from datetime import datetime
from multiprocessing import Pool
def get_id(x):
return x['motor_id']
def parallel_load(df, get_id):
print('parallel_load: ', datetime.now())
return df.apply(lambda x: get_id(x), axis=1)
def parallel_df(df, func, n_cores):
print('sta... | <python><multiprocess> | 2024-01-02 08:01:51 | 0 | 581 | Isaac Sim |
77,744,319 | 785,581 | Telethon: login not saved | <p>I want to write my own client for the Telegram messenger in Python. For this I use the <a href="https://github.com/LonamiWebs/Telethon" rel="nofollow noreferrer">Telethon</a> library. I take the example code <a href="https://stackoverflow.com/questions/77744149/telethon-how-to-get-information-about-yourself-correctl... | <python><telegram><telethon> | 2024-01-02 05:37:35 | 1 | 1,154 | Andrey Epifantsev |
77,744,169 | 3,291,077 | Docstring doesn't show on hover in vscode jupyter notebook | <p>When I import a function into a vscode notebook, instead of getting a docstring I just get this:</p>
<p><a href="https://i.sstatic.net/7RktN.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7RktN.png" alt="enter image description here" /></a></p>
<p>Here is the function:</p>
<pre><code>def balance_bina... | <python><visual-studio-code><autocomplete><docstring> | 2024-01-02 04:32:59 | 0 | 4,465 | rgalbo |
77,744,149 | 785,581 | Telethon: how to get information about yourself correctly? | <p>I want to write my own client for the Telegram messenger in Python. I use the <a href="https://github.com/LonamiWebs/Telethon" rel="nofollow noreferrer">Telethon</a> library. I took the code example from their main page:</p>
<pre><code> from telethon import TelegramClient
api_id = my_id
api_hash = 'my_hash'
cli... | <python><telegram><telethon> | 2024-01-02 04:21:11 | 2 | 1,154 | Andrey Epifantsev |
77,744,086 | 1,285,061 | Numpy use one array as mask for another array | <p>I am trying to do these steps in NumPy. It was easy to do this with python list <code>sort()</code>, and <code>argsort()</code>.</p>
<p>How do I do this in Numpy?</p>
<pre><code>a = np.array([10,30,20,40,50])
a_sorted = np.array([10,20,30,40,50])
</code></pre>
<p>Get mask of a_sorted</p>
<pre><code>b = np.array(['... | <python><arrays><numpy><sorting><mask> | 2024-01-02 03:46:40 | 0 | 3,201 | Majoris |
77,744,025 | 10,200,497 | Keep the previous maximum value and create a new column | <p>This is my DataFrame:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
{
'a': [1, 9, 8, 10, 7, 11, 20]
}
)
</code></pre>
<p>And this is the output that I want. I want to create column <code>b</code>:</p>
<pre><code> a b
0 1 1
1 9 9
2 8 9
3 10 10
4 7 10
5 11 11
6 20 20
... | <python><pandas><dataframe> | 2024-01-02 03:12:37 | 1 | 2,679 | AmirX |
77,743,898 | 10,200,497 | Keep the previous maximum value after the streak ends | <p>This is my dataframe:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
{
'a': [110, 115, 112, 180, 150, 175, 160, 145, 200, 205, 208, 203, 206, 207, 208, 209, 210, 215],
'b': [1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1],
}
)
</code></pre>
<p>And this is the output that I want... | <python><pandas><dataframe> | 2024-01-02 02:07:36 | 1 | 2,679 | AmirX |
77,743,753 | 5,484,417 | Python print function stopped working after installing super-gradients in Google Colab | <p>After installing super-gradients with different ways in Google Colab including <code>!pip install -qq super_gradients==3.5</code> and importing it, the python print() function stopped working and calling it resulted in no displaying output.</p>
| <python><google-colaboratory> | 2024-01-02 00:34:33 | 2 | 440 | CVDE |
77,743,561 | 3,486,773 | How do I left align data in pandas dataframe in tkinter label? | <p>I am trying to display a pandas dataframe in a tkinter label in a popup window so that the user can easily see the data.</p>
<p>Here is the code:</p>
<pre><code>from tkinter import Toplevel, Button, Tk
import tkinter as tk
import pandas as pd
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows... | <python><pandas><dataframe><tkinter><label> | 2024-01-01 22:46:22 | 1 | 1,278 | user3486773 |
77,743,557 | 338,479 | Python3 curses segfault on stdscr.refresh() | <p>Here is a very small program that demonstrates the problem:</p>
<pre><code>#!/usr/bin/env python3
import curses
import sys
import time
def main():
try:
stdscr = curses.initscr()
stdscr.clear()
stdscr.addstr(0,0, "This is the prompt")
stdscr.refresh()
time.sleep... | <python><python-3.x><macos><curses><macos-ventura> | 2024-01-01 22:45:29 | 2 | 10,195 | Edward Falk |
77,743,536 | 19,366,064 | How to remove trailing comma for Python code formatter Ruff | <p>Before applying the ruff formatter</p>
<pre><code>def method(arg1, arg2, arg3, ..., arg10):
</code></pre>
<p>After applying the ruff formatter</p>
<pre><code>def method(
arg1,
arg2,
arg3,
...,
arg10,
)
</code></pre>
<p>Is there a way to configure the ruff formatter to remove the trailing comma ne... | <python><visual-studio-code><ruff> | 2024-01-01 22:32:56 | 2 | 544 | Michael Xia |
77,743,437 | 14,735,451 | How to plot lists with different x axis and number of points? | <p>I have a collection of dictionaries:</p>
<pre><code>my_dict_1 = {"x=0": 0.33282876064333017, "x=50": 0.3466414380321665, "x=110": 0.3540208136234626, "x=120": 0.350236518448439, "x=130": 0.35042573320719017, "x=140": 0.33415326395458844, "x=150": ... | <python><matplotlib> | 2024-01-01 21:42:21 | 1 | 2,641 | Penguin |
77,743,320 | 12,178,630 | Read black and white image with OpenCV | <p>I tried to simply read a binary mask image that I have created. When I read it using</p>
<pre><code>bw_mask = cv2.imread('image.png')
</code></pre>
<p>the image is read as a numpy array of zeros that looks like:</p>
<pre><code>array([[[0, 0, 0],
[0, 0, 0],
[0, 0, 0],
...,
[0, 0, 0],
[0, 0, 0],
... | <python><numpy><opencv><image-processing> | 2024-01-01 20:54:28 | 1 | 314 | Josh |
77,743,218 | 1,319,998 | SQLite locking for xFileSize and xTruncate | <p>I'm writing a <a href="https://www.sqlite.org/c3ref/io_methods.html" rel="nofollow noreferrer">VFS</a> for SQLite using <a href="https://rogerbinns.github.io/apsw/vfs.html" rel="nofollow noreferrer">APSW's VFS layer</a>: <a href="https://github.com/michalc/sqlite-memory-vfs" rel="nofollow noreferrer">https://github.... | <python><python-3.x><multithreading><sqlite><locking> | 2024-01-01 20:17:05 | 1 | 27,302 | Michal Charemza |
77,743,164 | 8,372,755 | Orange Data Mining Python Script for LGBM w/optimization. Not showing parameters | <p>I tried to replicate the behavior of the Orange widgets for models like XGBoost. In this case, I managed to get the Test&Score to show results using LightGBM with Bayesian optimization. I had to create a wrapper and finally printed the parameters in the console, but I intend them to be viewable in a data table. ... | <python><orange> | 2024-01-01 19:54:08 | 0 | 409 | Antonio Velazquez Bustamante |
77,743,159 | 827,927 | Create a curve in which the space between points is balanced | <p>If I want to plot the curve of a function, say 1/x, between 0.1 and 10, I can do it like this:</p>
<pre><code>xx = np.linspace(0.1,10,1000)
yy = 1.0/xx
plt.plot(xx,yy)
</code></pre>
<p>The problem is that the spacing between points is not balanced along the curve. Specifically, at the left of the curve, where x<y... | <python><numpy><curve> | 2024-01-01 19:51:59 | 1 | 37,410 | Erel Segal-Halevi |
77,743,056 | 20,266,647 | Python OSError: [Errno 22] Invalid argument for datetime.timestamp() | <p>I got the issue in Python 3.9 under Windows, for datetime.timestamp():</p>
<pre><code>Traceback (most recent call last):
File "C:\Python\qgate-sln-mlrun\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3508, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<... | <python><timestamp> | 2024-01-01 19:12:04 | 1 | 1,390 | JIST |
77,742,927 | 5,800,969 | Selenium chromedriver not able to download file on virtual machine but downloading on local in headless mode using google-chrome | <p>I am download a file on download button click in default download folder using code below.</p>
<pre><code> prefs = {"download.default_directory": file_download_folder_path,
"download.prompt_for_download": False,
"download.directory_upgrade": True,
... | <python><selenium-webdriver><selenium-chromedriver><virtual-machine> | 2024-01-01 18:29:42 | 1 | 2,071 | iamabhaykmr |
77,742,640 | 16,136,190 | MoviePy: CompositeVideoClip generates blank, unplayable video | <p>I'm trying to generate a video: the image at the top, the text in the center and the video at the bottom.
I don't want any gap between them. The image is resized to become the first half, so the height is set to <code>960</code> (the final video is <code>1080 x 1920</code>). Similarly, the video is resized and cropp... | <python><mp4><moviepy><video-editing> | 2024-01-01 17:00:40 | 1 | 859 | The Amateur Coder |
77,742,624 | 22,466,650 | How to group items of a list based on their type transition? | <p>My input is a list:</p>
<pre><code>data = [
-1, 0,
'a','b', 1, 2, 3,
'c', 6,
'd', 'e', .4, .5,
'a', 'b', 4,
'f', 'g',
]
</code></pre>
<p>I'm trying to form groups (dictionary) where the keys are the strings and the values are the numbers right after them.</p>
<p>There are however three detail... | <python> | 2024-01-01 16:54:43 | 4 | 1,085 | VERBOSE |
77,742,544 | 17,932,951 | Maximize daily profit problem using Python and Pulp | <p>I am having trouble while trying to maximize the daily profit of a chocolate factory.</p>
<p>Problem: Maximize daily profit of a factory that produces individual chocolates(each one having a profit and a maximum daily production capacity), and special packs (each of them containing 3 chocolates and a profit). Exampl... | <python><pulp> | 2024-01-01 16:26:16 | 2 | 325 | Jay Craig |
77,742,521 | 4,177,926 | call python class method from c++ in pybind11 | <p>Consider a Callback class in Python.</p>
<pre><code>class My_Callback():
def __init__(self):
pass
def do_something(self, something):
print(something)
</code></pre>
<p>This Class is used in a DLL wrapper which is using pybind11 to expose it to python. A reference to the Class is stored in... | <python><c++><pybind11> | 2024-01-01 16:17:13 | 1 | 2,283 | user_na |
77,742,431 | 7,563,454 | Function that takes either a single argument or a tuple treated as multiple arguments | <p>There is a circumstance where I have a get function which returns a tuple of items. I have a set function and I want it to take either a single item, or the resulting tuple as multiple arguments. However if I use <code>*args</code> as the parameter of the set function to allow a variable number of results, it won't ... | <python> | 2024-01-01 15:50:40 | 2 | 1,161 | MirceaKitsune |
77,742,336 | 1,293,127 | Serialize SqlAlchemy query across process boundary | <p>Using <code>Python==3.10.12</code> and <code>sqlalchemy==2.0.23</code> (and postgres 12 under Ubuntu, if that makes any difference):</p>
<p><strong>How do I serialize an existing SqlAlchemy query so I can deserialize it and fetch its results in another process?</strong></p>
<p>In other words, I have a SqlAlchemy <co... | <python><sqlalchemy><orm> | 2024-01-01 15:20:41 | 2 | 8,721 | user124114 |
77,742,298 | 2,372,954 | Where should I store a bunch of strings I intend on using in a single feature (for a short amount of time)? | <p>I have a (relatively) big and complex (Django) app with multiple database tables.</p>
<p>Now, I'm building the landing page of a new feature that includes a section where are displayed 3 random sentences from a collection of 10 predefined strings.</p>
<p>I want to be able to update and change these strings without h... | <python><django><database><design-patterns> | 2024-01-01 15:08:43 | 1 | 360 | ahmed |
77,742,010 | 9,135,359 | Bad Request received in trying to get Flask form to display | <p>I have a simple Flask form that takes the username but it doesn't work. I keep getting a <code>Bad Request</code> error. Here's my code:</p>
<p>This is my <code>main.py</code>:</p>
<pre><code>from flask import Flask, render_template, request
app = Flask(__name__)
@app.route("/", methods=["GET",... | <python><flask> | 2024-01-01 13:19:18 | 1 | 844 | Code Monkey |
77,741,969 | 10,415,970 | SQLAlchemy access session within Base class method? | <p>I'm wanting to access a session from within my Base class's method without passing it in as an argument like this:</p>
<pre class="lang-py prettyprint-override"><code>class Job(Base):
__tablename__ = 'jobs'
# id = ..., etc.
def evaluate(self):
keywords = session.query(Keyword).all() # <-... | <python><sqlalchemy> | 2024-01-01 12:59:15 | 1 | 4,320 | Zack Plauché |
77,741,925 | 453,851 | Does python expose an interface for parsing package metadata? | <p><em>Note: I am <strong>NOT</strong> looking for a way to interrogate installed packages in the virtual environment and do not want to load packages in order to parse them.</em></p>
<p>I'm looking for a way to parse meta data from files [wheels and tar.gz] downloaded from pypi. The format isn't so complex so I'm not... | <python><pypi><python-wheel> | 2024-01-01 12:40:13 | 2 | 15,219 | Philip Couling |
77,741,075 | 16,319,191 | Merge dfs but avoid duplication of columns and maintain the order in Pandas | <p>All the dfs have a key col "id".
pd.merge is not a viable option even with the suffix option.
There are over 40k cols in each of the dfs so column binding and deleting later (suffix_x) is not an option. Exactly 50k (common) rows in each of the dfs identified by "id" col.</p>
<p>Minimal example wi... | <python><pandas><dataframe> | 2024-01-01 05:58:20 | 1 | 392 | AAA |
77,740,923 | 10,200,497 | Replacing a value with its previous value in a column if it is greater | <p>This is my DataFrame:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
{
'a': [101, 90, 11, 120, 1]
}
)
</code></pre>
<p>And this is the output that I want. I want to create column <code>y</code>:</p>
<pre><code> a y
0 101 101.0
1 90 101.0
2 11 90.0
3 120 120.0
4 1 ... | <python><pandas><dataframe> | 2024-01-01 04:02:28 | 2 | 2,679 | AmirX |
77,740,864 | 6,383,910 | How to generate unique sequences? | <p>I am trying to solve <a href="https://leetcode.com/problems/combination-sum-iv/" rel="nofollow noreferrer">377. Combination Sum 4</a>.</p>
<pre><code>Output: 7
Explanation:
The possible combination ways are:
(1, 1, 1, 1)
(1, 1, 2)
(1, 2, 1)
(1, 3)
(2, 1, 1)
(2, 2)
(3, 1)
</code></pre>
<p>Here's my solution so far:</... | <python><python-3.x> | 2024-01-01 03:02:50 | 2 | 2,132 | Gingerbread |
77,740,674 | 11,850,322 | Pandas Groupby - Run Self Function - Then Transform(Apply) | <p>I need to run regression for each group, then pass the coefficients into the new column <code>b</code>. Here is my code:</p>
<p><strong>Self-defined function:</strong></p>
<pre><code>def simplereg(g, y, x):
try:
xvar = sm.add_constant(g[x])
yvar = g[y]
model = sm.OLS(yvar, xvar, missing='... | <python><python-3.x><pandas><group-by> | 2024-01-01 00:22:02 | 1 | 1,093 | PTQuoc |
77,740,623 | 2,821,586 | How do I get access to Python doctest verbose flag inside a test? | <p>How do I get access to Python 3.8 doctest verbose flag inside a test?
I see it as <code>DocTestRunner._verbose</code> but I would need an instance to grab it from.
I'm trying to do something like</p>
<pre><code>def MyClass
"""
>>> if doctest.DocTestRunner.instance._verbose: printFancyStuf... | <python><doctest><verbose> | 2023-12-31 23:42:28 | 0 | 1,230 | brewmanz |
77,740,559 | 1,278,584 | Using BeautifulSoup, is there a way to target all elements with that contain a class name except the ones that contain an additional class name? | <p>I am looking to see if there is a way to <code>find_all</code> elements that have a certain class name, but remove the elements that contain an additional class name.</p>
<pre><code><div class="abc">1</div>
<div class="abc def">2</div> #Do not select
<div class="ab... | <python><python-3.x><beautifulsoup> | 2023-12-31 23:00:18 | 2 | 724 | zeropsi |
77,740,515 | 9,582,542 | Scrapy Shell extract text only from div class element | <p>I am trying to pull only the dates values from this site <a href="http://www.nflweather.com/" rel="nofollow noreferrer">http://www.nflweather.com/</a></p>
<p>I believe I have the code but I need to clean up the result a little bit</p>
<pre><code>response.xpath('//div[@class="fw-bold text-wrap"]/text()').ex... | <python><scrapy> | 2023-12-31 22:32:06 | 1 | 690 | Leo Torres |
77,740,462 | 2,817,602 | Deconvolution of distributions defined by histograms | <p>I'm reading an excellent paper (<a href="https://onlinelibrary.wiley.com/doi/full/10.1002/sim.9173" rel="nofollow noreferrer">here</a>) in which the authors begin with a dataset of effect estimates from randomized control trials.</p>
<p>In theory, these numbers are a convolution between an unknown distribution and a... | <python><scipy><signal-processing> | 2023-12-31 21:59:50 | 1 | 7,544 | Demetri Pananos |
77,740,412 | 12,160,503 | how to make a portable version of chrome for testing for linux | <p>After downloading chrome for testing from the official channel, I tried running it on my WSL2 as a test for work but it seems that it requires certain dependencies. Is there any way to create a portable version of it with all required dependencies? It being installed without its dependencies seems absurd but it is w... | <python><google-chrome><testing><chrome-for-testing> | 2023-12-31 21:31:33 | 1 | 1,720 | Isaac Anatolio |
77,740,183 | 3,748,679 | Use the same attributes of one class from the super class python | <p>I have two python classes <code>A</code> and <code>B(A)</code>. I want to use the variables of <code>A</code> in <code>B</code>. I mean when I create an instance of A with <code>a=16</code>, and an instance of <code>B</code> as the code shows, I want to have <code>b.a=16</code>. What is the problem here?</p>
<p>I ma... | <python> | 2023-12-31 19:18:52 | 1 | 1,594 | Jika |
77,740,070 | 1,914,781 | white line show after add background rect to second subplot | <p>I have a subplots with a rect shape as background. I would like to:
1. remove the white line above x-axis at the second subplots.
2. remove the white area near y-axis at the second subplot.</p>
<pre><code>import pandas as pd
def save_fig(fig,pngname):
fig.write_image(pngname,format="png",width=600,hei... | <python><plotly> | 2023-12-31 18:10:51 | 0 | 9,011 | lucky1928 |
77,739,972 | 7,563,454 | Get the frame number for a looping animation range based only on system time | <p>I'm looking for a way to animate a sprite using just the system time, without having to increment and store the active frame or time passed as a variable. I should be able to achieve this by properly stretching and looping the ms to get a range, accounting for animation speed the total number of frames and the range... | <python><python-3.x><pygame><game-engine><game-development> | 2023-12-31 17:32:38 | 1 | 1,161 | MirceaKitsune |
77,739,328 | 19,336,534 | Code Infilling fine-tuning with llama code | <p>I have a dataset of java methods and I want to fine-tune a code llm to provide accurate method names. Right now the dataset is in a .txt format with methods in text separated by a delimiter(###del###).<br />
To do this I thought about using CodeLLaMa and more specifically code infilling.<br />
From the original docu... | <python><pytorch><huggingface-transformers><huggingface> | 2023-12-31 13:49:18 | 0 | 551 | Los |
77,739,005 | 13,241,651 | Langchain OpenAI ImportError: cannot import name 'Iterator' from 'typing_extensions' (/usr/local/lib/python3.10/dist-packages/typing_extensions.py) | <pre><code>!pip install langchain openai --use-deprecated=legacy-resolver
</code></pre>
<pre class="lang-py prettyprint-override"><code>from langchain.llms import OpenAI
llm = OpenAI()
</code></pre>
<p>ERROR:</p>
<pre class="lang-bash prettyprint-override"><code>ImportError Traceback (mos... | <python><openai-api><langchain><py-langchain> | 2023-12-31 11:27:08 | 2 | 3,200 | Niteesh |
77,738,976 | 11,748,924 | vscode python autoformat indentation to 2 spaces instead of 4 spaces when saving the file | <p>How do I make my source code of python to forced using 2 spaces indentation when clicking save file. ChatGPT code generated always produce 4 spaces that's why I asked this. I don't feel comfortable for 4 spaces indentation in python. I tried autopep8 formatter extension but it didn't help me.</p>
<p>Here is my curre... | <python><visual-studio-code><indentation><auto-indent> | 2023-12-31 11:17:08 | 2 | 1,252 | Muhammad Ikhwan Perwira |
77,738,852 | 8,443,985 | pyspark print in for loop not working properly and skips some values | <p>I wrote a pyspark code like this:</p>
<pre><code>for current_date in dates_list:
print(f'loop started: {current_date}')
loop_start_date = current_date - timedelta(days=90)
dates_ = [loop_start_date + timedelta(days=i) for i in range((current_date - loop_start_date).days + 1)]
dates = ','.join(map(lam... | <python><pyspark><jupyter-notebook><bigdata> | 2023-12-31 10:26:19 | 0 | 796 | mohammad hassan bigdeli shamlo |
77,738,486 | 1,165,201 | Why can't I import from autoawq which was already installed? | <p>For this code</p>
<pre><code>from awq import AutoAWQForCausalLM
from transformers import AutoTokenizer
model_path = 'lmsys/vicuna-7b-v1.5'
quant_path = 'vicuna-7b-v1.5-awq'
quant_config = { "zero_point": True, "q_group_size": 128, "w_bit": 4, "version": "GEMM" }
# ... | <python><huggingface-transformers><large-language-model> | 2023-12-31 07:13:50 | 1 | 1,531 | susanna |
77,738,358 | 4,555,858 | Find max row value using .shift and .apply in pandas | <p>I have the following data frame:</p>
<pre><code>df = pd.DataFrame({'A': [2.001, 4.001, 8.001, 0.001],
'B': [2.001, 0.001, 0.001, 0.001],
'C': [11.001, 12.001, 11.001, 8.001],
'D': [12.001, 23.001, 12.001, 8.021],
'E': [11.001, 24.001, 18.001... | <python><pandas> | 2023-12-31 06:09:50 | 4 | 483 | Prateek Daniels |
77,738,283 | 13,759,058 | Is there a way in python to "emulate" running a python file? | <p>I want to be able to programmatically run a file, arbitrarily give it inputs (stdin) at any time, and periodically poll for any stdout. I also want to be able to kill the process whenever I want.</p>
<p>Here's what I have tried:</p>
<pre class="lang-py prettyprint-override"><code>import subprocess
from threading imp... | <python><subprocess><execution> | 2023-12-31 05:24:45 | 1 | 315 | Coder100 |
77,738,266 | 14,818,796 | How to make pydantic class fields immutable? | <p>I am trying to create a pydantic class with Immutable class fields (not instance fields).</p>
<p>Here is my base code:</p>
<pre><code>from pydantic import BaseModel
class ImmutableModel(BaseModel):
_name: str = "My Name"
_age: int = 25
ImmutableModel._age = 26
print("Class variables:")... | <python><python-3.6><pydantic> | 2023-12-31 05:14:18 | 3 | 1,001 | Arud Seka Berne S |
77,737,988 | 313,756 | How to create a temporary directory for a feature in python's behave (cucumber)? | <p>I'm trying to do a python port of some ruby code that uses <a href="https://cucumber.io/docs/cucumber/api/?lang=ruby" rel="nofollow noreferrer">Cucumber</a> for testing. I'm attempting to use the exact same feature files in the new port. One of the features looks a bit like:</p>
<pre><code>Feature: <whatever>... | <python><cucumber><python-behave> | 2023-12-31 01:50:13 | 1 | 10,469 | lindes |
77,737,904 | 1,625,455 | Apply an arbitrary function to Pandas dataframe groupby | <p>How do I apply an arbitrary function group-wise to Pandas dataframe? The function should be able to access an entire group df at once, as if it were a full pandas dataframe.</p>
<pre><code>import pandas as pd
def arbitrary_function(df):
"""This function acts on groups of a df. It can see every row... | <python><pandas><function><group-by> | 2023-12-31 01:02:00 | 1 | 346 | Atomic Tripod |
77,737,859 | 12,104,604 | How to pass results calculated in an external class to other classes and constantly update the values? | <p>I am creating code in Python. The following code is created using a GUI library called Kivy. It's code that automatically calculates and changes the font size when the UI size changes.</p>
<pre><code>#-*- coding: utf-8 -*-
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.core.text.markup... | <python><kivy> | 2023-12-31 00:34:10 | 1 | 683 | taichi |
77,737,797 | 5,036,928 | Generating uniformly spaced points along a Spline | <p>Maybe this post is better suited for Code Review SE but here goes:</p>
<p>I have a series of 3-5 points that are fairly distant. I would like to generate a spline using these points and sample N points along the spline. The only tool/algorithm I've found for this is <a href="https://www.google.com/url?sa=t&rct=j... | <python><matlab><scipy><interpolation> | 2023-12-31 00:02:46 | 0 | 1,195 | Sterling Butters |
77,737,772 | 5,942,779 | How to eliminate duplicate legends in Plotly with subplot (Python)? | <p>The following codes generate 2 plotly charts and lay them out in subplots. Each subplot contains legends that partially overlap with another subplot. As a result, there are duplicated legends on the right. Does anyone know a better way to eliminate duplicated legends in this situation? Thanks.</p>
<pre class="lang-p... | <python><plotly> | 2023-12-30 23:52:17 | 1 | 689 | Scoodood |
77,737,760 | 4,440,436 | Pandas join with multi-index and NaN | <p>I am using Pandas 2.1.3.</p>
<p>I am trying to join two DataFrames on multiple index levels, and one of the index levels has NA's. The minimum reproducible example looks something like this:</p>
<pre><code>a = pd.DataFrame({
'idx_a':['A', 'A', 'B'],
'idx_b':['alpha', 'beta', 'gamma'],
'idx_c': [1.0, 1.0,... | <python><pandas><dataframe> | 2023-12-30 23:47:29 | 3 | 413 | tcquinn |
77,737,562 | 9,346,630 | Scraping XML data from ClinicalTrials API V2 | <p>I am trying to reproduce the results of these questions:
<a href="https://stackoverflow.com/questions/70011389/python-beautifulsoup-scraping-xml-data-from-clinicaltrials-gov-api-parse-d">Scraping xml data from clinicaltrials</a> and <a href="https://stackoverflow.com/questions/70029265/python-beautifulsoup-extractin... | <python><xml><web-scraping><beautifulsoup> | 2023-12-30 22:11:29 | 1 | 493 | torakxkz |
77,737,462 | 11,268,857 | Using macro keyboard as app control board | <p>A while back, I bought a small 12-key (+2 rotary toggles) macro keyboard that can be programmed with various keys (<a href="https://github.com/jonnytest1/minikeyboard" rel="nofollow noreferrer">https://github.com/jonnytest1/minikeyboard</a>)</p>
<p>Now I want to use that keyboard to control random apps, but without ... | <python><keyboard><usb><hid><pywinusb> | 2023-12-30 21:29:57 | 0 | 881 | jonathan Heindl |
77,737,440 | 1,064,197 | Why selenium can't find element to click using xpath or css selector? | <p>I am trying to click on a ">" on the page here but the chrome XPATH or CSS Selector can't find it. I am trying to navigate through dates and get a table per date.
<a href="https://theanalyst.com/na/2023/08/opta-football-predictions/" rel="nofollow noreferrer">https://theanalyst.com/na/2023/08/opta-foo... | <python><selenium-webdriver><xpath><css-selectors><selenium-chromedriver> | 2023-12-30 21:22:59 | 2 | 2,625 | Michael WS |
77,737,430 | 893,254 | Multiprocessing in python where only one thread (process) may use one of a set of values at one time | <p>I am in the process of attempting to automate some slow processes by multithreading (multiprocessing - parallelizing) them with Python.</p>
<p>However I have a problem. Each running process must take a piece of data as an argument. For each piece of data, only one instance of each piece of data must be in use at any... | <python><multithreading><algorithm><parallel-processing><multiprocess> | 2023-12-30 21:17:05 | 4 | 18,579 | user2138149 |
77,737,429 | 519,422 | Python Pandas: why are some data missing from my dict when I get data from JSON-formatted text via dict(line.strip().split(None, 1)? | <p>I need to get data (property names and values) from JSON-formatted files. I can get what I need from the files as a list of strings. I.e., this always works:</p>
<pre><code>f = open("f.txt", "r")
data = json.load(f);
f.close()
get = data["payload"]["blob"]["rawLines&quo... | <python><json><python-3.x><pandas><dataframe> | 2023-12-30 21:16:32 | 1 | 897 | Ant |
77,737,387 | 477,969 | Build Python as static library with won't include basic modules | <p>I am trying to get the ultimate performance in my application based on python.</p>
<p>I am already using Cython and everything works compiling it in C++.
I am even able to pack everything with PyInstaller and binary dist works.
Now I want to reduce the overhead of interactions between Python DLL and my module PYDs (... | <python><c++><python-3.x><build><static-linking> | 2023-12-30 20:58:52 | 0 | 2,114 | JairoV |
77,737,358 | 1,234,434 | How is a list element being converted to a Tuple | <p>I am learning python. My research using google hasn't hit on any description on what is occurring here. I'm doing some basic exercises.</p>
<p>A person on a the codewars website put this solution down for a problem:</p>
<pre><code>data=[[18, 20], [45, 2], [61, 12], [37, 6], [21, 21], [78, 9]]
def openOrSenior(data)... | <python><for-loop> | 2023-12-30 20:47:59 | 3 | 1,033 | Dan |
77,737,323 | 1,397,061 | Why does parallel reading of an HDF5 Dataset max out at 100% CPU, but only for large Datasets? | <p>I'm using Cython to read a single Dataset from an HDF5 file using 64 threads. Each thread calculates a start index <code>start</code> and chunk size <code>size</code>, and reads from that chunk into a common buffer <code>buf</code>, which is a memoryview of a NumPy array. Crucially, each thread opens its own copy of... | <python><cython><hdf5><hdf> | 2023-12-30 20:36:42 | 2 | 27,225 | 1'' |
77,737,131 | 17,365,694 | `UNIQUE constraint failed at: pharmcare_patient.id` in my pharmcare app | <p>I have a Django app in my project I am currently working on called pharmcare, and I kind of getting into a unique constraint issue whenever I want to override the <code>save()</code> method to insert/save the <code>total</code> payment made by the patient so that the pharmacist that is creating the form or updating ... | <python><django><postgresql><django-orm><django-class-based-views> | 2023-12-30 19:13:33 | 2 | 474 | Blaisemart |
77,737,099 | 5,378,816 | pylint without user site directory? | <p>My installation of <code>pylint</code> started to behave strangely. It complained that packgages that were present could not be imported. I found the problem in the <code>pylint</code> script's shebang line:</p>
<pre><code>#! /usr/bin/python3 -sP
</code></pre>
<p>where the <code>-s</code> option has following meanin... | <python><pylint> | 2023-12-30 19:01:32 | 0 | 17,998 | VPfB |
77,737,062 | 6,759,459 | AttributeError: module 'redis' has no attribute 'Redis' | <h2>Problem</h2>
<p>Installed <code>redis</code> module and I cannot establish the client according documentation.
This is a Redis client in a Redis cluster hosted on Docker container.</p>
<p>Following <a href="https://github.com/redis/redis-py" rel="nofollow noreferrer">documentation</a>, as you can see:</p>
<pre><cod... | <python><caching><docker-compose><redis><redis-cluster> | 2023-12-30 18:50:40 | 1 | 926 | Ari |
77,736,948 | 6,934,489 | How to exclude values from a dataframe based on values in a second dataframe | <p>I have two dataframes, df1 and df2, example:</p>
<p><code>df1</code>:</p>
<pre><code>Date ID Value
1/2/2013 001 1
2/5/2013 002 15
3/4/2013 001 2
1/1/2014 005 17
2/5/2014 004 1
7/1/2016 002 2
7/1/2016 001 4
8/1/2016 007 4
</code></pre>
<p><code>df2</code>:</p>
<pre><c... | <python><pandas><dataframe> | 2023-12-30 18:10:31 | 2 | 755 | DPdl |
77,736,879 | 1,938,410 | Two images do not perfect align when using Pillow putalpha to set image transparency | <p>I am learning to use Pillow library to process images, and I am following this tutorial (<a href="https://note.nkmk.me/en/python-pillow-putalpha/" rel="nofollow noreferrer">https://note.nkmk.me/en/python-pillow-putalpha/</a>) to use the <code>putalpha()</code> method. I was able to use the <code>horse.png</code> and... | <python><python-imaging-library><png> | 2023-12-30 17:45:22 | 1 | 507 | SamTest |
77,737,654 | 1,725,974 | `columns[summary.sort_values() > 0]` behaviour not making sense | <p>I have a result of <code>isna()</code> like this:</p>
<pre><code>data.isna().sum().sort_values()
</code></pre>
<pre><code>index 0
Longtitude 0
Latitude 0
Landsize 0
Bathroom 0
Bedroom2 0
Regionname 0
Distance 0
Postcode ... | <python><pandas> | 2023-12-30 17:27:01 | 1 | 1,539 | Anonymous Person |
77,736,713 | 1,089,412 | PyGObject failed to install because of pycairo failing | <p>I'm trying to install system wide <code>PyGObject</code>. But I'm struggling with some weird error that pops up when installer try to build <code>pycairo</code> wheel. I tried to upgrade and reinstall <code>setuptools</code> using <code>sudo python3 -m pip install --upgrade --force-reinstall setuptools</code> but th... | <python><pip><setuptools><pycairo> | 2023-12-30 16:55:48 | 0 | 3,306 | piotrekkr |
77,736,611 | 5,703,539 | Cannot access Flask Rest api with docker anywhere on internet via VPS | <p>I have a basic REST API implemented in Flask. I implemented Docker to containerize it and it works well locally. I then was able to push my project on a VPS cause I want my Flask api to be access anywhere on the internet.
But I wasn't able to do so, I can't access my Flask api on the host server. I'm completely new ... | <python><docker><flask><vps> | 2023-12-30 16:26:24 | 1 | 1,665 | kabrice |
77,736,516 | 2,923,617 | Django DRF use same URL pattern for different views | <p>In Django Rest Framework, I have two separate views for the same model. I would like to use the same url pattern to access both views, and differentiate between the two based on the method that is used. So I have something like:</p>
<pre><code>class MyObjectListAPIView(generics.ListAPIView):
pass
class MyObjec... | <python><django><django-rest-framework><django-views> | 2023-12-30 15:57:27 | 1 | 486 | NiH |
77,736,459 | 12,178,630 | Sequential pattern with numpy array | <p>I would like to automatically fill (3x3x3) numpy array of zeros with the pattern the looks like this this, it starts with the coordinate <code>(0.0, 0.0, 0.0)</code> then sequentially and in the order shown starts to increase the <code>z</code> by the amount of <code>3.5</code> and <code>y</code> by the amount <code... | <python><python-3.x><numpy><numpy-ndarray> | 2023-12-30 15:40:31 | 2 | 314 | Josh |
77,736,397 | 194,735 | LIBUSB_ERROR_NOT_FOUND in python when trying jdmtool | <p>I am trying to use JDMtool in macOS Mojave (python 3.11):</p>
<p><a href="https://github.com/dimaryaz/jdmtool" rel="nofollow noreferrer">https://github.com/dimaryaz/jdmtool</a></p>
<p>to write my GNS430 datacards from my Jeppesen subscription.
The app works as I can login and download my subscription navigation data... | <python> | 2023-12-30 15:24:33 | 1 | 1,959 | icordoba |
77,736,263 | 16,626,443 | Pandas .loc() method using "not" and "in" operators | <p>I have a data frame and I want to remove some rows if their value is not equal to some values that I have stored in a list.</p>
<p>So I have a list variable stating the values of objects I want to keep:</p>
<pre class="lang-py prettyprint-override"><code>allowed_values = ["value1", "value2", &quo... | <python><pandas><dataframe> | 2023-12-30 14:40:18 | 1 | 760 | Mo0rBy |
77,736,224 | 8,106,583 | Inconsistent Behavior: Printing C++ Struct Properties in Python using ctypes gives unexpected results | <p>I'm writing a c++ library that I'm importing in python with <code>ctypes</code>. The library implements a function <code>Wtf returnwtf()</code> that returns an object of type <code>Wtf</code> and I want to print the objects properties in Python. The code however behaves strangely.</p>
<p>Here is a minimum non-workin... | <python><c++><ctypes> | 2023-12-30 14:27:35 | 0 | 2,437 | wuerfelfreak |
77,735,997 | 485,330 | DynamoDB Auto-increment | <p>Since DynamoDB does not natively support <strong>sequential auto-increment</strong> for "user_id" like MySQL; what's the best way to increment the "user_id" to the next in sequence?</p>
<p>I'm querying the latest "user_id" and incrementing it; however, this feels pretty lame.</p>
<p>Is ... | <python><database><amazon-web-services><amazon-dynamodb><dynamodb-queries> | 2023-12-30 13:01:44 | 1 | 704 | Andre |
77,735,923 | 17,580,381 | itertools.pairwise backwards compatibility and a dubious Pylance warning | <p><a href="https://docs.python.org/3/library/itertools.html#itertools.pairwise" rel="nofollow noreferrer">The <code>pairwise</code> function</a> was added to <code>itertools</code> in Python version 3.10.</p>
<p>I would like to use that function or, where not available, define my own function based on the documented r... | <python><python-itertools><python-typing> | 2023-12-30 12:33:51 | 1 | 28,997 | Ramrab |
77,735,912 | 5,865,393 | Sort list of dictionaries based on relative time | <p>I have a CSV file that I create from an API response. I get it unsorted and the API response does not have a query parameter to sort the returned payload. The CSV looks like below, where column A has some device identifiers and column B has the configuration last sync of these devices. The time is represented in rel... | <python><csv><natural-sort><natsort> | 2023-12-30 12:31:51 | 1 | 2,284 | Tes3awy |
77,735,868 | 11,426,624 | stack multiple columns in a pandas dataframe | <p>I have a pandas data frame and would like to stack 4 columns to 2. So I have this</p>
<pre><code>df = pd.DataFrame({'date':['2023-12-01', '2023-12-05', '2023-12-07'],
'other_col':['a', 'b', 'c'],
'right_count':[4,7,9], 'right_sum':[2,3,5],
'left_count':[1,8,5], 'left_sum':[0,8,4]})
</code></pre>
<pre><code> date ... | <python><pandas><dataframe> | 2023-12-30 12:11:52 | 1 | 734 | corianne1234 |
77,735,843 | 893,254 | How do I change the table schema with SQL Alchemy? | <p>I have some code which defines and creates SQL database tables using the SQL Alchemy declarative style.</p>
<p>The reference for the declarative style can be found <a href="https://docs.sqlalchemy.org/en/20/orm/declarative_tables.html#accessing-table-and-metadata" rel="nofollow noreferrer">here</a>.</p>
<p>Tables ar... | <python><sqlalchemy> | 2023-12-30 11:59:13 | 1 | 18,579 | user2138149 |
77,735,761 | 18,100,562 | How to draw a circular arc / hallow sector in pyglet | <br>
I desperately trying to draw circular arc / hallow sector in pyglet.
E.g from this post where ArcType.ROUND is shown
https://github.com/pyglet/pyglet/issues/349
<p>This gives me a filled sector:
<code>Sector(x=200, y=200, radius=200, segments=200, angle=22.5, start_angle=0)</code></p>
<p>This gives me only the lin... | <python><pyglet> | 2023-12-30 11:27:39 | 1 | 507 | mister_kanister |
77,735,728 | 5,703,539 | Flask + Docker => No connection | <p>I have a basic REST API implemented in Flask. I want to try using Docker to containerize it. I'm completely new to Docker, but based on what I was able to figure out on various forums, this is what I have set up.</p>
<p>Dockerfile</p>
<pre><code>FROM python:3.11
WORKDIR /app
COPY ./requirements.txt /app/requirem... | <python><docker><flask><flask-restful> | 2023-12-30 11:14:04 | 2 | 1,665 | kabrice |
77,735,694 | 275,552 | Show state borders but not county borders on US Choropleth map | <p>I have some US county-level data and I want a choropleth map that does show state borders but not county borders. Following <a href="https://community.plotly.com/t/adding-state-lines-to-county-level-geojson-based-choropleth/36269" rel="nofollow noreferrer">this solution</a>, I end up with this:</p>
<p><a href="https... | <python><pandas><plotly><choropleth> | 2023-12-30 11:04:42 | 2 | 16,225 | herpderp |
77,735,535 | 3,291,993 | How to fill a pandas dataframe from two 2d numpy arrays in an efficient way? | <pre><code>import pandas as pd
import numpy as np
s = [ "S" + str(i) for i in range(1,101)]
c = [ "C" + str(i) for i in range(1,51)]
arr1 = np.random.randn(len(c),len(s))
arr2 = np.random.randn(len(c),len(s))
</code></pre>
<p>How to create and fill pandas dataframe df with 100 * 50 = 5000 rows for... | <python><pandas><dataframe><numpy> | 2023-12-30 10:05:21 | 1 | 1,147 | burcak |
77,735,200 | 8,444,568 | Why I get NAN when calculate corr of those two series? | <p>I have two pandas Series object:</p>
<pre><code>print(s1)
print("="*80)
print(s2)
# output
0 -0.443538
1 -0.255012
2 -0.582948
3 -0.393485
4 0.430831
5 0.232216
6 -0.014269
7 -0.133158
8 0.127162
9 -1.855860
Name: s1, dtype: float64
=================================================... | <python><pandas><dataframe> | 2023-12-30 07:38:54 | 1 | 893 | konchy |
77,735,153 | 10,200,497 | Creating a new column by giving multiple conditions priority | <p>This is my dataframe:</p>
<pre><code>df = pd.DataFrame(
{
'a': [10, 20, 55],
'b': [3, 40, 33],
'c': [4, 50, 10]
}
)
</code></pre>
<p>And this is the output that I want. I want to create column <code>d</code>.</p>
<pre><code> a b c d
0 10 3 4 1.0
1 20 40 50 0.0
2 5... | <python><pandas> | 2023-12-30 07:16:37 | 0 | 2,679 | AmirX |
77,734,966 | 9,915,864 | What settings am I missing in VS Code so that Flask print statement output shows up in terminal? | <p>I would like to get <code>print</code> statements to show up in my VS Code terminal. I'm running Flask 3.0 and Python 3.12 from VS Code 1.85.1.</p>
<p>Part A. I've read through a bunch of different posts and have assembled the following settings, mainly from <a href="https://stackoverflow.com/questions/49171144/how-... | <python><flask> | 2023-12-30 05:35:15 | 2 | 341 | Meghan M. |
77,734,721 | 106,906 | How to disable a subset of Pylint checks for modules matching a string or regex? | <p><strong>I know how to disable a check entirely:</strong></p>
<pre class="lang-ini prettyprint-override"><code>disable = ["missing-module-doctring", ...]
</code></pre>
<p><strong>But I'm trying to do the equivalent of this:</strong></p>
<pre class="lang-ini prettyprint-override"><code>disable = [ {name=&quo... | <python><pylint> | 2023-12-30 02:57:45 | 1 | 16,978 | Dogweather |
77,734,670 | 1,982,032 | What does above exception points to in exception info thrown? | <p>The simplest built-in exception as below:</p>
<pre><code>>>> 1/0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero
</code></pre>
<p>Throw exception info ,then whole press is done.</p>
<p>Define function <code>f1</code> and not ... | <python><exception><try-except> | 2023-12-30 02:19:22 | 1 | 355 | showkey |
77,734,349 | 10,200,497 | Creating a new column by a condition and selecting the maximum value by shift | <p>This is my DataFrame:</p>
<pre><code>import pandas as pd
df = pd.DataFrame(
{
'a': [10, 20, 30, 400, 50, 60],
'b': [897, 9, 33, 4, 55, 65]
}
)
</code></pre>
<p>And this is the output that I want. I want to create column <code>c</code>.</p>
<pre><code> a b c
0 10 897 NaN
1 ... | <python><pandas><dataframe> | 2023-12-29 23:24:57 | 4 | 2,679 | AmirX |
77,734,086 | 2,142,728 | Unclear how to import from a module defined in another target (python bazel) | <p>I have the following file structure</p>
<pre><code>.
├── bedrock
│ ├── BUILD
│ └── bedrock
│ ├── __init__.py
│ └── main.py
└── boilerplate
├── BUILD
└── main.py
</code></pre>
<pre class="lang-py prettyprint-override"><code># boilerplate/BUILD
py_binary(
name ... | <python><bazel> | 2023-12-29 21:33:49 | 1 | 3,774 | caeus |
77,734,040 | 519,422 | Python re: why isn't my code for replacing values in a file throwing errors or changing the values? | <p>I need to replace certain values in an external file ("<code>file.txt</code>") with new values from a Pandas dataframe. The external file contents look like:</p>
<pre><code>(Many lines of comments, then)
identifier1 label2 = i \ label3 label4
label5
A1 = -556... | <python><python-3.x><pandas><replace><python-re> | 2023-12-29 21:15:19 | 1 | 897 | Ant |
77,733,721 | 14,029,775 | Why does Pandas str.fullmatch blank values default to else? | <p>Let's say we have a dataframe col df['Old'] that looks like this</p>
<pre><code>0 NaN
1 NEWARK, NJ
</code></pre>
<p>And we apply this to fill out the values of a new col</p>
<pre><code>df['New']=np.where(df['Old'].str.fullmatch('.*,...')==False,'Value','Else Value')
</code></pre>
<p>The result is</p>
<... | <python><pandas><regex><string> | 2023-12-29 19:38:59 | 1 | 365 | Jonathan Chen |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.