创建 seaborn 热图时 'could not convert string to float' ValueError

When creating a seaborn heatmap 'could not convert string to float' ValueError

大家好,我有以下数据框,我想用以下代码从中创建热图。

plt.figure(figsize=(10,10))
g = sns.heatmap(
    top_5_stations_hourly_total_traffic_by_time, 
    square=True,
    cbar_kws={'fraction' : 0.01},
    cmap='OrRd',
    linewidth=1
)

g.set_xticklabels(top_5_stations_hourly_total_traffic_by_time.STATION, rotation=45, horizontalalignment='right')
g.set_yticklabels(top_5_stations_hourly_total_traffic_by_time.TIME, rotation=45, horizontalalignment='right')

但它给出了以下错误:

ValueError: could not convert string to float: '125 ST'

pivot 调用前的数据 heatmap:

df_heatmap = df.pivot("STATION", "TIME", "HOURLY_TOTAL_TRAFFIC")

>>> sns.heatmap(df_heatmap)