<commit_before>#!/usr/bin/env python

import sqlite3
import pandas as pd
pd.set_option('display.max_columns', None)

TICKET_SALE_START_DATE = '2016-01-01'
DB_FILE = '../../epcon/data/site/p3.db'

conn = sqlite3.connect(DB_FILE)

c = conn.cursor()

query = c.execute("""
SELECT ORDER_ID, COUNTRY_ID
FROM assopy_orderitem, assopy_order
WHERE assopy_orderitem.order_id == assopy_order.id AND
assopy_order.created >= date('{}')""".format(TICKET_SALE_START_DATE))

countries = query.fetchall()

df = pd.DataFrame(countries, columns=['order_id', 'country'])

country_is_none = pd.isnull(df['country'])
df.loc[:, 'country'][country_is_none] = 'Others'

counts = df.groupby('country').count().sort_values(by='order_id', ascending=False)

print(counts)
<commit_msg>fix the output of country_order_stats.py<commit_after>#!/usr/bin/env python

import sqlite3
import pandas as pd
pd.set_option('display.max_columns', None)

TICKET_SALE_START_DATE = '2016-01-01'
DB_FILE = '../../epcon/data/site/p3.db'

conn = sqlite3.connect(DB_FILE)

c = conn.cursor()

query = c.execute("""
SELECT ORDER_ID, COUNTRY_ID
FROM assopy_orderitem, assopy_order
WHERE assopy_orderitem.order_id == assopy_order.id AND
assopy_order.created >= date('{}')""".format(TICKET_SALE_START_DATE))

countries = query.fetchall()

df = pd.DataFrame(countries, columns=['order_id', 'country'])

country_is_none = pd.isnull(df['country'])
df.loc[:, 'country'][country_is_none] = 'Others'

counts = df.groupby('country').count().sort_values(by='order_id', ascending=False)

for i, row in counts.reset_index().iterrows():
    print("{},{}".format(row['country'], row['order_id']))

{'fraction_non_alphanumeric': 0.17044757817290007, 'fraction_numerical': 0.0134886572654813, 'mean_word_length': 6.4520547945205475, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4644694', 'n_tokens_mistral': 627, 'n_tokens_neox': 604, 'n_words': 104}