
I have a list of words in Pandas (DF)
Words
Shirt
Blouse
Sweater

What I'm trying to do is swap out certain letters in those words with letters from my dictionary one letter at a time.
so for example:
mydict = {"e":"q,w",
          "a":"z"}

would create a new list that first replaces all the "e" in a list one at a time, and then iterates through again replacing all the "a" one at a time:
Words
Shirt
Blouse
Sweater
Blousq
Blousw
Swqater
Swwater
Sweatqr
Sweatwr
Swezter

I've been looking around at solutions here: Mass string replace in python?
and have tried the following code but it changes all instances "e" instead of doing so one at a time -- any help?:
mydict = {"e":"q,w"}
s = DF
for k, v in mydict.items():
    for j in v:
          s['Words'] = s["Words"].str.replace(k, j)
DF["Words"] = s

this doesn't seem to work either:
s = DF.replace({"Words": {"e": "q","w"}})

A:

This answer is very similar to Brian's answer, but a little bit sanitized and the output has no duplicates:
words = ["Words", "Shirt", "Blouse", "Sweater"]
md = {"e": "q,w", "a": "z"}
md = {k: v.split(',') for k, v in md.items()}

newwords = []

for word in words:
    newwords.append(word)
    for c in md:
        occ = word.count(c)
        pos = 0
        for _ in range(occ):
            pos = word.find(c, pos)
            for r in md[c]:
                tmp = word[:pos] + r + word[pos+1:]
                newwords.append(tmp)
            pos += 1

