Category "python"

Python/Pandas Calculate the mean time (hour) of a Datetime column

I have a Pandas DataFrame (data) with a column ['Date'] in DateTime (date and time) which represents the time of arrival. How to calculate the mean of only the

Web scraping from html code of a database using python

I am new to python and am learning things slowly. I have earlier performed API calls from databases to extract infromation. However, I was dealing with a partic

How to input a history of vectors to LSTM based network instead of a single vector?

I am trying to predict a simple pattern using LSTM based network. I input a single vector and get the output vector with the same shape as a prediction. How can

Filter dictionary of tuples with duplicated first element of the values based on some condition

Sample input data in which Value1 is duplicated across several keys {'Key1': ('Value1', '28.302', '30', '131', '10', '321'), 'Key2': ('Value2', '42.373', '44'

Chatbot-specific answers

I'm creating a chatbot that asks questions and answers questions, but for now it doesn't have a specific function of answering specific questions that it asks i

Python mock.patch() not mocking imported class module

I have a some code that looks like this (abridged): ## ./module_1/lambda_function.py from shared.graphql_helpers import GraphQLClient gql_client = GraphQLClie

How to return and download Excel file using FastAPI?

How do I return an excel file (version: Office365) using FastAPI? The documentation seems pretty straightforward. But, I don't know what media_type to use. H

Plotting the frequency of occurrences per date

I'm new to pandas and plotly. And I have a large csv file with two columns, a date column and a column that contains a string of text (event). Each event is a n

Cant run flask on ngrok

from flask import Flask, escape, request app = Flask(__name__) run_with_ngrok() @app.route('/') def hello(): name = request.args.get("name", "World") ret

Can´t copy tupel from one dataframe into another (Length of values does not match length of index)

I want to create columns in a dataframe (df_joined) that contains as values tupels from a second df (df_tupels). The tupels are (10,50) and (20,60). I tried var

Changing the time scale of a matplotlib graph in a real-time fashion

I'm making a real-time application that graphs sensor data in a real-time fashion. The data is saved to a .csv file and graphed using matplotlib in the followin

NameError: name '_mysql' is not defined - Django tailwind

When I run python manage.py runserver, my django server runs and I can see my webpage, however some of the tailwind doesn't work. When I then stop that server a

download the data day by day from ERA5

How to create a script using python (api code) to download daily data using (for loop) from ERA5, to make a circulation day by day during the year? notice, I ha

How to extract all text from pdf?

I'm using the PYPDF2 lib to extract texts from a PDF but I'm having a problem doing the loop. I'm using the following code and I can extract a string from the f

When I Run My Code I Get A Huge Error In Python

If I Run This Code: import re mapping = {'gde1': 'a', '4&TW': 'b', 'E#ZB': 'c', 'B0F&': 'd', 'uvRD': 'e', 'M7vr': 'f', 'X$*d': 'g', 'XQ%R': 'h', 'jma+':

Google Colab error: Import "tensorflow.keras.models" could not be resolved(reportMissingImports)

import tensorflow as tf tf.__version__ !sudo pip3 install keras from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Conv

Extracting information from website with BeautifulSoup and Python

I'm attempting to extract information from this website. I can't get the text in the three fields marked in the image (in green, blue, and red rectangles) no ma

Why does kivy show me a white background instead of the real rgba number?

In this program i set the background color of Label to 6, 61, 81, 1 like this : background_color: 6, 61, 81, 1 canvas.before: Color

Python cv2.VideoCapture() has wrong resolution and read cropped images

I'm trying to read images from an IDS GV-5240CP camera plugged to my laptop via ethernet using Python and OpenCV. This is what I am supposed to get : A 1280x102

How to get VS-Code style Intellisense(Case Insensitive and Intelligent) in jupyterlab?

TLDR version: How to make JupyterLab Autocomplete case insensitive? I would like to have Visual Studio Code style Intellisesne(prediction and auto complete) in