old_contents: #!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  import os
  import sys
  sys.path.append('./../../')
  
  from pyogi.ki2converter import *
  from pyogi.kifu import *
  
  
  if __name__ == '__main__':
      
      for n in range(0, 50000):
  
          n1 = (n // 10000)
          n2 = int(n < 10000)
      
          relpath = '~/data/shogi/2chkifu/{0}000{1}/{2:0>5}.KI2'.format(n1, n2, n)
          kifile = os.path.expanduser(relpath)
  
          if not os.path.exists(kifile):
              continue
              
          ki2converter = Ki2converter()
          ki2converter.from_path(kifile)
  
          csa = ki2converter.to_csa()
  
  
          kifu = Kifu(csa)
          res = kifu.get_forking(['OU', 'HI'])
          if res[2] or res[3]:
              print(kifu.players)
  
new_contents: #!/usr/bin/env python
  # -*- coding: utf-8 -*-
  
  import os
  import sys
  import pandas as pd
  sys.path.append('./../../')
  
  from pyogi.ki2converter import *
  from pyogi.kifu import *
  
  
  if __name__ == '__main__':
  
      res_table = []
      
      for n in range(0, 50000):
  
          n1 = (n // 10000)
          n2 = int(n < 10000)
      
          relpath = '~/data/shogi/2chkifu/{0}000{1}/{2:0>5}.KI2'.format(n1, n2, n)
          kifile = os.path.expanduser(relpath)
  
          if not os.path.exists(kifile):
              continue
              
          ki2converter = Ki2converter()
          ki2converter.from_path(kifile)
  
          csa = ki2converter.to_csa()
  
          if not csa:
              continue
  
          kifu = Kifu(csa)
          res = kifu.get_forking(['OU', 'HI'])
          if res[2] or res[3]:
              print(kifu.players)
  
          # Output
          # 1. sente forked | gote forked
          # 2. (sente won & sente forked) | (gote won & gote forked)
          res_table.append(
              [res[2] != [] or res[3] != [],
               (kifu.sente_win and res[2]!=[]) or 
               ((not kifu.sente_win) and res[3]!=[])])
  
  
  
      df = pd.DataFrame(res_table, columns=['fork', 'fork&win'])
      pd.crosstab(df.loc[:, 'fork'], df.loc[:, 'fork&win'])
  
subject: Add sum up part using pd.crosstab