questions

Loop to factor given list

Loop to factor given list Question: I have data l: [[Timestamp(‘2022-07-14 00:01:00’), Timestamp(‘2022-07-14 00:11:00’), 1], [Timestamp(‘2022-07-14 00:08:00’), Timestamp(‘2022-07-14 00:18:00’), 1], [Timestamp(‘2022-07-14 00:15:00’), Timestamp(‘2022-07-14 00:25:00’), 1], [Timestamp(‘2022-07-14 00:22:00’), Timestamp(‘2022-07-14 00:32:00’), 0], [Timestamp(‘2022-07-14 00:29:00’), Timestamp(‘2022-07-14 00:39:00’), 0], [Timestamp(‘2022-07-14 00:36:00’), Timestamp(‘2022-07-14 00:46:00’), 1], [Timestamp(‘2022-07-14 00:43:00’), Timestamp(‘2022-07-14 00:53:00’), 1], [Timestamp(‘2022-07-14 00:50:00’), Timestamp(‘2022-07-14 01:00:00’), 1], [Timestamp(‘2022-07-14 00:57:00’), Timestamp(‘2022-07-14 01:07:00’), 0], …

Total answers: 2

Qml, Reference error <signalName> is not defined when signal defined

Qml, Reference error <signalName> is not defined when signal defined Question: I have a very simple qml+python app to play and test signal/slot communication. All works fine so far, but when I run the app, a ReferenceError is reported on the QML side. However, all works fine, it is so simple code: QML: import QtQuick …

Total answers: 1

How do I quickly drop rows based on the max value in a groupby?

How do I quickly drop rows based on the max value in a groupby? Question: I have a large dataframe containing information on people and their job change history. Sometimes, someone had multiple changes to their record on one day, each of which is assigned a transaction sequence number. I just want to keep the …

Total answers: 1

Simple keyboard program with issues

Simple keyboard program with issues Question: This program sometimes counts one key press as 2 presses or as 0,5 press. Program: import keyboard while True: if keyboard.read_key() == ‘h’: print("1") elif keyboard.read_key() == ‘j’: print("2") elif keyboard.read_key() == ‘k’: print("3") I want this program to count 1 key press as one action. I have no …

Total answers: 1

How to check user for 2 fields from another model with ManyToMany fields

How to check user for 2 fields from another model with ManyToMany fields Question: How am i suppose to check request.user for 2 fields in the same time I want to show different pages in header if user is customer or contractor by another many to many field or if he is contractor and customer …

Total answers: 1

python file pass value to html with flask face Internal Server Error (jinja2.exceptions.TemplateNotFound: index.html)

python file pass value to html with flask face Internal Server Error (jinja2.exceptions.TemplateNotFound: index.html) Question: python file pass value to html with flask error Internal Server Error The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.` import mysql.connector …

Total answers: 1

Web scrapping can't grab the source of an image

Web scrapping can't grab the source of an image Question: import requests import bs4 res2 = requests.get("https://en.wikipedia.org/wiki/Deep_Blue_(chess_computer)") soup = bs4.BeautifulSoup(res2.text,’lxml’) soup.select(".image") computer = soup.select(".image")[0] computer[‘class’] computer [‘src’] When I run computer[‘class] I get back the class name “But when I run computer[‘src’] I get the following error KeyError Traceback (most recent call last) Input In …

Total answers: 2

How to change a parsed text into integer or remove decimal points?

How to change a parsed text into integer or remove decimal points? Question: How to convert a text into integer? The "reference_price" parsed from a webpage is "123.45" and its type is Text. However, I would like to change this to an integer like "123". ###### Parsing tbody = table.tbody for i, tr in enumerate(tbody.find_all(‘tr’)): …

Total answers: 2

How to merge dataframe faster?

How to merge dataframe faster? Question: I have a df as following import pandas as pd df = pd.DataFrame( {‘number_1’: [‘1’, ‘2’, None, None, ‘5’, ‘6’, ‘7’, ‘8’], ‘fruit_1’: [‘apple’, ‘banana’, None, None, ‘watermelon’, ‘peach’, ‘orange’, ‘lemon’], ‘name_1’: [‘tom’, ‘jerry’, None, None, ‘paul’, ‘edward’, ‘reggie’, ‘nicholas’], ‘number_2’: [None, None, ‘3’, None, None, None, None, None], …

Total answers: 1