Question: I want to display only UNIQUE divs that contain text typed in a search field. My HTML contains lots of repeated data (currently very crude). See example data below:

```html
<div class="faq_item">
   <h3><b>FAQ 1</b></h3> <!-- not unique -->                      
</div>
<div class="faq_item">
   <h3><b>FAQ 1</b></h3> <!-- not unique -->                  
</div>
<div class="faq_item">
   <h3><b>FAQ 2</b></h3>                      
</div>

```

I then add the class 'filtersearch' to each item if they contain the text stored in 'searchstring' variable:

```
for (var i = 0, len = $(".faq_item").length; i < len; ++i) {
   if($(".faq_item")[i].innerHTML.indexOf(searchstring) !== -1) {
      $($(".faq_item")[i]).addClass("filtersearch");
   }
}

```

This displays only divs that contain 'filtersearch', however, it doesn't hide divs with the same content. Instead of doing another massive loop over every div with 'filtersearch' class, what would be the best approach to only show unique divs?

Answer: 
you cant use the string module in pandas :

```
df['Words'].str.split(',').explode().value_counts()

```

output:

```
Hello      2
World      2
Germany    1
%          1
ML         1
100        1
Name: Words, dtype: int64

```

to make it into a dataframe:

```
pd.DataFrame(df['Words'].str.split(',').explode().value_counts()).reset_index().rename({'index':"Words","Words":"Count"},axis=1)

```

output:

```
    Words   Count
0   Hello   2
1   World   2
2   Germany 1
3   %       1
4   ML      1
5   100     1

```
One can use the above methods, and they are efficient.

Adding another way using `str.dummies` with `df.sum`

```
df['Words'].str.get_dummies(",").sum()

%          1
100        1
Germany    1
Hello      2
ML         1
World      2
dtype: int64

```

---

```
df['Words'].str.get_dummies(",").sum().rename_axis("Words").reset_index(name='Counts')

     Words  Counts
0        %       1
1      100       1
2  Germany       1
3    Hello       2
4       ML       1
5    World       2

```