我的熊猫数据框只有一列。
我想将column的每个值连接起来,使其变成一个向量。
Sub demo()
Dim ie As InternetExplorer
Dim html As HTMLDocument
Dim Link As Object
Dim ElementCol As Object
Application.ScreenUpdating = False
Set ie = New InternetExplorer
ie.Visible = True
ie.navigate "C:\Users\Administrator\Desktop\demo57.html" 'Change the URL as your requirement...
Do While ie.readyState <> READYSTATE_COMPLETE
DoEvents
Loop
Set html = ie.Document
Set ElementCol = html.getElementsByTagName("a")
For Each Link In ElementCol
If Link.innerHTML = "Submit" Then
Link.Click
End If
Next Link
Set ie = Nothing
Application.ScreenUpdating = True
End Sub
结果应为[55,75,97,47,51,107]
我尝试了np.vstack(),np.column_stack()等,但没有解决。 请帮助我
答案 0 :(得分:1)
这将从您的列中创建一个列表。
l = []
[l.extend(e) for e in df[0].values]
l # your list
答案 1 :(得分:1)
或者,您可以执行以下操作:
sum(dataframe[0],[])
或
[item for row in dataframe[0] for item in row]
答案 2 :(得分:0)
您可以在单独的列表中获得所有列,如下所示:
print (df['0'].tolist())
[[55,75,97], [47,51,107]]
因此,我们可以通过这种方式将它们组合到一个列表中。
print ([a for b in df[0].tolist() for a in b])
[[55,75,97,47,51,107]]