pandas传参报错TypeError: ufunc ‘add‘ did not contain a loop with signature matching types dtype(‘<U21‘)
这里的phone类型是<class ‘pandas.core.series.Series’>phone=(df['phone'].str.len())当把phone作为参数传到另一个函数(假设函数叫test(str)–接受参数为str)里,就变成了一个元组<class ‘tuple’>,此时我们要想在这个test里使用原来的类型,就要使用str[0].即此时的str[0]等
·
这里的phone类型是<class ‘pandas.core.series.Series’>
phone=(df['phone'].str.len())
当把phone作为参数传到另一个函数(假设函数叫test(str)–接受参数为str)里,就变成了一个元组<class ‘tuple’>,此时我们要想在这个test里使用原来的类型,就要使用str[0].
即此时的str[0]等价于原来函数里的phone。
更多推荐
所有评论(0)