我想从我的熊猫数据框创建多个绘图,如下所示:
dataset.head()
trip_id duration distance avg_speed avg_acc travel_mode
0 303633 1.0 42.74 0.00 70.46 foot
1 303637 30.0 521.07 1.43 27.86 car
2 303638 13.0 339.58 0.65 26.30 car
3 303642 12.0 459.94 0.00 78.67 car
4 303657 4.0 71.3 0.00 72.94 foot
travel_mode
列包含5种不同的运输方式:
dataset.travel_mode.unique()
array(['foot', 'car', 'bus', 'bike', 'metro'], dtype=object)
我想绘制每个旅行模式的duration, distance, avg_speed
和avg_acc
per的分布。你知道吗
col = ['duration', 'distance', 'avg_speed', 'avg_acc', 'travel_mode']
dataset[col].groupby('travel_mode').hist(bins=50, figsize=(6, 4))
数字的显示方式让你无法分辨哪个数字是哪种交通工具。然后我试着用偏态分布。你知道吗
偏度分布:
l = dataset.columns.values
n_cols=4
n_rows =5
plt.figure(figsize=(3*n_cols,2*n_rows))
for i in range(0,len(l)):
plt.subplot(n_rows + 1,n_cols,i+1)
sns.distplot(dataset[l[i]],kde=True)
TypeError: unsupported operand type(s) for /: 'str' and 'int'
如何按旅行模式显示带标签的分布,使旅行模式成行,列显示duration, distance, avg_speed,
和avg_acc
的数字?你知道吗
这应该可以通过
travel_mode
分隔。注意subplots=True
。你知道吗如果您想覆盖密度图,我认为它将适用于seaborn:
这不是一个漂亮的代码,但你可以识别组。。。标题是组名和列的串联。你知道吗
相关问题 更多 >
编程相关推荐