Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Python Tool: count words in column

G1
8 - Asteroid

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!

2 REPLIES 2
PaulN
Alteryx Alumni (Retired)

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

G1
8 - Asteroid

Apologies PaulN! I moved off this project and onto something new and never got around to replying. But thank you, that did work and will help me going forward now I'm picking this up again 🙂

Labels