Pandas Reading json给了我ValueError:Ploty Dash中的文件路径或缓冲区对象类型无效



此行:

else:
#add to this
nutrients_totals_df = pd.read_json(total_nutrients_json, orient='split')

正在引发错误。我把json写成:

nutrients_json = nutrients_df.to_json(date_format='iso', orient='split')

然后我把它藏在一个回调中的隐藏div或dcc.Storage中,并在另一个回调中将其获取。如何修复此错误?

当我阅读用Pandas编写的json文件时,我使用下面的函数并调用json.loads((内部。

def read_json_file_from_local(fullpath):
"""read json file from local"""
with open(fullpath, 'rb') as f:
data = f.read().decode('utf-8')
return data
df = json.loads(read_json_file_from_local(fullpath))

最新更新