我正在 Python 中使用 json 文件,我想将其转换为字典。
这就是我的文件的样子:
[
{
"label": "Label",
"path": "/label-path",
"image": "icon.svg",
"subcategories": [
{
"title": "Main Title",
"categories": {
"column1": [
{
"label": "Label Title",
"path": "/Desktop/Folder"
}
]
}
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
(抱歉身份问题)
这就是我所做的:
import json
# Opening JSON file
f = open('file.json')
# returns JSON object as
# a dictionary
data = json.load(f)
Run Code Online (Sandbox Code Playgroud)
然而,数据现在是一个列表,而不是一个字典。我试图考虑如何将其转换为字典,但(我)不知道该怎么做;(II) 没有办法将文件作为字典导入吗?
我很抱歉,如果已经有一个话题,但我真的很挣扎.R中有'msgbox'功能的王者吗?类似于VBA中的msgbox.我希望有一个工具,使用户和程序之间的交互更友好.例如,要求程序将使用的那天.或者某些事情提醒用户有关问题,这类问题
这应该是非常基本的,但这里似乎没有关于它的帖子(好吧,我没有找到任何)。
我尝试将 box-cox 变换应用于 Pandas 中的列,但收到此错误:
ValueError: Length of values does not match length of index
Run Code Online (Sandbox Code Playgroud)
这就是我所做的:
from scipy import stats
df['boxcox_col_1'] = stats.boxcox(df['col_1'])
Run Code Online (Sandbox Code Playgroud)
这不应该起作用吗?
它只是一个常规的 pandas 列,其数值变量范围为 0.005 到 39,并且没有缺失值。