小编jam*_*395的帖子

Dir()函数理解

' 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()做什么?

directory excel vba excel-vba

6
推荐指数
1
解决办法
328
查看次数

pandas:合并数据帧并替换值

我有两个数据帧:

   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)

任何想法如何去做?

python numpy pandas

1
推荐指数
1
解决办法
1085
查看次数

标签 统计

directory ×1

excel ×1

excel-vba ×1

numpy ×1

pandas ×1

python ×1

vba ×1