Pandas style.bar(align='mid') does not make sense. · Issue #26070 · pandas-dev/pandas (original) (raw)

Code Sample, a copy-pastable example if possible

import pandas as pd import numpy as np N = 10 df = pd.DataFrame(np.random.normal(size=(10, N))+np.arange(N)*100, columns=range(N)) df.style.bar(align="mid", color=['pink', 'lightgreen'], axis=0)

Problem description

With align='mid' I would expect the middle to be the mean. Essentially, as a tool to visualize the variance.

The dataframe above contains 10 columns with random numbers. To the n's column n*100 is added. So, column-wise, I would expect pretty similar output cause the mid should be the mean of each column.

But because for columns that contain only positive or (only negative) values, the alignment is done differently. The way it is done right now you cannot see anything for e.g. column 8.

An alignment method where the mean is always used would be nice.