title: Splitting and Visualizing in Python
body: <p>Dataset<br />
  Gender  KnownBrands<br />
  0   Man NIVEA MEN;GATSBY;<br />
  1   Man GATSBY;GARNIER MEN;L’OREAL MEN EXPERT;<br />
  2   Woman   CLINIQUE FOR MEN;SK-II MEN;Neutrogena MEN;<br />
  3   Man NIVEA MEN;GARNIER MEN;L’OREAL MEN EXPERT;GATSBY;<br />
  4   Woman   NIVEA MEN;GATSBY;<br /></p>
  <p>I need to split the <code>KnownBrands</code> into individual columns in order to do a count plot by brands.</p>
  <pre><code>#split the brands
  brands = Men[&quot;KnownBrands&quot;].str.split(&quot;;&quot;).explode().astype(object).reset_index()
  
  #use pivot to provide total for each brands
  output = brandnames.pivot(index=&quot;index&quot;, columns=&quot;KnownBrands&quot;, values= &quot;KnownBrands&quot;).reset_index(drop=True).drop('',1)
  </code></pre>
  <pre><code>brandname=output.count().plot.bar()
  
  #Rotate the x-axis name vertically to prevent overlapping
  plt.xticks(rotation='45',horizontalalignment='right')
  plt.xlabel(&quot;Brands&quot;)
  plt.ylabel(&quot;Frequency&quot;)
  plt.title(&quot;Brands Known by Respondents&quot;)
  #Chart data labels, only seaborn version 3.4.2 have this function
  plt.bar_label(brandname.containers[0])
  plt.show();
  </code></pre>
  <p><a href="https://i.stack.imgur.com/ZOLyM.png" rel="nofollow noreferrer">Plot</a></p>