Python 如何检查列中是否包含字符串

Python 如何检查列中是否包含字符串,python,pandas,Python,Pandas,代码如下。我想基于对列“value”的简单操作创建一个新列“value\u c” 但是,我收到了如下错误消息 TypeError: unsupported operand type(s) for -: 'str' and 'int' 如何检查列是否有字符串以及如何删除它们 谢谢你 使用pd.\u numeric然后dropna: frame['value_c'] = pd.to_numeric(frame['value'],errors='coerce').dropna().apply(lam

代码如下。我想基于对列“value”的简单操作创建一个新列“value\u c”

但是,我收到了如下错误消息

TypeError: unsupported operand type(s) for -: 'str' and 'int'
如何检查列是否有字符串以及如何删除它们


谢谢你

使用
pd.\u numeric
然后
dropna

frame['value_c'] = pd.to_numeric(frame['value'],errors='coerce').dropna().apply(lambda x: (x-32) / (5/9))

然后它会像预期的那样工作。

@hacker315很少有情况下你不能
。astype(int)
检查这个:@hacker315是的,anky_91是正确的,你只能
astype(int)
对字符串执行操作integers@YabinDa乐意帮忙:-)
frame['value_c'] = pd.to_numeric(frame['value'],errors='coerce').dropna().apply(lambda x: (x-32) / (5/9))