Category "python"

How to generate aware time object in Faker?

I have the following (simplified) model and factory: models.py class Event(): duration = FloatField() start_time = TimeField() finish_time = DateTim

Sklearn error: None of [Int64Index([2, 3], dtype='int64')] are in the [columns]

Could someone explain why this code: from sklearn.model_selection import train_test_split import pandas as pd from sklearn.model_selection import StratifiedKFol

How to create new dictionaries from nested dictionary?

I have a nested dictionary. How do I access them and get the result as follows: dict_lbl = { "lbl1":{"name":"label1","item1":"Accounts", "item2":"kannagu"

sum and len unsupported operand type(s) for +: 'int' and 'str

`list = [] with open("ads.txt", "r", encoding="UTF-8") as ads: first= ads.readline() for i in ads: i = i.strip().split(";") list.append(

Creating a list from the class attributes - Python

I was wondering if someone could elaborate on exactly why creating a new list out of the two attributes passed in the class returns a "NoneType"? class Finance:

ValueError: Input 0 of layer "sequential_35" is incompatible with the layer: expected shape=(None, 800, 1, 100), found shape=(None, 1, 100)

Hi Im currently working on the below program but im getting below error: ValueError: Input 0 of layer "sequential_35" is incompatible with the layer: expected s

how python [0] * 3 are independent but [[0] * 3] * 3 each sub list is the same object? [duplicate]

my_list = [0] * 3 my_list[0] = 1 outputs to [1, 0, 0] my_2ndlist = [[0] * 3] * 3 my_2ndlist[1][1] = 5 outputs to [[0, 5, 0], [0, 5, 0], [0,

How to convert mean value of each column variable and fill this mean value to corresponding variable in dataframe? [duplicate]

I have a mining dataset which has a following features Rock_type, Gold in grams(AU). Rock type has 8 different rock types and Gold (AU) has pr

Rollercoaster Project

I am supposed to filter the ages of the users through the following rule: if users >=120 cm then print("You can ride the rollercoaster!"), if users <=119

how do i port my machine learning model from python to java web app?

so I've been developing some machine learning models using sklearn and tensorflow in python . and I want to integrate it into a java web app. so far I've been s

fix the "element not interactable" exception?

I am trying to fix the following error from selenium, but right now I am not able to proceed. selenium.common.exceptions.ElementNotInteractableException: Messag

Building a package referencing a package in a parent directory in setup.py

I am trying to build a pip package from source code in a Git repository that has multiple packages that share a common package. (I am not allowed to change the

Problem with repetitive messages for whatsapp - python

I have been making a whatsapp chatbot with python, my problem is that it answers many messages, I think I have some open loop and I am not checking if the last

TypeError: 'int' object is not iterable - When trying to convert a string to a list

My code is as follows down below. However the x that I input into this function is not int data type, it should be a string. The other code will show you where

Rewriting SAS optimization in Python

I am trying to rewrite something similar to the following SAS optimization code in Python. The goal of the code is to find parameters for a continuous (in this

Iterating through XMLs, making dataframes from nodes and merging them with a master dataframe. How should I optimize this code?

I'm trying to iterate through a lot of xml files that have ~1000 individual nodes that I want to iterate through to extract specific attributes (each node has 1

cv2.VideoCapture inconsistent behavior between cap.set and loop read

I was trying to read the 600th frame of a video using cv2.VideoCapture. However, I found that the following two methods both successfully read an image but the

Split second level multindex column to create three level column in Pandas

Given a multiindex df X E1_ex0 E1_ex2 E2_ex0 E4_ex0 0 3 4 1 1 1 4 3 2 0 I would like to s

Python: Creating nested dictionaries, using keys stored in a list

EDIT: I forgot to mention that there are other dictionaries and lists, and the solutions suggested so far work very well for my example, but not if I want to ad

how to click on pop up elements using undetected chromedriver

i am trying to make 5-star bot i have already done half work for getting login with gmail only place i am stuck is when it come to clicking on pop up window ask