Getting a list of suffixes from the company names
<p>I have a data frame df with a column name - Company. Few examples of the company names are: ABC Inc., XYZ Gmbh, PQR Ltd, JKL Limited etc. I want a list of all the suffixes (Inc.,Gmbh, Ltd., Limited etc). Please notice that suffix length is always different. There might be companies without any suffix, for example: Apple. I need a complete list of all suffixes from the all the company names, keeping only unique suffixes in the list.</p>

<p>How do I accomplish this task? </p>

<p>This only adds the suffixes when the company name has more than one word as you required.</p>

<pre><code>company_names = ["Apple", "ABS LLC", "Animusoft Corp"]
suffixes = [name.split()[-1] for name in company_names if len(name.split()) &gt; 1]
</code></pre>

<p>Now having into account that this doesn't cover the unique requirement.
This doesn't cover that you can have a company named like "Be Smart" and "Smart" is not a suffix but part of the name. However this takes care of the unique requirement:    </p>

<pre><code>company_names = ["Apple", "ABS LLC", "Animusoft Corp", "BBC Corp"]
suffixes = []
for name in company_names:
    if len(name.split()) &gt; 1 and name.split()[-1] not in suffixes:      
        suffixes.append(name.split()[-1])
</code></pre>

python pandas