Exercise

Obtaining key-value pairs with melt()

Sometimes, all you need is some key-value pairs, and the context does not matter. If said context is in the index, you can easily obtain what you want.
For example, in the users DataFrame, the visitors and signups columns lend themselves well to being represented as key-value pairs. So if you created a hierarchical index with 'city' and 'weekday' columns as the index, you can easily extract key-value pairs for the 'visitors' and 'signups' columns by melting users and specifying col_level=0.

Instructions

100 XP

Set the index of users to ['city', 'weekday'].

Print the DataFrame users_idx to see the new index.

Obtain the key-value pairs corresponding to visitors and signups by melting users_idx with the keyword argument col_level=0.