Python类型错误(dtype('<U51')

卢克·辛普森

我有一个数据帧,其最终输出是以特定顺序连接的单元格。

目前我的代码如下

debit_creditquestionlist = ('Why is there a ' + df_credit[debit_credit] + ' in ' + df_credit[entity_name] + ' relating to ' + df_credit[account_name] +  ' of ' + df_credit[amount] + ' at ')

目前一切正常,除非df_credit[account_name]是以下错误的原因

TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U51') dtype('<U51') dtype('<U51')

我看了一下Stack Overflow,并dtype('<U51')说它是一个数字。

当我添加时,str它将返回每个数字,而不是我需要的单个数字。

请有人能够描述如何解决此问题?

我叔叔

您可能想要做:

df_credit[account_name].apply(str)

将向量的每个元素转换为字符串变量。除此以外:

 str(df_credit[account_name]) 

是将整个矢量转换为字符串的结果,您似乎已经获得了结果。

一个类似的问题

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

类型错误:ufunc 'add' 不包含签名匹配类型 dtype('<U78') dtype('<U78') dtype('<U78') 的循环

Matplotlib 错误类型错误:无法根据规则“安全”将数组数据从 dtype('float64') 转换为 dtype('<U32')

TypeError:ufunc'subtract'不包含签名匹配类型为dtype('<U1')dtype('<U1')dtype('<U1')的循环

TypeError:ufunc'add'不包含签名匹配类型为(dtype('<U21'),dtype('<U21'))-> dtype('<U21')的循环

TypeError:ufunc'add'不包含签名匹配类型为dtype('<U1')dtype('<U1')dtype('<U1')的循环

ufunc 'multiply' 不包含具有签名匹配类型的循环 (dtype('<U32'), dtype('<U32')) -> dtype('<U32')

如何解释python输出dtype ='<U32'?

python pandas错误-ufunc'subtract'不包含签名匹配类型为dtype的循环

Python 3.6 - scipy 引发错误:NotImplementedError:不支持输入类型“<U32”

U2F - 类型错误 | 无法注册密钥

错误:OSX 10.11.2中未知类型名称'u_char'

numpy.apply_along_axis会截断字符串,因为它会推断错误的dtype'<U1'

Python glutCreateWindow错误“类型错误”

Python Pandas 混合类型警告 - “dtype”保留数据?

意外的类型错误python

Python开发【类型错误】

Python - IF 语句类型错误

不匹配类型错误涉及 Columns("U2:U") 和 cells( , ).address

Java Optional.map() 错误:“无法推断 <U> map(Function<? super T,? extends U>) 的类型参数”

机器学习代码中的numpy.dtype错误(Python)

无法推断“ U”的类型

Python调用错误类型的变量类型

类型错误:dtype=datetime64[ns] 和日期之间的比较无效

图像类型错误:OpenCV Python

python function error:类型错误

不断收到类型错误python

Python 项目的类型错误

Python:href 标记类型错误

带星号的Java 7u51 / 7u55清单变量