' Display the names in C:\ that represent directories.
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> "" ' Start the loop.
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
' Display entry only if it's a directory.
MsgBox(MyName)
End If
MyName = Dir() ' Get next entry.
Loop
Run Code Online (Sandbox Code Playgroud)
我正在查看上面的代码.我特别不明白"MyName = Dir()"的作用.它被评论它得到了下一个条目,但我不明白它是如何得到下一个条目 - 特别是Dir()做什么?
我有两个数据帧:
A = pd.DataFrame(data=np.array([['t1',1,'t2',2]]).reshape(2,2),columns=['a','b'])
A
Out[6]:
a b
0 t1 1
1 t2 2
B = pd.DataFrame(data=np.array([[1,2,3],[2,5,6],[3,6,7]]).reshape(3,3),columns=['x','y','z'])
B
Out[8]:
x y z
0 1 2 3
1 2 5 6
2 3 6 7
Run Code Online (Sandbox Code Playgroud)
我试图基本匹配列'b'数据帧A上的数据帧B的列'x',但将匹配的值替换为数据帧A的列'a'.
即我想合并两个数据帧,以便输出如下所示:
x y z
0 t1 2 3
1 t2 5 6
2 3 6 7
Run Code Online (Sandbox Code Playgroud)
任何想法如何去做?