小编aoz*_*ozk的帖子

seaborn:无法将字符串转换为浮点数

我有 DataFrame df

Timestamp-start    datetime64[ns]
Timestamp-end      datetime64[ns]
M                          object
S                          object
Type                       object
description_x              object
description_y              object
Date               datetime64[ns]
number_col                 float64
dtype: object
Run Code Online (Sandbox Code Playgroud)

number_col :

51      0.0
0       1.0
1       2.0
2       3.0
52      5.0
      ...  
47    148.0
48    148.0
43    148.0
49    149.0
50    149.0
Name: number_col, Length: 132, dtype: float64
Run Code Online (Sandbox Code Playgroud)

我想使用seaborn和列number_col绘制直方图

>     import seaborn as sns
>     
>     sns.distplot(df, x='number_col')
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

ValueError: could not convert string to float: 'number_col'
Run Code Online (Sandbox Code Playgroud)

我不知道为什么会发生这种情况,“number_col”已经是一个浮点列。

python pandas seaborn

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

pandas ×1

python ×1

seaborn ×1