Category "python"

Convert string like dict into dict format [closed]

I have a string that looks like the following: { change:"2.429993", changePercent:"1.475316", dayVolume:10222078, exchange:NYQ, id:CVX, market

How to extract the price in selenium if they have same tag?

I would like to get first prices ($916.65) in pyhton but I do not know which method do I need to apply ? Each price has the same tag (div class="price"). Shoul

failed to use urllib.request with python in vscode

I tried to import urllib.request wth python in vscode but kept getting the message: ImportError: No module named request. I have no problem importing just urlli

How to evenly spread out date data (pandas)

I'm working on a project and I'm struggling with some formats of dataframes. I have two dataframes, each containing a different number of months. I want all the

Finding maximum difference between consecutive elements of an array

Say I have an array: [44, 30, 24, 32, 35, 30, 40, 38, 15] Here, every number represents a stock value on a certain day. I want to find the maximum profit that

Getting the next element of a list on a function call

Is there a way to return the next element in a list on a function call, this is what I have tried so far: from itertools import cycle def get_next_element():

How to use other def values?

I want to use other def values. For example, I added a 'pt' in the 'clean_beds_process' definition and add 'Patients' in the 'run' definition. I want to patient

Snell's Law not functioning

I am writing a program to calculate light refraction using snell's law, however, when I run the program it prints -0.7076118148 rather than the correct value of

(-5:Bad argument) in function 'rectangle' - Can't parse 'pt1'. Sequence item with index 0 has a wrong type

As I detect my tflite file, the problem happened. The command I wrote. python detect.py --weights ./checkpoints/yolov4-tiny-tf.tflite --size 416 --model yolov4

Use OpenCV to identiy hollow and filled circles

I'm using OpenCV houghcircles to identify all the circles (both hollow and filled). Follow is my code: import numpy as np import cv2 img = cv2.imread('images/3

Parsing JSON data in a good way [closed]

I have some JSON structured outputs that I would like to parse and get some values from it. But my attempts are not good and viable in deeper

How to make whole line same color in coloredlogs output in Python

I have just started using the coloredlogs package in Python. I am using the version 15.0. I can see that my message changes color depending on its log level (in

Adding drag and drop to a scroll area

I'm trying to create a scroll area that will allow drag and drop in QtPy5. I want to be able to drag one label (label 1) to another label (Label 3) and have the

Flatten XML data as a pandas dataframe

How can I convert this XML file at this address into a pandas dataframe? I have downloaded the XML as a file and called it '058com.xml' and run the code below,

How to create a dummy only if a column has non-zero values for certain dates but zero for other dates

Let's say, I want to identify traders who only traded during bull runs but did not trade (zero values) during downturns or stable periods. Let's say we have two

Returning None after conditional

Trying to return the math.floor of k, which is 2 import numpy as np import math j = 1 def k(j): k = j + 1.2 return k # 2.2 def foo2(): num

Yolov5s on Openvino

I have trained a model using yolov5 and it is working just fine: My ultimate goal is to use a model that I have trained on custom data (to detect the hook and

How to use and update same variable across multiple modules in python independently?

I have 3 files and I want to do something like below [1] conf.py var = 10 # Intialized with 10 (start) [2] file_1.py import conf print(conf.var) # Prints 10

Write data from broadcast variable (databricks) to azure blob

I have a url from where I download the data (which is in JSON format) using Databricks: url="https://tortuga-prod-eu.s3-eu-west-1.amazonaws.com/%2FNinetyDays/am

Is this a valid approach to scale your target in machine learning without leaking information? [closed]

Consider a housing price dataset, where the goal is to predict the sale price. I would like to do this by predicting the "Sale price per Squar