我收到错误:
ValueError: Wrong number of items passed 3, placement implies 1我正在努力弄清楚在哪里,以及我如何开始解决这个问题.
我真的不明白错误的含义; 这让我很难排除故障.我还包括了在我的Jupyter Notebook中触发错误的代码块.
数据很难附加; 所以我不是在寻找任何人试图为我重新创建这个错误.我只是想找到一些关于如何解决这个错误的反馈.
KeyError Traceback (most recent call last)
C:\Users\brennn1\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\indexes\base.py in get_loc(self, key, method, tolerance)
1944 try:
-> 1945 return self._engine.get_loc(key)
1946 except KeyError:
pandas\index.pyx in pandas.index.IndexEngine.get_loc (pandas\index.c:4154)()
pandas\index.pyx in pandas.index.IndexEngine.get_loc (pandas\index.c:4018)()
pandas\hashtable.pyx in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:12368)()
pandas\hashtable.pyx in pandas.hashtable.PyObjectHashTable.get_item (pandas\hashtable.c:12322)()
KeyError: 'predictedY'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
C:\Users\brennn1\AppData\Local\Continuum\Anaconda3\lib\site-packages\pandas\core\internals.py in set(self, item, value, check)
3414 try:
-> …Run Code Online (Sandbox Code Playgroud) 我有两个selectInputs,我想在第一个(Brand)中选择更改第二个(Candy)中的可能选择.因此,例如,如果有人在第一个输入框中选择了"雀巢",那么只有雀巢糖果将出现在第二个框中.我的数据表有一个Brand列和一个Candy bar类型列.
我有以下代码开始,但这显示了所有选项,无论选择如何.
selectInput(inputId="brand",
label="Brand:",
choices=as.character
(unique(candyData$Brand)),
selected = "Nestle"
),
selectInput(inputId="candy",
label="Candy:",
choices=as.character
(unique(candyData$Candy)),
selected = "100Grand"
Run Code Online (Sandbox Code Playgroud)
数据集如下所示:
Brand Candy
Nestle 100Grand
Netle Butterfinger
Nestle Crunch
Hershey's KitKat
Hershey's Reeses
Hershey's Mounds
Mars Snickers
Mars Twix
Mars M&Ms
Run Code Online (Sandbox Code Playgroud)
更新的问题 如何根据后续过滤更新仪表板中的ValueBox?
output$count <- renderValueBox({
valueBox(
value = nrow(candyData),
subtitle = "Number of Candy Bars",
icon = icon("table")
)
})
Run Code Online (Sandbox Code Playgroud) 我目前正在根据两列数据绘制散点图.但是,我想基于第三列中的类标签为数据点着色.
我的第三列中的标签是1,2或3.我如何根据第三列中的值为散点图颜色着色?
plt.scatter(waterUsage['duration'],waterUsage['water_amount'])
plt.xlabel('Duration (seconds)')
plt.ylabel('Water (gallons)')
Run Code Online (Sandbox Code Playgroud) 我的主面板中有几个图表,我Shiny Dashboard想知道如何扩展主面板底部的空白区域?我应该如何修改我ui.R这样做?
dashboardBody(
tabItems(
tabItem("dashboard",
mainPanel(
showOutput("plot3", "Nvd3"),
showOutput("plot4", "Nvd3")
)),
Run Code Online (Sandbox Code Playgroud)
我在MATLAB中有以下代码行,我试图转换为Python numpy:
pred = traindata(:,2:257)*beta;
Run Code Online (Sandbox Code Playgroud)
在Python中,我有:
pred = traindata[ : , 1:257]*beta
Run Code Online (Sandbox Code Playgroud)
beta 是一个256 x 1阵列.
在MATLAB中,
size(pred) = 1389 x 1
Run Code Online (Sandbox Code Playgroud)
但在Python中,
pred.shape = (1389L, 256L)
Run Code Online (Sandbox Code Playgroud)
所以,我发现乘以beta数组会产生两个数组之间的差异.
我如何编写原始的Python行,因此大小pred为1389 x 1,就像在MATLAB中乘以我的beta数组一样?
python ×3
r ×2
shiny ×2
data-science ×1
matlab ×1
matplotlib ×1
numpy ×1
pandas ×1
prediction ×1
scatter-plot ×1