有没有更好的方法来确定变量是否在Pandas
and/or NumPy
is numeric
或不 ?
我有一个自定义的dictionary
with dtypes
作为钥匙和numeric
/ not
作为价值观。
In pandas 0.20.2
你可以做:
import pandas as pd
from pandas.api.types import is_string_dtype
from pandas.api.types import is_numeric_dtype
df = pd.DataFrame({'A': ['a', 'b', 'c'], 'B': [1.0, 2.0, 3.0]})
is_string_dtype(df['A'])
>>>> True
is_numeric_dtype(df['B'])
>>>> True
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)