community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Python Tool: count words in column

Meteor

Hi All,

 

Does anyone know how to count words in a column in the Python tool? I am aware that this can be done with other Alteryx tools but I am having a go with the Python tool and i'm a little stuck with this particular problem.

 

Thanks in advance!

Moderator
Moderator

Hi @G1,

 

In all honesty, your question is purely Python and not really Alteryx related....

 

With that said, I guess that following will return what you are looking for:

from ayx import Alteryx
data = Alteryx.read('#1')
data['CountField1'] = data['Field1'].str.split().str.len()
print(data)

 

Thanks,

 

PaulN

Labels