We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError Traceback (most recent call last)
Cell In[188], line 1, in (x) ----> 1 df['genres'] = df['Title'].map(lambda x: get_genre(str(x)))
Cell In[186], line 7, in get_genre(x) 5 result = tmdb_movie.search(x) 6 if ( len(result) != 0 ): ----> 7 movie_id = str(result[0]['id']) 8 response = requests.get('https://api.themoviedb.org/3/movie/{}?api_key={}'.format(movie_id,tmdb. 9 data_json = response.json()
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\tmdbv3api\as_obj.py:47, in AsObj.getitem(self, key) 45 return self._obj_list[key] 46 else: ---> 47 return getattr(self, key)
TypeError: attribute name must be string, not 'int'
Here is the genre method:
from tmdbv3api import Movie tmdb_movie = Movie() def get_genre(x): genres = [] result = tmdb_movie.search(x) if ( len(result) != 0 ): print(type(result[0])) movie_id = str(result[0].id) response = requests.get('https://api.themoviedb.org/3/movie/{}?api_key={}'.format(movie_id,tmdb.api_key)) data_json = response.json() if data_json['genres']: genre_str = " " for i in range(0,len(data_json['genres'])): genres.append(data_json['genres'][i]['name']) return genre_str.join(genres) else: np.NaN else: np.NaN
The text was updated successfully, but these errors were encountered:
No branches or pull requests
TypeError Traceback (most recent call last)
Cell In[188], line 1, in (x)
----> 1 df['genres'] = df['Title'].map(lambda x: get_genre(str(x)))
Cell In[186], line 7, in get_genre(x)
5 result = tmdb_movie.search(x)
6 if ( len(result) != 0 ):
----> 7 movie_id = str(result[0]['id'])
8 response = requests.get('https://api.themoviedb.org/3/movie/{}?api_key={}'.format(movie_id,tmdb.
9 data_json = response.json()
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\tmdbv3api\as_obj.py:47, in AsObj.getitem(self, key)
45 return self._obj_list[key]
46 else:
---> 47 return getattr(self, key)
TypeError: attribute name must be string, not 'int'
Here is the genre method:
from tmdbv3api import Movie
tmdb_movie = Movie()
def get_genre(x):
genres = []
result = tmdb_movie.search(x)
if ( len(result) != 0 ):
print(type(result[0]))
movie_id = str(result[0].id)
response = requests.get('https://api.themoviedb.org/3/movie/{}?api_key={}'.format(movie_id,tmdb.api_key))
data_json = response.json()
if data_json['genres']:
genre_str = " "
for i in range(0,len(data_json['genres'])):
genres.append(data_json['genres'][i]['name'])
return genre_str.join(genres)
else:
np.NaN
else:
np.NaN
The text was updated successfully, but these errors were encountered: