我想用2列初始化一个空数组,以后可以在该数组中添加新行。
我有以下代码:
Sub ExportSlidesToIndividualPPPTX()
Dim oPPT As Presentation, oSlide As Slide
Dim sPath As String
Dim oTempPres As Presentation
Dim x As Long
' Location of PPTX File
Set oPPT = Presentations.Open(FileName:="K:\PRESENTATION_YOU_ARE_EXPORTING.pptx")
' Location Where Individual Slides Should Be Saved
' Add \ in the end
sPath = "K:\FOLDER PATH WHERE PPTX SHOULD BE EXPORTED\"
For Each oSlide In oPPT.Slides
lSlideNum = oSlide.SlideNumber
sFileName = sPath & "Slide - " & lSlideNum & ".pptx"
oPPT.SaveCopyAs sFileName
' open the saved copy windowlessly
Set oTempPres = Presentations.Open(sFileName, , , False)
' Delete all slides before the slide you want to save
For x = 1 To lSlideNum - 1
oTempPres.Slides(1).Delete
Next
' Delete all slides after the slide you want to save
For x = oTempPres.Slides.Count To 2 Step -1
oTempPres.Slides(x).Delete
Next
oTempPres.Save
oTempPres.Close
Next
Set oPPT = Nothing
End Sub
但是当我运行代码时,出现此错误:
import numpy as np
import statistics as st
import pyswarms as ps
import matplotlib.pyplot as plt
from sklearn.neural_network import MLPClassifier
def load_input():
dados = np.array([])
for x in range(1,22):
fich = np.loadtxt("%d.csv" %x,delimiter=",");
aux = []
valor = 5.0;
for y in range(0,len(fich)):
if fich[y][0] <= valor :
aux.append(fich[y,1])
aux.append(fich[y,2])
aux.append(fich[y,3])
else:
dados = np.vstack((dados,np.array([st.mean(aux),x])));
dados = np.vstack((dados,np.array([st.stdev(aux),x])));
y = y-1;
aux[:] = []
valor = valor + 5;
return dados
我认为在尝试将新行添加到数组后,错误就来了。我该如何解决?
答案 0 :(得分:0)
您应该使用np.stack()而不是np.vstack(),因为每个文档均不推荐使用vstack:[https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.vstack.html]
对dado使用普通的python数组并将其追加到其中,然后在构建数组后调用np.stack()。