Skip to content

Category: Questions

Way to call method depending on variable?

I already have a working, but in my oppinion not beautiful solution for a part of a long script. My script uses several similar methods, that differ too much to combine. However I came to a point where I want to call one of those methods depending on a given variable. The names of the methods are build up lik…

Grouping by multiple columns to find duplicate rows pandas

I have a df I want to group by val1 and val2 and get similar dataframe only with rows which has multiple occurance of same val1 and val2 combination. Final df: Answer You need duplicated with parameter subset for specify columns for check with keep=False for all duplicates for mask and filter by boolean index…

Finding author of a message

If someone writes “?name (arg)” I want my bot to say the author of the message + “, your name is” + arg. I can’t find of the author of the message though. Answer To get the name of the author of the message, you will need to use context

tensorflow – how to add an if statement?

This is a simplified version of what I am trying to do: Yet when trying to run this I get: How to fix this? EDIT: results in a: : Tensor(“cond/Merge:0”, shape=(?, 128), dtype=float32) Answer tensorflow objects can’t be used with regular python objects and functions. That’s how tensorfl…