如何在同一页面的图片中添加多个图形显示?我正在尝试将 html.Div 组件添加到以下代码中以更新页面布局以在单个页面上添加更多类似的图形,但是这些新添加的图形不会显示在页面上,只能在图片中显示旧图形。我应该修改什么元素,比如说在浏览器的 dash 应用程序的单页上添加 3 次在上传的图像中显示的图形?
import dash
import dash_core_components as dcc
import dash_html_components as html
i[enter image description here][1]mport plotly.express as px
import pandas as pd
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
# assume you have a "long-form" data frame
# see https://plotly.com/python/px-arguments/ for more options
df = pd.DataFrame({
"Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"],
"Amount": [4, 1, 2, 2, 4, 5],
"City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"]
})
fig = px.bar(df, x="Fruit", y="Amount", …Run Code Online (Sandbox Code Playgroud) 我在训练期间使用标签编码器,并希望通过保存并稍后加载来在生产中使用相同的编码器。无论我在网上找到什么解决方案,都只允许标签编码器一次应用于单个列,如下所示:
for col in col_list:
df[col]= df[[col]].apply(LabelEncoder().fit_transform)
Run Code Online (Sandbox Code Playgroud)
这种情况下如何保存并以后使用呢?因为我尝试拟合整个数据框,但出现以下错误。
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
C:\Users\DA~1\AppData\Local\Temp/ipykernel_3884/730613134.py in <module>
----> 1 l_enc.fit_transform(df_join[le_col].astype(str))
~\anaconda3\envs\ReturnRate\lib\site-packages\sklearn\preprocessing\_label.py in fit_transform(self, y)
113 Encoded labels.
114 """
--> 115 y = column_or_1d(y, warn=True)
116 self.classes_, y = _unique(y, return_inverse=True)
117 return y
~\anaconda3\envs\ReturnRate\lib\site-packages\sklearn\utils\validation.py in column_or_1d(y, warn)
1022 return np.ravel(y)
1023
-> 1024 raise ValueError(
1025 "y should be a 1d array, got an array of shape {} instead.".format(shape)
1026 )
ValueError: y should be a 1d array, …Run Code Online (Sandbox Code Playgroud) 我正在使用配备 Intel Corporation HD Graphics 520 的笔记本电脑。有谁知道如何为深度学习设置它,特别是 Pytorch?我已经看到如果你有 Nvidia 显卡我可以安装 cuda 但是当你有英特尔 GPU 时该怎么办?
我有一个 json 文件,它是使用rest api 调用生成的,如下所示:
import json
resp = requests.get('https://....offset=0&limit=500&where=....', headers=headers)
json_data = json.loads(resp.text)
with open('strings.json') as f:
d = json.load(f)
print(d)
Run Code Online (Sandbox Code Playgroud)
在变量中读取它后d,我得到以下结构数据:
d = [{}, {}, {},{}]
Run Code Online (Sandbox Code Playgroud)
我想将上述数据结构转换为以下格式并将其存储在 json 文件中,该文件也称为 jsonlines https://jsonlines.org/examples/:
required_format = {}{}{}{}
Run Code Online (Sandbox Code Playgroud)
在某种程度上,我想删除外部方括号以及相邻字典之间的空格、逗号,然后再次将其存储为 json 或任何其他文件格式,甚至不带扩展名。该文件在 Chrome 或任何其他浏览器中打开后应具有此结构。
{}{}{}{}
Run Code Online (Sandbox Code Playgroud) python ×3
gpu ×1
html ×1
json ×1
plotly ×1
plotly-dash ×1
python-3.x ×1
pytorch ×1
scikit-learn ×1