Skip to content
Advertisement

Tag: python-3.x

How to create rank column in Python based on other columns

I have a python dataframe that looks like the following: This dataframe has been sorted in descending order by ‘transaction_count’. I want to create another column in that dataframe called ‘rank’ that contains the count of occurrences of cust_ID. My desired output would look something like the following: For cust_ID = 1234 with transaction_count = 4, the rank would be

Make Tkinter Notebook draggable

A similar question was asked back in ’15 Make Tkinter Notebook be Draggable to Another View but that was a while ago and that also asked about re-binding the window. I was wondering how I would make a notebook draggable, even if is just to reorder the tabs. Any advice would be helpful and please let me know if this

supposedly incorrect output np.reshape function

I have an array called “foto_dct” with shape (16,16,8,8) which means 16×16 matrices of 8×8. When I print foto_dct[0,15], being the last matrix of the first row I get: when i do foto_dct_big = np.reshape(foto_dct,(128,128)) and print foto_dct_big I get this: As you can see is the top righter corner( which is supposed to be the matrix above with all

AttributeError: module ‘asyncio’ has no attribute ‘create_task’

I’m trying to asyncio.create_task() but I’m dealing with this error: Here’s an example: Out: So I tried with the following code snippet (.ensure_future()) instead, without any problem: Out: What’s wrong? [NOTE]: Python 3.6 Ubuntu 16.04 [UPDATE]: With borrowing from @user4815162342 Answer, my problem solved: Answer The create_task top-level function was added in Python 3.7, and you are using Python 3.6.

Advertisement