我使用热图来显示混淆矩阵.我喜欢标准颜色,但我希望浅橙色为0,深紫色为最高值.
我设法只使用另一组颜色(从浅到深的紫罗兰色),设置:
colormap = sns.cubehelix_palette(as_cmap=True)
ax = sns.heatmap(cm_prob, annot=False, fmt=".3f", xticklabels=print_categories, yticklabels=print_categories, vmin=-0.05, cmap=colormap)
Run Code Online (Sandbox Code Playgroud)
但我想保留这些标准的.这是我的代码和我得到的图像.
ax = sns.heatmap(cm_prob, annot=False, fmt=".3f", xticklabels=print_categories, yticklabels=print_categories, vmin=-0.05)
Run Code Online (Sandbox Code Playgroud)
我在使用 re.sub 时遇到了麻烦。我从其他答案中了解到,这是因为我引用了一个我没有的捕获组。
我的问题是:如何调整我的代码以拥有一个有效的组?
s = "hello a world today b is sunny c day"
markers = "a b c".split()
pattern = r'\b' + ' (?:\w+ )?(?:\w+ )?'.join(markers) + r'\b'
text = re.sub(pattern, r'<b>\1</b>', s) # this gives error
Run Code Online (Sandbox Code Playgroud)
我想要这个: "hello <b>a world today b is sunny c</b> day"
我正在尝试将嵌套的 json 转换为 csv 文件,但我正在努力解决文件结构所需的逻辑:它是一个包含 2 个对象的 json,我只想将其中一个对象转换为 csv,这是带嵌套的列表。
我在这篇博文中发现了非常有用的“扁平化”json 信息。我基本上已经根据我的问题调整了它,但它仍然对我不起作用。
我的 json 文件如下所示:
{
"tickets":[
{
"Name": "Liam",
"Location": {
"City": "Los Angeles",
"State": "CA"
},
"hobbies": [
"Piano",
"Sports"
],
"year" : 1985,
"teamId" : "ATL",
"playerId" : "barkele01",
"salary" : 870000
},
{
"Name": "John",
"Location": {
"City": "Los Angeles",
"State": "CA"
},
"hobbies": [
"Music",
"Running"
],
"year" : 1985,
"teamId" : "ATL",
"playerId" : "bedrost01",
"salary" : 550000
}
],
"count": 2
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我的代码如下所示: …