Category "python"

Make a list from a data frame that has repeated and non repeat values in columns

I have a data frame like this data = [['Ma', 1,'too'], ['Ma', 1,'taa'], ['Ma', 1,'tuu',],['Ga', 2,'too'], ['Ga', 2,'taa'], ['Ga', 2,'tuu',]] df = pd.DataFra

Triangle interpolation script not working

I solved a part of my question! So I removed the original question and updated it to this one: I am making a wind interpolation script. There are several weathe

Practicality of the position attribute of a Positional List Implementation in Python?

I am reading Chapter 7 of Data Structures and Algorithms in Python and I am finding the Positional List ADT quite hard to understand, the implementation given b

How to convert datetime format '%a, %d %b %Y %H:%M:%S %z' in python?

I'm trying to convert a string to datetime and keep getting the error: ValueError: time data 'Sat, 14 May 2022 12:15:00 +0000' does not match format '%a, %d %b

Loop Vectorisation

I need to vectorise the following loop using Numpy for performance purposes: for example in client_local_dataset: X.append(example['image'].numpy()) Y

The truth value of a is ambiguous when I used Iflese in Python

I am using conditional multiplication within data frame and using following syntax: if(df_merged1["region_id"]=="EMEA"): df_merged1["fcst_gr"] = df_merged1[

Requirement already satisfied but in another env - python env configuration

Even if I've enough experience with Python & VScode, I often get this major misunderstanding. For example, I have two projects Project1_folder .env1

how to pass a datetime string from strftime() as an excel sheet name using openpyxl?

The purpose of the code below is to check whether or not a sheet already exists in excel workbook. If sheet exists, then set sheet as active sheet with given na

Great expectation error when using save_expectations_config() function

I tried to run this code using PyCharm: import great_expectations as ge df=ge.read_csv(r"C:\Users\TasbeehJ\data\yellow_tripdata_2019-01.csv") print(df.expect_co

Python3 'cv2.resizeWindow('img', 500,500)' error

I am trying to run this face tracking program provided here, but running the python program returns; Traceback (most recent call last): File "C:\Users\User\De

How to refresh tkinter window if requirements aren't fulfilled when pushing button

So I have a make story button, but I want it to be so if the entry boxes are empty or an adjective is not selected, it refreshes the window and does not make th

What is the reason of this error I'm getting when using tkinter for a math app

Im making a program that will do most of my homework. Im trying to add some ui and it gives errors in my code. Please tell what's wrong. Make it easy enough for

How to create an ensemble model by stacking different model?

I want to use ensemble model by stacking Multiple Linear Regression, SVR, Decision Tree Regression and ANN regression. How can I do that?

I'm Trying to Build a Discord Bot that Sends a Message once Every Scheduled Interval

import discord import time import random import schedule import asyncio async def run_scheduled_tasks(): while True: schedule.run_pending()

Feature importance in neural networks with multiple differently shaped inputs in pytorch and captum (classification)

I have developed a model with three inputs types. Image, categorical data and numerical data. For Image data I've used ResNet50 for the other two I develop my o

How to replace a list inside a multildimensional array?

I was solving this question on SO and faced a few problems with the methods I was trying. OP has a list which looks like this, a = [[[100, 90, 80, 255],

How to write BigTable table data into a pandas dataframe?

I am trying to read a GCP BigTable - table to a pandas dataframe, and currently, the function I am using to fetch rows from BigTable is read_rows(), which retur

I want to delete all the lists with length 1 at the beginning and end but not in the middle in python

Given a list of lists (i.e. a nested list), I want to delete all the inner lists with length 1 from the beginning and the end of the outer list. For example d

How can decorators be used for callback recognition?

I am implementing a system that uses callbacks for event handling. I currently register the callbacks in a dictionary in each module. For example, see below: cl

How do I shutil.move my file, post processing, in python based on filename?

My code- import pandas as pd import datetime as dt import os import shutil path = "C:/Users/rocky/Desktop/autotranscribe/python/Matching" destination_path =