You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wanted to produce grouped histogram such that the heights of the bars add up to 1. The following code results in ValueError: weights should have the same shape as x
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(123)
n = 100
df = pd.DataFrame(np.random.randn(n), columns=['a'])
by = np.random.randint(1,5,n)
df.hist(by=by) # works
plt.show()
weights = np.repeat(1/len(df), len(df))
df.hist(weights = weights) # works
plt.show()
df.hist(by = by, weights = weights) # does not work
plt.show()
In [15]: pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.4.2.final.0
python-bits: 64
OS: Linux
OS-release: 3.18.6-1-ARCH
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8