<p>Pandas字符串方法紧跟Python方法:</p>
<pre><code>str.isnumeric(100) # TypeError
str.isnumeric('100') # True
str.isnumeric('a10') # False
</code></pre>
<p>任何产生错误的类型都将给出<code>NaN</code>。根据Python<a href="https://docs.python.org/3/library/stdtypes.html#str.isnumeric" rel="nofollow noreferrer">docs</a>,<code>str.isnumeric</code>仅适用于字符串:</p>
<blockquote>
<p><strong>str.isnumeric()</strong><br/> Return true if all characters in the string are numeric characters, and there is at least one character, false
otherwise.</p>
</blockquote>
<p>根据熊猫<a href="https://pandas.pydata.org/pandas-docs/version/0.22/generated/pandas.Series.str.isnumeric.html" rel="nofollow noreferrer">docs</a>,<code>pd.Series.str.isnumeric</code>相当于<code>str.isnumeric</code>:</p>
<blockquote>
<p><strong>Series.str.isnumeric()</strong><br/> Check whether all characters in each string in the Series/Index are numeric. Equivalent to <code>str.isnumeric()</code>.</p>
</blockquote>
<p>您的系列有“object”数据类型,这是一个包含所有内容的类型,它包含指向任意Python对象的指针。这些值可能是字符串、整数等的混合。因此,如果找不到字符串,则应使用<code>NaN</code>值。在</p>
<p>为了适应数字类型,您需要显式地转换为字符串,例如给定一个序列<code>s</code>:</p>
^{pr2}$