简单的问题,我有一个在 row_colors 中包含变量“age_range”的聚类图,我也想将变量“education”添加为 row_color。我有以下工作代码:
agerange = df_cor_small.pop("agerange")
lut = dict(zip(agerange.unique(), "rbg"))
row_colors = agerange.map(lut)
ax = sns.clustermap(df_cor_small, cmap='YlGnBu', row_colors=row_colors, figsize=(15,100), cbar_pos=(1.05, .2, .03, .4))
Run Code Online (Sandbox Code Playgroud)
(目前 df_cor_small 不包含变量“education”,但一旦我知道如何实现它,它就会包含在内,因此它将像“agerange”一样可弹出)
有什么建议我可以如何实现这个吗?
对于我的关于电晕跟踪应用程序的论文,我有以下查找 df (在其上使用了 pd.melt):
CTQ-tool opinion
0 Information and awareness purposes unacceptable
1 Information and awareness purposes unacceptable
2 Information and awareness purposes acceptable
3 Information and awareness purposes acceptable
4 Information and awareness purposes unacceptable
... ... ...
2827 Central/Local data storage NaN
2828 Central/Local data storage NaN
2829 Central/Local data storage NaN
2830 Central/Local data storage NaN
2831 Central/Local data storage NaN
2832 rows × 2 columns
Run Code Online (Sandbox Code Playgroud)
我正在使用 Seaborn 库制作以下猫图:
代码:
g = sns.catplot("opinion", col="CTQ-tool", col_wrap=4, data=df_original_small, kind="count", …Run Code Online (Sandbox Code Playgroud) TL; DR =>底部代码框中的代码有什么问题.
我试图调用一个名为'check'的函数来检查填写的用户名是否为空并且我的数据库中是否已存在.此检查功能如下所示:
@app.route("/check", methods=["GET"])
def check():
"""Return true if username available, else false, in JSON format"""
# User reached route via POST (as by submitting a form via POST)
if request.method == "GET":
username = request.args.get("username")
usernames = db.execute("SELECT * FROM users")[0][username]
if username is not None and len(username) > 1:
if username not in usernames:
return jsonify(True)
else:
return jsonify(False)
else:
return jsonify(False)
Run Code Online (Sandbox Code Playgroud)
我不知道这段代码是否正常工作,但我想我可以做到这一点.问题是我对jQuery缺乏经验.首先,我有一个相当简单的HTML代码设置一个注册页面:
<form action="/register" method="post">
<div class="form-group">
<input autocomplete="off" autofocus class="form-control" name="username" placeholder="Username" type="text">
</div> …Run Code Online (Sandbox Code Playgroud)