I would like to plot two columns of a pandas dataframe as side by side box plots by category. This is not the same as the question presented in here: Grouped boxplot with seaborn where the two columns have lists inside them. The solution there did not work for me.
MWE
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame(
[
[2, 4, "A"],
[4, 5, "C"],
[5, 4, "B"],
[10, 4.2, "A"],
[9, 3, "B"],
[3, 3, "C"]
], columns=['data1', 'data2', 'Categories'])
#Plotting by seaborn
fig, axs = plt.subplots(1, 1)
sns.boxplot(data=df,x="Categories",y='data1',ax=axs)
fig.show()
plt.waitforbuttonpress()
plt.close(fig)
Replacing "data1" with "data2" in the boxplot line would give:



