回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我正在使用pandas DataFrame。如果打印dataframe,它包含一些用脚本(-)代替数字的列。当我使用数据制作图表时,termninal返回:</p>
<pre><code>TypeError: Empty 'Series': no numeric data to plot
</code></pre>
<p>这些脚本(-)数据点不能在制作图形时使用吗?它们需要更换吗?如果是这样,怎么办?在</p>
<p>我写的代码是:</p>
^{pr2}$
<p><strong>示例数据</strong></p>
<p><code>data.csv</code></p>
<pre><code>a,b,c,d,e,f,g,h,i,j,k,l,m,n,nn,o,p,q,r,s,t,u,v,w,x,y,z,hh
12,2798,3.9,3.0,1.1,4.0,0.1,5.0,0.0,-,0.1,35.5,0.2,52.0,1.6,19.0,2.0,36.0,0.1,24.5,0.2,52.0,0.2,2.0,0.0,-,0.2,13.0
13,2757,8.5,6.0,3.4,15.0,0.1,1.0,0.0,3.0,0.0,-,0.6,6.0,2.5,12.0,2.4,14.0,0.1,41.0,0.3,25.5,0.3,4.0,0.1,5.0,0.1,19.0
14,2792,18.1,5.0,8.7,24.0,0.1,5.5,0.0,-,0.1,2.0,1.6,3.0,2.6,5.0,3.9,12.0,0.4,4.5,0.9,5.0,0.8,12.0,0.1,24.0,0.2,16.5
15,2956,29.2,6.0,14.5,25.0,0.5,4.0,0.1,9.5,0.2,1.0,2.1,4.0,2.5,5.5,5.5,10.0,0.8,3.0,2.0,4.5,1.5,6.0,0.3,10.5,0.4,30.0
</code></pre>
<p>使用埃文的答案:<code>df.replace(to_replace = '-', value = np.nan, inplace = True)</code>仍然得到相同的错误。在</p>
<p>它适用于第一列,因为这些列没有脚本(-)</p>