Category "python"

How to get the domain and string to the first slash

For example like this url = https://example.com/test/myname/myname.jpg result = re.search('(?:https?://)?(?P<host>.*?)(?:[:#?/@]|$)', url) I can get th

How is the list.index() method implemented? [duplicate]

I'm interested in the time complexity of the .index() in python function I'm trying to find the implementation in the docs but nothing so far.

how to retrieve values from plotly sunburst chart?

Plotly sunburst charts are great for visualizing hierarchical data. Is it possible to retrieve the values shown in the chart into a dictionary, or an array or s

how to retrieve the specific data from firebase realtime database using python?

I want to retrieve the specific data from realtime database in python file. I need to setup a connection first but I don't know how to set it up and then retrie

Log Sentry events to stdout

Using the Python Sentry SDK, is it possible to log Sentry events (capture_message, capture_exception, etc.) to stdout, preferably through the logging module? I'

temporary variable doesn't store the original value

I have this list of lists: lst = [[1],[2],[3],[4]] And I want to move the i+1 element to the [0] index, like this: [[2],[1],[3],[4]] / [[3],[1],[2],[4]] / [[

*** ValueError: not enough values to unpack (expected 2, got 1)

I'm trying to compare two dicts: > x_state [{'ID': 1, 'Wert': '6,6743', 'Name': 'Δ'}, {'Wert': 'Δ', 'ID': 3, 'Name': 'Δ'}, {'ID': 4, 'Name'

how to align sliding window to extract features from multi modal timeseries data?

I have two datasets that are collected at different frequencies at the same time. One is recorded at 128Hz and another one is recorded at 512 Hz. I am trying to

Python - stitch images back together after slicing

I have a directory of image patches that are all the same size (33x33), the images are ordered so that the first 7 images are row 1, then the next 7 images are

Snake and Ladder game stuck after 3 plays

I have been trying to implement the logic , when player rolled dice 3 times continues 6 then reset his score to initial old score before he rolled the dice to 6

AttributeError: 'QAction' object has no attribute 'setShortcutVisibleInContextMenu'

I am using Spyder on Windows. These are my python version and modules: PS C:\Windows\system32> python --version Python 3.9.10 PS C:\Windows\system32> pip

How can I pivot a dataframe?

What is pivot? How do I pivot? Is this a pivot? Long format to wide format? I've seen a lot of questions that ask about pivot tables. Even if they don't know t

Get a specific tag - BeautifulSoup

Below is the xml that I'm trying to parse. <url> <loc>https://www.houseofindya.com/aqua-chanderi-pleated-sharara-pants-177/iprdt</loc> &

Find which two angles an angle is between in Python

I have a list of angles (in radians) in the range [-pi, pi]. The angles can be assumed to ordered as follows: every increasing index in the list will be counter

next() call not iterating

var = 10 Constant = 10 def Gen(): i = 1 for x in range(var): yield i i +=1 o = Gen() c = next(o) * Constant for i in range(var):

Only download certain label tf dataset

Looking to do some fine tuning. The dataset (found here: https://knowyourdata-tfds.withgoogle.com/#dataset=sun397&filters=kyd%2Fsun397%2Flabel:%2Fh%2Fhouse&

json.decoder.JSONDecodeError : Expecting value: line 1 column 1

I'm trying to create a simple UserAgentHandler for my Telegram Bot that works with json ; But when I try to load empty json file I got this error: json.decoder

specific text in prompt for pythonscript

In JavaScript, you can use prompt("This text is above the field of the prompt.", "This text is in the field of the prompt.") to get a customized window appearin

Convert letter grades to grade points via python 3 [closed]

I have a question for transforming a list Given: [A,B,C,D,F,W] but any letter counts, except W. Where A = 4 , B = 3, C = 2, D = 1 and F = 0 so

How to bring data frame into single column from multiple columns in python

I have data format in these multiple columns. So I want to bring all 4 columns of data into a single column. YEAR Month pcp1 pcp2 pcp3 pcp4 1984