<jupyter_start><jupyter_text>Taux de Conversion<jupyter_code>df.head()
df.totalTransactionRevenue.count()
df.fullVisitorId.count()
total = df['fullVisitorId'].nunique()
total
total = df['fullVisitorId'].count()

# Calculate the number of people who bought
buyers = df["totalTransactionRevenue"].count()

# Calculate the conversion rate
conversion_rate = buyers/total
print(round(conversion_rate*100, 2), "%")<jupyter_output>1.12 %<jupyter_text>Taux de conversion par continent<jupyter_code>usefull_cols = ['continent','totalTransactionRevenue']
dfg = df[usefull_cols]
dfg['conversion'] = dfg['totalTransactionRevenue'].isna()

dfg
dfg.groupby(by='continent').conversion.value_counts()
tx_conversion = pd.crosstab(dfg.continent, dfg.conversion)
tx_conversion.columns=['achat', 'abandon']
tx_conversion
tx_conversion['tx_conv']=round((tx_conversion['achat']/(tx_conversion['achat']+tx_conversion['abandon'])*100), 2)
tx_conversion
tx_conversion = tx_conversion.sort_values(["tx_conv"], ascending=[0])
tx_conversion
plt.figure(figsize=(18,12))
sns.set(style="whitegrid")

ax = sns.barplot(x="continent", y="tx_conv", data=tx_conversion.reset_index(), facecolor=(0, 0, 0, 0), linewidth=5, edgecolor=sns.color_palette("dark", 3))
plt.title('Taux de conversion par continent - du 1er mai au 15 octobre 2018', fontsize=35, weight='bold')
plt.xlabel('continent', fontsize=20)
plt.ylabel('taux de conversion', fontsize=20)
plt.xticks(fontsize=30)
plt.yticks(fontsize=20)
plt.savefig("Taux de conversion par continent");<jupyter_output><empty_output><jupyter_text>Nb de connexions<jupyter_code>nbsession = df.groupby(['date'])['date'].count()
nbsession
sns.set(rc={'figure.figsize':(24, 7)})
ax=df.groupby('date').size().plot(linewidth=4, fontsize=20)
ax.set_ylabel('Nb connexions quotidiennes', fontsize=20)
ax.set_xlabel('Jour', fontsize=30)
#ax.set_ylim(0, 0.3) mettre l'échelle des ordonnées
ax.set_title('Evolution des connexions quotidiennes au site', fontsize=30, weight='bold')
plt.tight_layout()
plt.savefig('Evolution des connections quotidiennes au site.png');
df['year'] = data1_test25p['date'].dt.year
df['month'] = data1_test25p['date'].dt.month
df['day'] = data1_test25p['date'].dt.day
df['dayofweek'] = data1_test25p['date'].dt.weekday_name
from pandas.api.types import CategoricalDtype
cats = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
cat_type = CategoricalDtype(categories=cats, ordered=True)
df['dayofweek'] = df['dayofweek'].astype(cat_type)
df.head()
plt.figure(figsize=(20,10))
groups = df.groupby('dayofweek', sort=False).size()
groups.plot.bar(fontsize=20)
plt.xlabel('Jour de la semaine', fontsize=20)
plt.title("Dispersion des connexions au site par jour de la semaine", fontsize=30, weight='bold')
plt.xticks(fontsize=20)
plt.tight_layout()
plt.savefig('Dispersion des connections au site par jour de la semaine.png');<jupyter_output><empty_output><jupyter_text>Provenance géographique<jupyter_code>dfcountry = df.groupby(['country'])['date'].count()
dfcountry
df_visitor = df[['fullVisitorId', 'visitId', 'visitNumber', 'continent', 'subContinent', 'region', 'country', 'city', 'browser', 'deviceCategory', 'operatingSystem']] 
regionc = df_visitor.region.value_counts()
regionc.drop(regionc.index[[0,3]], inplace=True)
regionc.head(10)
plt.close('all')
region_count  = df_visitor['region'].value_counts()
region_count.drop(region_count.index[[0,3]], inplace=True)
region_count = region_count[:10,]
plt.figure(figsize=(18,10))
sns.barplot(region_count.index, region_count.values, alpha=0.8)
plt.title('Nombre de connections par région - du 1er mai au 15 octobre 2018', fontsize=30)
plt.ylabel('Nombre de connections', fontsize=20)
plt.xlabel('region', fontsize=20)
plt.savefig("Nombre de connections par région.png");
region_count  = df_visitor['region'].value_counts()
region_count.drop(region_count.index[[0,3]], inplace=True)
region_count = region_count[:10,]

sns.set(style="whitegrid")
plt.figure(figsize=(20,9))
sns.barplot(region_count.index, region_count.values, facecolor=(0, 0, 0, 0), linewidth=5, edgecolor=sns.color_palette("dark", 3))
plt.title('Nombre de connexions par région - 1er mai au 15 octobre 2018', fontsize=35, weight='bold')
plt.xlabel('region', fontsize=20)
plt.ylabel('Nombre de connexions', fontsize=20)
plt.xticks(fontsize=20, rotation=45)
plt.yticks(fontsize=20)
plt.tight_layout()  
plt.savefig("Nombre de connections - régions.png");<jupyter_output><empty_output><jupyter_text>Source du traffic<jupyter_code>df.channelGrouping.value_counts()
sns.set(style="whitegrid")
plt.figure(figsize=(20,9))
sns.barplot(x=df['channelGrouping'].value_counts()[:6].index,y=data1_test25p['channelGrouping'].value_counts()[:6].values, facecolor=(0, 0, 0, 0), linewidth=5, edgecolor=sns.color_palette("dark", 3))
plt.title('Source du traffic - 1er mai au 15 octobre 2018', fontsize=35, weight='bold')
plt.ylabel('Nb connexions', fontsize=20)
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)
plt.tight_layout()  
plt.savefig("Source du traffic.png");
# hue with bounce?

df_visitor.operatingSystem.value_counts()<jupyter_output><empty_output><jupyter_text>Produits<jupyter_code>try:
    pickle_off = open(r"SavePickle/produits.pickle","rb")
    produits = pickle.load(pickle_off)
    pickle_off.close()
except:
    print("il y''a eu 1 Pb avec produits.pickle")
    pass
try:
    pickle_off = open(r"SavePickle/product_nav.pickle","rb")
    product_nav = pickle.load(pickle_off)
    pickle_off.close()
except:
    print("il y''a eu 1 Pb avec product_nav.pickle")
    pass
produits.head()
product_nav.head()
product_info = product_nav.merge(produits, left_on='tous_skus', right_on='productSKU')
product_info.head()
product_hit = product_info.groupby('v2ProductName').size().sort_values(ascending=False).head(10)
product_hit<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16305841924398626, 'fraction_numerical': 0.029381443298969072, 'mean_word_length': 8.621487603305786, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '442410', 'license': 'MIT', 'n_tokens_mistral': 2293, 'n_tokens_neox': 2122, 'n_words': 362, 'path': 'code/GMSviz.ipynb', 'repo_name': 'Sophie123Pandas/Certification', 'size': '5820'}