程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

【pandas】read_ JSON: valueerror expected object or value

編輯:Python

background : Need to use pandas.read_json() Read a Local json File to dataframe, However, there is an error message :valueerror expected object or value

bing I searched for it , The answer is very accurate ( When can baidu do the same …)

In fact, that is pd.read_json(path_or_buf=path, orient='columns') This one in path Something went wrong. .

I tried to be direct pd.read_json(path_or_buf=r'E:\xxx\xxx\xx.json', orient='columns') It can read data , Then it must be lack of this again r As a result of .

Because my folder path and file name are stored in two variables respectively , So it can be handled like this :

# folder_path -- Folder path 
# file_name -- File name 
vpath = r"".join([folder_path, os.sep, file_name])
pd.read_json(path_or_buf=vpath,orient='columns')

Get it done *,°:.*( ̄▽ ̄)/$:.°* .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved