📜  pandas 从字符串中识别类型 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:40.138000             🧑  作者: Mango

代码示例1
import pandas as pd

df = pd.DataFrame({'A': [1, None, 'hello', True, 'world', 'mystr', 34.11]})

df['stringy'] = [isinstance(x, str) for x in df.A]

#        A stringy
# 0      1   False
# 1   None   False
# 2  hello    True
# 3   True   False
# 4  world    True
# 5  mystr    True
# 6  34.11   False