Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String Python中的运行时错误(TypeError:Can';t将';float';对象隐式转换为str) def预处理(自身,最大长度=0): “”“预处理数据 输出: 源输入:编码源输入 目标输入:编码的目标输入 输出:输出编码为“_String_Python 3.x - Fatal编程技术网

String Python中的运行时错误(TypeError:Can';t将';float';对象隐式转换为str) def预处理(自身,最大长度=0): “”“预处理数据 输出: 源输入:编码源输入 目标输入:编码的目标输入 输出:输出编码为“

String Python中的运行时错误(TypeError:Can';t将';float';对象隐式转换为str) def预处理(自身,最大长度=0): “”“预处理数据 输出: 源输入:编码源输入 目标输入:编码的目标输入 输出:输出编码为“,string,python-3.x,String,Python 3.x,Python中的运行时错误(TypeError:Can';t将';float';对象隐式转换为str) def预处理(自身,最大长度=0): “”“预处理数据 输出: 源输入:编码源输入 目标输入:编码的目标输入 输出:输出编码为“”的字 打印(“添加开始和结束标记…”) 对于索引,self.df.iterrows()中的行: 行['Target']=''+行['Target']+'' 回溯(最近一次呼叫最后一次): 文件“main_bengali_fh.py”,第28

Python中的运行时错误(TypeError:Can';t将';float';对象隐式转换为str) def预处理(自身,最大长度=0): “”“预处理数据 输出: 源输入:编码源输入 目标输入:编码的目标输入 输出:输出编码为“”的字 打印(“添加开始和结束标记…”) 对于索引,self.df.iterrows()中的行: 行['Target']=''+行['Target']+''
回溯(最近一次呼叫最后一次):
文件“main_bengali_fh.py”,第28行,在
源输入,输入起始,输出编码=tp.预处理(最大字数)
文件“/home/faisal/translation/text_preprocess_utils_fh.py”,第57行,预处理中
行['Target']={''+行['Target']+'}
TypeError:无法将“float”对象隐式转换为str

使用
str
将浮点数转换为字符串:
行['Target']=''+str(行['Target'])+''
谢谢@jspcal
 def preprocess(self,max_length=0):
    """Preprocess data
    output: 
    source_input: encoded source input
    target_input: encoded target input
    output: output words encoded"""
    print("Adding start and end tag....")
    for index,row in self.df.iterrows():
        row['Target']='<s> '+row['Target']+' <e>'