我正在尝试将网页中的csv读取为大熊猫,但是却出现了一些空白的数据框和一个0行和155列的对象。我感觉好像错过了一步。努力使用Web数据,而不是一般使用我的计算机。
url ="https://data.world/exercises/data-wrangling-exercise-1/workspace/file?filename=Crime_2015.csv"
crimex= pd.read_csv(url)
print(crimex)
输出如下:
空数据框 列:[data.world Loading ...?Feedback {“ dataset”:{“ hasError”:false,loadedDatasets:{},usersDatasets:{},loadedCurrentUsersDatasets:false,usersDatasetsTotalCount:0},user:{“ hasError”: false,loadedUsers:{},userFollows:{},userLikes:{},userInvites:null,userRecentComments:{},groupAuthorizations:{}},邀请:{},处理方式:[“ showVersions”,showWorkspaceTabs,showEntityLinkOptions,paramQueries] ,currentUser:{“ authorizedAccounts”:null,请求:[],unDismissedTourCount:2,needsAnalyticsAlias:false,通知:[],已解雇:[],个人资料:{“ agentid”:“”,访客编号:“ 109156be-c4fb- 41ea-b1b4-efe1671c580f“,displayName:”“,电子邮件:”“,公司:”“,activeSubscriptionid:”“,accountStanding:” good“,bio:”“,emailVerified:true,location:”“,网站:” “,avatarUrl:”“,numFollowers:0,numFollowing:0,numOrganizations:0,allowedRoles:[],关系:{},创建:”“,更新:”“,标签:[],abTests:{” buckets“ :{“ landingPageVideo”:{“ name”:“ video”,值:1},openAccessTwo:{“ name”:“ normal”,值:0},侧面doorVideo:{“名称”:“播放视频”,值:1}}},orgMode:“”,orgDetails:“”,级别:“”,userCapabilities:{}},requestsFetching:false,authorizedClients:[], isLoggedIn:假的,onboardThisSession:假的,令牌: “eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJwcm9kLXVzZXItY2xpZW50IiwiaXNzIjoiYXV0aG9yaXR5OmRhdGFkb3R3b3JsZDo6MEJGMEVCRDMtMkRFNy00OUZCLUI4N0ItQUQwMzA1N0JCODlFIiwiaWF0IjoxNTM4NDkxMzM0LCJyb2xlIjpbXSwiZXhwIjoxNTM4NTc3NzM0LCJ2aXNpdG9yaWQiOiIxMDkxNTZiZS1jNGZiLTQxZWEtYjFiNC1lZmUxNjcxYzU4MGYiLCJnZW5lcmFsLXB1cnBvc2UiOnRydWUsImF1dGhvcml0eWlkcyI6WyJkYXRhZG90d29ybGQiXX0.9zL3wK5ceD8ylOykw30wuN5JQLPNjArVYo7H-1R85OvTb2hHPTKekcZKYoW-fLhZhnRH22PXTfg23RD__wK3wA”},讨论:{},路由:{ “locationBeforeTransitions”:空},siteStatus:{ “uploadsOperational”:真实,queryOperational:真,websiteOperational:true,downloadsOperational:true,shouldAskReload:false,shouldForceReload:false,identityName:“”,eventMessage:“”,pageStatus:“ none”},loginModal:{“ show”:false},signUpModal:{“ show” :false,处理:空,处理属性s:null},linkedOnboardModal:{“ show”:false},查询:{},requestInfo:{“ pathsMarkedAs404”:[],元数据:{}},集成:{“ activeIntegrations”:[]},客户端:{ },事件:{“ status”:“ closed”,meta:{}}} {“ analytics”:{“ snowplow_pixel”:“ d2vtrn3jrzj4cp.cloudfront.net”,segment_id:“ IXhtZmPohuGM60VHk59cdSbWqWQBB7aR”},filestack_media_key:3 filestack_dataset_key: “AuM8NdQnIQGE3NOBFdr6wz”,filestack_dataset_strings_url: “HTTPS:\ u002F \ u002Fcdn.filepicker.io \ u002Fapi \ u002Ffile \ u002F2OkHIxqQqq0DvgBPfiAh”,filestack_max_upload_size:524288000,iframely_key: “e4239223dd4ad21531b3a044840d5898”,sentry_dsn_client:“HTTPS:\ u002F \ u002F78d03c5189424a139f3e29423a60f67f@app.getsentry .com \ u002F78710”,version_build:“ b003207”,version_commit:“ 96f0da448”,version_check_interval:60000,csrf_cookie_name:“ _ csrf”,csrf_header_name:“ x-csrf-token”,analytics_log_to_console:false,...] 索引:[]
[0行x 155列]
答案 0 :(得分:1)
您需要按照data.world网站上的说明进行操作。
点击下载链接(位于右上角),共享URL并使用以下任一方法:
共享安全下载链接:
https://query.data.world/s/xxxxxxxlink_codexxxxxxxx
要导入:
import pandas as pd
df = pd.read_csv('https://query.data.world/s/xxxxxxxlink_codexxxxxxxx')
注意:我的链接已被编辑为无法使用,您可以提供自己的链接。
请记住在接受的答案旁边打勾。