How can I get the count of how many times a string appears in my list? [closed]
Clash Royale CLAN TAG#URR8PPP
$begingroup$
I have a list of strings, like so:
"aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm"
I know WordCounts
will return the numbers of every single word, but I want to the word group numbers, i.e., "aa bb" 3 times, and "cc dd" 2 times. How can I do this?
string-manipulation counting
$endgroup$
closed as off-topic by MarcoB, Carl Lange, Henrik Schumacher, Öskå, march Mar 8 at 17:26
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Carl Lange, Henrik Schumacher, Öskå, march
add a comment |
$begingroup$
I have a list of strings, like so:
"aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm"
I know WordCounts
will return the numbers of every single word, but I want to the word group numbers, i.e., "aa bb" 3 times, and "cc dd" 2 times. How can I do this?
string-manipulation counting
$endgroup$
closed as off-topic by MarcoB, Carl Lange, Henrik Schumacher, Öskå, march Mar 8 at 17:26
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Carl Lange, Henrik Schumacher, Öskå, march
add a comment |
$begingroup$
I have a list of strings, like so:
"aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm"
I know WordCounts
will return the numbers of every single word, but I want to the word group numbers, i.e., "aa bb" 3 times, and "cc dd" 2 times. How can I do this?
string-manipulation counting
$endgroup$
I have a list of strings, like so:
"aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm"
I know WordCounts
will return the numbers of every single word, but I want to the word group numbers, i.e., "aa bb" 3 times, and "cc dd" 2 times. How can I do this?
string-manipulation counting
string-manipulation counting
edited Mar 4 at 7:07


m_goldberg
88k872199
88k872199
asked Mar 4 at 4:22


zongxianzongxian
1144
1144
closed as off-topic by MarcoB, Carl Lange, Henrik Schumacher, Öskå, march Mar 8 at 17:26
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Carl Lange, Henrik Schumacher, Öskå, march
closed as off-topic by MarcoB, Carl Lange, Henrik Schumacher, Öskå, march Mar 8 at 17:26
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Carl Lange, Henrik Schumacher, Öskå, march
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
You can try Tally
lst = "aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm";
Tally[lst]
Edit by m_goldberg
As J.M. says in his comment below, Counts
will give the same information as an association.
Counts[data]
<|"aa bb" -> 3, "cc dd" -> 2, "ww ss" -> 1, "ss ss" -> 1, "kk mm" -> 1|>
This is equivalent to
Rule @@@ Tally[data] // Association
$endgroup$
2
$begingroup$
Counts
should also work.
$endgroup$
– J. M. is slightly pensive♦
Mar 4 at 5:48
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
You can try Tally
lst = "aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm";
Tally[lst]
Edit by m_goldberg
As J.M. says in his comment below, Counts
will give the same information as an association.
Counts[data]
<|"aa bb" -> 3, "cc dd" -> 2, "ww ss" -> 1, "ss ss" -> 1, "kk mm" -> 1|>
This is equivalent to
Rule @@@ Tally[data] // Association
$endgroup$
2
$begingroup$
Counts
should also work.
$endgroup$
– J. M. is slightly pensive♦
Mar 4 at 5:48
add a comment |
$begingroup$
You can try Tally
lst = "aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm";
Tally[lst]
Edit by m_goldberg
As J.M. says in his comment below, Counts
will give the same information as an association.
Counts[data]
<|"aa bb" -> 3, "cc dd" -> 2, "ww ss" -> 1, "ss ss" -> 1, "kk mm" -> 1|>
This is equivalent to
Rule @@@ Tally[data] // Association
$endgroup$
2
$begingroup$
Counts
should also work.
$endgroup$
– J. M. is slightly pensive♦
Mar 4 at 5:48
add a comment |
$begingroup$
You can try Tally
lst = "aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm";
Tally[lst]
Edit by m_goldberg
As J.M. says in his comment below, Counts
will give the same information as an association.
Counts[data]
<|"aa bb" -> 3, "cc dd" -> 2, "ww ss" -> 1, "ss ss" -> 1, "kk mm" -> 1|>
This is equivalent to
Rule @@@ Tally[data] // Association
$endgroup$
You can try Tally
lst = "aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm";
Tally[lst]
Edit by m_goldberg
As J.M. says in his comment below, Counts
will give the same information as an association.
Counts[data]
<|"aa bb" -> 3, "cc dd" -> 2, "ww ss" -> 1, "ss ss" -> 1, "kk mm" -> 1|>
This is equivalent to
Rule @@@ Tally[data] // Association
edited Mar 4 at 7:19


m_goldberg
88k872199
88k872199
answered Mar 4 at 4:36


NasserNasser
58.6k489206
58.6k489206
2
$begingroup$
Counts
should also work.
$endgroup$
– J. M. is slightly pensive♦
Mar 4 at 5:48
add a comment |
2
$begingroup$
Counts
should also work.
$endgroup$
– J. M. is slightly pensive♦
Mar 4 at 5:48
2
2
$begingroup$
Counts
should also work.$endgroup$
– J. M. is slightly pensive♦
Mar 4 at 5:48
$begingroup$
Counts
should also work.$endgroup$
– J. M. is slightly pensive♦
Mar 4 at 5:48
add a comment |