pandas 读取json数据

input.json 文件内容

{
   "ID":["1","2","3","4","5","6","7","8" ],
   "Name":["Rick","Dan","Michelle","Ryan","Gary","Nina","Simon","Guru" ],
   "Salary":["623.3","515.2","611","729","843.25","578","632.8","722.5" ],
   "StartDate":[ "1/1/2012","9/23/2013","11/15/2014","5/11/2014","3/27/2015","5/21/2013",
      "7/30/2013","6/17/2014"],
   "Dept":[ "IT","Operations","IT","HR","Finance","IT","Operations","Finance"]
}

 

 

注意:一开始死活运行不了,后面各种尝试,后面百度说json文件不能注释。这才解决问题!!!!!

df = pd.read_json('F:/data_analysis/dataAnalysis/repeatable_code/data/input1.json',orient='recodes')
print(df)
print(df.loc[[1,3,5],['salary','Name']])

 

参考文献:

pandas处理json数据:https://blog.csdn.net/qq_24499417/article/details/81428594

你可能感兴趣的:(python3)