Skip to content
Advertisement

Count the number of times word appears in a single column

I’m attempting to count the number of times apples and oranges appear in my fruit column. The table looks like this:

Expected output:

My code thus far. I’m not sure how to do it when both appear and how to add them to the totals. I’m sure there is an easier way that this.

Cheers

Advertisement

Answer

If those fruits are single-worded and separated by a space, then such a generic approach might be interesting for you.

Lines #1 – 8 represent sample data; you already have that so you don’t type it. Code you might need starts at line #10.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement