Skip to content

unicode_escape without deprecation warning

In Python 3.8, the following: …produces a deprecation warning: Is this going to become an error in a future version of Python? Where is the reference for this? If No, is there a way to not display this warning, if Yes, what can I use instead? Edit: I am (obviously) not interested in fixing this for a st…

Applying lambda to whole dataframe with if condition

I have a df that looks like this: I want to calculate the mean of the columns where A>0 so that my df would look like this: I use: But get: TypeError: ‘float’ object is not subscriptable I also tried But get: KeyError: False Which is produced by the x[‘A’]>0 mask. And: I couldn&#…

upload file with slackclient 2.x

I’m upgrading from slackclient 1.3.1 to 2.9.3 using this guide. before I had this function: which I tried to migrate to: the function is called with something like this: However, I get: Object of type ‘BufferedReader’ is not JSON serializable I am guessing it is related to the way I pass the…

Difference of letting DataFrame’s column

I don’t know the difference of two ways that I let columns of DataFrame. the codes are here: when I printed A[‘ftr3’] to see elements of ftr3 of A, there was no problem. But when I printed B[‘ftr3’], the problem occured: Moreover, the reason I’m confused with this result wa…

Retrieving error while accessing files from the folders

I have the following code I need to files from the folder to be read by opencv. I am retrieving the below error. Help is highly appreciated. Thanks Answer You’re iterating over a string, so it will only get the first character. You need to list the contents of the directory. Use os.listdir like this.