I have the following pandas DataFrame df:
Datetime Field1 Field2 2018-10-01 10:00 10 13 2018-10-01 11:00 18 14 2018-10-01 12:00 11 16 2018-10-01 13:00 12 15 2018-10-01 14:00 13 15 2018-10-01 15:00 11 11 2018-10-02 10:00 14 15 2018-10-02 11:00 15 15 2018-10-02 12:00 12 12 2018-10-02 13:00 11 15 2018-10-02 14:00 10 13 2018-10-02 15:00 10 15 2018-10-03 10:00 15 11 2018-10-03 11:00 13 12 2018-10-03 12:00 11 12 2018-10-03 13:00 11 11 2018-10-03 14:00 11 13 2018-10-03 15:00 12 15 I need to create a box plot to show how the values of Field2 are distributed when grouped by Field1. The result should be conceptually similar to this plot, where X should be Field1 and Y should be Field2):
This is what I tried:
df = df.set_index("Field1") grouped = df.groupby(level="Field1") grouped.boxplot(rot=45, fontsize=12, figsize=(10,5)) But this code gets stuck and does not provide any results.



sns.boxplot(data=df, x="Field1", y="Field2")sns.boxplot(data=df, x='Field1', y='Field2')on the original dataframe (without theset_index).