【发布时间】:2021-06-16 07:26:05
【问题描述】:
books= ['When The Storm Breaks', 'When The Bough Breaks (Alex Delaware Novels (Paperback))', 'Storm Front (The Dresden Files, Book 1)', 'The Fellowship Of The Ring (The Lord Of The Rings, Part 1)', 'The Return Of The King (The Lord Of The Rings, Part 3)', 'The Sign Of The Beaver', 'The Fly On The Wall', 'The Cat In The Hat', 'The Member Of The Wedding']
这是我的列表,所以我试图从数据框中获取列表项图像,所以我尝试了以下代码:
def get_image(books):
img=[]
data = pd.read_csv('C:/Users/suhel/Desktop/book recommendation/file.csv')
for i in range(len(books)):
w=data.loc[data['title']==books[i],'Image']
img.append(w)
return img
但它只返回一个图片链接,其余如下:
[Series([], Name: Image, dtype: object), Series([], Name: Image, dtype: object), 360 http://images.amazon.com/images/P/0451457811.0...
Name: Image, dtype: object, Series([], Name: Image, dtype: object), Series([], Name: Image, dtype: object), Series([], Name: Image, dtype: object), Series([], Name: Image, dtype: object), Series([], Name: Image, dtype: object), Series([], Name: Image, dtype: object)]
有没有办法从数据框中获取所有列出的图像链接,而不需要索引对象或 dtype
【问题讨论】:
标签: python pandas dataframe series