@@ -1896,7 +1896,7 @@ def boxplot_stats(X, whis=1.5, bootstrap=None, labels=None):
1896
1896
======== ===================================
1897
1897
label tick label for the boxplot
1898
1898
mean arithemetic mean value
1899
- median 50th percentile
1899
+ med 50th percentile
1900
1900
q1 first quartile (25th percentile)
1901
1901
q3 third quartile (75th percentile)
1902
1902
cilo lower notch around the median
@@ -1962,13 +1962,34 @@ def _compute_conf_interval(data, med, iqr, bootstrap):
1962
1962
1963
1963
input_whis = whis
1964
1964
for ii , (x , label ) in enumerate (zip (X , labels ), start = 0 ):
1965
+
1965
1966
# empty dict
1966
1967
stats = {}
1967
1968
stats ['label' ] = label
1968
1969
1969
1970
# restore whis to the input values in case it got changed in the loop
1970
1971
whis = input_whis
1971
1972
1973
+ # note tricksyness, append up here and then mutate below
1974
+ bxpstats .append (stats )
1975
+
1976
+ # if empty, bail
1977
+ if len (x ) == 0 :
1978
+ stats ['fliers' ] = np .array ([])
1979
+ stats ['mean' ] = np .nan
1980
+ stats ['med' ] = np .nan
1981
+ stats ['q1' ] = np .nan
1982
+ stats ['q3' ] = np .nan
1983
+ stats ['cilo' ] = np .nan
1984
+ stats ['ciho' ] = np .nan
1985
+ stats ['whislo' ] = np .nan
1986
+ stats ['whishi' ] = np .nan
1987
+ stats ['med' ] = np .nan
1988
+ continue
1989
+
1990
+ # up-convert to an array, just to be safe
1991
+ x = np .asarray (x )
1992
+
1972
1993
# arithmetic mean
1973
1994
stats ['mean' ] = np .mean (x )
1974
1995
@@ -2021,9 +2042,9 @@ def _compute_conf_interval(data, med, iqr, bootstrap):
2021
2042
np .compress (x > stats ['whishi' ], x )
2022
2043
])
2023
2044
2024
- # add in teh remaining stats and append to final output
2045
+ # add in the remaining stats
2025
2046
stats ['q1' ], stats ['med' ], stats ['q3' ] = q1 , med , q3
2026
- bxpstats . append ( stats )
2047
+
2027
2048
2028
2049
return bxpstats
2029
2050
0 commit comments