Re: .replace() to replace elements in a Pandas DataFrame

2020-08-05 Thread Michio Suginoo
That said, what remains mystery is why the original one worked this morning. Strange! On Wed, Aug 5, 2020 at 10:15 PM Michio Suginoo wrote: > Hi Bob and MRAB, > Both of you, very kind. > Thanks. > I tried with DataFrame as my original code, but this time, I inserted > regex=True and it worked.

Re: .replace() to replace elements in a Pandas DataFrame

2020-08-05 Thread Michio Suginoo
Hi Bob and MRAB, Both of you, very kind. Thanks. I tried with DataFrame as my original code, but this time, I inserted regex=True and it worked. Thank you very much! Best On Wed, Aug 5, 2020 at 9:50 PM Bob van der Poel wrote: > I don't think that string.replace() has an option for a dictionary

Re: .replace() to replace elements in a Pandas DataFrame

2020-08-05 Thread Bob van der Poel
I don't think that string.replace() has an option for a dictionary of replacements ... mind you, it might be nice if it did. In the meantime, have you tried looping through the dictionary and changing each possible character? On Wed, Aug 5, 2020 at 5:12 PM Michio Suginoo wrote: > Hi MRAB, > > S

Re: .replace() to replace elements in a Pandas DataFrame

2020-08-05 Thread Michio Suginoo
Hi MRAB, In addition,. I also found out the following does not work either in my Jupyter Notebook. correction_dic2={ "La Boca" : "BOCA", "La Paternal": "PATERNAL", "Villa General Mitre": "VILLA GRAL. MITRE"} df = df.replace({'Name' : correction_dic2}) This case, unlike the earlier case, is aiming

Re: .replace() to replace elements in a Pandas DataFrame

2020-08-05 Thread Michio Suginoo
Hi MRAB, Sorry, I simply do not understand the intention of your statement. If .replace() does not do what I want to do: to replace all ' í ' with 'i' in any form . Could you advise me other means to do it? I am still a learner, so I am not knowledgeable. But, I presume, this sort of needs--to r

Re: .replace() to replace elements in a Pandas DataFrame

2020-08-05 Thread MRAB
On 2020-08-06 00:06, Michio Suginoo wrote: Hi MRAB, Here is an example: In the original dataframe, I have something like, 'Agronomía'. And I try to transform it to 'Agronomia'. In this case, I try to replace í with i: the former with a Spanish accent, the latter without. That's what you want

Re: .replace() to replace elements in a Pandas DataFrame

2020-08-05 Thread Michio Suginoo
Hi MRAB, Here is an example: In the original dataframe, I have something like, 'Agronomía'. And I try to transform it to 'Agronomia'. In this case, I try to replace í with i: the former with a Spanish accent, the latter without. Thanks Best On Wed, Aug 5, 2020 at 8:00 PM MRAB wrote: > On 2020-

Re: .replace() to replace elements in a Pandas DataFrame

2020-08-05 Thread MRAB
On 2020-08-05 23:21, Michio Suginoo wrote: Hi, I have trouble with .replace() method in a Pandas DataFrame. My code is something like this: correction_dic1 = {'á': 'a', 'í': 'i', 'ú': 'u', 'ó': 'o'} df = df.replace({'Name' : correction_dic1}) Basically, what I am trying to do here is to replace

.replace() to replace elements in a Pandas DataFrame

2020-08-05 Thread Michio Suginoo
Hi, I have trouble with .replace() method in a Pandas DataFrame. My code is something like this: correction_dic1 = {'á': 'a', 'í': 'i', 'ú': 'u', 'ó': 'o'} df = df.replace({'Name' : correction_dic1}) Basically, what I am trying to do here is to replace bowels with Spanish accent with a plain set o