Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/301.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
Python 同时使用map和lower函数_Python_Pandas_Lambda - Fatal编程技术网

Python 同时使用map和lower函数

Python 同时使用map和lower函数,python,pandas,lambda,Python,Pandas,Lambda,我试图将map与lower一起使用,以便将一些字符串值转换为数字值,但我遇到了语法错误。有人能帮助实现这一点吗 我试过: df['Response'] = df['Response'].apply(lambda x.lower() : x.map({'yes':1.0,'no':0.0,'maybe':0.5})) 以及: 我怎样才能解决这个问题?谢谢@Chris,我不知道没有lambda也能解决这个问题!当询问错误时,实际发布错误是有帮助的。。。 df['Response'].str.low

我试图将
map
lower
一起使用,以便将一些字符串值转换为数字值,但我遇到了语法错误。有人能帮助实现这一点吗

我试过:

df['Response'] = df['Response'].apply(lambda x.lower() : x.map({'yes':1.0,'no':0.0,'maybe':0.5}))
以及:


我怎样才能解决这个问题?

谢谢@Chris,我不知道没有lambda也能解决这个问题!当询问错误时,实际发布错误是有帮助的。。。
df['Response'].str.lower().map({'yes':1.0,'no':0.0,'maybe':0.5})
df['Response'].str.lower().map({'yes':1.0,'no':0.0,'maybe':0.5})