简体   繁体   English

在 DataFrame 的列上调用 Python function

[英]Calling Python function on a column in DataFrame

I got below function to convert string to uppercase我低于 function 将字符串转换为大写

def changecase(col):
  return col.upper()

Trying to applying a column in dataframe throw error:尝试在 dataframe 中应用列时抛出错误:

df['Description'] = df['Description'].apply(changecase)

Error:错误:

TypeError: 'Column' object is not callable

在此处输入图像描述

You probably need @udf at the top of your code.您可能需要在代码顶部使用@udf

So:所以:

@udf

...your code...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM