title: How do you create a Kolmogorov-Smirnov chart in python for a 2 sample string lists?
body: <p>I am having difficulty in creating a Kolmogorov-Smirnov chart for 2 sample string lists that will display Cumulative Distribution Function (CDF)?</p>
  
  <p>As shown in <a href="https://en.wikipedia.org/wiki/Kolmogorov%E2%80%93Smirnov_test" rel="nofollow noreferrer">Two-sample Kolmogorov–Smirnov test</a></p>
  
  <p>I have been able to calculate the <code>Ks_2sampResult(statistic=0.12939662567915355, pvalue=0.4183080902726968)</code> for the overall string lists however the difficulty is how to chart this that will display the Cumulative Frequency Distribution (CFS)</p>
  
  <p><strong>Data List Samples</strong></p>
  
  <p>Subset of List 1 e.g. <code>['team', 'new', 'estate', 'ho', 'ur', 'la', 'pak', 'ebay', 'biz', 'best']</code></p>
  
  <p>Subset of List 2 e.g. <code>['ilsilenzio', 'stilllife', 'mathiasboe', 'achininimeshikaratnasiri', 'andrewdabeka', 'davekhodabux', 'lilytermetz', 'marianhorsley', 'lindacloutier', 'moniquehoogland',]</code></p>
  
  <p><strong>Get the data lists</strong></p>
  
  <pre><code>    def getWikidataList():
      with open('./file1.csv', 'r') as f:
          read = csv.reader(f) 
          next(read)
          for line in read:
              lineitem = line[0].split()[0]
              item1 = process_text(lineitem)
              wikidatalist.append(item1[0])
          return wikidatalist
  
  
  def getTwitterList1():
      with open('file2.csv', 'r') as f:
          read = csv.reader(f) 
          next(read)
          for line in read:
              lineitem = line[0].split()[0]
              item1 = process_text(lineitem)
              twitterdatalist.append(item1[0])
          return twitterdatalist
  
  
  
  wikidatalist = getWikidataList()
  twitterData = getTwitterList1()
  </code></pre>
  
  <p><strong>Plot the CDFs</strong></p>
  
  <pre><code>def ks_plot_comp(data_1, data_2):
  
      plt.figure(figsize=(12, 7))
      plt.plot(data_1, np.linspace(0, 1, len(data_1), endpoint=False))
      plt.plot(data_2, np.linspace(0, 1, len(data_2), endpoint=False))
      plt.legend('top right')
      plt.legend(['wikidata', 'twitterdata'])
      plt.title('Comparing 2 CDFs for KS-Test')
      plt.show()    
      ks_plot_comp(wikidatalist, twitterData)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/331Oy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/331Oy.png" alt="enter image description here"></a></p>