小编oll*_*lly的帖子

如何在列中的每个不同值上拆分 DataFrame?

下面是一个示例数据帧。

      0      1     2     3          4
0   0.0  13.00  4.50  30.0   0.0,13.0
1   0.0  13.00  4.75  30.0   0.0,13.0
2   0.0  13.00  5.00  30.0   0.0,13.0
3   0.0  13.00  5.25  30.0   0.0,13.0
4   0.0  13.00  5.50  30.0   0.0,13.0
5   0.0  13.00  5.75   0.0   0.0,13.0
6   0.0  13.00  6.00  30.0   0.0,13.0
7   1.0  13.25  0.00  30.0  0.0,13.25
8   1.0  13.25  0.25   0.0  0.0,13.25
9   1.0  13.25  0.50  30.0  0.0,13.25
10  1.0  13.25  0.75  30.0  0.0,13.25
11  2.0  13.25  1.00  30.0  0.0,13.25
12  2.0 …
Run Code Online (Sandbox Code Playgroud)

python numpy dataframe python-3.x pandas

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

如何在 VBA 中使用正则表达式替换第 n 次出现?

例如,我尝试将“This 9 is 8 a 77 6 test”中第二次出现的数字替换为“hello”。

所以我希望结果是“This 9 is hello a 77 6 test”。

相反,我得到的是“hellohello test”。

我在用着:

=RegexReplace("This 9 is 8 a 77 6 test","(?:\D*(\d+)){2}","hello")
Run Code Online (Sandbox Code Playgroud)

其中 RegexReplace 定义如下:

Function RegexReplace(text As String, pattern As String, replace As String)

        Static re As Object

        If re Is Nothing Then
            Set re = CreateObject("VBScript.RegExp")
            re.Global = True
            re.MultiLine = True
        End If

        re.IgnoreCase = True
        re.pattern = pattern
        RegexReplace = re.replace(text, replace)
        Set re = Nothing

End Function
Run Code Online (Sandbox Code Playgroud)

regex excel vba

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

标签 统计

dataframe ×1

excel ×1

numpy ×1

pandas ×1

python ×1

python-3.x ×1

regex ×1

vba ×1