@staticmethod<EOL><INDENT>def _bar(s, align, colors, width=<NUM_LIT:100>, vmin=None, vmax=None):<DEDENT>
<EOL>smin = s.min() if vmin is None else vmin<EOL>if isinstance(smin, ABCSeries):<EOL><INDENT>smin = smin.min()<EOL><DEDENT>smax = s.max() if vmax is None else vmax<EOL>if isinstance(smax, ABCSeries):<EOL><INDENT>smax = smax.max()<EOL><DEDENT>if align == '<STR_LIT>':<EOL><INDENT>smin = min(<NUM_LIT:0>, smin)<EOL>smax = max(<NUM_LIT:0>, smax)<EOL><DEDENT>elif align == '<STR_LIT>':<EOL><INDENT>smax = max(abs(smin), abs(smax))<EOL>smin = -smax<EOL><DEDENT>normed = width * (s.values - smin) / (smax - smin + <NUM_LIT>)<EOL>zero = -width * smin / (smax - smin + <NUM_LIT>)<EOL>def css_bar(start, end, color):<EOL><INDENT>"""<STR_LIT>"""<EOL>css = '<STR_LIT>'<EOL>if end > start:<EOL><INDENT>css += '<STR_LIT>'<EOL>if start > <NUM_LIT:0>:<EOL><INDENT>css += '<STR_LIT>'.format(<EOL>s=start, c=color<EOL>)<EOL><DEDENT>css += '<STR_LIT>'.format(<EOL>e=min(end, width), c=color,<EOL>)<EOL><DEDENT>return css<EOL><DEDENT>def css(x):<EOL><INDENT>if pd.isna(x):<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>color = colors[<NUM_LIT:1>] if x > zero else colors[<NUM_LIT:0>]<EOL>if align == '<STR_LIT:left>':<EOL><INDENT>return css_bar(<NUM_LIT:0>, x, color)<EOL><DEDENT>else:<EOL><INDENT>return css_bar(min(x, zero), max(x, zero), color)<EOL><DEDENT><DEDENT>if s.ndim == <NUM_LIT:1>:<EOL><INDENT>return [css(x) for x in normed]<EOL><DEDENT>else:<EOL><INDENT>return pd.DataFrame(<EOL>[[css(x) for x in row] for row in normed],<EOL>index=s.index, columns=s.columns<EOL>)<EOL><DEDENT>
Draw bar chart in dataframe cells.