#!/usr/bin/env pythonimport pandas as pdimport datetimetoday = datetime.date.today()yesterday = today - datetime.timedelta(days=1)yesterday_time = str(int(yesterday.strftime('%Y%m%d')))path_name = '/home/user/Thursday_data/active_rate_' file_name = path_name + yesterday_time + '.txt'mydata = pd.read_csv(file_name, sep='\t')mydata.columns = ['data_time', 'pa000_total_user','pw001_total_user','tob_total_user','pa000_active_user','pw001_active_user','tob_active_user']total_user_result = [mydata.iloc[0,i] for i in range(1,4)]active_user_result = [mydata.iloc[0,i] for i in range(4,7)]user_type = ['PingAn', 'Agent', 'to B']user_active_rate = list(zip(user_type, total_user_result, active_user_result))for i in range(len(user_active_rate)): print "%s active_rate: %.1f%%" % (user_active_rate[i][0], 100*user_active_rate[i][2]/user_active_rate[i][1])