質問編集履歴

1

df = pd.DataFrame---より上のプログラムを追記いたしました。

2021/11/06 22:36

投稿

ssshhlll
ssshhlll

スコア0

test CHANGED
File without changes
test CHANGED
@@ -48,6 +48,30 @@
48
48
 
49
49
  -------------------------------------------------
50
50
 
51
+ def track_info(limit = 50):
52
+
53
+ saved_tracks = sp.current_user_saved_tracks(limit = limit, offset = 50)
54
+
55
+
56
+
57
+ track_id = lambda i: saved_tracks['items'][i]['track']['id']
58
+
59
+ track_name = lambda i: sp.track(track_id(i))['name']
60
+
61
+
62
+
63
+ info = [[track_id(i), track_name(i)] for i in range(limit)]
64
+
65
+ return pd.DataFrame(info, columns = ['track_id','track_name'])
66
+
67
+
68
+
69
+ #上で取得した楽曲の特徴を取得
70
+
71
+ def track_features(track_ids, limit = 50):
72
+
73
+ return pd.DataFrame(sp.audio_features(track_ids))
74
+
51
75
  df = pd.DataFrame(sp.audio_features(track_info()['track_id']))
52
76
 
53
77
  mnum = float(input('min : '))