擅长:python、mysql、java
<p>要解决此问题,必须转换要转换的特定列
用于数字。首先,让我创建一个简单的数据帧,其中<code>pandas</code>和<code>numpy</code>到
更好地理解它。</p>
<pre><code>#creating the dataframe
import pandas as pd
import numpy as np
details=[['kofi',30,'male',1.5],['ama',43,'female',2.5]]
pf=pd.DataFrame(np.array(details),[0,1],['name','age','sex','id'])
pf #here i am calling the dataframe
name age sex id
0 kofi 30 male 1.5
1 ama 43 female 2.5
#to make your plot work you need to convert the columns that have numbers into numeric
as seen below
pf.id=pd.to_numeric(pf.id)
pf.age=pd.to_numeric(pf.age)
pf.plot.scatter(x='id',y='age')
#This should work perfectly
</code></pre>