How to pass Dataframe element in function?

python

#1

Hi friends,

Need your help again.

df = pd.DataFrame({"A": ['I love cooking'], "B": [['cooking','rowing']]})
df
          A	                 B
0	I love cooking	[cooking, rowing]

df['A']
output:
0 I love cooking
Name: A, dtype: object

Now I want to use df['A'] as input in user define function but it gives me error:
'Series' object has no attribute 'split'

if I write manually in function input it works but when I try to pass dataframe element it gives me error

How can I pass element in function?

I tried pandas’s to_string() function, astype() function but no luck

if someone know how can I use direct element in function please let me know.

Thanks in Advance


#2

Friends From some research I got answer

if we need to find row location there is command called iloc() so I used like follow:

df.iloc['A'][0]

for first element of row