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,896,895 | 15,768,044 | Using an existing Enum in new Alembic migration in python | <p>I've created Enum for one model in first migration:</p>
<pre><code>def upgrade() -> None:
β¦
gender_enum = postgresql.ENUM('MALE', 'FEMALE', 'OTHER', name='genderenum', create_type=False)
gender_enum.create(op.get_bind(), checkfirst=True)
op.add_column('user', sa.Column('gender', gender_enum, nulla... | <python><database><postgresql><alembic> | 2022-12-23 06:48:10 | 1 | 521 | aryadovoy |
74,896,614 | 14,624,039 | debug with terminal commands in vscode | <p>For some reason, I want to debug my python file in vscode via the command line.</p>
<p>I followed this guide. <a href="https://code.visualstudio.com/docs/python/debugging" rel="nofollow noreferrer">https://code.visualstudio.com/docs/python/debugging</a></p>
<p>The guide says that I can use this command</p>
<pre><cod... | <python><vscode-debugger> | 2022-12-23 06:04:23 | 1 | 432 | Arist12 |
74,896,585 | 273,506 | pandas replace values of a list column | <p>I have a dataframe like this</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">ID</th>
<th style="text-align: left;">Feeback</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">T223</td>
<td style="text-align: left;">[Good, Bad, Bad]</td>
</tr>
<tr>
<td... | <python><pandas><dataframe> | 2022-12-23 05:58:11 | 4 | 1,069 | Arjun |
74,896,349 | 1,230,724 | How to share zero copy dataframes between processes with PyArrow | <p>I'm trying to work out how to share data between processes with PyArrow (to hopefully at some stage share pandas DataFrames). I am at a rather experimental (read: Newbie) stage and am trying to figure out how to use PyArrow. I'm a bit stuck and need help.</p>
<p>Going through the documentation, I found an <a href="h... | <python><pandas><pyarrow> | 2022-12-23 05:15:40 | 2 | 8,252 | orange |
74,896,299 | 4,414,359 | Find if a string contains substring with a number, some distance from another substring | <p>I have a string like</p>
<pre><code>s = 'ahlkhsa-anchorawO&B6o77ooiynlhwlkfnbla,)9;}[test:""ajanchorkh,2Yio98vacpoi [p{7}]test:"2"*iuyanchorap07A(p)a test:""*^g8p9JiguanchorLI;ntest:"9.3"'
</code></pre>
<p>i'd like to see if there exists a substring <code>test:"some_n... | <python><regex><substring> | 2022-12-23 05:06:09 | 1 | 1,727 | Raksha |
74,896,124 | 7,190,950 | Python Selenium webdriver.Chrome() sometimes returns "Timeout error from renderer: 600.00" exception | <p>I'm using Selenium to run tests using Chrome Webdriver. Most of the time script works fine, but sometimes it returns a Timeout error when initializing webdriver.Chrome() constructor.</p>
<p>Below is the error message I'm receiving.</p>
<pre><code> Message: session not created
source-app-1 | from timeout: Timed o... | <python><selenium><selenium-chromedriver> | 2022-12-23 04:31:06 | 0 | 421 | Arman Avetisyan |
74,896,106 | 9,257,578 | How to remove elements from json file using python? | <p>I have a json file which looks like this</p>
<pre><code>{
"name1": {
"name": "xyz",
"roll": "123",
"id": "A1"
},
"name2":{
"name": &qu... | <python><json> | 2022-12-23 04:26:08 | 2 | 533 | Neetesshhr |
74,895,923 | 10,461,632 | Create a treemap showing directory structure with plotly graph object | <p>I want to create a treemap that shows the folders in a given directory, including all subfolders and files using <a href="https://plotly.com/python-api-reference/generated/plotly.graph_objects.Treemap.html" rel="nofollow noreferrer">plotly.graph_objects.Treemap</a>. I understand simple examples like this <a href="ht... | <python><plotly> | 2022-12-23 03:47:42 | 2 | 788 | Simon1 |
74,895,783 | 4,435,175 | Bruteforce 7z archive with a password list | <p>I have a 7z file and a password list.</p>
<p>I want to bruteforce that file with that list.</p>
<p>I use Windows 10, Python 3.11.1 and 7z 22.1.0.0</p>
<p>My code:</p>
<pre><code>path_7z: str = "C:/Program Files/7-Zip/7z.exe"
with open("passwords.txt", "r", encoding="UTF-8") as... | <python><7zip> | 2022-12-23 03:14:43 | 0 | 2,980 | Vega |
74,895,771 | 11,922,765 | Python Dataframe Find the length of maximum element in a dataframe | <p>I am trying to find the length (number of digits) in the maximum value of a data frame. Why? Then I know how much y-axis ticks will extend when plotting this data, and accordingly, I can adjust the plot's left border.</p>
<p>My code:</p>
<pre><code>df =
datetime A B C
2022-08-23 06:12:0... | <python><pandas><dataframe><matplotlib> | 2022-12-23 03:12:08 | 1 | 4,702 | Mainland |
74,895,761 | 19,826,650 | Showing multilabel in figures python knn | <p>i have this kind of csv data
<a href="https://i.sstatic.net/CoCvp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CoCvp.png" alt="example data" /></a>
i want to show them with matplotlib like this figure
<a href="https://i.sstatic.net/1I0wj.png" rel="nofollow noreferrer"><img src="https://i.sstatic.ne... | <python><matplotlib><machine-learning> | 2022-12-23 03:10:44 | 1 | 377 | Jessen Jie |
74,895,640 | 6,077,239 | How to do regression (simple linear for example) in polars select or groupby context? | <p>I am using polars in place of pandas. I am quite amazed by the speed and lazy computation/evaluation. Right now, there are a lot of methods on lazy dataframe, but they can only drive me so far.</p>
<p>So, I am wondering what is the best way to use polars in combination with other tools to achieve more complicated op... | <python><python-polars> | 2022-12-23 02:39:33 | 3 | 1,153 | lebesgue |
74,895,526 | 12,506,984 | ValueError: The truth value of an array with more than one element is ambiguous Use a.any() or a.all() in masked extracting code | <p>I am trying to use a mask to mark the elements in the vector nodes that are in the matrix e. For that I am using a mask for the vector nodes, and trying to set to false the corresponding position, so that at the end I can extract all elements in nodes that are left with a TRUE in the corresponding mask array</p>
<pr... | <python><arrays> | 2022-12-23 02:11:35 | 1 | 333 | some_math_guy |
74,895,516 | 4,377,095 | Add a new column for each item in a list inside a cell in a Pandas DataFrame | <p>Assuming I have this table</p>
<pre><code>import pandas as pd
df_test = pd.DataFrame()
df_test = df_test.assign(A=[[1,2,3], [1,2], [], [1,2,3,4]])
df_test
+ββββββββββββ+
| list |
+ββββββββββββ+
| [1,2,3] |
| [1,2] |
| [] |
| [1,2,3,4] |
+ββββββββββββ+
</code></pre>
<p>What I want to do is t... | <python><python-3.x><pandas> | 2022-12-23 02:09:39 | 3 | 537 | Led |
74,895,441 | 9,206,962 | Patching Function That Gets Imported In a Separate File | <pre><code># a.py
from b import my_func
def do_something():
my_func()
# b.py
from c import my_other_func # patch this while testing a.do_something()
def my_func():
my_other_func()
</code></pre>
<p>I have a unit test for <code>do_something</code> and I need to mock out something that gets imported in another ... | <python><pytest><patch><pytest-mock> | 2022-12-23 01:50:51 | 2 | 417 | michjo |
74,895,435 | 1,229,736 | Generator with For In only returning first character instead of the whole string | <p>I want this generator to return these characters in a loop: "><><><"
instead it's only returning the first character ">>>>>>"</p>
<p>if I replace yield with print it works correctly, why is it only returning the first character?</p>
<pre><code>def gn():
whi... | <python><loops><generator> | 2022-12-23 01:49:45 | 1 | 829 | Chris Rudd |
74,895,414 | 9,297,601 | How can I generate instances of a class with inter-dependent attributes? | <p>Assume this simple case: (reposted and lightly edited from <a href="https://groups.google.com/g/hypothesis-users/c/munEwoJDUCY/m/7BWnti9OAwAJ" rel="nofollow noreferrer">the Hypothesis mailing list</a>)</p>
<pre class="lang-py prettyprint-override"><code>@dataclass
class A:
names: list[str]
ages: dict[str, flo... | <python><python-hypothesis> | 2022-12-23 01:43:50 | 1 | 3,132 | Zac Hatfield-Dodds |
74,895,292 | 3,321,579 | Why do breakpoints in my function with a yield do not break? | <p>I am writing Python in VSCode. I have a file with two functions, and a second file that calls those function. When I put breakpoints in one of the functions, the breakpoint does not hit.</p>
<p>Here is test2.py that has the two functions...</p>
<pre><code>def func1():
for i in range(10):
yield i
def fun... | <python> | 2022-12-23 01:13:01 | 2 | 1,947 | Scorb |
74,895,071 | 8,705,841 | Python find broken symlinks caused by Git | <p>I'm currently working on a script that is supposed to go through a cloned Git repo and remove any existing symlinks (broken or not) before recreating them for the user to ease with project initialization.</p>
<p>The solved problems:</p>
<ul>
<li>Finding symbolic links (broken or unbroken) in Python is <a href="https... | <python><windows><git><filesystems><symlink> | 2022-12-23 00:25:41 | 0 | 467 | elkshadow5 |
74,895,049 | 17,365,694 | TypeError: PaystackPayment() missing 1 positional argument: "request" | <p>I'm getting the error</p>
<pre><code>PaystackPayment() missing 1 required positional argument: 'request'
</code></pre>
<p>at line 246 of my <code>core.views</code> of my Ecommerce project when trying to access the function PaystackPayment(). I don't know what is wrong.</p>
<p>views:</p>
<pre><code>def PaystackPayme... | <python><django><django-models><django-views><django-templates> | 2022-12-23 00:21:10 | 1 | 474 | Blaisemart |
74,895,015 | 13,236,293 | Sort a nested list inside and outside in Python | <p>I am wondering how to sort a nested list in ascending order from both inside the nested list and outside the nested list. Any list comprehension way I can do this easily?</p>
<pre><code>abc = [[6, 2], [7, 1]]
</code></pre>
<p>Current working but no good:</p>
<pre><code>list(map(sorted, abc))
[[2, 6], [1, 7]]
</code>... | <python> | 2022-12-23 00:14:40 | 1 | 1,664 | codedancer |
74,894,984 | 10,308,255 | How to flatten a column containing a list of dates as strings into just date? | <p>I have a dataframe containing a column that has a list of dates stored as strings:</p>
<pre><code># sample dataframe
data = [[1, ["2019-08-02 08:30:56"]], [2, ["2020-08-02 08:30:56"]]]
df = pd.DataFrame(data, columns=["items", "dates"])
df["dates"] = df["dates&... | <python><pandas><list><dataframe><datetime> | 2022-12-23 00:04:59 | 3 | 781 | user |
74,894,927 | 3,321,579 | Why does VSCode Python code completion not work for my firestore client variable? | <p>I have the following python snippet...</p>
<pre><code>import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
cred = credentials.Certificate("./cert.json")
firebase_admin.initialize_app(cred)
client = firestore.client()
client.
</code></pre>
<p>When I type the do... | <python><visual-studio-code><pylance> | 2022-12-22 23:54:22 | 1 | 1,947 | Scorb |
74,894,926 | 9,331,134 | mlflow: INVALID_PARAMETER_VALUE Parameters can not be modified after a value is set | <p>I get the following exception raised, help me please</p>
<pre><code>mlflow.exceptions.RestException: INVALID_PARAMETER_VALUE: Response:
{
'Error': {
'Code': 'ValidationError',
'Severity': None,
'Message': 'Parameters can not be modified after a value is set.',
'MessageFormat': None,
'MessagePar... | <python><mlflow><mlops> | 2022-12-22 23:54:20 | 0 | 1,082 | Kaushik J |
74,894,806 | 12,198,552 | Unable to import a python package in Pyodide | <p>I am trying to import a custom package in <code>Pyodide</code> but it is not working.</p>
<p>The directory structure is</p>
<pre><code>index.html
package/
__init__.py
</code></pre>
<p>And my index.html looks like this</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<script src="https... | <python><webassembly><pyodide> | 2022-12-22 23:29:46 | 2 | 646 | Sanskar Jethi |
74,894,738 | 6,742,108 | Get request returns unfriendly response Python | <p>I am trying to perform a get request on <a href="https://www.tcgplayer.com/" rel="nofollow noreferrer">TCG Player</a> via <code>Requests</code> on <code>Python</code>. I checked the sites <code>robots.txt</code> which specifies:</p>
<pre><code>User-agent: *
Crawl-Delay: 10
Allow: /
Sitemap: https://www.tcgplayer.com... | <python><python-requests> | 2022-12-22 23:13:53 | 1 | 516 | karafar |
74,894,719 | 9,591,001 | How can I find images inside a specific class? | <p>I have been trying to use <code>Selenium</code> to do a webscraping.</p>
<p>I need to download two lists of information: name and picture.</p>
<p>I used this code to download the list of names:</p>
<pre class="lang-py prettyprint-override"><code>### click on right div
browser.find_element("xpath","/ht... | <python><selenium> | 2022-12-22 23:10:12 | 1 | 556 | RxT |
74,894,371 | 13,454,049 | Pylint redundant comparison for NaN | <p>Why does Pylint think this is a redundant comparison? Is this not the fastest way to check for NaN?</p>
<blockquote>
<p>Refactor: R0124<br />
Redundant comparison - value_1 != value_1<br />
Redundant comparison - value_2 != value_2</p>
</blockquote>
<p>How else am I supposed to check if two values are equal includin... | <python><pylint> | 2022-12-22 22:14:40 | 2 | 1,205 | Nice Zombies |
74,894,318 | 12,349,734 | How can I match a pattern, and then everything upto that pattern again? So, match all the words and acronyms in my below example | <h4>Context</h4>
<p>I have the following paragraph:</p>
<pre class="lang-py prettyprint-override"><code>text = """
ΧΧΧΧΧΧ "Χ‘ - ΧΧΧΧͺ ΧΧΧ Χ‘Χͺ ΧΧ"Χ - ΧΧΧ ΧΧΧ©ΧΧΧ ΧΧͺ"Χ - ΧΧͺΧΧ§ΧΧ Χ ΧΧΧ§Χ Χ
ΧΧΧ"Χ¨ - ΧΧΧ©ΧΧΧΧͺ ΧΧ¨ΧΧΧ ΧΧΧͺ Χ"Χ - Χ' ΧΧΧΧ§ΧΧΧ ΧΧͺΧΧ' - ΧΧͺΧΧΧΧ
ΧΧΧ "Χ - ΧΧΧ ΧΧΧ¨ ΧΧ’ΧΧ Χ"Χ - Χ' ΧΧΧ§ΧΧ ... | <python><regex><match><python-re> | 2022-12-22 22:08:24 | 3 | 20,556 | MendelG |
74,894,286 | 7,267,480 | tensorflow installation/usage problem under wsl - can't see GPU and libraries | <p>Tried to install Tensorflow under WSL20 (Ubuntu) using pip.</p>
<p>installed automatically using pip install tensorflow, without any error messages.</p>
<p>When I am trying to run simple script like this:</p>
<pre><code>import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
print(tf.reduce_sum(tf.... | <python><linux><tensorflow> | 2022-12-22 22:03:46 | 2 | 496 | twistfire |
74,894,119 | 5,112,032 | Is it possible to pass an xcom into a python variable? | <p>I am simply trying to get the <code>return</code> value from an xcom into a python variable, something like this:</p>
<pre><code>datasets = S3ListPrefixesOperator(
task_id='list_s3_prefixes',
bucket = get_bucket(),
prefix = 'my_key/',
delimiter = '/'
)
bucket_keys = task_instance.xcom_pull(task_ids=... | <python><airflow> | 2022-12-22 21:41:19 | 0 | 2,522 | eljusticiero67 |
74,894,030 | 19,797,660 | Numpy How to make a moving(growing) sum of table contents without a for loop? | <p>Due to the fact english is not my first language it is very hard to me to explain simply the problem I am trying to solve in the topic, and thus I am sorry.</p>
<p>So instead of trying to explain with bare words I am going to give an example.</p>
<p>Let's say we have an array that is instantiated like this:</p>
<pre... | <python><numpy> | 2022-12-22 21:29:43 | 1 | 329 | Jakub Szurlej |
74,893,967 | 7,267,480 | ANN for object identification: how to prepare input data for learning (signals with varying length) and what structure to use? | <p>I am trying to artificial neural network as an instrument to identify some specific "peaks" in noised signals and get their coordinates.
I want to use keras for that purpose.</p>
<p>But I don't get how to prepare data for learning, can you suggest some example similar to my task or provide a link for the m... | <python><keras><neural-network> | 2022-12-22 21:21:01 | 0 | 496 | twistfire |
74,893,922 | 1,391,441 | Sublime Text 4: folding Python functions with a line break | <p>I'm running Sublime Text Build 4143. Given a function with parameters that spill over the 80 character limit like so:</p>
<pre><code>def func(parameter_1, parameter_2, parameter_3, parameter_4, parameter_5, parameter_6):
"""
"""
print("hello world")
return
</... | <python><sublimetext4> | 2022-12-22 21:15:10 | 2 | 42,941 | Gabriel |
74,893,906 | 6,057,371 | pandas nested dict to flat dataframe | <p>I have a dict:</p>
<pre><code>d = {12 : [8,2,3,4]
15 : [6,1,9,2]}
</code></pre>
<p>I want to transform it to a flat dataframe:</p>
<pre><code>df = val 0 1 2 3
12 8 2 3 4
15 6 1 9 2
</code></pre>
<p>How can I do this?</p>
| <python><pandas><dataframe><data-science> | 2022-12-22 21:13:06 | 0 | 2,050 | Cranjis |
74,893,893 | 1,011,926 | Colima, PyCharm, and AWS SAM - cannot find pydevd.py | <p>Running a Mac M1 trying to start AWS SAM inside a Docker container through PyCharm fails with</p>
<pre class="lang-bash prettyprint-override"><code>START RequestId: 35db17a5-d684-4ffa-b3ad-d50e253561b7 Version: $LATEST
/var/lang/bin/python3.9: can't open file '/tmp/lambci_debug_files/pydevd.py': [Errno 2] No such fi... | <python><docker><pycharm><colima> | 2022-12-22 21:11:39 | 2 | 3,677 | Chris |
74,893,820 | 3,423,825 | Django's DRF has_object_permission method not called with get_object | <p>I scratch my head to understand why the <code>has_object_permission</code> bellow has no effect, because the documentation says that this method should be executed with <code>get_object</code>. What could be the reason ?</p>
<pre><code>@permission_classes([HasViewObjectPermission])
class IndividualDetailsView(Retrie... | <python><django><django-rest-framework> | 2022-12-22 21:04:30 | 1 | 1,948 | Florent |
74,893,742 | 10,357,604 | How to solve AttributeError: module 'numpy' has no attribute 'bool'? | <p>I'm using a conda environment with Python version 3.9.7,
pip 22.3.1, numpy 1.24.0, gluoncv 0.10.5.post0,
mxnet 1.7.0.post2</p>
<p><code>from gluoncv import data, utils</code> gives the error:</p>
<pre><code>C:\Users\std\anaconda3\envs\myenv\lib\site-packages\mxnet\numpy\utils.py:37: FutureWarning: In the future `np... | <python><python-3.x><numpy><attributeerror> | 2022-12-22 20:53:45 | 8 | 1,355 | thestruggleisreal |
74,893,662 | 8,973,609 | Transpose pandas DF based on value data type | <p>I have pandas <code>DataFrame</code> A. I am struggling transforming this into my desired format, see <code>DataFrame</code> B. I tried <code>pivot</code> or <code>melt</code> but I am not sure how I could make it conditional (<code>string</code> values to <code>FIELD_STR_VALUE</code>, <code>numeric</code> values to... | <python><pandas><dataframe> | 2022-12-22 20:42:51 | 3 | 507 | konichiwa |
74,893,648 | 9,973,902 | How to add a timestamp and error messages to Python rotating log? | <p>I created a rotating log for a Python project but can't seem to add timestamps for the debug log messages or any errors messages:</p>
<pre><code>logger = logging.getLogger("Rotating Log")
logger.setLevel(logging.DEBUG)
path="Logs\Process.log"
handler = RotatingFileHandler(path, maxBytes=2000000,... | <python><logging> | 2022-12-22 20:40:49 | 1 | 341 | Riley Spotton |
74,893,568 | 14,397,434 | Display all prime numbers within a range | <pre><code># Write a program to display all prime numbers within a range
start = 25
end = 50
for num in range(start, end + 1):
if num > 1: # all prime #s are greater than 1
for i in range(2,num):
if (num % i) == 0:
break
else:
print(num)
</code></pre>
<p>... | <python><for-loop><if-statement><range> | 2022-12-22 20:29:47 | 1 | 407 | Antonio |
74,893,381 | 8,584,739 | error "unmatched group" when using re.sub in Python 2.7 | <p>I have a list of strings. Each element represents a field as key value separated by space:</p>
<pre><code>listA = [
'abcd1-2 4d4e',
'xyz0-1 551',
'foo 3ea',
'bar1 2bd',
'mc-mqisd0-2 77a'
]
</code></pre>
<h3>Behavior</h3>
<p>I need to return a <code>dict</code> out of this list with expanding the keys like <code>'xyz... | <python><regex><python-2.7> | 2022-12-22 20:08:07 | 3 | 1,228 | Vijesh |
74,893,354 | 14,401,160 | Is literal ellipsis really valid as ParamSpec last argument? | <p>Quote from <a href="https://docs.python.org/3/library/typing.html#typing.Concatenate" rel="nofollow noreferrer">Python docs for <code>Concatenate</code></a>:</p>
<blockquote>
<p>The last parameter to Concatenate must be a ParamSpec or ellipsis (...).</p>
</blockquote>
<p>I know what <code>ParamSpec</code> is, but th... | <python><python-typing><type-variables> | 2022-12-22 20:04:24 | 1 | 8,871 | STerliakov |
74,893,346 | 17,696,880 | Set search pattern by setting a constraint on how a substring should not start and another on how a substring should not end | <pre class="lang-py prettyprint-override"><code>import re, datetime
input_text = "Por las maΓ±anas de verano voy a la playa, y en la manana del 22-12-22 16:22 pm o quizas maΓ±ana en la maΓ±ana hay que estar alli y no 2022-12-22 a la manana"
today = datetime.date.today()
tomorrow = str(today + datetime.timedelt... | <python><python-3.x><regex><replace><regex-group> | 2022-12-22 20:03:21 | 1 | 875 | Matt095 |
74,893,304 | 14,945,939 | How do I speed up my GitHub PyTest executions? | <p>I have a repository of several hundred tests that have been fast enough up to now, but as we continue to grow the codebase I worry that it will get so slow that my team will be caught up in waiting for CI runs to complete.</p>
<p>What can I do to speed this up and make my tests faster both in the short run and in th... | <python><performance><continuous-integration><pytest><github-actions> | 2022-12-22 19:58:45 | 1 | 1,817 | vanhooser |
74,893,278 | 13,618,407 | Tensorflow error Invalid argument Compilation failure: Detected unsupported operations when trying to compile graph cluster_tpu_function | <p>I am receiving an error when I train my Deep Learning network using TPU</p>
<p>The error is related to the below part of my code but I don't know how to solve it.</p>
<pre><code>preprocessing.RandomCrop(28, 28)
</code></pre>
<p><strong>NB: the code is running fine if I use no accelerator or GPU but not on TPU</stron... | <python><tensorflow><kaggle><tpu> | 2022-12-22 19:54:59 | 0 | 561 | stic-lab |
74,893,239 | 8,260,088 | Keep the date and not the time in to_datetime pandas (while importing data from csv) | <p>Can you please help me with the following issue? When I import a csv file I have a dataframe like smth like this:</p>
<pre><code>df = pd.DataFrame(['29/12/17',
'30/12/17', '31/12/17', '01/01/18', '02/01/18'], columns=['Date'])
</code></pre>
<p>What I want is to convert `Date' column of df into Date Time object. So I... | <python><pandas> | 2022-12-22 19:50:49 | 1 | 875 | Alberto Alvarez |
74,893,227 | 7,717,176 | How to merge two pandas dataframes based on a dictionary? | <p>There are two pandas dataframes as follows:</p>
<pre><code>df1:
col11 col22 col33
abc 25 36
bcd 55 96
cdf 15 19
abc 74 26
</code></pre>
<p>and</p>
<pre><code>df2:
col01 col02 col03
name1 x 346
name2 g 926
name3 t 179
name1 k 286
</code></pre... | <python><pandas><dataframe><dictionary><merge> | 2022-12-22 19:49:31 | 1 | 391 | HMadadi |
74,893,199 | 5,652,080 | Apply str.replace() to string but error says it's a float | <p>I'm using Pandas to strip a '$' out of some strings in a column.</p>
<pre><code>df['Amount'].dtypes` --> `dtype('O')
</code></pre>
<p>So, I figure I can do string modification now:</p>
<pre><code>df['Amount'].apply(lambda x: x.replace('$', ''))
</code></pre>
<p>I get the error: <code>'float' object has no attribu... | <python><pandas> | 2022-12-22 19:45:47 | 1 | 690 | Sam Dillard |
74,893,175 | 4,821,779 | Trying to concat a list of 12 AnnData objects but am getting duplicates | <p>I'm prepping our experimental data for trajectory analysis by partially following this guide <a href="https://smorabit.github.io/tutorials/8_velocyto/" rel="nofollow noreferrer">here</a> and I have a list of 12 AnnData objects that I read in as loom files. 6 of them come from one sequencing run whereas the other 6 c... | <python><scanpy> | 2022-12-22 19:42:52 | 1 | 1,108 | CelineDion |
74,893,089 | 14,397,434 | Printing -1 to -10 in python exercise | <pre><code># the answer key
for num in range(-10, 0, 1):
print(num)
</code></pre>
<p>I wanted to see if I could find a way to do it without using range():</p>
<pre><code>i = -1
while abs(i) <= 10:
print(i)
</code></pre>
<p>I'm new to python.</p>
<p>Thank you.</p>
| <python><for-loop><while-loop><range><sequence> | 2022-12-22 19:31:48 | 1 | 407 | Antonio |
74,892,847 | 11,226,214 | Fields from Django Abstract model are returning None | <p>I have an abstract django model and a basic model. I am expecting any instance of the basic model to have a value for the field created_at or updated_at. However, as of now, all my instances have None for both these fields. What am I doing wrong?</p>
<pre><code>from django.db import models
class Trackable(models.M... | <python><django><django-models> | 2022-12-22 19:01:31 | 1 | 1,797 | nolwww |
74,892,827 | 12,242,085 | How to convert JSON column in DataFrame to "normal" columns in DataFrame in Python Pandas? | <p>I have DataFrame like below:</p>
<pre><code>ABT = pd.read_excel("ABT.xlsx")
</code></pre>
<p>DATA TYPES:</p>
<ul>
<li><p>COL1 - float</p>
</li>
<li><p>COL2 - int</p>
</li>
<li><p>COL3 - object</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>COL1</th>
<th>COL2</th>
<th>COL3</th>... | <python><json><pandas><dataframe> | 2022-12-22 18:59:15 | 0 | 2,350 | dingaro |
74,892,805 | 14,909,857 | I'm unable to connect with DNS seed list format to Atlas but works with old string format | <p>I recently moved from town and i have a different ISP. In my old house i used to connect to Atlas with</p>
<pre><code>mongodb+srv://cluster0.wiiy6cz.mongodb.net/myFirstDatabase" --username <username>
</code></pre>
<p>and now it's not working, i have my new public ip Whitelisted on Atlas and the error mess... | <python><mongodb><pymongo><mongodb-atlas> | 2022-12-22 18:57:52 | 0 | 336 | eljapi |
74,892,481 | 1,175,266 | How to authenticate a GitHub Actions workflow as a GitHub App so it can trigger other workflows? | <p>By default (when using the default <code>secrets.GITHUB_TOKEN</code>) GitHub Actions <a href="https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow" rel="noreferrer">workflows can't trigger other workflows</a>. So for example if a workflow sends a pull request... | <python><github><github-actions><github-api><github-cli> | 2022-12-22 18:20:47 | 2 | 15,138 | Sean Hammond |
74,892,362 | 45,207 | How do I fix this Pyspark which modifies a complex struct inside an array | <h3>Problem Setup</h3>
<p>Given a data frame where each row is a struct with an <code>answers</code> field that holds an array of answer structs, each with multiple fields, the following code is supposed to process each answer in the array, by examining its <code>render</code> field and applying some process to it. (No... | <python><apache-spark><pyspark><aws-glue> | 2022-12-22 18:10:14 | 2 | 8,570 | LaserJesus |
74,892,355 | 12,084,907 | tkinter: How to have one labelframe under another expand as the page grows without leaving space between the two frames, using grid() | <p>I apologize in advance where I am new to tkinter. I am making a search tool to find a moniker(username) and am currently working on the front end. While working on this I have started using sticky to help the different parts stretch as the user adjusts the page size. My current problem is that as I stretch it downwa... | <python><tkinter> | 2022-12-22 18:09:48 | 1 | 379 | Buzzkillionair |
74,892,266 | 10,976,654 | Nested structured array to pandas dataframe with new column names | <p>How can I convert/explode a nested numpy structured array into a pandas dataframe, while keeping the headers from the nested arrays?</p>
<p>Using Python 3.8.3, numpy 1.18.5, pandas 1.3.4.</p>
<p><strong>Example structured array</strong>: I am given a nested numpy structured array that looks like this, and I am just ... | <python><pandas><multidimensional-array><structured-array> | 2022-12-22 18:01:15 | 2 | 3,476 | a11 |
74,892,218 | 1,833,539 | Run alembic operations manually by code, using an sqlalchemy engine | <p>I invested some time to understand Alemic, how I could run migrations manually without any setup. Due to some reasons we need that, we need to be able to execute operations manually without init, ini files or execution context.</p>
| <python><sql><python-3.x><sqlalchemy><alembic> | 2022-12-22 17:56:38 | 1 | 2,616 | Denny Weinberg |
74,892,198 | 20,585,541 | Function in a class doesn't require self parameter | <p>Trying to make a Python module which provides functions for user input.
My code looks like this:</p>
<pre class="lang-py prettyprint-override"><code>class PyInput:
def inputString(prompt = "Enter a string: >>> "):
userInput = input(prompt)
return userInput
</code></pre>
<p>I'm ... | <python><python-3.x><function><python-typing><self> | 2022-12-22 17:55:18 | 1 | 555 | TechyBenji |
74,892,023 | 4,321,525 | How to do columnwise operations with Numpy structured arrays? | <p>This shows the problem nicely:</p>
<pre><code>import numpy as np
a_type = np.dtype([("x", int), ("y", float)])
a_list = []
for i in range(0, 8, 2):
entry = np.zeros((1,), dtype=a_type)
entry["x"][0] = i
entry["y"][0] = i + 1.0
a_list.append(entry)
a_array = n... | <python><numpy><structured-array> | 2022-12-22 17:37:03 | 1 | 405 | Andreas Schuldei |
74,892,000 | 1,542,011 | CPLEX 22.1 on MacBook with M1 architecture | <p>I do not succeed to install CPLEX (version 22.1.1) on a MacBook with M1 chip (macOS Ventura - 13.1).</p>
<p>The installer keeps installing the files for the wrong architecture, i.e., x86_64 instead of arm64.</p>
<pre><code>/Applications/CPLEX_Studio2211/cplex/bin/x86-64_osx
</code></pre>
<p>When I try to use the Pyt... | <python><macos><cplex> | 2022-12-22 17:34:48 | 1 | 1,490 | Christian |
74,891,956 | 649,920 | Throwing away from dataframe samples that are too close in time | <p>I have an original pandas dataframe with datetime column <code>ts</code>, ordered by this column. I need to build a new dataframe as follows:</p>
<ol>
<li>its first row is the first row of the original dataframe</li>
<li>I only add the row from the original dataframe if it at least 5 seconds away from the last row o... | <python><pandas><datetime> | 2022-12-22 17:30:49 | 1 | 357 | SBF |
74,891,571 | 7,794,924 | Python ImportError of "sounddevice" on M1 Mac when running script in PyCharm (incompatible architecture) | <p>I have an M1 Mac. My program was running fine in PyCharm when using the Intel-based dmg. PyCharm kept notifying me to upgrade to the version optimized for Apple Silicon. PyCharm opened noticeably smoother. But trying to run my script now gives me an ImportError for "sounddevice" library. I tried to pip uni... | <python><pycharm><apple-m1><python-sounddevice> | 2022-12-22 16:53:51 | 1 | 812 | nhershy |
74,891,544 | 4,150,078 | How to select number of k in cross validation for fbprophet? | <p>I have data in pandas DataFrame and have been trying to train the model fbprophet. During the <code>cross validation</code> stage I am unable to select number of <code>k</code> like you can in sklearn. Meaning k=5, k=50 folds...etc. Is there an option here or way to pass that? I couldn't find this information in the... | <python><python-3.x><facebook-prophet> | 2022-12-22 16:51:51 | 1 | 2,158 | sharp |
74,891,522 | 1,028,270 | Most reliable way to get the repo name? | <p>I'm not seeing anything in the docs for how to just get the repo name: <a href="https://www.pygit2.org/repository.html" rel="nofollow noreferrer">https://www.pygit2.org/repository.html</a></p>
<p>Is reading the origin remote and parsing it out the only way pygit supports this or is there a more reliable or specific ... | <python><pygit2> | 2022-12-22 16:50:14 | 0 | 32,280 | red888 |
74,891,497 | 12,164,800 | Is it possible to monkeypatch all objects of a class regardless of initialisation method? | <p>I'm testing some code that manipulates data using pandas, and I want to avoid writing out the data during tests.</p>
<p>Let's say my code in a file name module.py is this:</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
import dask.dataframe as dd
def do_stuff() -> None:
df = pd.Data... | <python><pandas><mocking><pytest><monkeypatching> | 2022-12-22 16:47:37 | 1 | 457 | houseofleft |
74,891,473 | 20,793,070 | How I can round up values in Polars | <p>I have some calculated float columns. I want to display values of one column rounded, but <code>round(pl.col("value"), 2)</code> not working properly in Polars. How I can make it?</p>
| <python><dataframe><python-polars> | 2022-12-22 16:45:41 | 2 | 433 | Jahspear |
74,891,472 | 248,123 | Fastavro fails to parse Avro schema with enum | <p>I have the following code block:</p>
<pre><code>import fastavro
schema = {
"name": "event",
"type": "record",
"fields": [{"name": "event_type", "type": "enum", "symbols": ["START", "STOP&qu... | <python><python-3.x><enums><avro><fastavro> | 2022-12-22 16:45:39 | 1 | 17,567 | andand |
74,891,398 | 885,014 | How to share a library among several Dockerfiles and repos? | <p>I am working on a project that's evolved from one Dockerfile supporting several apps to one Dockerfile per app.</p>
<p>This generally works better than having them all together in one, but I'd like to share one Python library file among the apps without duplicating it.</p>
<p>I don't see a good way to do this, at le... | <python><docker> | 2022-12-22 16:37:59 | 1 | 651 | Mark McWiggins |
74,891,196 | 6,687,699 | Azure Database for PostgreSQL flexible server Slow with Django | <p>Am using Django to connect to <code>Azure Database for PostgreSQL flexible server</code> but it's very slow, below are the specs of the server :</p>
<p><strong>Compute + storage</strong></p>
<pre><code>Pricing tier
Memory Optimized
Compute size
Standard_E4s_v3 (4 vCores, 32 GiB memory, 6400 max iops)
Storage
32 GiB
... | <python><django><postgresql><azure> | 2022-12-22 16:19:04 | 1 | 4,030 | Lutaaya Huzaifah Idris |
74,891,119 | 3,834,415 | How does only output only dataframe columns to csv? | <p>Use case: golfing on the CLI in a utility function that I can't afford to make complicated.</p>
<p>I need to peek at only the column names only of a large file in binary format, and not the column names plus, say, the first data row.</p>
<p>In my current implementation, I have to write the burdensome command to peek... | <python><pandas><dataframe> | 2022-12-22 16:11:08 | 1 | 31,690 | Chris |
74,890,785 | 1,694,518 | How to create a histogram with different space between the bars in matplotlib | <p>I want to create a histogram with four pairs of bars as following. How to do it?<a href="https://i.sstatic.net/MqD67.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MqD67.png" alt="enter image description here" /></a></p>
| <python><matplotlib> | 2022-12-22 15:41:07 | 1 | 1,155 | f. c. |
74,890,783 | 1,531,280 | Is Django db_index helpful in text search queries? | <p>I've the following model in a Django project:</p>
<pre><code>from django.db import models
class Book(models.Model):
title = models.CharField(verbose_name='Title', max_length=255, db_index=True)
authors = models.CharField(verbose_name='Authors', max_length=255, db_index=True)
date = models.DateField(verb... | <python><django><django-models><django-queryset><database-indexes> | 2022-12-22 15:40:32 | 1 | 2,712 | Dos |
74,890,722 | 9,003,672 | how can I see the List of all lines from where my method or class is getting called in Jupyter Notebook? | <p>How can I redirect to the line from where the definition or class is called?</p>
<p>I want something like this <a href="https://i.sstatic.net/tzzxg.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/tzzxg.jpg" alt="enter image description here" /></a></p>
<p>I find it hard to believe this does not exist.... | <python><jupyter-notebook><jupyter><jupyter-lab><jupyterhub> | 2022-12-22 15:36:05 | 2 | 501 | Binit Amin |
74,890,684 | 2,077,648 | How to generate a report in python containing the difference of last and first row of multiple csv files? | <p>I have multiple csv files in the below format:</p>
<p><strong>CSV File 1:</strong></p>
<p><a href="https://i.sstatic.net/x0UqI.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/x0UqI.png" alt="enter image description here" /></a></p>
<p><strong>CSV File 2:</strong></p>
<p><a href="https://i.sstatic.net/... | <python><pandas><dataframe><numpy><glob> | 2022-12-22 15:33:21 | 1 | 967 | user2077648 |
74,890,547 | 12,883,297 | Increase the number of rows till we reach some condition in pandas | <p>I have a dataframe</p>
<pre><code>df = pd.DataFrame([["X","day_2"],["Y","day_4"],["Z","day_3"]],columns=["id","day"])
</code></pre>
<pre><code>id day
X day_2
Y day_4
Z day_3
</code></pre>
<p>I want to increase the rows for each id... | <python><python-3.x><pandas><dataframe> | 2022-12-22 15:21:12 | 4 | 611 | Chethan |
74,890,514 | 4,706,745 | Django file upload is not uploading the file? | <p>I have created a file upload something like this:</p>
<p><em>DataUpload</em> is the view that handles template rendering and <em>handle_uploaded_file</em> is the function that reads the file.</p>
<p><strong>View.py</strong></p>
<pre><code>def DataUpload(request):
if request.method == 'POST':
form = Uploa... | <python><django><django-views><django-forms><django-templates> | 2022-12-22 15:18:33 | 1 | 4,217 | jax |
74,890,270 | 3,521,180 | why the pyspark function is changing the data type of columns in pyspark? | <p>I am in a tricky situation.
I have two columns with <code>string type</code> and it is supposed to be <code>dateType</code> in the final path. So, to achieve that, I am passing it as a python dictionary</p>
<pre><code>d = {"col1": DateType(), "col2": DateType()}
</code></pre>
<p>The above is pass... | <python><python-3.x><pyspark> | 2022-12-22 14:58:21 | 1 | 1,150 | user3521180 |
74,890,214 | 6,702,598 | Type hint callback function with optional parameters (aka Callable with optional parameter) | <p>How do I specify the type of a callback function which takes an optional parameter?</p>
<p>For example, I have the following function:</p>
<pre><code>def getParam(param: str = 'default'):
return param
</code></pre>
<p>I'd like to pass it on as a callback function and use it both as <code>Callable[[str], str]</code... | <python><python-3.x> | 2022-12-22 14:53:12 | 1 | 3,673 | DarkTrick |
74,890,197 | 2,278,742 | networkx: Assigning node colors based on weight when using bbox | <p>I want to draw a graph with <code>networx</code> and render the nodes as boxes wide enough to contain each node's name, colored according to its weight.</p>
<p>If I use the default shape, they are colored correctly, but when I use the bbox parameter facecolor, they all have the same color.</p>
<p><a href="https://i.... | <python><matplotlib><graph><networkx> | 2022-12-22 14:51:46 | 1 | 493 | 804b18f832fb419fb142 |
74,890,115 | 12,725,674 | Keep part of text between strings using regex | <p>Using the following code I have extracted a transcripted Interview from a pdf:</p>
<pre><code>from pdfminer.high_level import extract_text
text = extract_text(f"C:/Users/User/Desktop/Interview1.pdf")
</code></pre>
<p>The general structure of a transcript looks like this (\n are included on purpose as these... | <python><regex> | 2022-12-22 14:46:51 | 1 | 367 | xxgaryxx |
74,889,884 | 4,391,249 | How to ensure expressions that evaluate to floats, give the expected integer value with int(*) | <p>In this question's most general form, I want to know how I can guarantee that <code>int(x * y)</code> (with <code>x</code> and <code>y</code> both being <code>float</code>s gives me the arithmetically "correct" answer when I know the result to be a round number. For example: 1.5 * 2.0 = 3, or 16.0 / 2.0 = ... | <python><floating-point><integer> | 2022-12-22 14:26:20 | 1 | 3,347 | Alexander Soare |
74,889,866 | 4,162,689 | How can I scape data from nested tables in Python? | <p>I am trying to scrape <a href="http://www.radiofeeds.co.uk/mp3.asp" rel="nofollow noreferrer">radiofeeds</a> so that I can compile the following list of all UK radio stations.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Station Name</th>
<th>Geographical Location</th>
<th>Stream URLs... | <python><html><web-scraping><beautifulsoup> | 2022-12-22 14:24:49 | 1 | 972 | James Geddes |
74,889,837 | 11,401,702 | Do I get any important benefits of using Gunicorn to run a Flask server on AWS Fargate? | <p>I'm currently looking at a Flask server run with Gunicorn in a Docker container on EC2.
I would like to move the server to Fargate.</p>
<p>Coming from NodeJS, my understanding of Gunicorn is it's like PM2; since Python is single threaded, Gunicorn increases or decrease the Python processes to handle the load. (plus ... | <python><flask><gunicorn><aws-fargate> | 2022-12-22 14:22:17 | 1 | 428 | Ismael |
74,889,613 | 2,333,021 | Creating a hierarchical tree dict | <p>I have been working with D3 and ObservableHQ to create a Tree Plot of some hierarchical data (SARS-CoV-2 Variant lineages). I'm looking at ways to expand what I can do with the dataset and so I am moving it to Python to experiment.</p>
<p>One thing I did with D3 was the use d3.stratify on my tsv dataset. I am trying... | <python><python-3.x><d3.js><tree><hierarchy> | 2022-12-22 14:04:17 | 1 | 4,887 | Christopher Rucinski |
74,889,555 | 11,252,809 | Query an instrumentedattribute by its length in SQLAlchemy | <p>The way the database is setup is like this. I'm using SQLModel, but underneath it's SQLAlchemy.</p>
<pre><code>class Paper(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
similar: List["PaperSimilarLink"] = Relationship(
link_model=PaperSimilarLink,
... | <python><sql><sqlalchemy><sqlmodel> | 2022-12-22 13:59:06 | 0 | 565 | phil0s0pher |
74,889,515 | 6,245,473 | Write to CSV the last non-null row from pandas dataframe? | <p>This writes all records, including null PbRatios. I would like to write the last non-null record only. When I add <code>df[df.asOfDate == df.asOfDate.max()].to_csv</code>, it gets the last record, which is always null.</p>
<pre><code>import pandas as pd
from yahooquery import Ticker
symbols = ['AAPL','GOOG','MSFT'... | <python><pandas><dataframe><csv><null> | 2022-12-22 13:56:26 | 2 | 311 | HTMLHelpMe |
74,889,490 | 4,576,519 | A faster Hessian vector product in PyTorch | <p>I need to take a Hessian vector product of a loss w.r.t. model parameters a large number of times. It seems that there is no efficient way to do this and a for loop is always required, resulting in a large number of independent <code>autograd.grad</code> calls. My current implementation is given below, it is represe... | <python><performance><pytorch><autograd><hessian> | 2022-12-22 13:54:02 | 0 | 6,829 | Thomas Wagenaar |
74,889,280 | 20,174,226 | Combine and fill a Pandas Dataframe with the single row of another | <p>If I have two dataframes:</p>
<h3>df1:</h3>
<pre><code>df1 = pd.DataFrame({'A':[10,20,15,30,45], 'B':[17,33,23,10,12]})
A B
0 10 17
1 20 33
2 15 23
3 30 10
4 45 12
</code></pre>
<br>
<br>
<h3>df2:</h3>
<pre><code>df2 = pd.DataFrame({'C':['cat'], 'D':['dog'], 'E':['emu'], 'F':['frog'], 'G':['goat'],... | <python><pandas><dataframe><assign> | 2022-12-22 13:34:36 | 2 | 4,125 | ScottC |
74,889,152 | 19,003,861 | Django - How to use delete() in ManyToMany relationships to only delete a single relationship | <p>I have a model <code>Voucher</code> that can be allocated to several <code>users</code>.</p>
<p>I used a <code>M2M</code> relationship for it.</p>
<p>I want, in the template, the possibility to delete the voucher allocated to the logged in user, and the logged in user only (not all relationships).</p>
<p>The problem... | <python><django><django-models><django-views> | 2022-12-22 13:23:40 | 1 | 415 | PhilM |
74,889,074 | 17,148,496 | How to calculate SSR in python | <p>I've trained a linear regression model:</p>
<pre><code>reg = linear_model.LinearRegression()
reg.fit(X, Y)
</code></pre>
<p>And I want to calculate the three sum of squares SST, SSR and SSRES (a.k.a SSE).</p>
<p>I've calculated the SSE like this: (X is 4 predictive features)</p>
<pre><code>y_pred = reg.predict(X)
df... | <python><machine-learning><regression><linear-regression> | 2022-12-22 13:16:45 | 0 | 375 | Kev |
74,889,073 | 12,895,094 | why numpy array (skimage object) inside a list wasn't updated when iterated inside a for loop? | <p>I'm trying to do some operations on skimage objects. they are fundamentally numpy arrays.
But it has this weird behavior. If I put them in a list and iterate through the list, the operation doesn't reflect on the array/image.</p>
<p>here is an example. I'm trying to convert it to float type, by using the img_as_flo... | <python><numpy><scikit-image> | 2022-12-22 13:16:43 | 1 | 372 | fenixnano |
74,889,001 | 774,575 | Format string to alternate between fixed and scientific form, in order to show n digits at most | <p>I've difficulties to master the <code>g</code> <a href="https://docs.python.org/2/library/stdtypes.html#string-formatting-operations" rel="nofollow noreferrer">format for floats</a>. I'm trying to find a format which shows 2 figures at most. This requires to switch from <code>f</code> to <code>e</code> according to ... | <python><formatting> | 2022-12-22 13:11:08 | 2 | 7,768 | mins |
74,888,929 | 12,760,550 | Assign row as primary depending on the combination of columns pandas dataframe | <p>I have the following dataframe:</p>
<pre><code>ID Contract Type Company
10000 Employee Fake
10000 Contingent Fake
10000 Employee Fake
10001 Non-Worker Fake5
10002 Employee Fake4
10002 Employee Fake4
10002 Employee Fake4
10003 Contingent Fake3
10003 Employee Fake3
10003 Emp... | <python><pandas><dataframe><filter> | 2022-12-22 13:05:08 | 1 | 619 | Paulo Cortez |
74,888,836 | 19,079,397 | How to read R dataframe as a Pandas dataframe? | <p>I am executing the R code in python using <code>rpy2</code> library where I was able to achieve a data frame that I wanted. The dataframe has column with geometry, now I am trying to read the created R dataframe as Pandas dataframe using <code>ro.conversion.rpy2py</code>, but when I try to do the same it is giving a... | <python><r><pandas><geometry><rpy2> | 2022-12-22 12:55:34 | 0 | 615 | data en |
74,888,671 | 11,162,983 | How to convert trained models (ResNet) into inference-models PyTorch? | <p>I trained the model and then saved it as shown in the figure (right side), and I would like to convert it as shown in the figure (left side).</p>
<p>I found the <a href="https://github.com/thohemp/6DRepNet/blob/master/sixdrepnet/convert.py" rel="nofollow noreferrer">script</a> for <a href="https://github.com/DingXia... | <python><pytorch><resnet> | 2022-12-22 12:42:08 | 0 | 987 | Redhwan |
74,888,577 | 13,235,421 | Import dynamically classes in Pyinstaller | <p>I have a structure like this :</p>
<pre><code>src
β main.py
β
ββββmodules
β __init__.py
β module1.py
β module2.py
| module3.py
</code></pre>
<p>I want to get all the classes dynamically in the <em>modules</em> folder. Therefore, I edited the <strong>init</strong>.py file like this :</p>
<p... | <python><pyinstaller> | 2022-12-22 12:31:49 | 1 | 377 | tCot |
74,888,515 | 9,668,218 | How to map a column in PySpark DataFrame and avoid getting Null values? | <p>I have a PySpark DataFrame and I want to map values of a column.</p>
<p>Sample dataset:</p>
<pre><code>data = [(1, 'N'), \
(2, 'N'), \
(3, 'C'), \
(4, 'S'), \
(5, 'North'), \
(6, 'Central'), \
(7, 'Central'), \
(8, 'South')
]
columns = ["ID", &... | <python><dataframe><pyspark><null><mapping> | 2022-12-22 12:26:35 | 1 | 1,033 | Mohammad |
74,888,483 | 309,812 | Efficient and performant way to calculate the change percentage columns | <p>I am using <code>yfinance</code> via pandas datareader to download multiple-symbols' multi-year data and am trying to calculate 'MTDChg', 'YTDChg' and I figure this is one of the slowest parts in the runtime.</p>
<p>Here is the snippet of the code, where I have reservations about picking of the end of the previous p... | <python><pandas><dataframe><multi-index> | 2022-12-22 12:22:18 | 1 | 736 | Nikhil Mulley |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.