Skip to content Skip to sidebar Skip to footer

Boxplot For List In Pandas Dataframe

I have the foll. dataframe: Month(s) Vals 0 Mar [3.691756, 3.59027575] 1 Mar - Apr [4.75706325,

Solution 1:

Preparing your DataFrame by setting "Month(s)" as index

df = pd.DataFrame([('      Mar',[3.691756, 3.59027575]),
               ('Mar - Apr', [4.75706325, 3.138456625, 1.90741175, 3.019323]),
               ('Mar - May',[4.698454875, 3.317812375, 2.512695375, 2.8096]),
               ('Mar - Jun', [4.70111125, 3.474370375, 2.53445075, 2.926820]),
               ('Mar - Jul', [4.79324375, 3.56983175, 2.39309125, 3.0682476]),
               ('Mar - Aug', [4.618898125, 3.613308875, 2.361248375, 3.0536])],
              columns=['Month(s)','Vals']).set_index('Month(s)')

will enable you to convert each row to a Series

df['Vals'].apply(lambda x: pd.Series(x)).T.boxplot(figsize=(10,10),rot=45)

Plot Output

Post a Comment for "Boxplot For List In Pandas Dataframe"