logo
Loading...

如何讀取DataFrame的資料 - Cupoy

from PIL import Imagefrom io import BytesIOimport ...

ml100-3,ml100-3-d05

如何讀取DataFrame的資料

2019/09/03 02:17 PM
機器學習新手論壇
林致寬
觀看數:0
回答數:1
收藏數:0
ml100-3
ml100-3-d05

from PIL import Image
from io import BytesIO
import numpy as np
import matplotlib.pyplot as plt

# 請用 df.loc[...] 得到第一筆資料的連結
first_link = df.loc[0:0,1:]
response = requests.get(first_link)
img = Image.open(BytesIO(response.content))

# Convert img to numpy array

plt.imshow(img)
plt.show()

---------------------------------------------------------------------------
InvalidSchema                             Traceback (most recent call last)
<ipython-input-6-f4733d600c3c> in <module>
     6 # 請用 df.loc[...] 得到第一筆資料的連結
     7 first_link = df.loc[0:0,1:]
----> 8 response = requests.get(first_link)
     9 img = Image.open(BytesIO(response.content))
    10

D:\Program\Anaconda\lib\site-packages\requests\api.py in get(url, params, **kwargs)
    73
    74     kwargs.setdefault('allow_redirects', True)
---> 75     return request('get', url, params=params, **kwargs)
    76
    77

D:\Program\Anaconda\lib\site-packages\requests\api.py in request(method, url, **kwargs)
    58     # cases, and look like a memory leak in others.
    59     with sessions.Session() as session:
---> 60         return session.request(method=method, url=url, **kwargs)
    61
    62

D:\Program\Anaconda\lib\site-packages\requests\sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
   531         }
   532         send_kwargs.update(settings)
--> 533         resp = self.send(prep, **send_kwargs)
   534
   535         return resp

D:\Program\Anaconda\lib\site-packages\requests\sessions.py in send(self, request, **kwargs)
   638
   639         # Get the appropriate adapter to use
--> 640         adapter = self.get_adapter(url=request.url)
   641
   642         # Start time (approximately) of the request

D:\Program\Anaconda\lib\site-packages\requests\sessions.py in get_adapter(self, url)
   729
   730         # Nothing matches :-/
--> 731         raise InvalidSchema("No connection adapters were found for '%s'" % url)
   732
   733     def close(self):

InvalidSchema: No connection adapters were found for '1
0  
http://farm1.static.flickr.com/145/430300483_2...'



請問該如何讓 df.loc[0:0,1:] 只之輸出單格的內容,而不要出現row 和 column 的值