2017-10-09 47 views

回答

2

我认为ispossible创建在seaborn堆叠酒吧,但真的很复杂。

Simplier是使用DataFrame.plot.bar与参数stacked=True

from collections import Counter 

df = pd.DataFrame({'A':['1110','1111', '0000']}) 

print (df) 
     A 
0 1110 
1 1111 
2 0000 

#get counts of 0, 1 
x = Counter([a for x in df['A'] for a in list(x)]) 
print (x) 
Counter({'1': 7, '0': 5}) 

df = pd.DataFrame([x]) 
print (df) 
    0 1 
0 5 7 

df.plot.bar(stacked=True)