Category "python"

Select agents by a condition out of the model and change that attribute in mesa?

For an agent based modelling I'm doing with mesa & mesa-geo I need a way, to select and manipulate the agents out of the model.py. For example, if you take

F5 SDK - SSL Insecure request

Is there a way to ignore SSL? I'm running Python 3.10.1 code: from f5sdk.bigip import ManagementClient device = ManagementClient('10.10.17.127', user='admin',

Search Twitter API for tweets. Save and clean them up to a new txt file

I'm trying to get the below done, but keep getting an error. I know that I'm getting the information from Twitter because my monthly usage increasing. Any help

WebDriverException: failed to wait for extension background page to load: xxx Selenium

When I try to add an extension on my script like for example "Selenium" I get this error message: selenium.common.exceptions.WebDriverException: Message: unkn

Generating same numbers in array of Objects

Ive got problem with generating same numbers in my code im not using any seed and evry, the object is created in the loop it has same numbers inside array. clas

How to open url from altair chart in a new tab (href)

I've made an altair scattered chart with links. It works perfectly from my Jupyter Notebook. Problems start when altair is in Streamlit environment. As I invest

How to use nn.TransTransformerEncoder from pytorch

I am trying to use PyTorch's '''nn.TransformerEncoder''' module for a classification task. I have data points of varying lengths i.e I have sequences of differe

How to create a dictionary, where the key is the key of a dictionary of lists and the value is the longest list

I have this dictionary of lists of dictionaries: dict_countries ={'uk': [{'datetime': '1955-10-10 17:00:00', 'city': 'chester'},{'datetime': '1956-09-10 13:00:0

How to access shared google drive from remote server's jupyter notebook?

I have a big dataset on my shared google drive. I want to access/read the dataset from a remote server's jupyter notebook to train my deep learning model. I can

Groupby hours +/- some integer of additional hours

I have a data frame consisting of some columns, where the index is datetime, i.e. it looks something like: df = col1 col2

python get sys.platform values

i am interested in the list of values that sys.platform returns. i came across this answer, but the list was given without any reference to see that it is indee

python: initialize class members

I am using class to scope data (yap, maybe I should move this to a 2nd module). This class will contain a lot of "constants", however some of them need to be ca

How to use a variable/function from a class instance in a differrent class with kivy?

first, I'm new here, so don't hesitate to correct me if I act innapropriatly ! I'm making a sudo turn based RPG combat to train with kivy tools and I've come in

100 Days of Code - 37 - Love Calculator - What's wrong with my code?

Newbie here and I've taken a shot at a Love Calculator using the logic in my brain and here is what I got prior to some learning tweaks from the 100 Days of Cod

AWS SAM-lambda: Cannot import from parent directory containing a fastapi app

I'm trying to deploy a fastapi application to AWS lambda using the SAM client. The issue is that I cannot get Lambda to recognize the parent folder. I have a fa

How to have a single csv file after applying partitionBy in Pysark

I have to first partition by a "customer group" but I also want to make sure that I have a single csv file per "customer_group" . This is because it is timeseri

Import "brownie" could not be resolved in Pylance

Error is: Import "brownie" could not be resolvedPylance I know there are other SO posts that refer to this, but it seems most of them are talking about booting

How to run background task in parallel (python, FastAPI)

I am currently developing an API that has several endpoints. One of them is to register data in a database, other endpoints are related to simple CRUD endpoints

Is there any way to filter by the first child using SqlAlchemy?

I'm trying to find a way to filter by the attribute of the first row returned as children. class Parent(Base): __tablename__ = "parent_table" id = Colum

Minimize chrome ribbon button in python selenium

I have python selenium code to expand chrome button as mentioned below. button.click() And it expands button like this: Now I want to minimize button. Is ther