如何解决拆分控制的语法
我已经将一个应用程序从 .NET Core 移植到了 .NET Framework,它似乎适用于所有情况,除了我必须拆分字符串以便用它填充表格的一行。然后我必须擦除除一个之外的所有空格,所以我写道:
Dim item() As String = line.Trim.Split(" "c,StringSplitOptions.RemoveEmptyEntries)
在 NET Core 中没有发现错误。这里我有以下错误:
Error BC30518 Overload resolution failed because no accessible 'Split' can be called with these arguments:
'Public Overloads Function Split(ParamArray separator As Char()) As String()': Value of type 'StringSplitOptions' cannot be converted to 'Char'.
'Public Overloads Function Split(separator As Char(),count As Integer) As String()': Value of type 'Char' cannot be converted to 'Char()'.
'Public Overloads Function Split(separator As Char(),options As StringSplitOptions) As String()': Value of type 'Char' cannot be converted to 'Char()'.
'Public Overloads Function Split(separator As String(),options As StringSplitOptions) As String()': Value of type 'Char' cannot be converted to 'String()'. FDS2Ansys C:\Users\Nicola\source\repos\FDS2Ansys\FDS2Ansys\Form2.vb 113 Active
我认为我必须将空格 " "c
表示为字符,但我不明白如何。有没有人可以帮我解决这个问题?非常感谢大家都来回答我。最好的问候。
解决方法
由于 print (df[1].max(level=0))
first
A 0.734800
B -0.591926
C 1.103283
D -0.936198
Name: 1,dtype: float64
df['new'] = df[0].div(df[1].max(level=0))
print (df)
0 1 new
first second
A one 0.991026 0.734800 1.348702
two 0.582370 0.720825 0.792556
B one 0.795826 -1.155040 -1.344469
two 0.013736 -0.591926 -0.023206
C one -0.538078 0.291372 -0.487706
two 1.605806 1.103283 1.455480
D one -0.617655 -1.438617 0.659748
two 1.495949 -0.936198 -1.597898
需要字符数组或字符串数组作为第一个参数,您应该按如下方式更改代码:
Split
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。