Skip to content

dedup records(window function pandas)

Hi I am looking to dedup my records ordered by cancel date so I will only be interested in the most recent record. sample data id cancel_date type_of_fruit 1 2021-03-02 apple 1 2021-01-01 apple 2 2021-02-01 orange expected output id cancel_date type_of_fruit 1 2021-03-02 apple 2 2021-02-01 orange I wrote the …

assert menu.__str__() == “” AssertionError

I get assertion error when i try to assert “” (empty string) into str function. Could anyone enlighten me as of why that happens. Totally clueless here. I know the str function needs to return a string but as far as i know it is returning a string when i run: The error comes when i run: here is my

Duration between two timestamps

I have a dataframe with different timestamp for each user, and I want to calculate the duration. I used this code to import my CSV files: df.head() And I want to get something like that I’ve used this code, but doesn’t work for me Answer Operations which occur over groups of values are GroupBy ope…

Apply threshold for numpy.ndarray

I have a model predictions type of numpy.ndarray The predictions looks like where the first value of inner array corresponds to 0 class and the second value corresponds to 1 class. For this y_pred i need to apply FNR threshold 0.21552509277542697, which i also calculated. That is the efficient numpy way to do…

‘Member’ has no attribute ‘server’

In the given code below I was trying to give a role to the person who reacts to a message by using any emoji but this code throws me an error saying that ‘Member’ has no attribute ‘server’ what should I do now? Answer First off take a look at the documentation. It’ll tell you eve…