df = pd.melt(df, id_vars="class", var_name="sex", value_name="survival rate")
df
Out:
class sex survival rate
0 first men 0.914680
1 second men 0.300120
2 third men 0.118990
3 first woman 0.667971
4 second woman 0.329380
5 third woman 0.189747
6 first children 0.660562
7 second children 0.882608
8 third children 0.121259
是,您需要重塑数据帧:
现在,您可以使用factorplot(v0.8.1或更早版本):
对于0.9.0或更高版本,正如Matthew在comments中所指出的,您需要使用重命名的版本
catplot
。我知道我的答案来得很晚,但我希望有人能从中受益。
为了解决上述问题,我在重新整理数据后使用了下面的代码:
数据:
相关问题 更多 >
编程相关推荐