Computer scienceData scienceInstrumentsPandasData analysis with pandas

Crosstab in pandas

Time of the day

Report a typo

Suppose we are working with the following dataset:

+----+--------------+-------+--------+----------+-------+--------+--------+
|    |   total_bill |   tip | sex    | smoker   | day   | time   |   size |
|----+--------------+-------+--------+----------+-------+--------+--------|
|  0 |        16.99 |  1.01 | Female | No       | Sun   | Dinner |      2 |
|  1 |        10.34 |  1.66 | Male   | No       | Sun   | Dinner |      3 |
|  2 |        21.01 |  3.5  | Male   | No       | Sun   | Dinner |      3 |
|  3 |        23.68 |  3.31 | Male   | No       | Sun   | Dinner |      2 |
|  4 |        24.59 |  3.61 | Female | No       | Sun   | Dinner |      4 |
+----+--------------+-------+--------+----------+-------+--------+--------+

Below is the starting code:

import pandas as pd
from seaborn import load_dataset

df = load_dataset("tips")

We want to get the sum of the tips for each combination of the weekday and the time. Select the day and the time during which the highest amount of tips was collected.

Select one option from the list
___

Create a free account to access the full topic