用整数值替换数据集(列)中的几个不同的字符串
数据集示例:
ABC
DEF
GHI
JKL
ABC
GHI
JKL
JKL
ABC
我的数据集中有一个列,每个单元格中都有三个字符字符串,类似于上面的示例。我想用增量整数(第一个唯一字符串= 1,第二个唯一字符串= 2等)替换字符串的每个唯一事件。
大约有。 300该列中的唯一三个字母组合。
因此,基本上: 通过列直到第一个唯一的三个字母组合,然后用“ 1”代替它。 - >通过列的其余部分,将每三个字母组合替换为“ 1”。
通过列直到第二个唯一的三个字母组合,然后用“ 2”代替它。 - >通过列的其余部分,将每三个字母组合替换为“ 2”。
- >重复该列中每个唯一的三个字母组合,
上面的数据集应像这样:
ABC -> 1
DEF -> 2
GHI -> 3
JKL -> 4
ABC -> 1
GHI -> 3
JKL -> 4
JKL -> 4
ABC -> 1
有没有办法进行自动搜索并用Excel替换?我只能手动替换所有事件,必须做300次以上的事情。我可以编码它,但是我不知道它是否真的可以节省那么多时间,因为我只需要一次。如果有任何语言的库来解决这个特定问题,那么很高兴知道。
这与Microsoft Excel可以做到吗? 如果没有,是否有任何可以迅速解决此问题的语言的库?
谢谢。
Dataset example:
ABC
DEF
GHI
JKL
ABC
GHI
JKL
JKL
ABC
I have one column in my dataset that has three character strings in every cell, similar to the example above. I want to replace every unique occurence of a string with an incremented integer (first unique string = 1, second unique string = 2 etc.).
There are approx. 300 unique three letter combinations in that column.
So basically:
Go through column until first unique three letter combination and replace it with "1".
-> Go through the rest of the column and replace every same three letter combination with "1".
Go through column until second unique three letter combination and replace it with "2".
-> Go through the rest of the column and replace every same three letter combination with "2".
->repeat for every unique three letter combination in that column
The dataset above should look like this afterwards:
ABC -> 1
DEF -> 2
GHI -> 3
JKL -> 4
ABC -> 1
GHI -> 3
JKL -> 4
JKL -> 4
ABC -> 1
Is there a way to do this automated search and replace with excel? I can only replace every occurence manually, and would have to do that 300+ times. I could code it but i don't know if it would really save that much time, because I only have to do it once. If there's a library in any language for this specific question it would be great to know though.
Is this possible to do with Microsoft Excel?
If not, is there a library in any language that could solve this problem quickly?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论