简体   繁体   中英

passing a column as parameter in python function

I have been trying to store unqiue values in a column from pandas data frame using the following code to further use in the function. Code snippet:

def mergeFields(data,field):

    oldlist = pd.unique(data[field])

data_rcvd_from_satish.tags = mergeFields("data_rcvd_from_satish","tags")

Error: 
TypeError: string indices must be integers, not list

I know the error which i have been getting is similar to many other question still I am not able to resolve the error. I would request not to consider this duplicate and please answer.

data is a string. Please review the arguments passed to mergeFields . you basically wrote:

"data_rcvd_from_satish"["tags"]

which is invalid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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