如何将str转换为float?

时间:2020-03-18 17:34:57

标签: python-3.x string pandas dataframe floating-point

输入:

df.groupby('Age Group').size()

输出:

  18 thru 24      352
  25 thru 34      358
  35 thru 44      341
  45 thru 54      336
  55 and Older    269
  Under 18        103
  dtype: int64 

输入:

age = df.loc[df['Age Group']== '18 thru 24'].count()[0]
labels = ['18 thru 24']
plt.pie(['18 thru 24'], labels = labels)
plt.show()

输出:

ValueError: could not convert string to float: '18 thru 24'

0 个答案:

没有答案