I am having trouble assigning a role to a user when they type in a command Code: When the user types “!BMOrole”, I want to give them a role called, “BMO” and also display a message. The error I’m receiving is: Answer you forget set a default user:
How to use pandas apply to replace iterrows?
I am calculating the sentiment value on every row in the dataset based on news headline. I used iterrows to achieve this: However, the processing time is taking too long (>30 minutes runtime and it is not done yet). I have 16.6k rows in my dataset. This is a small section of the dataset: I have read that i…
How to trigger a method in 2 instances of the same class object in Python?
I had 2 instances (st0, st1) of the same class (State) in which has 2 methods. Somehow when st0.loc_st() is called, I want that st1.rem_st() to be automatically triggered. How can I achieve that purpose with Python OOP? Sorry the code looks a bit naive, but it’s a simplified model saves the reading effo…
Python generator expression recursion
This is a question about Python internals. The following code is taken from this video about laziness in python: The sieve function generates prime numbers lazily (read this for the original concept). Conceptually, we add filters to the “sieve”, so every number (say, 10) is tested against all the …
I would try change channel for keras pretrained model
I got an Xception model. I have combined the model to change the Input Channel to 3. however I have got error Answer You simply have to embed Xception in the correct way in your new model: We create a new Input layer, than we operate upsampling and in the end we pass all to Xception Here is the running
Cross-validation with time series data in sklearn
I have a question with regard to cross-validation of time series data in general. The problem is macro forecasting, e.g. forecasting the 1-month ahead Price of the S&P500 using different monthly macro variables. Now I read about the following approach: One should/could use a rolling cross-validation appro…
Create a list of dictionaries from nested list
I do have a dynamic text that will change. I want to store those values in a meaningful way. I have created a nested list to store them but I need to convert those to individual dictionaries and store it into a list. How do I do this? So far good. Devices variable is a nested list. I need to
Custom list class slicing functionality
I want to implement my own type of list called Stack. I also want to add slicing functionality with the __getitem__ method like so: Now if I create a Stack instance and append some elements to it I get the Stack type: but if I slice my Stack, it becomes a list again: how can I make st_sliced to stay
Define the variable of a function call indirectly
I have two files file1.py and file2.py. I execute a function from file2.py which executes a function from file1.py. The transfer function from file1.py is used in several other files in the tree. Could I, from outside the tree, set the token variable for the transfer function in my file1.py? Which would be ap…
How to know a movie has how many 0.5/1/1.5/2/2.5/3/3.5/4/4.5/5 rating that rated by every user?
I would like to know how many 0.5/1/1.5/2/2.5/3/3.5/4/4.5/5 ratings that rated by every user in a data frame of a certain movie which is Ocean’s Eleven (2001) in order to calculate Pearson Correlation using the formula. Below is the code In this case, I just can know there are two 4.0 ratings, but I hav…