def read_tb(path):
import pandas<EOL>import numpy as np<EOL>from glob import glob<EOL>from collections import defaultdict<EOL>import tensorflow as tf<EOL>if osp.isdir(path):<EOL><INDENT>fnames = glob(osp.join(path, "<STR_LIT>"))<EOL><DEDENT>elif osp.basename(path).startswith("<STR_LIT>"):<EOL><INDENT>fnames = [path]<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError("<STR_LIT>"%path)<EOL><DEDENT>tag2pairs = defaultdict(list)<EOL>maxstep = <NUM_LIT:0><EOL>for fname in fnames:<EOL><INDENT>for summary in tf.train.summary_iterator(fname):<EOL><INDENT>if summary.step > <NUM_LIT:0>:<EOL><INDENT>for v in summary.summary.value:<EOL><INDENT>pair = (summary.step, v.simple_value)<EOL>tag2pairs[v.tag].append(pair)<EOL><DEDENT>maxstep = max(summary.step, maxstep)<EOL><DEDENT><DEDENT><DEDENT>data = np.empty((maxstep, len(tag2pairs)))<EOL>data[:] = np.nan<EOL>tags = sorted(tag2pairs.keys())<EOL>for (colidx,tag) in enumerate(tags):<EOL><INDENT>pairs = tag2pairs[tag]<EOL>for (step, value) in pairs:<EOL><INDENT>data[step-<NUM_LIT:1>, colidx] = value<EOL><DEDENT><DEDENT>return pandas.DataFrame(data, columns=tags)<EOL>
path : a tensorboard file OR a directory, where we will find all TB files
       of the form events.*