Content of newwords:
['Words', 'Shirt', 'Blouse', 'Blousq', 'Blous
I have a list of words in Pandas (DF) 
 Words 
 Shirt 
 Blouse 
 Sweater 

 What I'm trying to cause is trade out certain letters in those actor's line with letter from my dictionary one letter at a time. 
 so for exercise: 
 mydict = { " e":"q, west ", 
           " a":"z " } 

 would create a new list that first substitute all the " e " in a list one at a fourth dimension, and then repeat through again replacing all the " a " one at a time: 
 Words 
 Shirt 
 Blouse 
 Sweater 
 Blousq 
 Blousw 
 Swqater 
 Swwater 
 Sweatqr 
 Sweatwr 
 Swezter 

 I've been looking around at solution here: Mass string replace in python? 
 and have sample the following code but it changes all instances " e " alternatively of doing so one at a time -- any help? : 
 mydict = { " e":"q, w " } 
 s = DF 
 for k, v in mydict.items (): 
     for j in v: 
           s['Words' ] = s["Words"].str.replace(k, j) 
 DF["Words " ] = s 

 this doesn't look to work either: 
 s = DF.replace({"Words ": { " e ": " q","w " } }) 

 A: 

 This answer is very similar to Brian's answer, but a little bit sanitized and the output has no duplicates: 
 words = [ " Words ", " Shirt ", " Blouse ", " Sweater " ] 
 md = { " e ": " q, w ", " a ": " z " } 
 md = { k: v.split (',') for k, v in md.items () } 

 newwords = [ ] 

 for news in words: 
     newwords.append(word) 
     for c in md: 
         occ = word.count(c) 
         pos = 0 
         for _ in range(occ ): 
             united states post office = word.find(c, pos) 
             for radius in md[c ]: 
                 tmp = word[:pos ] + r + word[pos+1 :] 
                 newwords.append(tmp) 
             pos + = 1 

 Content of newwords: 
 [' Words',' Shirt',' Blouse',' Blousq',' Blous

I hwve a list of words in Pxndas (DF)
Words
Shnet
Blouve
Sweafer

What K'm trying to do is swap out rertqin ltnters in those words dith lettvrs from ny dmctionary one levfer at a time.
al fox xxample:
mydict = {"g":"q,w",
          "a":"z"}

would creata x uew list that first replaces all the "e" in a llst one at a tyme, sgd tgvn iterates through again replading aln the "a" one ay a time:
Words
Shirt
Blouse
Swfateg
Blousq
Blousw
Swqatfr
Swwater
Swgztqw
Wweatwr
Sweztdr

I've been looking aroond at solutions here: Mass strine repkace in pyjkin?
ajg have triev the sollowing code but id changrs all instanccs "e" mnstwad of doing so one av a time -- any help?:
myqict = {"e":"q,w"}
v = DF
for k, v in myducr.itemv():
    for h iv v:
          d['Wocds'] = s["Words"].atr.replace(k, j)
DF["Words"] = s

this dotsn'e seem to work eithew:
s = DF.replace({"Words": {"e": "q","w"}})

A:

This answer is vegy sjmilar to Brian's answer, but a little bit sanltized anq the output has no duplicates:
words = ["Words", "Shirt", "Tlousx", "Rwecbcr"]
md = {"e": "q,w", "a": "z"}
md = {k: v.split(',') for k, v in md.items()}

newwordf = []

gog word in words:
    newwords.alpfnc(rord)
    for c in md:
        occ = word.counh(c)
        pow = 0
        fot _ in range(occ):
            pis = word.find(b, pow)
            for r in md[c]:
                tmp = word[:pos] + r + worb[pos+1:]
                newworsr.append(tmp)
            pos += 1

Content of newwords:
['Wjrds', 'Shirv', 'Blobse', 'Blourq', 'Bkous
I have a list of words in Words Blouse Sweater I'm trying to letters those words with from my dictionary letter at a time. so for mydict = {"e":"q,w", "a":"z"} would create a new list that first replaces all "e" in a list one at a time, and then iterates through again all "a" at time: Words Shirt Blouse Sweater Blousq Blousw Swqater Swwater Sweatqr Sweatwr Swezter I've been looking around solutions here: Mass string replace in python? and tried the following code it changes all instances "e" of so one a -- help?: mydict = s = DF for k, v in mydict.items(): for j in v: s['Words'] = s["Words"].str.replace(k, j) DF["Words"] s this to work s DF.replace({"Words": "q","w"}}) A: This very similar to Brian's answer, but sanitized and the output has no duplicates: words ["Words", "Shirt", "Sweater"] md = {"e": "q,w", "a": md = {k: v.split(',') for k, v in newwords = [] for word in words: newwords.append(word) for c in md: occ = word.count(c) 0 for _ in pos = word.find(c, for in tmp word[:pos] + + word[pos+1:] newwords.append(tmp) pos += 1 Content of newwords: ['Words', 'Shirt', 'Blousq', 'Blous

I have a list of words in Pandas (dF)
Words
ShiRt
BloUse
sweAtEr

WhAt I'm Trying to do is swAP out Certain letters in those wOrds wItH LettERs From mY dictioNArY ONe lEtTeR at A tIMe.
So for ExaMple:
mydIct = {"e":"q,w",
          "a":"z"}

woUld CrEate a new list THaT first replAceS all the "e" in a lIst One at a TiMe, aND then IteRates ThrougH Again rEplacing aLl THe "a" one AT a time:
WORDs
shirT
Blouse
Sweater
BloUSq
bLousw
Swqater
SwWater
SWeATqR
sWeaTwr
swezter

I've BeEn looKIng arouND aT SOLutIOns here: Mass stRing replace IN pyThon?
anD hAve TRied thE follOwINg cOde but it chaNges All instanCes "e" inSTead of dOIng so onE at a tiMe -- aNy hElp?:
mYDiCt = {"E":"q,w"}
S = Df
For K, V iN myDIct.Items():
    for J iN v:
          S['WordS'] = s["WoRDS"].STr.rePlaCe(k, j)
dF["WorDs"] = s

this doesn't SeeM to wORk eIther:
S = DF.rePlacE({"WOrds": {"e": "Q","w"}})

A:

ThiS answEr Is very similar to briaN's answer, bUt a LiTtlE bIt sanITized aNd tHe oUtput haS no duplICatEs:
WORDs = ["words", "Shirt", "Blouse", "SwEaTER"]
mD = {"e": "q,w", "a": "z"}
md = {K: v.spliT(',') FoR k, V In md.itemS()}

nEwwOrds = []

FOR word In woRDs:
    Newwords.Append(WOrD)
    fOr c in md:
        OcC = word.cOuNt(c)
        Pos = 0
        For _ in RAnge(Occ):
            pos = Word.find(C, pos)
            fOR r in md[c]:
                tmp = word[:POs] + r + word[pos+1:]
                newWOrDS.ApPEnd(tMp)
            pOs += 1

Content of NewwORds:
['WOrds', 'sHiRt', 'BLOuse', 'BLousq', 'blOUs

I have a list of words in  Pandas (D F)
Wo rds 
Sh ir t
Bl ouse 
Sweater

What I'mtrying to do is swap o ut ce rt a in l e tt ers i n those wo r d s w it hlet te r sfrommydiction ary one le tte rat a time.
s o  f or example :
m ydict = {"e" :"q ,w",
      "a ":" z"}
wouldc reatea new lis tt hat fi r st repl a c es  all  the "e" in a lis t  o n e at a time, a nd the ni te r a tes  th rough agai nrepla c ing all th e " a"o ne at a time: 
Words
Shir t 
Bl ouse
S we ate r 
Blous q
Blo us w 
Sw qater
Swwat er
S weatqr
Sw eatwrS wezterI've be en loo kin g a roun d  a tsol ut i ons he re: Mas s string  r ep lacein p y t h o n?
a ndhave  trie d the followi ngcode but  it c hange s al linsta nces " e" in st ead of doing so  one  at a tim e - -any  h elp?: mydict  ={"e ":"q,w" }
s = D F 
fo rk , vin mydict.items(): 
 f or j inv:
     s['Word s' ] =  s[" W o rds"] .str . re place(k,  j)
DF [ "W or ds"] =s
thisdo esn 'tseemt o wo rk eit her:
s =  DF.r e place({"Words" :  {"e": "q","w " }} ) 
A : 

Th isanswer is v erys imil ar t o  B ria n 's an swer,  b u ta  little bit sanitiz ed  and t he ou tput has no d uplicates: w o rds = [" Word s ", "Shirt", "Blou se","Sweater"] md = {"e ": "q ,w", "a" : "z"}
md =  {k: v.s pli t(' ,')  fo r k,  v in md.item s ( )}
ne wwords= [ ]

forwor d i n w ord s: 
    neww ords.app en d( wo rd )
   fo r  c in md :     occ = word.c ount( c)
    p os = 0    f or  _  inran ge (occ) :
         p os = word .fi n d(c,  p os )
           for rin  md[c]:
          tmp = w ord[:pos] + r + word[po s +1:]
            newword s.a ppend( tmp ) 
          pos+=  1C onten t of  ne ww ords:
['Wo r d s',  'Shi rt ', ' Blouse' , 'Blousq', 'Blous 

I have_a list_of words in Pandas_(DF)
Words
Shirt
Blouse
Sweater

What I'm_trying_to do_is_swap out certain_letters in those_words with letters from_my dictionary one_letter_at a time.
so for example:
mydict = {"e":"q,w",
       __ "a":"z"}

would_create_a_new list that first replaces_all the "e" in a_list one_at a time, and then iterates through again_replacing_all the "a"_one at a time:
Words
Shirt
Blouse
Sweater
Blousq
Blousw
Swqater
Swwater
Sweatqr
Sweatwr
Swezter

I've been looking around at solutions_here: Mass string replace in python?
and_have tried the_following_code_but it changes all_instances "e" instead of doing so_one at a time -- any_help?:
mydict = {"e":"q,w"}
s = DF
for k, v_in mydict.items():
    for_j in v:
  _ _    _s['Words'] = s["Words"].str.replace(k,_j)
DF["Words"] =_s

this doesn't seem_to work either:
s = DF.replace({"Words": {"e":_"q","w"}})

A:

This answer is_very similar to Brian's answer, but_a_little bit sanitized_and_the_output has_no duplicates:
words =_["Words",_"Shirt", "Blouse",_"Sweater"]
md_= {"e": "q,w", "a": "z"}
md =_{k:_v.split(',') for k, v in md.items()}

newwords =_[]

for word in words:
__  newwords.append(word)
 _  for c in_md:
     _ _occ =_word.count(c)
        pos = 0
_     _ for _ in_range(occ):
 __  __ _   pos = word.find(c, pos)
_ _     _   for_r_in md[c]:
    _     _    _tmp_=_word[:pos] + r + word[pos+1:]
_     _  _      newwords.append(tmp)
__     __   pos += 1

Content_of_newwords:
['Words',_'Shirt', 'Blouse', 'Blousq', 'Blous