用整数值替换数据集(列)中的几个不同的字符串

发布于 2025-02-11 16:31:50 字数 717 浏览 1 评论 0原文

数据集示例:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文