[英]i was trying to run the code and im still getting same error value error invalid file or buffer
import json
import pandas as pd
with open(r'C:\Users\hp\Downloads\vertpoal.com_vv.json')as d:
dictData=json.load(d)
df=pd.read_json(dictData)
and I'm getting error:我收到错误:
ValuErorr: invalid file path or buffer object type;<class 'dict'>
Try:尝试:
df = pd.DataFrame.from_dict(dictData)
json.load
transforms JSON to a python dict which is redundant, because pd.read_json
expects ' a valid JSON str, path object or file-like object ' ( https://pandas.pydata.org/docs/reference/api/pandas.read_json.html ) json.load
transforms JSON to a python dict which is redundant, because pd.read_json
expects ' a valid JSON str, path object or file-like object ' ( https://pandas.pydata.org/docs/reference/api/pandas .read_json.html )
import pandas as pd
with open(r'C:\Users\hp\Downloads\vertpoal.com_vv.json')as d:
df=pd.read_json(d)
# some further actions with df object.
You should be able to access df
variable outside of with
scope.您应该能够
with
scope 之外访问df
变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.