<jupyter_start><jupyter_text>Imports<jupyter_code>import os
from pathlib import Path
import pandas as pd<jupyter_output><empty_output><jupyter_text>Data Exploration<jupyter_code>ls data/song_data/A/A/A/
PATH = Path('data/')
len(list((PATH / 'song_data').rglob('*.json')))<jupyter_output><empty_output><jupyter_text>We have 71 songs metadata.<jupyter_code>len(list((PATH / 'log_data').rglob('*.json')))<jupyter_output><empty_output><jupyter_text>We have 30 files where each one has logs data.<jupyter_code>len(list(PATH.rglob('*.json')))<jupyter_output><empty_output><jupyter_text>Songs Metadata<jupyter_code>songs_files = list((PATH / 'song_data').rglob('*.json'))
song_df = pd.read_json(songs_files[0], lines=True)
song_df.head()
for i, f in enumerate(songs_files):
    if i == 0:
        songs_df = pd.read_json(f, lines=True)
    else:
        songs_df = songs_df.append(pd.read_json(f, lines=True), ignore_index=True)
songs_df.head()
songs_df.shape<jupyter_output><empty_output><jupyter_text>Logs Data<jupyter_code>logs_files = list((PATH / 'log_data').rglob('*.json'))
log_df = pd.read_json(logs_files[0], lines=True)
log_df.head()
log_df.shape, song_df.shape
logs_files = list((PATH / 'log_data').rglob('*.json'))
for i, f in enumerate(logs_files):
    if i == 0:
        logs_df = pd.read_json(f, lines=True)
    else:
        logs_df = logs_df.append(pd.read_json(f, lines=True), ignore_index=True)
logs_df.head()
logs_df.shape
logs_df.columns
(logs_df['page'] == 'NextSong').sum()
logs_df['page'].value_counts()
logs_files[0].resolve()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16518424396442186, 'fraction_numerical': 0.005717916137229987, 'mean_word_length': 6.835820895522388, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '165160', 'license': 'MIT', 'n_tokens_mistral': 638, 'n_tokens_neox': 623, 'n_words': 90, 'path': 'Data-Exlporation.ipynb', 'repo_name': 'ImadDabbura/data-modeling-with-postgres', 'size': '1574'}