You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Python生成数据集中名词的单复数组合并处理对应列

Hey there! Let's tackle this problem step by step. We need to generate all possible singular-plural combinations for nouns in col1, keep non-noun strings exactly as they are, and repeat the corresponding col2 value for each new combination. Here's the formatted result:

1. Input Row: col1="cat", col2="rat"

Both "cat" and "rat" are singular nouns, so we generate every combination of their singular and plural forms:

col1col2
catrat
catrats
catsrat
catsrats

2. Input Row: col1="Lion", col2=""

"Lion" is a singular noun; we include both its singular and plural forms while keeping the empty col2 value consistent:

col1col2
Lion
Lions

3. Input Row: col1="children, geese,pantss", col2="man"

First, we correct the typo "pantss" to the standard plural noun "pants". Then we handle each noun's singular-plural pairs:

  • children (plural) ↔ child (singular)
  • geese (plural) ↔ goose (singular)
  • pants (plural) ↔ pant (singular)
  • man (singular) ↔ men (plural)

Below are key example combinations (the full set includes 16 total combinations following the same pattern):

col1col2
children, geese, pantssman
children, geese, pantssmen
children, geese, pantsman
children, geese, pantsmen
children, goose, pantssman
child, geese, pantssmen
child, goose, pantman

内容的提问来源于stack exchange,提问作者Niranjanp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:07:16