I have a dataframe with several columns, where every column has between 5 and 2535 entries (the rest is NAN). I want to plot a boxplot when the column has more than 9 numeric entries and a swarmplot otherwise. I used my mad paint skills to create an example.
The problem is that I am only able to plot both as overlays, as in this example. I tried using the position keyword, but this only works for the boxplot, not for the swarmplot. So, how can this be done?
An example dataset can be produced like this:
np.random.seed(1)
df = pd.DataFrame(np.nan, index=range(100), columns=range(11))
for i, column in enumerate(df.columns):
if i % 2 == 0:
fill_till = np.random.randint(1,11)
df.loc[:fill_till-1,column] = np.random.random(fill_till)
else:
fill_till = np.random.randint(11,101)
df.loc[:fill_till-1,column] = np.random.random(fill_till)