<jupyter_start><jupyter_text>Airbnb User Sessions Data Exploration<jupyter_code>%matplotlib inline

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# Set figure aesthetics
sns.set_style("white", {'ytick.major.size': 10.0})
sns.set_context("poster", font_scale=1.1)
# Load the data into DataFrames
path = '../data/'
train_users = pd.read_csv(path + 'train_users.csv')
test_users = pd.read_csv(path + 'test_users.csv')
sessions = pd.read_csv(path + 'sessions.csv')
# Merge train and test users
users = pd.concat((train_users, test_users), axis=0, ignore_index=True)
print("We have", len(users), "users and", len(sessions.user_id.unique()), "ID's in the session set.")
print(sessions.shape)
sessions.isnull().sum()
sessions.loc[sessions['user_id'].isnull()].head()
sessions.action_type.unique()
sessions['action_type'] = sessions['action_type'].replace('-unknown-', np.nan)
# list(sessions.action.unique())
sessions.action.value_counts().head()
sessions.action_type.value_counts()
sessions.loc[sessions.action_type == 'booking_response']
sessions.device_type.value_counts()
train_users.set_index('id', inplace=True)
sessions.set_index('user_id', inplace=True)
users_with_destination = train_users.loc[train_users['country_destination'] != 'NDF']
a = users_with_destination.index.values
b = sessions.index.unique()
sessions_id = list(set(a).intersection(b))
users_with_destination_sessions = sessions.loc[sessions_id]
users_with_destination_sessions.action.value_counts()
# When there is a booking what is the most probable action
# Elapsed Seconds<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14012345679012345, 'fraction_numerical': 0.003703703703703704, 'mean_word_length': 7.622340425531915, 'pattern_counts': {'":': 0, '<': 5, '<?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}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '545956', 'license': 'MIT', 'n_tokens_mistral': 562, 'n_tokens_neox': 555, 'n_words': 109, 'path': 'airbnb-kaggle/kaggle-airbnb-master/notebooks/User Sessions Data.ipynb', 'repo_name': 'raafatzahran/Udacity-DataScience', 'size': '1620'}