我正在尝试显示 Streamlit/Hydralit 组件,但是当我将其部署到 Cloud Run 上时,我遇到了此超时错误(本地从未遇到过):
Your app is having trouble loading the hydralit_components.NavBar.nav_bar component.
(The app is attempting to load the component from **, and hasn't received its "streamlit:componentReady"** message.)
If this is a development build, have you started the dev server?
If this is a release build, have you compiled the frontend?
For more troubleshooting help, please see the Streamlit Component docs or visit our forums.
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个相关问题?
晚上好,
我有一个dataframe(Pandas),其列表示日期,格式如下:
print(df["date"])
14/01/18 12:47
14/01/18 12:48
14/01/18 12:50
14/01/18 12:57
14/01/18 12:57
14/01/18 12:57
14/01/18 12:57
14/01/18 12:57
14/01/18 12:58
Run Code Online (Sandbox Code Playgroud)
具体来说,我想:1. 使用pd.to_datetime 将其转换为datetime。2 .创建以下附加列:
df["month"]
df["day"]
df["year"]
df["hour"]
df["minute"]
Run Code Online (Sandbox Code Playgroud)
我试着跑:
df['date'] = pd.to_datetime(df['date'], format = "%d/%m/%Y %H/%M" )
Run Code Online (Sandbox Code Playgroud)
但是出现以下错误:
time data '02/01/18 08:41' does not match format '%d/%m/%Y %H/%M' (match)
Run Code Online (Sandbox Code Playgroud) 我正在使用 XGBoost 算法进行回归,因为
clf = XGBRegressor(eval_set = [(X_train, y_train), (X_val, y_val)],
early_stopping_rounds = 10,
n_estimators = 10,
verbose = 50)
clf.fit(X_train, y_train, verbose=False)
print("Best Iteration: {}".format(clf.booster().best_iteration))
Run Code Online (Sandbox Code Playgroud)
它正确地训练自己,但打印功能引发以下错误,
TypeError: 'str' object is not callable
Run Code Online (Sandbox Code Playgroud)
如何获得模型的最佳 迭代次数?
此外,我怎么能打印训练 误差的每 一轮?
晚上好,
我试图估计循环结束的剩余 时间;我用过:
start = datetime.now()
progress = 0
for i in range(1000):
#do a few calculations
progress += 1
stop = datetime.now()
execution_time = stop-start
remaining = execution_time * ( 1000 - progress )
print("Progress:", progress, "%, estimated", remaining, "time remaining")
Run Code Online (Sandbox Code Playgroud)
但它似乎无法正常工作,因为它会长达几分钟,尽管循环总共需要 20 秒,并且在到达末尾时会迅速减少。
如何有效且正确地预测循环的剩余 时间?
早上好,
我有以下数据框(年,月,日,小时,秒):
print(df)
Date Price
2018-01-02 09:42:00 2
2018-01-02 09:46:00 4
2018-01-02 10:22:00 6
...
Run Code Online (Sandbox Code Playgroud)
我想得到,没有分钟和几秒钟:
print(final_df)
Date Price
2018-01-02 2
2018-01-02 4
2018-01-02 6
...
Run Code Online (Sandbox Code Playgroud)
我试过了:
df['Date'] = datetime.datetime.strptime(df['Date'], '%Y-%m-%d').date()
Run Code Online (Sandbox Code Playgroud)
但是它报告“ strptime()参数1必须是str,而不是Series”
我正在尝试使用 Postman 触发经过身份验证的 GCP 云功能。
为此,我创建了一个具有“Cloud Functions Invoker”角色的专用服务帐户,并下载了一个结构如下的 .json 密钥:
{
"type": "service_account",
"project_id": "xxx",
"private_key_id": "xxx",
"private_key": "-----BEGIN PRIVATE KEY-----\n1234=\n-----END PRIVATE KEY-----\n",
"client_email": "xxx.iam.gserviceaccount.com",
"client_id": "xxxx",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "xxx.iam.gserviceaccount.com"
}
Run Code Online (Sandbox Code Playgroud)
我尝试将整个“private_key”(-----BEGIN PRIVATE KEY-----\n1234=\n-----END PRIVATE KEY-----\n)粘贴为承载令牌,但我得到出现以下错误:
<title>401 Unauthorized</title>
Run Code Online (Sandbox Code Playgroud)
现在,如何使用 GCP 中的 .json 文件通过 Postman 进行身份验证?我应该使用哪些参数?
google-cloud-platform postman bearer-token google-cloud-functions
我正在通过 GitHub 和 Google Cloud Build 使用以下 .yaml 文件创建 CICD 管道:
# Cloud Function specifications
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args:
- functions
- deploy
- hello_world
- --source=./src
- --trigger-http
- --memory=1024MB
- --max-instances=5
- --runtime=python39
- --region=europe-west6
- --entry-point=predict
- --allow-unauthenticated
Run Code Online (Sandbox Code Playgroud)
一切正常,功能部署正确;但是,每当我尝试调用它时,都会引发以下错误:
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>401 Unauthorized</title>
</head>
Run Code Online (Sandbox Code Playgroud)
似乎 --allow-unauthenticated 参数无法正常工作。如何公开 API 并授予公众访问权限?
笔记:
如果我跑gcloud functions describe --project=XXXXXX --region=europe-west6 hello_world
我得到:
availableMemoryMb: 1024
buildId: 1234
entryPoint: predict
environmentVariables:
ABC: '"discount"'
httpsTrigger:
securityLevel: SECURE_OPTIONAL
url: https://europe-west6-XXX.cloudfunctions.net/hello_world
ingressSettings: ALLOW_ALL …Run Code Online (Sandbox Code Playgroud) 我有以下数据帧:
print(inventory_df)
dt_op Prod_1 Prod_2 Prod_n
1 10/09/18 5 50 2
2 11/09/18 4 0 0
3 12/09/18 2 0 0
4 13/09/18 0 0 0
5 14/09/18 4 30 1
Run Code Online (Sandbox Code Playgroud)
我想将值更改为零,使用最后一个值!=从零开始,在每列中,如下所示:
print(final_inventory_df)
dt_op Prod_1 Prod_2 Prod_n
1 10/09/18 5 50 2
2 11/09/18 4 50 2
3 12/09/18 2 50 2
4 13/09/18 2 50 2
5 14/09/18 4 30 1
Run Code Online (Sandbox Code Playgroud)
我怎么能这样做?
我正在尝试从基于 Hydralit 的 Streamlit(v.1.1.0)应用程序中删除白色间距(如图所示;徽标和主页下方的两个空格。
我尝试过:
# 1
st.markdown(
f""" <style>
.reportview-container .main .block-container{{
padding-top: 0 rem;
padding-right: 0 rem;
padding-left: 0 rem;
padding-bottom: 0 rem;
}} </style> """,
unsafe_allow_html=True,
)
# 2
st.markdown("""
<style>
.css-18e3th9 {
padding-top: 0rem;
padding-bottom: 10rem;
padding-left: 5rem;
padding-right: 5rem;
}
.css-1d391kg {
padding-top: 3.5rem;
padding-right: 1rem;
padding-bottom: 3.5rem;
padding-left: 1rem;
}
</style>
""", unsafe_allow_html=True)
Run Code Online (Sandbox Code Playgroud)
但它们似乎都不起作用;如何压缩布局并有效减少徽标下方和页面第一个标题上方的空间?
我有以下数据框,其中col_1是整数类型:
print(df)
col_1
100
200
00153
00164
Run Code Online (Sandbox Code Playgroud)
如果位数等于3,我想添加两个零。
final_col
00100
00200
00153
00164
Run Code Online (Sandbox Code Playgroud)
我尝试过:
df.col_1 = df.col_1.astype(int).astype(str)
df["final_col"] = np.where(len(df["col_1"]) == 3, "00" + df.col_1, df.col_1 )
Run Code Online (Sandbox Code Playgroud)
但是,它不会产生预期的输出(满足条件时,不会将两位数字相加)。
我该如何解决?
python ×6
pandas ×3
datetime ×2
streamlit ×2
bearer-token ×1
cicd ×1
for-loop ×1
forecasting ×1
html ×1
numpy ×1
postman ×1
python-3.x ×1
regression ×1
xgboost ×1
yaml ×1