How can I get the count of how many times a string appears in my list? [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












2












$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?










share|improve this question











$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
If this question can be reworded to fit the rules in the help center, please edit the question.




















    2












    $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?










    share|improve this question











    $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
    If this question can be reworded to fit the rules in the help center, please edit the question.


















      2












      2








      2





      $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?










      share|improve this question











      $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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      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
      If this question can be reworded to fit the rules in the help center, please edit the question.







      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
      If this question can be reworded to fit the rules in the help center, please edit the question.




















          1 Answer
          1






          active

          oldest

          votes


















          8












          $begingroup$

          You can try Tally



          lst = "aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm";
          Tally[lst]


          Mathematica graphics



          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





          share|improve this answer











          $endgroup$








          • 2




            $begingroup$
            Counts should also work.
            $endgroup$
            – J. M. is slightly pensive
            Mar 4 at 5:48

















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          8












          $begingroup$

          You can try Tally



          lst = "aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm";
          Tally[lst]


          Mathematica graphics



          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





          share|improve this answer











          $endgroup$








          • 2




            $begingroup$
            Counts should also work.
            $endgroup$
            – J. M. is slightly pensive
            Mar 4 at 5:48















          8












          $begingroup$

          You can try Tally



          lst = "aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm";
          Tally[lst]


          Mathematica graphics



          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





          share|improve this answer











          $endgroup$








          • 2




            $begingroup$
            Counts should also work.
            $endgroup$
            – J. M. is slightly pensive
            Mar 4 at 5:48













          8












          8








          8





          $begingroup$

          You can try Tally



          lst = "aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm";
          Tally[lst]


          Mathematica graphics



          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





          share|improve this answer











          $endgroup$



          You can try Tally



          lst = "aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm";
          Tally[lst]


          Mathematica graphics



          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






          share|improve this answer














          share|improve this answer



          share|improve this answer








          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












          • 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


          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?