Visualize Ctripref Coverage Stats

Run stats and dump csv


In [1]:
import subprocess

subprocess.call(['python', 'ctripref_stats_gai.py', 
                 '--days', '-21'])

print('Task compelte!')


Task compelte!

Take lastest csv and draw


In [2]:
%matplotlib notebook

import pandas as pd
import numpy as np
import matplotlib

from matplotlib import pyplot as plt
from matplotlib.ticker import FuncFormatter

import glob, os

newest = max(glob.iglob('output_hotel_ref_stats_*.csv'), key=os.path.getctime)
print(newest)

headers = ['date', '#_of_bookings', '#_of_hotel_ref', 'comment', 'coverage']
df = pd.read_csv(newest)
print(df)
ax = df.plot(x='date', y='coverage', style='o-')
plt.gcf().autofmt_xdate()
# ax.set_yticklabels(['{:3.2f}%'.format(x*100) for x in vals])
ax.yaxis.set_major_formatter(FuncFormatter(lambda y, _: '{:.0%}'.format(y)))


output_hotel_ref_stats_180703_1538.csv
          date  #_of_bookings  #_of_hotel_ref  comment  coverage
0   2018-06-12            362             236      NaN     0.652
1   2018-06-13            378             278      NaN     0.735
2   2018-06-14            440             309      NaN     0.702
3   2018-06-15            493             335      NaN     0.680
4   2018-06-16            555             425      NaN     0.766
5   2018-06-17            466             314      NaN     0.674
6   2018-06-18            358             236      NaN     0.659
7   2018-06-19            389             231      NaN     0.594
8   2018-06-20            301             179      NaN     0.595
9   2018-06-21            306             187      NaN     0.611
10  2018-06-22            315               0      NaN     0.000
11  2018-06-23            448               0      NaN     0.000
12  2018-06-24            393               0      NaN     0.000
13  2018-06-25            417             275      NaN     0.659
14  2018-06-26            467             311      NaN     0.666
15  2018-06-27            473             323      NaN     0.683
16  2018-06-28            421             262      NaN     0.622
17  2018-06-29            481             354      NaN     0.736
18  2018-06-30            518             365      NaN     0.705
19  2018-07-01            469             339      NaN     0.723
20  2018-07-02            478             326      NaN     0.682

In [ ]: