<jupyter_start><jupyter_text>Area 51<jupyter_code>kaggle[(kaggle['song_id'] == '3mQ6SLdxxaL52Yte7KF2Ks') | (kaggle['song_id'] == '35KmOEIUqAGn02t7n4qaIr')]
kaggle['artists'][169843]
list(kaggle['artists'][169843].split(','))
# clustering_dict[0]['subclusters'][0]['main']
# def build_sim_dict(clust_num,subclust_num,row):
    
#     '''
#     Find the similarity measure based on the angle between the vectors, 
#     and build a dictionary with the cosine of the angle as key.
#     List of songs with the same rounded cosine.
#     '''
    
#     partial_df = clustering_dict[clust_num]['subclusters'][subclust_num]['main'][['popularity','danceability', 'energy', 'song_key', 'loudness', 'song_mode','speechiness', 'acousticness', 'instrumentalness', 'liveness','valence', 'tempo', 'duration_ms', 'year']]
#     partial_df.head()

#     # Standarizing the data
#     stdscaler = StandardScaler()
#     partial_df_std = stdscaler.fit_transform(partial_df)

#     partial_df_std = partial_df_std / np.linalg.norm(partial_df_std,axis=1, keepdims=True)  
    
#     similarity_dict = {}
#     for i, _ in enumerate(partial_df.index):

#         similarity = round(partial_df_std.dot(np.transpose(partial_df_std))[row][i],4)


#         if similarity not in similarity_dict:

#             similarity_dict[similarity] = []
            
#         similarity_dict[similarity].append(clustering_dict[clust_num]['subclusters'][subclust_num]['main'].iloc[i,0])

#     return similarity_dict

# build_sim_dict(0,0,0)
# lst_of_sim_dcts = [build_sim_dict(0,0,row) for row in range(len(clustering_dict[0]['subclusters'][0]['main']))]
# # Build a dict with song_id as key
# song_dict = {}

# for i in range(len(clustering_dict.keys())-2):

#     for j in range(len(clustering_dict[i]['subclusters'].keys())-2):

#         lst_of_sim_dcts = [build_sim_dict(i,j,row) for row in range(len(clustering_dict[i]['subclusters'][j]['main']))]

#         for k,id in enumerate(clustering_dict[i]['subclusters'][j]['main']['song_id']):

#             song_dict[id] = lst_of_sim_dcts[k]
            
#         del lst_of_sim_dcts


kaggle[kaggle['artists'] == "['Maluma']"]
# Hawai - Maluma & The Weekend 
kaggle[kaggle['song_id'] == '0GzuHFG4Ql6DoyxFRnIk3F']
# Hawai - Maluma (Only)
kaggle[kaggle['song_id'] == '1yoMvmasuxZfqHEipJhRbp']
# 11 PM - Maluma 
kaggle[kaggle['song_id'] == '7KbF6AdprOXEEHlsq11Z6d']
playlist_id = '5u29iIDT3bBUwusA9Zfq4w'
pl_data = sp.playlist_tracks(playlist_id=playlist_id)
pl_data['items'][99]['track'].keys()
pl_data['items'][99]['track']['album']['release_date'][:4]
track_data = sp.audio_features('10k3RAOXYP96FY4oyp1aQ4')
track_data[0]
sp.track('10k3RAOXYP96FY4oyp1aQ4')['album']['release_date'][:4]
['4pRCW4Rt4rl6tPm1CpIadt', '1rbsI0Xp6dHaRXCeI42czz', '32riLnBjERrOOzOt8XKPim', '7DWxOrMQIz1CCOKByJxFLA', '1J1zEzxWRFpTjjmJr2NdwD', '19uuiVuN6YvFvetpjzfUYg', '7q7auGTn2flEH9urOSz8W3', '60o4stCyzWKF6ziLD5OGt6', '6wB2Ix5KYhZU9HIMSZVAdr']
connection = psycopg2.connect(user=os.environ.get('db_user'),password=os.environ.get('db_password'),host=os.environ.get('db_host'),port=os.environ.get('db_port'),database=os.environ.get('db_name'))
cursor.execute('''SELECT followed_by FROM playlists WHERE playlist_id = %s ''',(playlist_id,))
cursor.execute('''SELECT coded_artists FROM songs WHERE artists = %s;''',(str(song_dict['artists']),))
str(kaggle[kaggle['artists'] == '<NAME>, <NAME>']['artists'].item())
spotify:playlist:37i9dQZF1DWZC2yew0xGiz
playlist_id = '37i9dQZF1DWZC2yew0xGiz'
user_id = '22tbf4n6jbom3jvylao3jydbi'
results = sp.playlist_tracks(playlist_id=playlist_id)

results<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16694306246545051, 'fraction_numerical': 0.037866224433388614, 'mean_word_length': 6.385714285714286, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '315988', 'license': 'MIT', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1526, 'n_words': 183, 'path': 'first_steps.ipynb', 'repo_name': 'CodingDuckmx/Spotify_suggestions', 'size': '3630'}