質問編集履歴
6
コードの修繕
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,13 +5,26 @@
|
|
5
5
|
分からないことがたくさんあり、教えていただけると幸いです
|
6
6
|
### 発生している問題・エラーメッセージ
|
7
7
|
```
|
8
|
+
https://open.spotify.com/track/58dxGXavrcagRqA58fNB0Z <class 'str'>
|
9
|
+
https://open.spotify.com/track/2yozZfRYHP7Elsymghu5t3 <class 'str'>
|
10
|
+
https://open.spotify.com/track/3S3DDZrPOYTirleXRyHnNM <class 'str'>
|
11
|
+
https://open.spotify.com/track/5DMEvbg3gUmiR5HIBWdveV <class 'str'>
|
12
|
+
中略
|
13
|
+
https://open.spotify.com/track/0U9vBvoG3LN1PnuVl47E3W <class 'str'>
|
14
|
+
https://open.spotify.com/track/2tgWF9EZzqiq4Qzdzeow1A <class 'str'>
|
15
|
+
https://open.spotify.com/track/4jaaMznp3KPllxbmRdiIbx <class 'str'>
|
16
|
+
https://open.spotify.com/track/6Flllj0iIJPwXUpxL9KdxC <class 'str'>
|
17
|
+
https://open.spotify.com/track/4XkqVSWIPb07iLEDvAPq93 <class 'str'>
|
18
|
+
https://open.spotify.com/track/7yXwERf5YbjCXkVqU1fZvA <class 'str'>
|
19
|
+
nan <class 'float'>
|
20
|
+
---------------------------------------------------------------------------
|
8
21
|
TypeError Traceback (most recent call last)
|
9
|
-
<ipython-input-
|
22
|
+
<ipython-input-24-69a5d88baf73> in <module>()
|
10
|
-
4
|
11
23
|
5 for url in songs["URL"] :
|
24
|
+
6 print(url, type(url))
|
12
|
-
---->
|
25
|
+
----> 7 df = pd.DataFrame.from_dict(spotify.audio_features(url))
|
13
|
-
|
26
|
+
8 song_info = song_info.append(df)
|
14
|
-
|
27
|
+
9
|
15
28
|
|
16
29
|
/usr/local/lib/python3.6/dist-packages/spotipy/client.py in audio_features(self, tracks)
|
17
30
|
826 results = self._get('audio-features/?ids=' + trackid)
|
@@ -19,6 +32,7 @@
|
|
19
32
|
--> 828 tlist = [self._get_id('track', t) for t in tracks]
|
20
33
|
829 results = self._get('audio-features/?ids=' + ','.join(tlist))
|
21
34
|
830 # the response has changed, look for the new style first, and if
|
35
|
+
|
22
36
|
TypeError: 'float' object is not iterable
|
23
37
|
```
|
24
38
|
|
@@ -40,15 +54,17 @@
|
|
40
54
|
|
41
55
|
song_info = pd.DataFrame()
|
42
56
|
|
43
|
-
URL = ["
|
57
|
+
URL = ["https://open.spotify.com/track/58dxGXavrcagRqA58fNB0Z"]
|
44
58
|
|
45
|
-
for url in songs["URL"] :
|
59
|
+
for url in songs["URL"] :
|
60
|
+
print(url, type(url))
|
46
|
-
|
61
|
+
df = pd.DataFrame.from_dict(spotify.audio_features(url))
|
47
|
-
|
62
|
+
song_info = song_info.append(df)
|
48
63
|
|
49
64
|
#index振り直し
|
50
65
|
song_info=song_info.reset_index(drop=True)
|
51
66
|
song_info.head(10)
|
67
|
+
song_info.dtypes
|
52
68
|
dropna(how="all")
|
53
69
|
```
|
54
70
|
### 試したこと
|
5
コードの修繕
title
CHANGED
File without changes
|
body
CHANGED
@@ -40,7 +40,7 @@
|
|
40
40
|
|
41
41
|
song_info = pd.DataFrame()
|
42
42
|
|
43
|
-
URL = ["https://open.spotify.com/track/58dxGXavrcagRqA58fNB0Z"]
|
43
|
+
URL = ["[楽曲、PretenderのURL](https://open.spotify.com/track/58dxGXavrcagRqA58fNB0Z)"]
|
44
44
|
|
45
45
|
for url in songs["URL"] :
|
46
46
|
df = pd.DataFrame.from_dict(spotify.audio_features(url))
|
4
コードの修繕
title
CHANGED
File without changes
|
body
CHANGED
@@ -19,9 +19,9 @@
|
|
19
19
|
--> 828 tlist = [self._get_id('track', t) for t in tracks]
|
20
20
|
829 results = self._get('audio-features/?ids=' + ','.join(tlist))
|
21
21
|
830 # the response has changed, look for the new style first, and if
|
22
|
+
TypeError: 'float' object is not iterable
|
23
|
+
```
|
22
24
|
|
23
|
-
```
|
24
|
-
TypeError: 'float' object is not iterable
|
25
25
|
### 該当のソースコード
|
26
26
|
```
|
27
27
|
!pip install pandas
|
3
コードの修繕
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
分からないことがたくさんあり、教えていただけると幸いです
|
6
6
|
### 発生している問題・エラーメッセージ
|
7
|
+
```
|
7
8
|
TypeError Traceback (most recent call last)
|
8
9
|
<ipython-input-5-c14133083d45> in <module>()
|
9
10
|
4
|
@@ -19,8 +20,10 @@
|
|
19
20
|
829 results = self._get('audio-features/?ids=' + ','.join(tlist))
|
20
21
|
830 # the response has changed, look for the new style first, and if
|
21
22
|
|
23
|
+
```
|
22
24
|
TypeError: 'float' object is not iterable
|
23
25
|
### 該当のソースコード
|
26
|
+
```
|
24
27
|
!pip install pandas
|
25
28
|
!pip install spotipy
|
26
29
|
import pandas as pd
|
@@ -28,8 +31,8 @@
|
|
28
31
|
from spotipy.oauth2 import SpotifyClientCredentials
|
29
32
|
import json
|
30
33
|
import csv
|
31
|
-
client_id =
|
34
|
+
client_id =
|
32
|
-
client_secret =
|
35
|
+
client_secret =
|
33
36
|
client_credentials_manager = spotipy.oauth2.SpotifyClientCredentials(client_id, client_secret)
|
34
37
|
spotify = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
35
38
|
songs = pd.read_csv("data.csv", encoding="shift-jis" , index_col=0)
|
@@ -42,11 +45,12 @@
|
|
42
45
|
for url in songs["URL"] :
|
43
46
|
df = pd.DataFrame.from_dict(spotify.audio_features(url))
|
44
47
|
song_info = song_info.append(df)
|
48
|
+
|
45
|
-
|
49
|
+
#index振り直し
|
46
50
|
song_info=song_info.reset_index(drop=True)
|
47
51
|
song_info.head(10)
|
48
52
|
dropna(how="all")
|
49
|
-
|
53
|
+
```
|
50
54
|
### 試したこと
|
51
55
|
URLを思いつく限り、コードも調べて変えられそうなところは試してみました
|
52
56
|
|
2
コードの修繕
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,8 +4,37 @@
|
|
4
4
|
|
5
5
|
分からないことがたくさんあり、教えていただけると幸いです
|
6
6
|
### 発生している問題・エラーメッセージ
|
7
|
+
TypeError Traceback (most recent call last)
|
8
|
+
<ipython-input-5-c14133083d45> in <module>()
|
9
|
+
4
|
10
|
+
5 for url in songs["URL"] :
|
11
|
+
----> 6 df = pd.DataFrame.from_dict(spotify.audio_features(url))
|
12
|
+
7 song_info = song_info.append(df)
|
13
|
+
8
|
14
|
+
|
15
|
+
/usr/local/lib/python3.6/dist-packages/spotipy/client.py in audio_features(self, tracks)
|
16
|
+
826 results = self._get('audio-features/?ids=' + trackid)
|
17
|
+
827 else:
|
18
|
+
--> 828 tlist = [self._get_id('track', t) for t in tracks]
|
19
|
+
829 results = self._get('audio-features/?ids=' + ','.join(tlist))
|
20
|
+
830 # the response has changed, look for the new style first, and if
|
21
|
+
|
7
22
|
TypeError: 'float' object is not iterable
|
8
23
|
### 該当のソースコード
|
24
|
+
!pip install pandas
|
25
|
+
!pip install spotipy
|
26
|
+
import pandas as pd
|
27
|
+
import spotipy
|
28
|
+
from spotipy.oauth2 import SpotifyClientCredentials
|
29
|
+
import json
|
30
|
+
import csv
|
31
|
+
client_id = ''
|
32
|
+
client_secret = ''
|
33
|
+
client_credentials_manager = spotipy.oauth2.SpotifyClientCredentials(client_id, client_secret)
|
34
|
+
spotify = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
35
|
+
songs = pd.read_csv("data.csv", encoding="shift-jis" , index_col=0)
|
36
|
+
songs.head(10)
|
37
|
+
|
9
38
|
song_info = pd.DataFrame()
|
10
39
|
|
11
40
|
URL = ["https://open.spotify.com/track/58dxGXavrcagRqA58fNB0Z"]
|
@@ -22,5 +51,6 @@
|
|
22
51
|
URLを思いつく限り、コードも調べて変えられそうなところは試してみました
|
23
52
|
|
24
53
|
### 補足情報(FW/ツールのバージョンなど)
|
25
|
-
|
54
|
+
GoolgleColabolatlyを使用させていただいています
|
55
|
+
https://qiita.com/kazuya-n/items/fbee07ef778e166cb6dd
|
26
|
-
|
56
|
+
参考にさせていただいているサイトのURLです
|
1
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -17,7 +17,6 @@
|
|
17
17
|
song_info=song_info.reset_index(drop=True)
|
18
18
|
song_info.head(10)
|
19
19
|
dropna(how="all")
|
20
|
-
```ここに言語名を入力
|
21
20
|
|
22
21
|
### 試したこと
|
23
22
|
URLを思いつく限り、コードも調べて変えられそうなところは試してみました
|