早晨
我有一个lage df,想用joinplot
绘制我的inc_open_hours_bucket
乘inc_volume
data = {'inc_open_hours_bucket': ['No Data', '0_15_min', '15_30_min', '30_45_min', '45_60_min',
'1_1.5_hour', '1.5_2_hour', '2_2.5_hour', '2.5_3_hour',
'3_3.5_hour', '3.5_4_hour', '4_4.5_hour', '4.5_5_hour',
'5_5.5_hour', '5.5_6_hour', '> 6_hour'],
'inc_volume': [153, 99, 50, 46, 53, 73, 50, 44, 37, 34, 29, 23, 13, 15, 18, 417]}
df = pd.DataFrame(dict(data))
print(df)
inc_open_hours_bucket inc_volume
0 No Data 153
1 0_15_min 99
2 15_30_min 50
3 30_45_min 46
4 45_60_min 53
5 1_1.5_hour 73
6 1.5_2_hour 50
7 2_2.5_hour 44
8 2.5_3_hour 37
9 3_3.5_hour 34
10 3.5_4_hour 29
11 4_4.5_hour 23
12 4.5_5_hour 13
13 5_5.5_hour 15
14 5.5_6_hour 18
15 > 6_hour 417
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 16 entries, 0 to 15
Data columns (total 2 columns):
inc_open_hours_bucket 16 non-null object
inc_volume 16 non-null int64
dtypes: int64(1), object(1)
memory usage: 336.0+ bytes
我在jointplot
函数调用中得到了错误TypeError: can't multiply sequence by non-int of type 'float'
.
我需要将这些强制为特定类型才能使用这种类型的图表吗?
# Create jointplot
sns.set(font_scale = 0.5)
ax = sns.jointplot(x='inc_open_hours_bucket',y='inc_volume',data=df,kind='hex')
# Add attributes
plt.title("INC by inc_open_hours_bucket")
plt.show()
# Save image
ax_Figure = ax.get_figure()
# Set to high resolution and save
ax_Figure.savefig('12. INC by inc_open_hours_bucket.png', dpi=300)