<jupyter_start><jupyter_text>BitMEX Users AnalysisAuthor : <NAME>  Imports<jupyter_code>import pandas as pd
import datetime
from datetime import timedelta<jupyter_output><empty_output><jupyter_text>Load data<jupyter_code>data = pd.read_csv("../Dumps/BitMEX_chat.csv")
data.head()
channels = pd.read_json("../Dumps/BitMEX_channels.json")
channels = pd.Series(channels.name.values,index=channels.id).to_dict()
channels
#Channels dictionary in English
channels[2] = "Chinese"
channels[3] = "Russian"
channels[4] = "Korean"
channels[5] = "Japanese"
channels[6] = "Spanish"
channels[7] = "French"
channels<jupyter_output><empty_output><jupyter_text>Data engineering<jupyter_code>#Useless columns and NaN
columns_to_drop = ["fromBot","id","message","user"]
data.drop(columns_to_drop, axis=1, inplace=True)
data.fillna("", inplace=True)

#Date features
data["date"] = data.apply(lambda row: datetime.datetime.strptime(row["date"][:19],"%Y-%m-%d %H:%M:%S"), axis=1)
data["date_cal"] = data.apply(lambda row: row["date"].date(), axis=1)
data["hour_UTC"] = data.apply(lambda row: row["date"].hour, axis=1)

#Channel feature
data["channel"] = data.apply(lambda row: channels[row["channelID"]], axis=1)<jupyter_output><empty_output><jupyter_text>Internal statistics<jupyter_code>start = data.iloc[-1]["date"]
end = data.iloc[0]["date"]

print("Conversation started: {}".format(str(start)))
print("Conversation ended: {}".format(str(end)))
#Reduction to one month
data = data[(data["date_cal"] <= datetime.date(2018,12,17)) & (data["date_cal"] >= datetime.date(2018,11,18))]
data.head()
print("Mean from 11-18-2018 to 12-17-2018")
table = (pd.crosstab(data.channel, data.hour_UTC, normalize=True)*100).round(4)
table
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize=(20, 8))
ax = plt.axes()
heatmap = sns.heatmap(table, cmap="Greens", ax = ax, annot=True)
ax.set_title('One-month mean from 11-18-2018 to 12-17-2018')
plt.show()
figure = heatmap.get_figure()    
figure.savefig('heatmap.png')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18061023622047245, 'fraction_numerical': 0.0344488188976378, 'mean_word_length': 7.955947136563877, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '600453', 'license': 'MIT', 'n_tokens_mistral': 803, 'n_tokens_neox': 745, 'n_words': 133, 'path': 'BitMEX_GeographicAnalysis.ipynb', 'repo_name': 'ArnaudCarrere/CryptoLexicon', 'size': '2040'}